From 66aa22c1db0778bef7a8693abec95ef0a6c5dd5d Mon Sep 17 00:00:00 2001
From: jean-pierre charras
Date: Sun, 28 Jun 2015 18:45:05 +0200
Subject: [PATCH] Eeschema: remove an unused argument in a few functions. Fix
also the minor Bug #1469504.
---
eeschema/busentry.cpp | 8 ++++----
eeschema/onleftclick.cpp | 39 ++++++++++++++++++++++-----------------
eeschema/schedit.cpp | 9 ++++-----
eeschema/schframe.cpp | 22 ++++++++--------------
eeschema/schframe.h | 12 +++++++-----
eeschema/sheet.cpp | 15 +--------------
6 files changed, 46 insertions(+), 59 deletions(-)
diff --git a/eeschema/busentry.cpp b/eeschema/busentry.cpp
index b7baf06892..20d266c412 100644
--- a/eeschema/busentry.cpp
+++ b/eeschema/busentry.cpp
@@ -42,25 +42,25 @@
static int s_LastShape = '\\';
-SCH_BUS_BUS_ENTRY* SCH_EDIT_FRAME::CreateBusBusEntry( wxDC* aDC )
+SCH_BUS_BUS_ENTRY* SCH_EDIT_FRAME::CreateBusBusEntry()
{
// Create and place a new bus entry at cursor position
SCH_BUS_BUS_ENTRY* busEntry = new SCH_BUS_BUS_ENTRY( GetCrossHairPosition(), s_LastShape );
busEntry->SetFlags( IS_NEW );
GetScreen()->SetCurItem( busEntry );
- addCurrentItemToList( aDC );
+ addCurrentItemToList();
return busEntry;
}
-SCH_BUS_WIRE_ENTRY* SCH_EDIT_FRAME::CreateBusWireEntry( wxDC* aDC )
+SCH_BUS_WIRE_ENTRY* SCH_EDIT_FRAME::CreateBusWireEntry()
{
// Create and place a new bus entry at cursor position
SCH_BUS_WIRE_ENTRY* busEntry = new SCH_BUS_WIRE_ENTRY( GetCrossHairPosition(), s_LastShape );
busEntry->SetFlags( IS_NEW );
GetScreen()->SetCurItem( busEntry );
- addCurrentItemToList( aDC );
+ addCurrentItemToList();
return busEntry;
}
diff --git a/eeschema/onleftclick.cpp b/eeschema/onleftclick.cpp
index 5cf751b918..39cc14d3bc 100644
--- a/eeschema/onleftclick.cpp
+++ b/eeschema/onleftclick.cpp
@@ -83,7 +83,7 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition )
case SCH_FIELD_T:
case SCH_BITMAP_T:
case SCH_NO_CONNECT_T:
- addCurrentItemToList( aDC );
+ addCurrentItemToList();
return;
case SCH_LINE_T: // May already be drawing segment.
@@ -138,7 +138,7 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition )
}
else
{
- addCurrentItemToList( aDC );
+ addCurrentItemToList();
}
break;
@@ -155,31 +155,31 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition )
}
else
{
- addCurrentItemToList( aDC );
+ addCurrentItemToList();
}
break;
case ID_WIRETOBUS_ENTRY_BUTT:
if( ( item == NULL ) || ( item->GetFlags() == 0 ) )
{
- CreateBusWireEntry( aDC );
+ CreateBusWireEntry();
m_canvas->SetAutoPanRequest( true );
}
else
{
- addCurrentItemToList( aDC );
+ addCurrentItemToList();
}
break;
case ID_BUSTOBUS_ENTRY_BUTT:
if( ( item == NULL ) || ( item->GetFlags() == 0 ) )
{
- CreateBusBusEntry( aDC );
+ CreateBusBusEntry();
m_canvas->SetAutoPanRequest( true );
}
else
{
- addCurrentItemToList( aDC );
+ addCurrentItemToList();
}
break;
@@ -210,7 +210,7 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition )
}
else
{
- addCurrentItemToList( aDC );
+ addCurrentItemToList();
}
break;
@@ -222,7 +222,7 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition )
}
else
{
- addCurrentItemToList( aDC );
+ addCurrentItemToList();
}
break;
@@ -234,7 +234,7 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition )
}
else
{
- addCurrentItemToList( aDC );
+ addCurrentItemToList();
}
break;
@@ -252,7 +252,7 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition )
}
else
{
- addCurrentItemToList( aDC );
+ addCurrentItemToList();
}
break;
@@ -269,7 +269,7 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition )
}
else
{
- addCurrentItemToList( aDC );
+ addCurrentItemToList();
}
break;
@@ -290,7 +290,7 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition )
}
else if( (item->Type() == SCH_SHEET_PIN_T) && (item->GetFlags() != 0) )
{
- addCurrentItemToList( aDC );
+ addCurrentItemToList();
}
break;
@@ -303,7 +303,7 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition )
}
else
{
- addCurrentItemToList( aDC );
+ addCurrentItemToList();
}
break;
@@ -318,7 +318,7 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition )
}
else
{
- addCurrentItemToList( aDC );
+ addCurrentItemToList();
}
break;
@@ -363,7 +363,12 @@ void SCH_EDIT_FRAME::OnLeftDClick( wxDC* aDC, const wxPoint& aPosition )
case SCH_COMPONENT_T:
EditComponent( (SCH_COMPONENT*) item );
- m_canvas->MoveCursorToCrossHair();
+ GetCanvas()->MoveCursorToCrossHair();
+
+ if( item->GetFlags() == 0 )
+ GetScreen()->SetCurItem( NULL );
+
+ GetCanvas()->Refresh();
break;
case SCH_TEXT_T:
@@ -379,7 +384,7 @@ void SCH_EDIT_FRAME::OnLeftDClick( wxDC* aDC, const wxPoint& aPosition )
case SCH_FIELD_T:
EditComponentFieldText( (SCH_FIELD*) item );
- m_canvas->MoveCursorToCrossHair();
+ GetCanvas()->MoveCursorToCrossHair();
break;
case SCH_MARKER_T:
diff --git a/eeschema/schedit.cpp b/eeschema/schedit.cpp
index 88d065822a..db64c0519a 100644
--- a/eeschema/schedit.cpp
+++ b/eeschema/schedit.cpp
@@ -234,7 +234,7 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
case ID_POPUP_SCH_END_SHEET:
m_canvas->MoveCursorToCrossHair();
- addCurrentItemToList( &dc );
+ addCurrentItemToList();
break;
case ID_POPUP_SCH_RESIZE_SHEET:
@@ -377,7 +377,7 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
item = screen->GetCurItem();
if( item )
- addCurrentItemToList( &dc );
+ addCurrentItemToList();
break;
@@ -876,8 +876,6 @@ void SCH_EDIT_FRAME::OnEditItem( wxCommandEvent& aEvent )
SCH_SCREEN* screen = GetScreen();
SCH_ITEM* item = screen->GetCurItem();
- INSTALL_UNBUFFERED_DC( dc, m_canvas );
-
if( item == NULL )
{
// If we didn't get here by a hot key, then something has gone wrong.
@@ -955,7 +953,8 @@ void SCH_EDIT_FRAME::OnEditItem( wxCommandEvent& aEvent )
}
case SCH_SHEET_T:
- EditSheet( (SCH_SHEET*) item, m_CurrentSheet, &dc );
+ if( EditSheet( (SCH_SHEET*) item, m_CurrentSheet ) )
+ m_canvas->Refresh();
break;
case SCH_SHEET_PIN_T:
diff --git a/eeschema/schframe.cpp b/eeschema/schframe.cpp
index 4b3ea2bfcc..57cc4b1c6e 100644
--- a/eeschema/schframe.cpp
+++ b/eeschema/schframe.cpp
@@ -1196,7 +1196,7 @@ bool SCH_EDIT_FRAME::isAutoSaveRequired() const
}
-void SCH_EDIT_FRAME::addCurrentItemToList( wxDC* aDC )
+void SCH_EDIT_FRAME::addCurrentItemToList( bool aRedraw )
{
SCH_SCREEN* screen = GetScreen();
SCH_ITEM* item = screen->GetCurItem();
@@ -1235,11 +1235,14 @@ void SCH_EDIT_FRAME::addCurrentItemToList( wxDC* aDC )
// the m_mouseCaptureCallback function.
m_canvas->SetMouseCapture( NULL, NULL );
- if( !EditSheet( (SCH_SHEET*)item, m_CurrentSheet, aDC ) )
+ if( !EditSheet( (SCH_SHEET*)item, m_CurrentSheet ) )
{
screen->SetCurItem( NULL );
- item->Draw( m_canvas, aDC, wxPoint( 0, 0 ), g_XorMode );
delete item;
+
+ if( aRedraw )
+ GetCanvas()->Refresh();
+
return;
}
@@ -1276,10 +1279,6 @@ void SCH_EDIT_FRAME::addCurrentItemToList( wxDC* aDC )
SaveUndoItemInUndoList( undoItem );
}
- // Erase the wire representation before the 'normal' view is drawn.
- if ( item->IsWireImage() )
- item->Draw( m_canvas, aDC, wxPoint( 0, 0 ), g_XorMode );
-
item->ClearFlags();
screen->SetModify();
screen->SetCurItem( NULL );
@@ -1289,13 +1288,8 @@ void SCH_EDIT_FRAME::addCurrentItemToList( wxDC* aDC )
if( item->IsConnectable() )
screen->TestDanglingEnds();
- if( aDC )
- {
- EDA_CROSS_HAIR_MANAGER( m_canvas, aDC ); // Erase schematic cursor
- undoItem->Draw( m_canvas, aDC, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE );
- }
-
- m_canvas->Refresh();
+ if( aRedraw )
+ GetCanvas()->Refresh();
}
diff --git a/eeschema/schframe.h b/eeschema/schframe.h
index c5f33b61b5..8761eda086 100644
--- a/eeschema/schframe.h
+++ b/eeschema/schframe.h
@@ -200,9 +200,9 @@ protected:
* adds the item currently being edited to the schematic and adds the changes to
* the undo/redo container.
*
- * @param aDC A pointer the device context to draw on when not NULL.
+ * @param aRedraw = true (default) to redrw -the screen after adding the item.
*/
- void addCurrentItemToList( wxDC* aDC );
+ void addCurrentItemToList( bool aRedraw = true );
void updateFindReplaceView( wxFindDialogEvent& aEvent );
@@ -868,8 +868,8 @@ private:
void UpdateTitle();
// Bus Entry
- SCH_BUS_WIRE_ENTRY* CreateBusWireEntry( wxDC* DC );
- SCH_BUS_BUS_ENTRY* CreateBusBusEntry( wxDC* DC );
+ SCH_BUS_WIRE_ENTRY* CreateBusWireEntry();
+ SCH_BUS_BUS_ENTRY* CreateBusBusEntry();
void SetBusEntryShape( wxDC* DC, SCH_BUS_ENTRY_BASE* BusEntry, char entry_shape );
/**
@@ -1002,8 +1002,10 @@ public:
* and the file name does not exist in the schematic hierarchy or on the file system,
* the current associated screen file name is changed and saved to disk.
*
+ *
+ * Note: the screen is not refresh. The caller is responsible to do that
*/
- bool EditSheet( SCH_SHEET* aSheet, SCH_SHEET_PATH* aHierarchy, wxDC* aDC );
+ bool EditSheet( SCH_SHEET* aSheet, SCH_SHEET_PATH* aHierarchy );
wxPoint GetLastSheetPinPosition() const { return m_lastSheetPinPosition; }
diff --git a/eeschema/sheet.cpp b/eeschema/sheet.cpp
index 9ef1a5ccc5..e532ec4df6 100644
--- a/eeschema/sheet.cpp
+++ b/eeschema/sheet.cpp
@@ -41,7 +41,7 @@
#include
-bool SCH_EDIT_FRAME::EditSheet( SCH_SHEET* aSheet, SCH_SHEET_PATH* aHierarchy, wxDC* aDC )
+bool SCH_EDIT_FRAME::EditSheet( SCH_SHEET* aSheet, SCH_SHEET_PATH* aHierarchy )
{
if( aSheet == NULL || aHierarchy == NULL )
return false;
@@ -82,10 +82,6 @@ bool SCH_EDIT_FRAME::EditSheet( SCH_SHEET* aSheet, SCH_SHEET_PATH* aHierarchy, w
if( !fileName.IsOk() )
{
DisplayError( this, _( "File name is not valid!" ) );
-
- if( m_canvas )
- m_canvas->Refresh();
-
return false;
}
@@ -96,10 +92,6 @@ bool SCH_EDIT_FRAME::EditSheet( SCH_SHEET* aSheet, SCH_SHEET_PATH* aHierarchy, w
{
DisplayError( this, wxString::Format( _( "A sheet named \"%s\" already exists." ),
GetChars( dlg.GetSheetName() ) ) );
-
- if( m_canvas )
- m_canvas->Refresh();
-
return false;
}
@@ -143,9 +135,6 @@ bool SCH_EDIT_FRAME::EditSheet( SCH_SHEET* aSheet, SCH_SHEET_PATH* aHierarchy, w
if( !IsOK( this, msg ) )
{
- if( m_canvas )
- m_canvas->Refresh();
-
return false;
}
}
@@ -209,7 +198,6 @@ bool SCH_EDIT_FRAME::EditSheet( SCH_SHEET* aSheet, SCH_SHEET_PATH* aHierarchy, w
}
}
- aSheet->Draw( m_canvas, aDC, wxPoint( 0, 0 ), g_XorMode );
m_canvas->SetIgnoreMouseEvents( true );
if( isUndoable )
@@ -267,7 +255,6 @@ bool SCH_EDIT_FRAME::EditSheet( SCH_SHEET* aSheet, SCH_SHEET_PATH* aHierarchy, w
m_canvas->MoveCursorToCrossHair();
m_canvas->SetIgnoreMouseEvents( false );
- aSheet->Draw( m_canvas, aDC, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE );
OnModify();
return true;