コード例 #1
0
ファイル: bannerwindow.cpp プロジェクト: 0ryuO/dolphin-avsync
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
0
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
0
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
0
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
0
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
0
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
0
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
0
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
0
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
0
ファイル: svgtest.cpp プロジェクト: EdgarTx/wx
// 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);
            dc.SetBrush(*wxRED_BRUSH);
            //top left corner, width and height, start and end angle
                                 // 315 same center and x-radius as last pie-arc, half Y radius
            dc.DrawEllipticArc(25,50,100,50,180.0,45.0) ;

            wP = *wxCYAN_PEN ;
            wP.SetWidth(3);
            dc.SetPen(wP);
                                 //wxTRANSPARENT));
            dc.SetBrush (wxBrush (_T("SALMON"),wxSOLID)) ;
            dc.DrawEllipticArc(300,  0,200,100, 0.0,145.0) ;
                                 //same end point
            dc.DrawEllipticArc(300, 50,200,100,90.0,145.0) ;
            dc.DrawEllipticArc(300,100,200,100,90.0,345.0) ;

#if wxUSE_STATUSBAR
            s = wxT("This is an arc test page");
#endif // wxUSE_STATUSBAR
            break ;

        case 4:
            dc.DrawCheckMark ( 30,30,25,25);
            dc.SetBrush (wxBrush (_T("SALMON"),wxTRANSPARENT));
            dc.DrawCheckMark ( 80,50,75,75);
            dc.DrawRectangle ( 80,50,75,75);
#if wxUSE_STATUSBAR
            s = wxT("Two check marks");
#endif // wxUSE_STATUSBAR
            break ;

        case 5:
            wF = wxFont ( 18, wxROMAN, wxITALIC, wxBOLD, false, wxT("Times New Roman"));
            dc.SetFont(wF);
            dc.DrawLine(0, 0, 200, 200);
            dc.DrawLine(200, 0, 0, 200);
            dc.DrawText(wxT("This is an 18pt string"), 50, 60);

            // rescale and draw in blue
            wP = *wxCYAN_PEN ;
            dc.SetPen(wP);
            dc.SetUserScale (2.0,0.5);
            dc.SetDeviceOrigin(200,0);
            dc.DrawLine(0, 0, 200, 200);
            dc.DrawLine(200, 0, 0, 200);
            dc.DrawText(wxT("This is an 18pt string 2 x 0.5 UserScaled"), 50, 60);
            dc.SetUserScale (2.0,2.0);
            dc.SetDeviceOrigin(200,200);
            dc.DrawText(wxT("This is an 18pt string 2 x 2 UserScaled"), 50, 60);

            wP = *wxRED_PEN ;
            dc.SetPen(wP);
            dc.SetUserScale (1.0,1.0);
            dc.SetDeviceOrigin(0,10);
            dc.SetMapMode (wxMM_METRIC) ; //svg ignores this
            dc.DrawLine(0, 0, 200, 200);
            dc.DrawLine(200, 0, 0, 200);
            dc.DrawText(wxT("This is an 18pt string in MapMode"), 50, 60);
#if wxUSE_STATUSBAR
            s = wxT("Scaling test page");
#endif // wxUSE_STATUSBAR
            break ;

        case 6:
            dc.DrawIcon( wxIcon(mondrian_xpm), 10, 10 );
            dc.DrawBitmap ( wxBitmap(svgbitmap_xpm), 50,15);
#if wxUSE_STATUSBAR
            s = wxT("Icon and Bitmap ");
#endif // wxUSE_STATUSBAR
            break ;

    }
#if wxUSE_STATUSBAR
    m_child->SetStatusText(s);
#endif // wxUSE_STATUSBAR
}
コード例 #11
0
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
0
ファイル: IsoLine.cpp プロジェクト: fzschornack/OpenCPN
//---------------------------------------------------------------
void IsoLine::drawIsoLine(GRIBOverlayFactory *pof, wxDC &dc, PlugIn_ViewPort *vp, bool bShowLabels, bool bHiDef)
{
      int nsegs = trace.size();
      if(nsegs < 1)
            return;

      GetGlobalColor ( _T ( "UITX1" ), &isoLineColor );
      wxPen ppISO ( isoLineColor, 2 );

#if wxUSE_GRAPHICS_CONTEXT
      wxMemoryDC *pmdc;
//      pmdc = dynamic_cast<wxMemoryDC*>(&dc);
      pmdc= wxDynamicCast(&dc, wxMemoryDC);
      wxGraphicsContext *pgc = wxGraphicsContext::Create(*pmdc);
      pgc->SetPen(ppISO);
#endif

      dc.SetPen(ppISO);



      std::list<Segment *>::iterator it;

    //---------------------------------------------------------
    // Dessine les segments
    //---------------------------------------------------------
    for (it=trace.begin(); it!=trace.end(); it++)
    {
        Segment *seg = *it;

        {
 //             wxPoint ab = vp->GetMercatorPixFromLL(seg->py1, seg->px1);
 //             wxPoint cd = vp->GetMercatorPixFromLL(seg->py2, seg->px2);
            wxPoint ab;
            GetCanvasPixLL(vp, &ab, seg->py1, seg->px1);
            wxPoint cd;
            GetCanvasPixLL(vp, &cd, seg->py2, seg->px2);


///            ClipResult res = cohen_sutherland_line_clip_i ( &ab.x, &ab.y, &cd.x, &cd.y,
///                         0, vp->pix_width, 0, vp->pix_height );
///            if ( res != Invisible )
             {
#if wxUSE_GRAPHICS_CONTEXT
                  if(bHiDef && pgc)
                        pgc->StrokeLine(ab.x, ab.y, cd.x, cd.y);
                  else 
                        dc.DrawLine(ab.x, ab.y, cd.x, cd.y);
#else
                  dc.DrawLine(ab.x, ab.y, cd.x, cd.y);
#endif
             }

        }
    }
//#endif

      int text_sx, text_sy;
      dc.GetTextExtent(_T("10000"), &text_sx, &text_sy);
//      double m = text_sy / 2;
      int label_size = text_sx;
      int label_space = 400;
//      double coef = .01;
      int len = label_space/4;

      //    Allocate an array big enough
      wxPoint *pPoints = new wxPoint[nsegs+1];

      MySegListList::Node *listnode;
      listnode = m_SegListList.GetFirst();
      while(listnode)
      {
            MySegList *listsort = listnode->GetData();

            //    Fill in the array
            MySegList::Node *node;
            Segment *seg;

            node = listsort->GetFirst();
            if(node)
            {
                  seg = node->GetData();
//                  wxPoint ab = vp->GetMercatorPixFromLL(seg->py1, seg->px1);
//                  wxPoint ab(0,0);
				  wxPoint ab;
				  GetCanvasPixLL(vp, &ab, seg->py1, seg->px1);
                  pPoints[0] = ab;
            }
            int ip=1;

            while (node)
            {
                  seg = node->GetData();
//                  wxPoint cd = vp->GetMercatorPixFromLL(seg->py2, seg->px2);
//                  wxPoint cd(0,0);
				  wxPoint cd;
				  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
0
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

    if (gc)
    {
        // make a path that contains a circle and some lines, centered at 100,100
        gc->SetPen( *wxRED_PEN );

        wxGraphicsPath path = gc->CreatePath();
        path.AddCircle( 50.0, 50.0, 50.0 );
        path.MoveToPoint(0.0, 50.0);
        path.AddLineToPoint(100.0, 50.0);
        path.MoveToPoint(50.0, 0.0);
        path.AddLineToPoint(50.0, 100.0 );
        path.CloseSubpath();
        path.AddRectangle(25.0, 25.0, 50.0, 50.0);

        gc->StrokePath(path);

        // draw some text
        wxString text("Text by wxGraphicsContext");
        gc->SetFont( m_testFont, *wxBLACK );
        gc->DrawText(text, 25.0, 60.0);

        // draw rectangle around the text
        double w, h, d, el;
        gc->GetTextExtent(text, &w, &h, &d, &el);
        gc->SetPen( *wxBLACK_PEN );
        gc->DrawRectangle(25.0, 60.0, w, h);

        delete gc;
    }
#endif
}
コード例 #14
0
ファイル: pictype.cpp プロジェクト: BhushanRB/usbpicprog
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, 
                     DRAWPIN_NUMBERS_INSIDE_PINS, wxBOTTOM);
            DrawPins(dc, wxPoint(BoxX+BoxL, BoxY), BoxL, PinPerSide*2, PinPerSide*3, 
                     DRAWPIN_INVERTED_ORDER|DRAWPIN_NUMBERS_INSIDE_PINS, wxRIGHT);
            DrawPins(dc, wxPoint(BoxX, BoxY), BoxL, PinPerSide*3, PinPerSide*4, 
                     DRAWPIN_INVERTED_ORDER|DRAWPIN_NUMBERS_INSIDE_PINS, wxTOP);
        }
        break;

    default:
        break;
    }
}
コード例 #15
0
ファイル: pictype.cpp プロジェクト: BhushanRB/usbpicprog
void ChipPackage::DrawPins(wxDC& dc, const wxPoint& pt, unsigned int PackageLen,
                           unsigned int FirstPin, unsigned int LastPin,
                           int flags,
                           wxDirection dir)
{
    wxASSERT_MSG(LastPin>FirstPin, "invalid pin indexes");

    // NOTE: inside this function context
    //    pin number == the index of the pin (e.g. "1", "2", etc)
    //    pin name == pin label == the name of the pin signal (e.g. "VCC", "GND" etc)
    //    pin == pin rectangle


    // some drawing constants:

    const unsigned int PinCount = LastPin - FirstPin;

    // pin height is calculated imposing that
    // 1) PinCount*PinH + (PinCount+1)*PinSpacing = PackageLen
    // 2) PinSpacing = PinH/2
    // solving for PinH yields:
    unsigned int PinH = (unsigned int)floor(2*PackageLen/(3.0*PinCount+1));
    unsigned int PinW = (unsigned int)1.5*PinH;
    const unsigned int PinSpacing = (const unsigned int)floor(PinH/2.0);

    // the error which force us to have a "pin y offset" is caused by rounding
    // in the calculation of PinH:
    const int PinOffset = (PackageLen - (PinCount*PinH + (PinCount+1)*PinSpacing))/2;
    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"));
}
コード例 #16
0
/* draws text with ellipses instead cutting it */
void CBOINCGridCtrl::DrawTextRectangle( wxDC& dc,
                               const wxArrayString& lines,
                               const wxRect& rect,
                               int horizAlign,
                               int vertAlign,
                               int textOrientation )
{
    long textWidth, textHeight;
    long lineWidth, lineHeight;
    unsigned int nLines;

    dc.SetClippingRegion( rect );

    nLines = (unsigned int)lines.GetCount();
    if( nLines > 0 )
    {
        unsigned int l;
        float x = 0.0, y = 0.0;

        if( textOrientation == wxHORIZONTAL )
            GetTextBoxSize(dc, lines, &textWidth, &textHeight);
        else
            GetTextBoxSize( dc, lines, &textHeight, &textWidth );

        switch( vertAlign )
        {
        case wxALIGN_BOTTOM:
            if( textOrientation == wxHORIZONTAL )
                y = rect.y + (rect.height - textHeight - 1);
            else
                x = rect.x + rect.width - textWidth;
            break;

        case wxALIGN_CENTRE:
            if( textOrientation == wxHORIZONTAL )
                y = rect.y + ((rect.height - textHeight)/2);
            else
                x = rect.x + ((rect.width - textWidth)/2);
            break;

        case wxALIGN_TOP:
        default:
            if( textOrientation == wxHORIZONTAL )
                y = rect.y + 1;
            else
                x = rect.x + 1;
            break;
        }

        // Align each line of a multi-line label
        for( l = 0; l < nLines; l++ )
        {
            dc.GetTextExtent(lines[l], &lineWidth, &lineHeight);

            switch( horizAlign )
            {
            case wxALIGN_RIGHT:
                if( textOrientation == wxHORIZONTAL )
                    x = rect.x + (rect.width - lineWidth - 1);
                else
                    y = rect.y + lineWidth + 1;
                break;

            case wxALIGN_CENTRE:
                if( textOrientation == wxHORIZONTAL )
                    x = rect.x + ((rect.width - lineWidth)/2);
                else
                    y = rect.y + rect.height - ((rect.height - lineWidth)/2);
                break;

            case wxALIGN_LEFT:
            default:
                if( textOrientation == wxHORIZONTAL )
                    x = rect.x + 1;
                else
                    y = rect.y + rect.height - 1;
                break;
            }

            if( textOrientation == wxHORIZONTAL )
            {
				//changes applies here
				wxString formattedText = FormatTextWithEllipses(dc,lines[l],rect.width);
                dc.DrawText( formattedText, (int)x, (int)y );
                y += lineHeight;
            }
            else
            {
                dc.DrawRotatedText( lines[l], (int)x, (int)y, 90.0 );
                x += lineHeight;
            }
        }
    }
    dc.DestroyClippingRegion();
}
コード例 #17
0
ファイル: TGraphScale.cpp プロジェクト: magnusmanske/gentle-m
void TGraphScale::drawit ( wxDC &dc , wxRect &r , wxRect &inner )
	{
   	wxRect ir = CalcInternalRect ( r ) ;
   	int border = 2 ;
   	
   	if ( horizontal )
   		{
	    if ( ir.x < inner.x ) ir.x = inner.x ;
	    while ( ir.GetRight() > inner.GetRight() ) ir.width-- ;
	    outline = ir ;
	    ir.height -= border*2 ;
	    ir.y += border ;
   		}
    else
    	{
	    if ( ir.y < inner.y ) ir.y = inner.y ;
	    while ( ir.GetBottom() > inner.GetBottom() ) ir.height-- ;
	    outline = ir ;
	    ir.width -= border*2 ;
	    ir.x += border ;
     	}        
   	
   	// Selected? Draw nice background!
   	if ( selected )
   		{
	    dc.SetPen ( *MYPEN ( TGraphDisplay::prettyColor ) ) ;
	    dc.SetBrush ( *MYBRUSH ( TGraphDisplay::prettyColor ) ) ;
	    dc.DrawRectangle ( outline ) ;
	    dc.SetBrush ( *wxTRANSPARENT_BRUSH ) ;
   		}   
   	
   	// Calculate major and minor units
   	float multiplier = 10 ; //( unit == _T("s") ) ? 6 : 10 ;
   	float factor = 1 ;
   	while ( factor <= max ) factor *= multiplier ;
   	float f2 = top - bottom ;
   	while ( factor >= f2 ) factor /= multiplier ;
   	
   	float major = factor ;
   	float minor = major / 5 ;
   	
   	// Draw scale
   	dc.SetFont ( *MYFONT ( 8 , wxMODERN , wxNORMAL , wxNORMAL ) ) ;
   	dc.SetTextForeground ( col ) ;
   	dc.SetPen ( *MYPEN ( col ) ) ;
   	
   	float p = 0 ;
   	while ( p > bottom ) p -= minor ;
   	while ( p < bottom ) p += minor ;
   	if ( p != bottom ) p -= minor ;
   	while ( p <= top )
   		{
			wxString label ;
/*			if ( unit == _T("s") ) label = wxString::Format ( _T("%d:%2d") , p / 60 , ((int)p) % 60 ) ;
			else */label = wxString::Format ( _T("%f") , p ) ;
			DrawMark ( dc , p , ir , label , ( p - ((int)(p/major))*major ) == 0 ) ;
			p += minor ;
   		}    
	
	// Draw "backline" and name/unit
	wxString text = name ;
	if ( !unit.IsEmpty() ) text += _T(" [") + unit + _T("]") ;
   	int tw , th ;
   	dc.GetTextExtent ( text , &tw , &th ) ;
	if ( horizontal )
		{
  		if ( left )
    		{
          	dc.DrawLine ( ir.x , ir.y , ir.GetRight() , ir.y ) ;
          	dc.DrawText ( text , ir.x , ir.y ) ;
          	}   	
  		else
    		{
     		dc.DrawLine ( ir.x , ir.GetBottom() , ir.GetRight() , ir.GetBottom() ) ;
          	dc.DrawText ( text , ir.x , ir.GetBottom() - th ) ;
     		}  		
  		if ( show_mark )
  			{
	    	int c = GetRealCoord ( GetVirtualCoordinate ( mark , inner ) , inner ) ;
	    	dc.SetPen ( *wxRED_PEN ) ;
	    	dc.DrawLine ( c , ir.GetTop() , c , ir.GetBottom() ) ;
  			}    
		}		
	else
		{
		if ( left )
  			{
         dc.DrawLine ( ir.x , ir.y , ir.x , ir.GetBottom() ) ;
         dc.DrawRotatedText ( text , ir.x + 2 , ir.GetBottom() , 90 ) ;
         }   	
		else
  			{
    		dc.DrawLine ( ir.GetRight() , ir.y , ir.GetRight() , ir.GetBottom() ) ;
         dc.DrawRotatedText ( text , ir.GetRight()-th , ir.GetBottom() , 90 ) ;
      	}
  		if ( show_mark )
  			{
	    	int c = GetRealCoord ( GetVirtualCoordinate ( mark , inner ) , inner ) ;
	    	dc.SetPen ( *wxRED_PEN ) ;
	    	dc.DrawLine ( ir.GetLeft() , c , ir.GetRight() , c ) ;
  			}    
  		}
	last_inner = inner ;
	show_mark = false ;
	}    
コード例 #18
0
void SeqPlot::show ( wxDC& dc )
    {
    if ( s.IsEmpty() ) return ;
    mylog ( "SeqPlot::show" , "1" ) ;
    dc.SetFont(*can->font);
    wxColour tbg = dc.GetTextBackground () ;
    wxColour tfg = dc.GetTextForeground () ;
    int bm = dc.GetBackgroundMode () ;
    int a , b , cnt = offset+1 ;
    wxString t ;
    char u[100] , valid[256] ;
    for ( a = 0 ; a < 256 ; a++ ) valid[a] = 0 ;
    valid['A'] = valid['C'] = valid['T'] = valid['G'] = valid[' '] = 1 ;
//    dc.SetTextBackground ( *wxWHITE ) ;
    dc.SetTextForeground ( fontColor ) ;
//    dc.SetBackgroundMode ( wxSOLID ) ;
    dc.SetBackgroundMode ( wxTRANSPARENT ) ;
    int xa , xb , ya , yb ;
    dc.GetDeviceOrigin ( &xa , &ya ) ;
    ya = -ya ;
    xa = -xa ;
    can->MyGetClientSize ( &xb , &yb ) ;
    yb += ya ;
    xb += xa ;
    int lx = 0 ;
    startOfLine = true ;
    mylog ( "SeqPlot::show" , "2" ) ;
    for ( a = 0 ; a < pos.p.GetCount() ; a++ )
        {
			mylog ( "SeqPlot::show" , "2a" ) ;
        if ( can->hardstop > -1 && a > can->hardstop ) break ;
			mylog ( "SeqPlot::show" , "2b" ) ;
        b = pos.p[a] ;
        int tx = pos.r[a].x , ty = pos.r[a].y ;
        int tz = ty + can->charheight * lines ;
        bool insight = true ; // Meaning "is this part visible"
        if ( tz < ya ) insight = false ;
        if ( ty > yb ) insight = false ;
        if ( tx + can->charwidth < xa ) insight = false ;
        if ( tx > xb ) insight = false ;
        if ( can->getDrawAll() ) insight = true ;
        if ( !insight && ty > yb ) a = pos.p.GetCount() ;
        if ( b > 0 && !insight ) cnt++ ;
			mylog ( "SeqPlot::show" , "2c" ) ;
        if ( b > 0 && insight ) // Character
           {
           if ( lx == 0 ) lx = tx ;
           t = s.GetChar(b-1) ;
           if ( can->isPrinting() )
	       {
		   if (getMark ( a ) == 1 )
			   {
		       dc.SetBrush ( *MYBRUSH ( wxColour ( 230 , 230 , 230 ) ) ) ;
		       dc.SetPen(*wxTRANSPARENT_PEN);
		       dc.DrawRectangle ( tx , ty , can->charwidth , can->charheight ) ;
			   }
			mylog ( "SeqPlot::show" , "2c1" ) ;
		   if ( !can->getPrintToColor() )
			   {
		       dc.SetBackgroundMode ( wxTRANSPARENT ) ;
		       dc.SetTextForeground ( *wxBLACK ) ;
			   }
	       }

			mylog ( "SeqPlot::show" , wxString::Format ( _T("2c2 (type %d)") , type ) ) ;
           switch ( type )
              {
              case CHOU_FASMAN : showChouFasman ( dc , b-1 , tx , ty , lx ) ; break ;
              case COILED_COIL : showChouFasman ( dc , b-1 , tx , ty , lx ) ; break ;
              case M_W : showMW ( dc , b-1 , tx , ty , lx ) ; break ;
              case P_I : showPI ( dc , b-1 , tx , ty , lx ) ; break ;
              case H_P : showHP ( dc , b-1 , tx , ty , lx ) ; break ;
              }
           lx = tx + can->charwidth ;
           cnt++ ;
           startOfLine = false ;
			mylog ( "SeqPlot::show" , "2c3" ) ;
           }
        else if ( insight ) // Front
           {           
			mylog ( "SeqPlot::show" , "2d1" ) ;
           lx = 0 ;
           startOfLine = true ;
           if ( !can->isMiniDisplay() ) continue ;
			mylog ( "SeqPlot::show" , "2d2" ) ;
           dc.SetFont(*can->smallFont);
           if ( type == CHOU_FASMAN ) t = _T("Chou-Fasman") ;
           if ( type == COILED_COIL ) t = _T("Coiled-coil") ;
           else if ( type == M_W ) t = _T("MW") ;
           else if ( type == P_I ) t = _T("pI") ;
           else if ( type == H_P )
              {
              t = _T("t_method_") ;
              t += hp_method ;
              t = txt(t) ;
              t += wxString::Format( _T(" [%d]") , hp_window ) ;
              }
			mylog ( "SeqPlot::show" , "2d3" ) ;
           dc.SetTextForeground ( *wxBLACK ) ;
           int tw , th ;
           dc.GetTextExtent ( t , &tw , &th ) ;
           int ty = pos.r[a].y ;
           ty += lines * can->charheight ;
			mylog ( "SeqPlot::show" , "2d4" ) ;
#ifdef __WXGTK__
	   ty += th / 2 ;
	   dc.DrawText ( t , pos.r[a].x , ty ) ;
#else
           ty -= ( lines * can->charheight - tw ) / 2 ;
           dc.DrawRotatedText ( t , pos.r[a].x, ty , 90 ) ;
#endif
           dc.SetFont(*can->font);
           }
			mylog ( "SeqPlot::show" , "2e" ) ;
        }
    mylog ( "SeqPlot::show" , "3" ) ;
    dc.SetBackgroundMode ( bm ) ;
    dc.SetTextBackground ( tbg ) ;
    dc.SetTextForeground ( tfg ) ;
    }
コード例 #19
0
ファイル: CRawlogTreeView.cpp プロジェクト: 3660628/mrpt
/* ------------------------------------------------------------
						reloadFromRawlog
   ------------------------------------------------------------ */
void CRawlogTreeView::OnDraw(wxDC& dc)
{
	// The origin of the window:
	int xc0,y0;
	GetViewStart(&xc0,&y0);		// Not pixels, but **lines**

	int w,h;
	GetSize(&w,&h);

	wxRect  visibleArea(xc0*ROW_HEIGHT,y0*ROW_HEIGHT,w*ROW_HEIGHT,h*ROW_HEIGHT);

	//wxBufferedDC	dc(&real_dc, visibleArea.GetSize() ); //wxSize(w,h) );

	dc.SetPen( *wxTRANSPARENT_PEN );
	dc.SetBrush( *wxWHITE_BRUSH );
	dc.DrawRectangle(xc0*ROW_HEIGHT,y0*ROW_HEIGHT,w,h);

	// The first time only, create fonts:
	static wxFont	font_normal(11,wxFONTFAMILY_ROMAN, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL );
	static wxFont	font_bold  (11,wxFONTFAMILY_ROMAN, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD  );
	static wxColour wxColorGray(40,40,40);
	static wxColour brush_SELECTED_COLOR( 0,200, 200);
	static wxPen gray_thick( brush_SELECTED_COLOR, 3 );
	static wxPen gray_thin( brush_SELECTED_COLOR, 1 );

	size_t first_item = y0;

	size_t n_visible_items = (h/ROW_HEIGHT)+1;
	if (n_visible_items<1) n_visible_items=1;

	size_t last_item = first_item+n_visible_items-1;

	last_item = min(last_item, m_tree_nodes.size() );

	// Draw icons?
	// ----------------------------
	int   x0 = 30;
	int   Ax0_img  = 0; // Increment in x for the icons, if any.

	if (m_imageList && m_imageList->GetImageCount()>0)
	{
		int		imgw,imgh;
		m_imageList->GetSize(0,imgw,imgh);
		Ax0_img = imgw + 4;
	}

	// Draw only those elements that are visible:
	// -----------------------------------------------
	const int		first_tim_y = ROW_HEIGHT + 1;
	const int		last_tim_y  = (m_tree_nodes.size()-1)*ROW_HEIGHT - 1;


	for (size_t i=first_item;i<last_item;i++)
	{
		int y = i*ROW_HEIGHT;	// y= bottom of that row
		TNodeData  &d = m_tree_nodes[i];

		switch (d.level)
		{
		case 0:
			dc.SetFont( font_bold );
			dc.SetTextForeground( *wxBLACK );
			break;

		case 1:
			dc.SetFont( font_normal );
			dc.SetTextForeground( *wxBLACK );
			break;

		default:
		case 2:
			dc.SetFont( font_normal );
			dc.SetTextForeground( wxColorGray );
			break;
		};

		// Select icon & text according to type of object
		// ------------------------------------------------
		int			icon = -1;
		wxString	s;

		if (i==0)
		{
			// The root node:
			s = _U( format("Rawlog: %s",m_rawlog_name.c_str()).c_str() );
			icon = 3;
		}
		else
		{
			// According to class ID:
			m_rawlog->getAsGeneric( d.index );  // Just to assure it's on memory

			if (d.data.present())
			{
				// Icon:
				icon = iconIndexFromClass( d.data->GetRuntimeClass() );

				// Text:
				if (d.level==1)
				{
					s << _U( format("[%i] ",(int)d.index ).c_str() );
				}

				s << _U( d.data->GetRuntimeClass()->className );

				// Sensor label:
				if ( d.data->GetRuntimeClass()->derivedFrom( CLASS_ID(CObservation) ) )
				{
					CObservationPtr obs = CObservationPtr(d.data);

					/*if (first_tim==INVALID_TIMESTAMP)
					{
						first_tim = obs->timestamp;
						first_tim_y = y+1;
					}

					last_tim = obs->timestamp;
					last_tim_y = y+1;*/

					if ( !obs->sensorLabel.empty())
						s << wxT(" : ") << _U( obs->sensorLabel.c_str() );
				}
			}
		}

		// Draw text and icon:
		// ------------------------------------
		if (m_selectedItem==int(i))
		{
			dc.SetBrush( brush_SELECTED_COLOR );
			dc.DrawRectangle(x0+TREE_HORZ_STEPS * d.level,y,w-x0,ROW_HEIGHT);
			dc.SetTextBackground( brush_SELECTED_COLOR );

			dc.SetPen( gray_thick );
			dc.DrawLine(x0,y+1,x0+TREE_HORZ_STEPS * d.level,y+1);
		}
		else
		{
			dc.SetTextBackground( GetBackgroundColour() );

			dc.SetPen( gray_thin );
			dc.DrawLine(x0,y+1,x0+TREE_HORZ_STEPS * d.level,y+1);
		}

		dc.DrawText( s, Ax0_img + x0 + TREE_HORZ_STEPS * d.level, y );
		if (m_imageList && icon>=0)
			m_imageList->Draw(icon, dc,x0 + TREE_HORZ_STEPS * d.level +1,y );
	}

	// Draw time-line:
	// -----------------------------------------------
	dc.SetPen( *wxLIGHT_GREY_PEN );
	dc.DrawLine(15, visibleArea.GetTop() ,15, visibleArea.GetBottom() );

	dc.SetTextForeground( wxColorGray );
	dc.SetFont( font_normal );
	dc.DrawRotatedText(_("Time"),17,10,-90);

	// timestamps in time-line:
	// -----------------------------------------------
	if (m_rawlog_start!=INVALID_TIMESTAMP && m_rawlog_last!=INVALID_TIMESTAMP && last_tim_y>first_tim_y)
	{
		dc.SetFont( font_normal );

		const double len_tim = mrpt::system::timeDifference(m_rawlog_start,m_rawlog_last);

		for (size_t i=first_item;i<last_item;i++)
		{
			int y = i*ROW_HEIGHT;	// y= bottom of that row
			TNodeData  &d = m_tree_nodes[i];

			if (d.data.present())
			{
				TTimeStamp	t_this = INVALID_TIMESTAMP;
				if ( d.data->GetRuntimeClass()->derivedFrom( CLASS_ID(CObservation) ) )
				{
					CObservationPtr obs = CObservationPtr(d.data);
					t_this = obs->timestamp;
				}

				if (t_this!=INVALID_TIMESTAMP)
				{
					// Draw line:
					if (m_selectedItem==int(i))
							dc.SetPen( gray_thick );
					else	dc.SetPen( gray_thin );

					// Calc. the "y" coordinate for this time:
					double At = mrpt::system::timeDifference(m_rawlog_start,t_this);
					double rat = At / len_tim;
					int  ty =  first_tim_y + (last_tim_y-first_tim_y)*rat;

					dc.DrawLine(15,ty,x0,y+1);

					// Draw some text labels with times:
					if ((i%5)==0)
					{
						dc.DrawLine(10,ty,15,ty);

						// Seconds from start of rawlog:
						if (m_rawlog_start!=INVALID_TIMESTAMP)
						{
							double sec = mrpt::system::timeDifference(m_rawlog_start,t_this);
							wxString s = _U( format("%.03fs", sec ).c_str() );
							dc.DrawRotatedText(s,17,ty+3,-90);
						}
					}
				}
			}
		} // end for i
	}
}
コード例 #20
0
void kwxAngularMeter::DrawTicks(wxDC &dc)
{
	double intervallo = (m_nAngleEnd - m_nAngleStart) / (m_nTick + 1.0); //angle between each ticks (deg)
	double valint = m_nAngleStart; //(deg)
	double tx, ty;
	double val;
	double dx, dy;
	int n, w, h;
	int tw, th;
	wxString s;

	GetClientSize(&w, &h);

	dc.SetPen(*wxThePenList->FindOrCreatePen(*wxBLACK, 2, wxSOLID));

	for(n = 0;n < m_nTick+2;n++)
	{
		dc.SetPen(*wxThePenList->FindOrCreatePen(*wxBLACK, 4, wxSOLID));
		val=(valint * m_dPI) / 180;
		//wxLogTrace("v: %f",valint);
		dx = cos(val) * (h/2);	//point on the circle
		dy = sin(val) * (h/2);

		tx = cos(val) * ((h / 2) - 10);	//point in the circle
		ty = sin(val) * ((h / 2) - 10);

		dc.DrawLine((w / 2) - tx, (h / 2) - ty, (w / 2) - dx, (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(wxT("%d"), rightval); //only use integer value

		dc.GetTextExtent(s, &tw, &th);

		val = valint * m_dPI/ 180 - 0.5*tw/(0.5*h - 12.0);	//angle moved (rad)
		tx = cos(val) * ((h / 2) - 12);	//item text
		ty = sin(val) * ((h / 2) - 12);

		dc.SetFont(m_Font);

		dc.DrawRotatedText(s,(w / 2) - tx, (h / 2) - ty, 90 - valint);


        //draw SubTick (Do not draw subticks after the last Tick)
        if (n==m_nTick+1)
            continue;

        double stepSubtick  = intervallo*m_dPI/5.0/180.0;
        double beginSubtick = valint*m_dPI/180.0+stepSubtick;
		for (int i = 0; i<4; i++)
        {
            dc.SetPen(*wxThePenList->FindOrCreatePen(*wxBLACK, 1, wxSOLID));

            dx = cos(beginSubtick) * (h/2);	//point on the circle
            dy = sin(beginSubtick) * (h/2);
            tx = cos(beginSubtick) * ((h / 2) - 5);	//point in the circle
            ty = sin(beginSubtick) * ((h / 2) - 5);

            dc.DrawLine((w / 2) - tx, (h / 2) - ty, (w / 2) - dx, (h / 2) - dy);
            beginSubtick += stepSubtick;
        }

		valint = valint + intervallo;
	}

}
コード例 #21
0
// 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);
            //top left corner, width and height, start and end angle
                                 // 315 same center and x-radius as last pie-arc, half Y radius
            dc.DrawEllipticArc(25,50,100,50,180.0,45.0);

            wP = *wxCYAN_PEN;
            wP.SetWidth(3);
            dc.SetPen(wP);
                                 //wxTRANSPARENT));
            dc.SetBrush (wxBrush (wxT("SALMON")));
            dc.DrawEllipticArc(300,  0,200,100, 0.0,145.0);
                                 //same end point
            dc.DrawEllipticArc(300, 50,200,100,90.0,145.0);
            dc.DrawEllipticArc(300,100,200,100,90.0,345.0);

#if wxUSE_STATUSBAR
            s = wxT("This is an arc test page");
#endif // wxUSE_STATUSBAR
            break;

        case 4:
            dc.DrawCheckMark ( 30,30,25,25);
            dc.SetBrush (wxBrush (wxT("SALMON"),wxBRUSHSTYLE_TRANSPARENT));
            dc.DrawCheckMark ( 80,50,75,75);
            dc.DrawRectangle ( 80,50,75,75);
#if wxUSE_STATUSBAR
            s = wxT("Two check marks");
#endif // wxUSE_STATUSBAR
            break;

        case 5:
            wF = wxFont ( 18, wxROMAN, wxITALIC, wxBOLD, false, wxT("Times New Roman"));
            dc.SetFont(wF);
            dc.DrawLine(0, 0, 200, 200);
            dc.DrawLine(200, 0, 0, 200);
            dc.DrawText(wxT("This is an 18pt string"), 50, 60);

            // rescale and draw in blue
            wP = *wxCYAN_PEN;
            dc.SetPen(wP);
            dc.SetUserScale (2.0,0.5);
            dc.SetDeviceOrigin(200,0);
            dc.DrawLine(0, 0, 200, 200);
            dc.DrawLine(200, 0, 0, 200);
            dc.DrawText(wxT("This is an 18pt string 2 x 0.5 UserScaled"), 50, 60);
            dc.SetUserScale (2.0,2.0);
            dc.SetDeviceOrigin(200,200);
            dc.DrawText(wxT("This is an 18pt string 2 x 2 UserScaled"), 50, 60);

            wP = *wxRED_PEN;
            dc.SetPen(wP);
            dc.SetUserScale (1.0,1.0);
            dc.SetDeviceOrigin(0,10);
            dc.SetMapMode (wxMM_METRIC); //svg ignores this
            dc.DrawLine(0, 0, 200, 200);
            dc.DrawLine(200, 0, 0, 200);
            dc.DrawText(wxT("This is an 18pt string in MapMode"), 50, 60);
#if wxUSE_STATUSBAR
            s = wxT("Scaling test page");
#endif // wxUSE_STATUSBAR
            break;

        case 6:
            dc.DrawIcon( wxICON(sample), 10, 10 );
            dc.DrawBitmap ( wxBitmap(svgbitmap_xpm), 50,15);
#if wxUSE_STATUSBAR
            s = wxT("Icon and Bitmap ");
#endif // wxUSE_STATUSBAR
            break;

        case 7:
            dc.SetTextForeground(wxT("RED"));
            dc.DrawText(wxT("Red = Clipping Off"), 30, 5);
            dc.SetTextForeground(wxT("GREEN"));
            dc.DrawText(wxT("Green = Clipping On"), 30, 25);

            dc.SetTextForeground(wxT("BLACK"));

            dc.SetPen(*wxRED_PEN);
            dc.SetBrush (wxBrush (wxT("SALMON"),wxBRUSHSTYLE_TRANSPARENT));
            dc.DrawCheckMark ( 80,50,75,75);
            dc.DrawRectangle ( 80,50,75,75);

            dc.SetPen(*wxGREEN_PEN);

            // Clipped checkmarks
            dc.DrawRectangle(180,50,75,75);
            dc.SetClippingRegion(180,50,75,75);                   // x,y,width,height version
            dc.DrawCheckMark ( 180,50,75,75);
            dc.DestroyClippingRegion();

            dc.DrawRectangle(wxRect(80,150,75,75));
            dc.SetClippingRegion(wxPoint(80,150),wxSize(75,75));  // pt,size version
            dc.DrawCheckMark ( 80,150,75,75);
            dc.DestroyClippingRegion();

            dc.DrawRectangle(wxRect(180,150,75,75));
            dc.SetClippingRegion(wxRect(180,150,75,75));          // rect version
            dc.DrawCheckMark ( 180,150,75,75);
            dc.DestroyClippingRegion();

            dc.DrawRectangle(wxRect( 80,250,50,65));
            dc.DrawRectangle(wxRect(105,260,50,65));
            dc.SetClippingRegion(wxRect( 80,250,50,65));  // second call to SetClippingRegion
            dc.SetClippingRegion(wxRect(105,260,50,65));  // forms intersection with previous
            dc.DrawCheckMark(80,250,75,75);
            dc.DestroyClippingRegion();                   // only one call to destroy (there's no stack)

            /*
            ** Clipping by wxRegion not implemented for SVG.   Should be
            ** possible, but need to access points that define the wxRegion
            ** from inside DoSetDeviceClippingRegion() and wxRegion does not
            ** implement anything like getPoints().
            points[0].x = 180; points[0].y = 250;
            points[1].x = 255; points[1].y = 250;
            points[2].x = 180; points[2].y = 325;
            points[3].x = 255; points[3].y = 325;
            points[4].x = 180; points[4].y = 250;

            dc.DrawLines (5, points);
            wxRegion reg = wxRegion(5,points);

            dc.SetClippingRegion(reg);
            dc.DrawCheckMark ( 180,250,75,75);
            dc.DestroyClippingRegion();
            */

#if wxUSE_STATUSBAR
            s = wxT("Clipping region");
#endif // wxUSE_STATUSBAR
            break;

        case 8:
            wxString txtStr;
            wxCoord txtX, txtY, txtW, txtH, txtDescent, txtEL;
            wxCoord txtPad = 0;

            wP = *wxRED_PEN;
            dc.SetPen(wP);
            //dc.SetBackgroundMode(wxBRUSHSTYLE_SOLID);
            //dc.SetTextBackground(*wxBLUE);

            // Horizontal text
            txtStr = wxT("Horizontal string");
            dc.GetTextExtent(txtStr, &txtW, &txtH, &txtDescent, &txtEL);
            txtX = 50;
            txtY = 300;
            dc.DrawRectangle(txtX, txtY, txtW + 2*txtPad, txtH + 2*txtPad);
            dc.DrawText(txtStr, txtX + txtPad, txtY + txtPad);

            // Vertical text
            txtStr = wxT("Vertical string");
            dc.GetTextExtent(txtStr, &txtW, &txtH, &txtDescent, &txtEL);
            txtX = 50;
            txtY = 250;
            dc.DrawRectangle(txtX, txtY - (txtW + 2*txtPad), txtH + 2*txtPad, txtW + 2*txtPad);
            dc.DrawRotatedText(txtStr, txtX + txtPad, txtY - txtPad, 90);

            // 45 degree text
            txtStr = wxT("45 deg string");
            dc.GetTextExtent(txtStr, &txtW, &txtH, &txtDescent, &txtEL);
            double lenW = (double)(txtW + 2*txtPad) / sqrt(2.0);
            double lenH = (double)(txtH + 2*txtPad) / sqrt(2.0);
            double padding = (double)txtPad / sqrt(2.0);
            txtX = 150;
            txtY = 200;
            dc.DrawLine(txtX - padding, txtY, txtX + lenW, txtY - lenW); // top
            dc.DrawLine(txtX + lenW, txtY - lenW, txtX - padding + lenH + lenW, txtY + (lenH - lenW));
            dc.DrawLine(txtX - padding, txtY, txtX - padding + lenH, txtY + lenH);
            dc.DrawLine(txtX - padding + lenH, txtY + lenH, txtX - padding + lenH + lenW, txtY + (lenH - lenW)); // bottom
            dc.DrawRotatedText(txtStr, txtX, txtY, 45);
#if wxUSE_STATUSBAR
            s = wxT("Text position test page");
#endif // wxUSE_STATUSBAR
            break;
    }
#if wxUSE_STATUSBAR
    m_child->SetStatusText(s);
#endif // wxUSE_STATUSBAR
}
コード例 #22
0
ファイル: compdateaxis.cpp プロジェクト: lukecian/wxfreechart
void CompDateAxis::DrawSpan(wxDC &dc, wxRect rcAxis, int spanNum, wxString spanLabel, double start, double end)
{
    double winMin, winMax;
    GetWindowBounds(winMin, winMax);

    if (end <= winMin || start >= winMax) {
        return ; // span is not visible
    }

    wxCoord spanExtent = GetSpanExtent(dc);
    wxRect rcSpan;

    wxCoord minCoord, axisSize;
    if (IsVertical()) {
        minCoord = rcAxis.y;
        axisSize = rcAxis.height;
    }
    else {
        minCoord = rcAxis.x;
        axisSize = rcAxis.width;
    }

    wxCoord gStart, gEnd, gCenter;
    if (start <= winMin) {
        gStart = minCoord;
    }
    else {
        gStart = Axis::ToGraphics(dc, minCoord, axisSize, start);
    }

    if (end >= winMax) {
        gEnd = minCoord + axisSize;
    }
    else {
        gEnd = Axis::ToGraphics(dc, minCoord, axisSize, end);
    }

    gCenter = Axis::ToGraphics(dc, minCoord, axisSize, (start + end) / 2);

    if (IsVertical()) {
        rcSpan.x = rcAxis.x + spanNum * spanExtent;
        rcSpan.y = gStart;
        rcSpan.width = spanExtent;
        rcSpan.height = gEnd - gStart;
    }
    else {
        rcSpan.x = gStart;
        rcSpan.y = rcAxis.y + spanNum * spanExtent;
        rcSpan.width = gEnd - gStart;
        rcSpan.height = spanExtent;
    }

    wxDCClipper clipper(dc, rcSpan);

    m_spanDraw->Draw(dc, rcSpan);

    int labelCount;
    wxCoord xIncr, yIncr;
    wxCoord size;
    wxCoord labelGap;
    wxCoord x, y;

    dc.SetFont(m_labelFont);
    dc.SetTextForeground(m_labelColour);

    wxSize textExtent = dc.GetTextExtent(spanLabel);

    if (IsVertical()) {
        size = rcSpan.height;
        labelCount = 1;//size / (textExtent.x + 2 * m_minLabelGap);
        labelGap = 3 * m_minLabelGap + size / labelCount - textExtent.x;
        xIncr = 0;
        yIncr = labelGap;
        x = rcSpan.x + m_labelMargin;
        y = rcSpan.y + rcSpan.height - labelGap;
    }
    else {
        size = rcSpan.width;
        labelCount = 1;//size / (textExtent.x + 2 * m_minLabelGap);
        labelGap = 3 * m_minLabelGap + size / labelCount - textExtent.x;
        xIncr = labelGap;
        yIncr = 0;
        x = rcSpan.x;
        y = rcSpan.y + m_labelMargin;
    }

    // draw span labels
    for (int n = 0; n < labelCount; n++) {
        if (IsVertical()) {
            dc.DrawRotatedText(spanLabel, x, y, 90);
        }
        else {
            dc.DrawText(spanLabel, x, y);
        }

        x += xIncr;
        y += yIncr;
    }
}