← Back to team overview

kicad-developers team mailing list archive

[PATCH 20/27] PinTypeComboBox: fully initialize in c'tor

 

---
 eeschema/dialogs/dialog_lib_edit_pin.cpp | 13 -------------
 eeschema/dialogs/dialog_lib_edit_pin.h   |  1 -
 eeschema/pinedit.cpp                     |  2 --
 eeschema/widgets/pin_type_combobox.cpp   | 15 +++++++++++++++
 4 files changed, 15 insertions(+), 16 deletions(-)

diff --git a/eeschema/dialogs/dialog_lib_edit_pin.cpp b/eeschema/dialogs/dialog_lib_edit_pin.cpp
index 74e2966..de35dc0 100644
--- a/eeschema/dialogs/dialog_lib_edit_pin.cpp
+++ b/eeschema/dialogs/dialog_lib_edit_pin.cpp
@@ -157,16 +157,3 @@ void DIALOG_LIB_EDIT_PIN::SetOrientationList( const wxArrayString& list,
             m_choiceOrientation->Insert( list[ii], KiBitmap( aBitmaps[ii] ), ii );
     }
 }
-
-
-void DIALOG_LIB_EDIT_PIN::SetElectricalTypeList( const wxArrayString& list,
-                                                 const BITMAP_DEF* aBitmaps )
-{
-    for ( unsigned ii = 0; ii < list.GetCount(); ii++ )
-    {
-        if( aBitmaps == NULL )
-            m_choiceElectricalType->Append( list[ii] );
-        else
-            m_choiceElectricalType->Insert( list[ii], KiBitmap( aBitmaps[ii] ), ii );
-    }
-}
diff --git a/eeschema/dialogs/dialog_lib_edit_pin.h b/eeschema/dialogs/dialog_lib_edit_pin.h
index b508443..8012495 100644
--- a/eeschema/dialogs/dialog_lib_edit_pin.h
+++ b/eeschema/dialogs/dialog_lib_edit_pin.h
@@ -59,7 +59,6 @@ public:
     }
     int GetOrientation( void ) { return m_choiceOrientation->GetSelection(); }
 
-    void SetElectricalTypeList( const wxArrayString& list, const BITMAP_DEF* aBitmaps );
     void SetElectricalType( ElectricPinType type )
     {
         m_choiceElectricalType->SetSelection( type );
diff --git a/eeschema/pinedit.cpp b/eeschema/pinedit.cpp
index d77b8de..a9045e6 100644
--- a/eeschema/pinedit.cpp
+++ b/eeschema/pinedit.cpp
@@ -105,8 +105,6 @@ void LIB_EDIT_FRAME::OnEditPin( wxCommandEvent& event )
     dlg.SetOrientationList( LIB_PIN::GetOrientationNames(), LIB_PIN::GetOrientationSymbols() );
     dlg.SetOrientation( LIB_PIN::GetOrientationCodeIndex( pin->GetOrientation() ) );
     dlg.SetStyle( pin->GetShape() );
-    dlg.SetElectricalTypeList( LIB_PIN::GetElectricalTypeNames(),
-                               LIB_PIN::GetElectricalTypeSymbols() );
     dlg.SetElectricalType( pin->GetType() );
     dlg.SetPinName( pin->GetName() );
     dlg.SetPinNameTextSize( StringFromValue( g_UserUnit, pin->GetNameTextSize() ) );
diff --git a/eeschema/widgets/pin_type_combobox.cpp b/eeschema/widgets/pin_type_combobox.cpp
index 3c2ac7e..c83d14f 100644
--- a/eeschema/widgets/pin_type_combobox.cpp
+++ b/eeschema/widgets/pin_type_combobox.cpp
@@ -28,6 +28,8 @@
 
 #include "pin_type_combobox.h"
 
+#include <lib_pin.h>
+
 PinTypeComboBox::PinTypeComboBox( wxWindow* parent,
         wxWindowID id,
         const wxString& value,
@@ -40,4 +42,17 @@ PinTypeComboBox::PinTypeComboBox( wxWindow* parent,
         const wxString& name ) :
     wxBitmapComboBox( parent, id, value, pos, size, n, choices, style, validator, name )
 {
+    wxArrayString texts = LIB_PIN::GetElectricalTypeNames();
+    const BITMAP_DEF* bitmaps = LIB_PIN::GetElectricalTypeSymbols();
+
+    for( unsigned ii = 0; ii < PINTYPE_COUNT; ++ii )
+    {
+        wxString text = texts[ ii ];
+        BITMAP_DEF bitmap = bitmaps[ ii ];
+
+        if( bitmap == NULL )
+            Append( text );
+        else
+            Insert( text, KiBitmap( bitmap ), ii );
+    }
 }

Follow ups

References