diff --git a/eeschema/dialogs/dialog_lib_edit_draw_item.cpp b/eeschema/dialogs/dialog_lib_edit_draw_item.cpp index ff917dbe03..2854421e2d 100644 --- a/eeschema/dialogs/dialog_lib_edit_draw_item.cpp +++ b/eeschema/dialogs/dialog_lib_edit_draw_item.cpp @@ -1,3 +1,30 @@ +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * Copyright (C) 2006-2012 KiCad Developers, see change_log.txt for contributors. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, you may find one here: + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * or you may search the http://www.gnu.org website for the version 2 license, + * or you may write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + +/** + * @file dialog_lib_edit_draw_item.cpp + */ + #include diff --git a/eeschema/libedit_onleftclick.cpp b/eeschema/libedit_onleftclick.cpp index 7d8f161d96..3ba219fa72 100644 --- a/eeschema/libedit_onleftclick.cpp +++ b/eeschema/libedit_onleftclick.cpp @@ -29,13 +29,10 @@ */ #include -#include #include -#include #include #include -#include #include #include @@ -43,19 +40,17 @@ void LIB_EDIT_FRAME::OnLeftClick( wxDC* DC, const wxPoint& aPosition ) { LIB_ITEM* item = m_drawItem; + bool no_item_edited = item == NULL || item->GetFlags() == 0; if( m_component == NULL ) // No component loaded ! return; - if( item == NULL || item->GetFlags() == 0 ) + if( ( GetToolId() == ID_NO_TOOL_SELECTED ) && no_item_edited ) { item = LocateItemUsingCursor( aPosition ); if( item ) - - { item->DisplayInfo( this ); - } else { DisplayCmpDoc(); @@ -84,7 +79,7 @@ void LIB_EDIT_FRAME::OnLeftClick( wxDC* DC, const wxPoint& aPosition ) break; case ID_LIBEDIT_PIN_BUTT: - if( m_drawItem == NULL || m_drawItem->GetFlags() == 0 ) + if( no_item_edited ) { CreatePin( DC ); } @@ -99,7 +94,7 @@ void LIB_EDIT_FRAME::OnLeftClick( wxDC* DC, const wxPoint& aPosition ) case ID_LIBEDIT_BODY_CIRCLE_BUTT: case ID_LIBEDIT_BODY_RECT_BUTT: case ID_LIBEDIT_BODY_TEXT_BUTT: - if( m_drawItem == NULL || m_drawItem->GetFlags() == 0 ) + if( no_item_edited ) { m_drawItem = CreateGraphicItem( m_component, DC ); } diff --git a/eeschema/symbdraw.cpp b/eeschema/symbdraw.cpp index cf755624e2..f6f8d7db5d 100644 --- a/eeschema/symbdraw.cpp +++ b/eeschema/symbdraw.cpp @@ -68,19 +68,19 @@ void LIB_EDIT_FRAME::EditGraphicSymbol( wxDC* DC, LIB_ITEM* DrawItem ) dialog.SetWidthUnits( ReturnUnitSymbol( g_UserUnit ) ); - wxString val = ReturnStringFromValue( g_UserUnit, m_drawLineWidth ); + wxString val = ReturnStringFromValue( g_UserUnit, DrawItem->GetWidth() ); dialog.SetWidth( val ); - dialog.SetApplyToAllUnits( !m_drawSpecificUnit ); + dialog.SetApplyToAllUnits( DrawItem->GetUnit() == 0 ); dialog.EnableApplyToAllUnits( component && component->GetPartCount() > 1 ); - dialog.SetApplyToAllConversions( !m_drawSpecificConvert ); + dialog.SetApplyToAllConversions( DrawItem->GetConvert() == 0 ); dialog.EnableApplyToAllConversions( component && component->HasConversion() ); -// dialog.SetFillStyle( m_drawFillStyle ); // could better to show the current setting dialog.SetFillStyle( DrawItem->GetFillMode() ); dialog.EnableFillStyle( DrawItem->IsFillable() ); if( dialog.ShowModal() == wxID_CANCEL ) return; + // Init default values (used to create a new draw item) val = dialog.GetWidth(); m_drawLineWidth = ReturnValueFromString( g_UserUnit, val ); m_drawSpecificConvert = !dialog.GetApplyToAllConversions(); diff --git a/pcbnew/modedit_onclick.cpp b/pcbnew/modedit_onclick.cpp index 3a343f3523..be0b16edd9 100644 --- a/pcbnew/modedit_onclick.cpp +++ b/pcbnew/modedit_onclick.cpp @@ -58,18 +58,19 @@ void FOOTPRINT_EDIT_FRAME::OnLeftClick( wxDC* DC, const wxPoint& MousePos ) } } } + + else + { + if( !wxGetKeyState( WXK_SHIFT ) && !wxGetKeyState( WXK_ALT ) + && !wxGetKeyState( WXK_CONTROL ) ) + item = ModeditLocateAndDisplay(); + + SetCurItem( item ); + } } item = GetCurItem(); - - if( !item || (item->GetFlags() == 0) ) - { - if( !wxGetKeyState( WXK_SHIFT ) && !wxGetKeyState( WXK_ALT ) - && !wxGetKeyState( WXK_CONTROL ) ) - item = ModeditLocateAndDisplay(); - - SetCurItem( item ); - } + bool no_item_edited = item == NULL || item->GetFlags() == 0; switch( GetToolId() ) { @@ -79,7 +80,7 @@ void FOOTPRINT_EDIT_FRAME::OnLeftClick( wxDC* DC, const wxPoint& MousePos ) case ID_MODEDIT_CIRCLE_TOOL: case ID_MODEDIT_ARC_TOOL: case ID_MODEDIT_LINE_TOOL: - if( !item || item->GetFlags() == 0 ) + if( no_item_edited ) { STROKE_T shape = S_SEGMENT; @@ -117,9 +118,9 @@ void FOOTPRINT_EDIT_FRAME::OnLeftClick( wxDC* DC, const wxPoint& MousePos ) break; case ID_MODEDIT_DELETE_TOOL: - if( item == NULL || // No item to delete - (item->GetFlags() != 0) ) // Item in edit, cannot delete it + if( ! no_item_edited ) // Item in edit, cannot delete it break; + item = ModeditLocateAndDisplay(); if( item->Type() != PCB_MODULE_T ) // Cannot delete the module itself {