예제 #1
0
파일: concanv.cpp 프로젝트: KastB/OpenCPN
void AnnunText::OnPaint( wxPaintEvent& event )
{
    int sx, sy;
    GetClientSize( &sx, &sy );
    ocpnStyle::Style* style = g_StyleManager->GetCurrentStyle();

    //    Do the drawing on an off-screen memory DC, and blit into place
    //    to avoid objectionable flashing
    wxMemoryDC mdc;

    wxBitmap m_bitmap( sx, sy, -1 );
    mdc.SelectObject( m_bitmap );
    mdc.SetBackground( m_backBrush );
    mdc.Clear();

    if( style->consoleTextBackground.IsOk() ) mdc.DrawBitmap( style->consoleTextBackground, 0, 0 );

    mdc.SetTextForeground( m_default_text_color );

    if( m_plabelFont ) {
        mdc.SetFont( *m_plabelFont );
        mdc.SetTextForeground( m_legend_color );
        mdc.DrawText( m_label, 5, 2 );
    }

    if( m_pvalueFont ) {
        mdc.SetFont( *m_pvalueFont );
        mdc.SetTextForeground( m_val_color );

        int w, h;
        mdc.GetTextExtent( m_value, &w, &h );
        int cw, ch;
        mdc.GetSize( &cw, &ch );

        mdc.DrawText( m_value, cw - w - 2, ch - h - 2 );
    }

    wxPaintDC dc( this );
    dc.Blit( 0, 0, sx, sy, &mdc, 0, 0 );
    
}
예제 #2
0
void AnnunText::OnPaint(wxPaintEvent& event)
{
      int sx,sy;
      GetClientSize(&sx, &sy);

      //    Do the drawing on an off-screen memory DC, and blit into place
      //    to avoid objectionable flashing
      wxMemoryDC mdc;

      wxBitmap m_bitmap(sx, sy, -1);
      mdc.SelectObject(m_bitmap);
      mdc.SetBackground(*m_pbackBrush);
      mdc.Clear();

      mdc.SetTextForeground(m_text_color);

      if(m_plabelFont)
      {
            mdc.SetFont(*m_plabelFont);
            mdc.DrawText(m_label, 5, 2);
      }

      if(m_pvalueFont)
      {
            mdc.SetFont(*m_pvalueFont);

            int w, h;
            mdc.GetTextExtent(m_value, &w, &h);
            int cw, ch;
            mdc.GetSize(&cw, &ch);

            mdc.DrawText(m_value, cw - w - 2, ch - h - 2);
      }

      wxPaintDC dc(this);
      dc.Blit(0, 0, sx, sy, &mdc, 0, 0);

}
예제 #3
0
파일: concanv.cpp 프로젝트: KastB/OpenCPN
void CDI::OnPaint( wxPaintEvent& event )
{
    int sx, sy;
    GetClientSize( &sx, &sy );

    //    Do the drawing on an off-screen memory DC, and blit into place
    //    to avoid objectionable flashing
    wxMemoryDC mdc;

    wxBitmap m_bitmap( sx, sy, -1 );
    mdc.SelectObject( m_bitmap );
    mdc.SetBackground( *m_pbackBrush );
    mdc.Clear();

    int xp = sx / 2;
    int yp = sy * 9 / 10;

    int path_length = sy * 3;
    int pix_per_xte = 120;

    if( g_pRouteMan->GetpActiveRoute() ) {
        double angle = 90 - ( g_pRouteMan->GetCurrentSegmentCourse() - gCog );

        double dy = path_length * sin( angle * PI / 180. );
        double dx = path_length * cos( angle * PI / 180. );

        int xtedir;
        xtedir = g_pRouteMan->GetXTEDir();
        double xte = g_pRouteMan->GetCurrentXTEToActivePoint();

        double ddy = xtedir * pix_per_xte * xte * sin( ( 90 - angle ) * PI / 180. );
        double ddx = xtedir * pix_per_xte * xte * cos( ( 90 - angle ) * PI / 180. );

        int ddxi = (int) ddx;
        int ddyi = (int) ddy;

        int xc1 = xp - (int) ( dx / 2 ) + ddxi;
        int yc1 = yp + (int) ( dy / 2 ) + ddyi;
        int xc2 = xp + (int) ( dx / 2 ) + ddxi;
        int yc2 = yp - (int) ( dy / 2 ) + ddyi;

        wxPoint road[4];

        int road_top_width = 10;
        int road_bot_width = 40;

        road[0].x = xc1 - (int) ( road_bot_width * cos( ( 90 - angle ) * PI / 180. ) );
        road[0].y = yc1 - (int) ( road_bot_width * sin( ( 90 - angle ) * PI / 180. ) );

        road[1].x = xc2 - (int) ( road_top_width * cos( ( 90 - angle ) * PI / 180. ) );
        road[1].y = yc2 - (int) ( road_top_width * sin( ( 90 - angle ) * PI / 180. ) );

        road[2].x = xc2 + (int) ( road_top_width * cos( ( 90 - angle ) * PI / 180. ) );
        road[2].y = yc2 + (int) ( road_top_width * sin( ( 90 - angle ) * PI / 180. ) );

        road[3].x = xc1 + (int) ( road_bot_width * cos( ( 90 - angle ) * PI / 180. ) );
        road[3].y = yc1 + (int) ( road_bot_width * sin( ( 90 - angle ) * PI / 180. ) );

        mdc.SetBrush( *m_proadBrush );
        mdc.SetPen( *m_proadPen );
        mdc.DrawPolygon( 4, road, 0, 0, wxODDEVEN_RULE );

///        mdc.DrawLine( xc1, yc1, xc2, yc2 );

        mdc.DrawLine( 0, yp, sx, yp );
        mdc.DrawCircle( xp, yp, 6 );
        mdc.DrawLine( xp, yp + 5, xp, yp - 5 );
    }

    wxPaintDC dc( this );
    dc.Blit( 0, 0, sx, sy, &mdc, 0, 0 );
}