← Back to team overview

kicad-developers team mailing list archive

[PATCH 14/19] 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 ae12e34..ce78fda 100644
--- a/eeschema/dialogs/dialog_lib_edit_pin.cpp
+++ b/eeschema/dialogs/dialog_lib_edit_pin.cpp
@@ -161,16 +161,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 ab23264..ebbcb4e 100644
--- a/eeschema/dialogs/dialog_lib_edit_pin.h
+++ b/eeschema/dialogs/dialog_lib_edit_pin.h
@@ -61,7 +61,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 dd31c93..86432fc 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