diff --git a/eeschema/busentry.cpp b/eeschema/busentry.cpp index ea010658c6..afe9897500 100644 --- a/eeschema/busentry.cpp +++ b/eeschema/busentry.cpp @@ -72,37 +72,12 @@ void SCH_EDIT_FRAME::SetBusEntryShape( wxDC* DC, SCH_BUS_ENTRY* BusEntry, int en if( BusEntry->m_Flags == 0 ) SaveCopyInUndoList( BusEntry, UR_CHANGED ); + s_LastShape = entry_shape == '/' ? '/' : '\\'; + BusEntry->Draw( DrawPanel, DC, wxPoint( 0, 0 ), g_XorMode ); - - wxSize size = BusEntry->GetSize(); - - switch( entry_shape ) - { - case '\\': - s_LastShape = '\\'; - size.y = 100; - BusEntry->SetSize( size ); - break; - - case '/': - s_LastShape = '/'; - size.y = -100; - BusEntry->SetSize( size ); - break; - } - + BusEntry->SetBusEntryShape( s_LastShape ); GetScreen()->TestDanglingEnds(); BusEntry->Draw( DrawPanel, DC, wxPoint( 0, 0 ), g_XorMode ); + OnModify( ); } - - -int SCH_EDIT_FRAME::GetBusEntryShape( SCH_BUS_ENTRY* BusEntry ) -{ - int entry_shape = '\\'; - - if( BusEntry->GetSize().y < 0 ) - entry_shape = '/'; - - return entry_shape; -} diff --git a/eeschema/menubar.cpp b/eeschema/menubar.cpp index 57bcddb279..226a5e4baa 100644 --- a/eeschema/menubar.cpp +++ b/eeschema/menubar.cpp @@ -310,7 +310,7 @@ void SCH_EDIT_FRAME::ReCreateMenuBar() // Wire to Bus entry text = AddHotkeyName( _( "Wire to Bus &Entry" ), s_Schematic_Hokeys_Descr, - HK_ADD_WIRE_ENTRY, IS_ACCELERATOR ); // addan accelerator, not a shortcut + HK_ADD_WIRE_ENTRY, IS_ACCELERATOR ); // add an accelerator, not a shortcut AddMenuItem( placeMenu, ID_WIRETOBUS_ENTRY_BUTT, text, HELP_PLACE_WIRE2BUS_ENTRY, KiBitmap( add_line2bus_xpm ) ); diff --git a/eeschema/onrightclick.cpp b/eeschema/onrightclick.cpp index 799b36bdef..fae0761f95 100644 --- a/eeschema/onrightclick.cpp +++ b/eeschema/onrightclick.cpp @@ -62,6 +62,7 @@ static void AddMenusForComponent( wxMenu* PopMenu, SCH_COMPONENT* Component ); static void AddMenusForComponentField( wxMenu* PopMenu, SCH_FIELD* Field ); static void AddMenusForMarkers( wxMenu* aPopMenu, SCH_MARKER* aMarker, SCH_EDIT_FRAME* aFrame ); static void AddMenusForBitmap( wxMenu* aPopMenu, SCH_BITMAP * aBitmap ); +static void AddMenusForBusEntry( wxMenu* aPopMenu, SCH_BUS_ENTRY * aBusEntry ); @@ -149,22 +150,7 @@ bool SCH_EDIT_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu ) break; case SCH_BUS_ENTRY_T: - if( !flags ) - { - wxString msg = AddHotkeyName( _( "Move Bus Entry" ), s_Schematic_Hokeys_Descr, - HK_MOVE_COMPONENT_OR_ITEM ); - AddMenuItem( PopMenu, ID_SCH_MOVE_ITEM, msg, KiBitmap( move_xpm ) ); - } - - if( GetBusEntryShape( (SCH_BUS_ENTRY*) item ) == '\\' ) - AddMenuItem( PopMenu, ID_POPUP_SCH_ENTRY_SELECT_SLASH, - _( "Set Bus Entry /" ), KiBitmap( change_entry_orient_xpm ) ); - else - AddMenuItem( PopMenu, ID_POPUP_SCH_ENTRY_SELECT_ANTISLASH, - _( "Set Bus Entry \\" ), KiBitmap( change_entry_orient_xpm ) ); - - AddMenuItem( PopMenu, ID_POPUP_SCH_DELETE, _( "Delete Bus Entry" ), - KiBitmap( delete_bus_xpm ) ); + AddMenusForBusEntry( PopMenu, (SCH_BUS_ENTRY*) item ); break; case SCH_MARKER_T: @@ -748,3 +734,24 @@ void AddMenusForBitmap( wxMenu* aPopMenu, SCH_BITMAP * aBitmap ) AddMenuItem( aPopMenu, ID_POPUP_SCH_DELETE, msg, KiBitmap( delete_xpm ) ); } } + +void AddMenusForBusEntry( wxMenu* aPopMenu, SCH_BUS_ENTRY * aBusEntry ) +{ + wxString msg; + if( !aBusEntry->GetFlags() ) + { + msg = AddHotkeyName( _( "Move Bus Entry" ), s_Schematic_Hokeys_Descr, + HK_MOVE_COMPONENT_OR_ITEM ); + AddMenuItem( aPopMenu, ID_SCH_MOVE_ITEM, msg, KiBitmap( move_xpm ) ); + } + + if( aBusEntry->GetBusEntryShape() == '\\' ) + AddMenuItem( aPopMenu, ID_POPUP_SCH_ENTRY_SELECT_SLASH, + _( "Set Bus Entry Shape /" ), KiBitmap( change_entry_orient_xpm ) ); + else + AddMenuItem( aPopMenu, ID_POPUP_SCH_ENTRY_SELECT_ANTISLASH, + _( "Set Bus Entry Shape \\" ), KiBitmap( change_entry_orient_xpm ) ); + + msg = AddHotkeyName( _( "Delete Bus Entry" ), s_Schematic_Hokeys_Descr, HK_DELETE ); + AddMenuItem( aPopMenu, ID_POPUP_SCH_DELETE, msg, KiBitmap( delete_xpm ) ); +} diff --git a/eeschema/sch_bus_entry.cpp b/eeschema/sch_bus_entry.cpp index a08103af7c..1d676d8d48 100644 --- a/eeschema/sch_bus_entry.cpp +++ b/eeschema/sch_bus_entry.cpp @@ -296,3 +296,37 @@ void SCH_BUS_ENTRY::doPlot( PLOTTER* aPlotter ) aPlotter->move_to( m_pos ); aPlotter->finish_to( m_End() ); } + +/* SetBusEntryShape: + * Set the shape of the bus entry. + * aShape = ascii code '/' or '\' + */ +void SCH_BUS_ENTRY::SetBusEntryShape( int aShape ) +{ + switch( aShape ) + { + case '\\': + if( m_size.y < 0 ) + m_size.y = -m_size.y; + break; + + case '/': + if( m_size.y > 0 ) + m_size.y = -m_size.y; + break; + } +} + + +/* GetBusEntryShape: + * return the shape of the bus entry, as an ascii code '/' or '\' + */ +int SCH_BUS_ENTRY::GetBusEntryShape() const +{ + int shape = '\\'; + + if( GetSize().y < 0 ) + shape = '/'; + + return shape; +} diff --git a/eeschema/sch_bus_entry.h b/eeschema/sch_bus_entry.h index b2faf2242a..7b27a5801a 100644 --- a/eeschema/sch_bus_entry.h +++ b/eeschema/sch_bus_entry.h @@ -64,6 +64,18 @@ public: wxPoint m_End() const; + /** + * function GetBusEntryShape + * @return the shape of the bus entry, as an ascii code '/' or '\' + */ + int GetBusEntryShape() const; + + /** + * function SetBusEntryShape + * @param aShape = the shape of the bus entry, as an ascii code '/' or '\' + */ + void SetBusEntryShape( int aShape ); + int GetWidth() const { return m_width; } void SetWidth( int aWidth ) { m_width = aWidth; } diff --git a/include/wxEeschemaStruct.h b/include/wxEeschemaStruct.h index 4f5144bea9..65f09de0bb 100644 --- a/include/wxEeschemaStruct.h +++ b/include/wxEeschemaStruct.h @@ -761,7 +761,6 @@ private: // Bus Entry SCH_BUS_ENTRY* CreateBusEntry( wxDC* DC, int entry_type ); void SetBusEntryShape( wxDC* DC, SCH_BUS_ENTRY* BusEntry, int entry_type ); - int GetBusEntryShape( SCH_BUS_ENTRY* BusEntry ); /** * Function AddNoConnect