Commit 96849d5a authored by charras's avatar charras
Browse files

code cleaning

parent b808fcf4
Loading
Loading
Loading
Loading
+1 −3
Original line number Original line Diff line number Diff line
@@ -39,9 +39,7 @@ void WinEDA_DrawFrame::CopyToClipboard( wxCommandEvent& event )


        if( DrawPanel->ManageCurseur && DrawPanel->ForceCloseManageCurseur )
        if( DrawPanel->ManageCurseur && DrawPanel->ForceCloseManageCurseur )
        {
        {
            wxClientDC dc( DrawPanel );
            KicadGraphicContext dc( DrawPanel );

            DrawPanel->PrepareGraphicContext( &dc );
            DrawPanel->ForceCloseManageCurseur( DrawPanel, &dc );
            DrawPanel->ForceCloseManageCurseur( DrawPanel, &dc );
        }
        }
    }
    }
+2 −5
Original line number Original line Diff line number Diff line
@@ -340,9 +340,7 @@ void WinEDA_DrawFrame::ReDrawPanel()
    if( DrawPanel == NULL )
    if( DrawPanel == NULL )
        return;
        return;


    wxClientDC dc( DrawPanel );
    KicadGraphicContext dc( DrawPanel );

    DrawPanel->PrepareGraphicContext( &dc );
    DrawPanel->ReDraw( &dc );
    DrawPanel->ReDraw( &dc );
}
}


@@ -599,9 +597,8 @@ void WinEDA_DrawFrame::AdjustScrollBars()
    int x, y, scroll_x, scroll_y;
    int x, y, scroll_x, scroll_y;
    double scale_x, scale_y;
    double scale_x, scale_y;


    wxClientDC DC( this );
    DrawPanel DC( this );


    DrawPanel->PrepareGraphicContext( &DC );
    x = DC.LogicalToDeviceXRel( draw_size.GetWidth() );
    x = DC.LogicalToDeviceXRel( draw_size.GetWidth() );
    y = DC.LogicalToDeviceYRel( draw_size.GetHeight() );
    y = DC.LogicalToDeviceYRel( draw_size.GetHeight() );


+29 −24
Original line number Original line Diff line number Diff line
@@ -16,6 +16,26 @@
#define CURSOR_SIZE 12           // Cursor size in pixels
#define CURSOR_SIZE 12           // Cursor size in pixels




// Helper class to handle the client Device Context
KicadGraphicContext::KicadGraphicContext( WinEDA_DrawPanel * aDrawPanel )
    : wxClientDC(aDrawPanel)
{
    GRResetPenAndBrush( this );
    SetBackgroundMode( wxTRANSPARENT );
#ifdef WX_ZOOM
    double scale = aDrawPanel->GetScreen()->GetScalingFactor();
    SetUserScale( scale, scale );
    wxPoint origin = aDrawPanel->GetScreen()->m_DrawOrg;
    SetLogicalOrigin( origin.x, origin.y );
#endif
    aDrawPanel->SetBoundaryBox();
}

KicadGraphicContext::~KicadGraphicContext( )
{
}


/* Used to inhibit a response to a mouse left button release, after a
/* Used to inhibit a response to a mouse left button release, after a
 * double click (when releasing the left button at the end of the second
 * double click (when releasing the left button at the end of the second
 * click.  Used in eeschema to inhibit a mouse left release command when
 * click.  Used in eeschema to inhibit a mouse left release command when
@@ -172,19 +192,6 @@ wxRealPoint WinEDA_DrawPanel::GetGrid()
}
}




void WinEDA_DrawPanel::PrepareGraphicContext( wxDC* DC )
{
    GRResetPenAndBrush( DC );
    DC->SetBackgroundMode( wxTRANSPARENT );
#ifdef WX_ZOOM
    double scale = GetScreen()->GetScalingFactor();
    DC->SetUserScale( scale, scale );
    wxPoint origin = GetScreen()->m_DrawOrg;
    DC->SetLogicalOrigin( origin.x, origin.y );
#endif
    SetBoundaryBox();
}



/** Calculate the cursor position in internal units.
/** Calculate the cursor position in internal units.
 * @return  position (in internal units)
 * @return  position (in internal units)
@@ -194,8 +201,8 @@ wxPoint WinEDA_DrawPanel::CursorRealPosition( const wxPoint& ScreenPos )
{
{
#ifdef WX_ZOOM
#ifdef WX_ZOOM
    wxCoord x, y;
    wxCoord x, y;
    wxClientDC DC( this );
    KicadGraphicContext DC( this );
    PrepareGraphicContext( &DC );

    x = DC.DeviceToLogicalX( ScreenPos.x );
    x = DC.DeviceToLogicalX( ScreenPos.x );
    y = DC.DeviceToLogicalY( ScreenPos.y );
    y = DC.DeviceToLogicalY( ScreenPos.y );
    return wxPoint( x, y );
    return wxPoint( x, y );
@@ -304,8 +311,8 @@ wxPoint WinEDA_DrawPanel::CursorScreenPosition()
{
{
#ifdef WX_ZOOM
#ifdef WX_ZOOM
    wxCoord x, y;
    wxCoord x, y;
    wxClientDC DC( this );
    KicadGraphicContext DC( this );
    PrepareGraphicContext( &DC );

    x = DC.LogicalToDeviceX( GetScreen()->m_Curseur.x );
    x = DC.LogicalToDeviceX( GetScreen()->m_Curseur.x );
    y = DC.LogicalToDeviceY( GetScreen()->m_Curseur.y );
    y = DC.LogicalToDeviceY( GetScreen()->m_Curseur.y );
    return wxPoint( x, y );
    return wxPoint( x, y );
@@ -332,8 +339,7 @@ wxPoint WinEDA_DrawPanel::GetScreenCenterRealPosition( void )
    GetScreen()->Unscale( realpos );
    GetScreen()->Unscale( realpos );
#ifdef WX_ZOOM
#ifdef WX_ZOOM
//    wxCoord x, y;
//    wxCoord x, y;
//    wxClientDC DC( this );
//    KicadGraphicContext DC( this );
//    PrepareGraphicContext( &DC );
//    realpos.x = DC.DeviceToLogicalX( realpos.x );
//    realpos.x = DC.DeviceToLogicalX( realpos.x );
//    realpos.y = DC.DeviceToLogicalY( realpos.y );
//    realpos.y = DC.DeviceToLogicalY( realpos.y );
#else
#else
@@ -567,7 +573,6 @@ void WinEDA_DrawPanel::OnPaint( wxPaintEvent& event )
    wxRect    PaintClipBox;
    wxRect    PaintClipBox;
    wxPoint   org;
    wxPoint   org;


    PrepareGraphicContext( &paintDC );
    tmp = m_ClipBox;
    tmp = m_ClipBox;


    org = m_ClipBox.GetOrigin();
    org = m_ClipBox.GetOrigin();
@@ -1010,11 +1015,11 @@ void WinEDA_DrawPanel::OnMouseEvent( wxMouseEvent& event )
    screen->m_MousePosition =
    screen->m_MousePosition =
        CursorRealPosition( screen->m_MousePositionInPixels );
        CursorRealPosition( screen->m_MousePositionInPixels );


    wxClientDC DC( this );
    KicadGraphicContext DC( this );

    int        kbstat = 0;
    int        kbstat = 0;


    DC.SetBackground( *wxBLACK_BRUSH );
    DC.SetBackground( *wxBLACK_BRUSH );
    PrepareGraphicContext( &DC );


    g_KeyPressed = localkey;
    g_KeyPressed = localkey;


@@ -1259,10 +1264,10 @@ void WinEDA_DrawPanel::OnKeyEvent( wxKeyEvent& event )
    if( event.ShiftDown() && (key > 256) )
    if( event.ShiftDown() && (key > 256) )
        localkey |= GR_KB_SHIFT;
        localkey |= GR_KB_SHIFT;


    wxClientDC DC( this );
    KicadGraphicContext DC( this );

    BASE_SCREEN* Screen = GetScreen();
    BASE_SCREEN* Screen = GetScreen();


    PrepareGraphicContext( &DC );


    g_KeyPressed = localkey;
    g_KeyPressed = localkey;


+1 −2
Original line number Original line Diff line number Diff line
@@ -722,8 +722,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::SetInitCmp( wxCommandEvent& event )
    if( entry == NULL )
    if( entry == NULL )
        return;
        return;


    wxClientDC dc( m_Parent->DrawPanel );
    KicadGraphicContext dc( m_Parent->DrawPanel );
    m_Parent->DrawPanel->PrepareGraphicContext( &dc );


    RedrawOneStruct( m_Parent->DrawPanel, &dc, m_Cmp, g_XorMode );
    RedrawOneStruct( m_Parent->DrawPanel, &dc, m_Cmp, g_XorMode );


+3 −9
Original line number Original line Diff line number Diff line
@@ -179,9 +179,7 @@ SCH_ITEM* WinEDA_SchematicFrame::FindComponentAndItem(
            Recadre_Trace( mouseWarp );
            Recadre_Trace( mouseWarp );
        else
        else
        {
        {
            wxClientDC dc( DrawPanel );
            KicadGraphicContext dc( DrawPanel );

            DrawPanel->PrepareGraphicContext( &dc );


            EXCHG( old_cursor_position, sheet->LastScreen()->m_Curseur );
            EXCHG( old_cursor_position, sheet->LastScreen()->m_Curseur );
            DrawPanel->CursorOff( &dc );
            DrawPanel->CursorOff( &dc );
@@ -356,9 +354,7 @@ SCH_ITEM* WinEDA_SchematicFrame::FindMarker( int SearchType )
            Recadre_Trace( TRUE );
            Recadre_Trace( TRUE );
        else
        else
        {
        {
            wxClientDC dc( DrawPanel );
            KicadGraphicContext dc( DrawPanel );

            DrawPanel->PrepareGraphicContext( &dc );
            EXCHG( old_cursor_position, sheet->LastScreen()->m_Curseur );
            EXCHG( old_cursor_position, sheet->LastScreen()->m_Curseur );
            DrawPanel->CursorOff( &dc );
            DrawPanel->CursorOff( &dc );
            DrawPanel->MouseTo( curpos );
            DrawPanel->MouseTo( curpos );
@@ -581,9 +577,7 @@ SCH_ITEM* WinEDA_SchematicFrame::FindSchematicItem( const wxString& pattern,
            Recadre_Trace( mouseWarp );
            Recadre_Trace( mouseWarp );
        else
        else
        {
        {
            wxClientDC dc( DrawPanel );
            KicadGraphicContext dc( DrawPanel );

            DrawPanel->PrepareGraphicContext( &dc );


            EXCHG( old_cursor_position, Sheet->LastScreen()->m_Curseur );
            EXCHG( old_cursor_position, Sheet->LastScreen()->m_Curseur );
            DrawPanel->CursorOff( &dc );
            DrawPanel->CursorOff( &dc );
Loading