Commit e50d18bc authored by jean-pierre charras's avatar jean-pierre charras

Minor enhancement and minor code cleaning.

parent 018ffe7e
......@@ -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 );
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;
}
s_LastShape = entry_shape == '/' ? '/' : '\\';
BusEntry->Draw( DrawPanel, DC, wxPoint( 0, 0 ), g_XorMode );
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;
OnModify( );
}
......@@ -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 ) );
......
......@@ -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 ) );
}
......@@ -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;
}
......@@ -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; }
......
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment