viewlib_frame: fix incorrect management of the unit selection combo box.
This commit is contained in:
parent
21195a751d
commit
5f31ce03f7
|
@ -41,7 +41,6 @@
|
||||||
void LIB_VIEW_FRAME::ReCreateHToolbar()
|
void LIB_VIEW_FRAME::ReCreateHToolbar()
|
||||||
{
|
{
|
||||||
wxString msg;
|
wxString msg;
|
||||||
LIB_PART* part = NULL;
|
|
||||||
|
|
||||||
if( m_mainToolBar )
|
if( m_mainToolBar )
|
||||||
m_mainToolBar->Clear();
|
m_mainToolBar->Clear();
|
||||||
|
@ -119,33 +118,6 @@ void LIB_VIEW_FRAME::ReCreateHToolbar()
|
||||||
// reflect the changes
|
// reflect the changes
|
||||||
m_mainToolBar->Realize();
|
m_mainToolBar->Realize();
|
||||||
|
|
||||||
if( m_libraryName.size() && m_entryName.size() )
|
|
||||||
{
|
|
||||||
if( Prj().SchSymbolLibTable()->HasLibrary( m_libraryName ) )
|
|
||||||
{
|
|
||||||
part = GetLibPart( LIB_ID( m_libraryName, m_entryName ) );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @todo Move updating the symbol units in the combobox to the symbol select function
|
|
||||||
/// and stop calling this function to update the toolbar. All of the other toolbar
|
|
||||||
/// updates are handled by wxUpdateUIEvents.
|
|
||||||
int parts_count = 1;
|
|
||||||
|
|
||||||
if( part )
|
|
||||||
parts_count = std::max( part->GetUnitCount(), 1 );
|
|
||||||
|
|
||||||
m_selpartBox->Clear();
|
|
||||||
|
|
||||||
for( int ii = 0; ii < parts_count; ii++ )
|
|
||||||
{
|
|
||||||
msg.Printf( _( "Unit %c" ), 'A' + ii );
|
|
||||||
m_selpartBox->Append( msg );
|
|
||||||
}
|
|
||||||
|
|
||||||
m_selpartBox->SetSelection( m_unit > 0 ? m_unit - 1 : 0 );
|
|
||||||
m_selpartBox->Enable( parts_count > 1 );
|
|
||||||
|
|
||||||
m_mainToolBar->Refresh();
|
m_mainToolBar->Refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -87,6 +87,7 @@ BEGIN_EVENT_TABLE( LIB_VIEW_FRAME, EDA_DRAW_FRAME )
|
||||||
EVT_UPDATE_UI( ID_LIBVIEW_DE_MORGAN_CONVERT_BUTT,
|
EVT_UPDATE_UI( ID_LIBVIEW_DE_MORGAN_CONVERT_BUTT,
|
||||||
LIB_VIEW_FRAME::onUpdateAlternateBodyStyleButton )
|
LIB_VIEW_FRAME::onUpdateAlternateBodyStyleButton )
|
||||||
EVT_UPDATE_UI( ID_LIBVIEW_SHOW_ELECTRICAL_TYPE, LIB_VIEW_FRAME::OnUpdateElectricalType )
|
EVT_UPDATE_UI( ID_LIBVIEW_SHOW_ELECTRICAL_TYPE, LIB_VIEW_FRAME::OnUpdateElectricalType )
|
||||||
|
EVT_UPDATE_UI( ID_LIBVIEW_SELECT_PART_NUMBER, LIB_VIEW_FRAME::OnUpdateSelectionPartBox )
|
||||||
|
|
||||||
END_EVENT_TABLE()
|
END_EVENT_TABLE()
|
||||||
|
|
||||||
|
@ -367,6 +368,45 @@ void LIB_VIEW_FRAME::OnUpdateElectricalType( wxUpdateUIEvent& aEvent )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void LIB_VIEW_FRAME::OnUpdateSelectionPartBox( wxUpdateUIEvent& aEvent )
|
||||||
|
{
|
||||||
|
LIB_PART* part = nullptr;
|
||||||
|
|
||||||
|
if( m_libraryName.size() && m_entryName.size() )
|
||||||
|
{
|
||||||
|
if( Prj().SchSymbolLibTable()->HasLibrary( m_libraryName ) )
|
||||||
|
part = GetLibPart( LIB_ID( m_libraryName, m_entryName ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
int unit_count = 1;
|
||||||
|
|
||||||
|
if( part )
|
||||||
|
unit_count = std::max( part->GetUnitCount(), 1 );
|
||||||
|
|
||||||
|
m_selpartBox->Enable( unit_count > 1 );
|
||||||
|
|
||||||
|
if( unit_count > 1 )
|
||||||
|
{
|
||||||
|
// rebuild the unit list if it is not suitable
|
||||||
|
if( unit_count != (int)m_selpartBox->GetCount() )
|
||||||
|
{
|
||||||
|
m_selpartBox->Clear();
|
||||||
|
|
||||||
|
for( int ii = 0; ii < unit_count; ii++ )
|
||||||
|
|
||||||
|
m_selpartBox->Append( wxString::Format( _( "Unit %c" ), 'A' + ii ) );
|
||||||
|
|
||||||
|
m_selpartBox->SetSelection( m_unit > 0 ? m_unit - 1 : 0 );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if( m_selpartBox->GetCount() )
|
||||||
|
m_selpartBox->Clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
double LIB_VIEW_FRAME::BestZoom()
|
double LIB_VIEW_FRAME::BestZoom()
|
||||||
{
|
{
|
||||||
LIB_PART* part = NULL;
|
LIB_PART* part = NULL;
|
||||||
|
@ -475,7 +515,6 @@ bool LIB_VIEW_FRAME::ReCreateListLib()
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cmp_changed = ReCreateListCmp();
|
bool cmp_changed = ReCreateListCmp();
|
||||||
ReCreateHToolbar();
|
|
||||||
DisplayLibInfos();
|
DisplayLibInfos();
|
||||||
m_canvas->Refresh();
|
m_canvas->Refresh();
|
||||||
|
|
||||||
|
@ -555,7 +594,6 @@ void LIB_VIEW_FRAME::SetSelectedLibrary( const wxString& aLibraryName )
|
||||||
ReCreateListCmp();
|
ReCreateListCmp();
|
||||||
m_canvas->Refresh();
|
m_canvas->Refresh();
|
||||||
DisplayLibInfos();
|
DisplayLibInfos();
|
||||||
ReCreateHToolbar();
|
|
||||||
|
|
||||||
// Ensure the corresponding line in m_libList is selected
|
// Ensure the corresponding line in m_libList is selected
|
||||||
// (which is not necessary the case if SetSelectedLibrary is called
|
// (which is not necessary the case if SetSelectedLibrary is called
|
||||||
|
@ -598,7 +636,6 @@ void LIB_VIEW_FRAME::SetSelectedComponent( const wxString& aComponentName )
|
||||||
}
|
}
|
||||||
|
|
||||||
Zoom_Automatique( false );
|
Zoom_Automatique( false );
|
||||||
ReCreateHToolbar();
|
|
||||||
m_canvas->Refresh();
|
m_canvas->Refresh();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -171,6 +171,7 @@ private:
|
||||||
void onUpdateNormalBodyStyleButton( wxUpdateUIEvent& aEvent );
|
void onUpdateNormalBodyStyleButton( wxUpdateUIEvent& aEvent );
|
||||||
void onUpdateViewDoc( wxUpdateUIEvent& aEvent );
|
void onUpdateViewDoc( wxUpdateUIEvent& aEvent );
|
||||||
void OnUpdateElectricalType( wxUpdateUIEvent& aEvent );
|
void OnUpdateElectricalType( wxUpdateUIEvent& aEvent );
|
||||||
|
void OnUpdateSelectionPartBox( wxUpdateUIEvent& aEvent );
|
||||||
void onSelectNextSymbol( wxCommandEvent& aEvent );
|
void onSelectNextSymbol( wxCommandEvent& aEvent );
|
||||||
void onSelectPreviousSymbol( wxCommandEvent& aEvent );
|
void onSelectPreviousSymbol( wxCommandEvent& aEvent );
|
||||||
void onViewSymbolDocument( wxCommandEvent& aEvent );
|
void onViewSymbolDocument( wxCommandEvent& aEvent );
|
||||||
|
|
Loading…
Reference in New Issue