← Back to team overview

kicad-developers team mailing list archive

[PATCH 3/5] Refactor ELECTRICAL_PINTYPE

 

 - Move to separate header
 - Move UI text and bitmap lookups out of LIB_PIN
 - Move widget init code out of dialog, into own widget class
---
 eeschema/CMakeLists.txt                       |   2 +
 eeschema/dialogs/dialog_erc.cpp               |  18 ++--
 eeschema/dialogs/dialog_erc.h                 |   4 +-
 eeschema/dialogs/dialog_lib_edit_pin.cpp      |  13 ---
 eeschema/dialogs/dialog_lib_edit_pin.h        |   8 +-
 eeschema/dialogs/dialog_lib_edit_pin_base.cpp |   3 +-
 eeschema/dialogs/dialog_lib_edit_pin_base.fbp |   2 +-
 eeschema/dialogs/dialog_lib_edit_pin_base.h   |   3 +-
 eeschema/erc.cpp                              |  22 ++---
 eeschema/lib_pin.cpp                          |  78 +++--------------
 eeschema/lib_pin.h                            |  45 +---------
 eeschema/pin_type.cpp                         | 116 ++++++++++++++++++++++++++
 eeschema/pin_type.h                           |  59 +++++++++++++
 eeschema/pinedit.cpp                          |   2 -
 eeschema/widgets/pin_type_combobox.cpp        |  69 +++++++++++++++
 eeschema/widgets/pin_type_combobox.h          |  51 +++++++++++
 16 files changed, 340 insertions(+), 155 deletions(-)
 create mode 100644 eeschema/pin_type.cpp
 create mode 100644 eeschema/pin_type.h
 create mode 100644 eeschema/widgets/pin_type_combobox.cpp
 create mode 100644 eeschema/widgets/pin_type_combobox.h

diff --git a/eeschema/CMakeLists.txt b/eeschema/CMakeLists.txt
index 036322c..e68a5e8 100644
--- a/eeschema/CMakeLists.txt
+++ b/eeschema/CMakeLists.txt
@@ -74,6 +74,7 @@ set( EESCHEMA_DLGS
 set( EESCHEMA_WIDGETS
     widgets/widget_eeschema_color_config.cpp
     widgets/pin_shape_combobox.cpp
+    widgets/pin_type_combobox.cpp
     )
 
 
@@ -140,6 +141,7 @@ set( EESCHEMA_SRCS
     pinedit.cpp
     pin_number.cpp
     pin_shape.cpp
+    pin_type.cpp
     plot_schematic_DXF.cpp
     plot_schematic_HPGL.cpp
     plot_schematic_PS.cpp
diff --git a/eeschema/dialogs/dialog_erc.cpp b/eeschema/dialogs/dialog_erc.cpp
index 3186bf5..5f15760 100644
--- a/eeschema/dialogs/dialog_erc.cpp
+++ b/eeschema/dialogs/dialog_erc.cpp
@@ -49,8 +49,8 @@
 #include <erc.h>
 #include <id.h>
 
-extern int           DiagErc[PIN_NMAX][PIN_NMAX];
-extern int           DefaultDiagErc[PIN_NMAX][PIN_NMAX];
+extern int           DiagErc[PINTYPE_COUNT][PINTYPE_COUNT];
+extern int           DefaultDiagErc[PINTYPE_COUNT][PINTYPE_COUNT];
 
 
 
@@ -63,7 +63,7 @@ bool DIALOG_ERC::m_tstUniqueGlobalLabels = true;    // saved only for the curren
 #define ID_MATRIX_0 1800
 
 BEGIN_EVENT_TABLE( DIALOG_ERC, DIALOG_ERC_BASE )
-    EVT_COMMAND_RANGE( ID_MATRIX_0, ID_MATRIX_0 + ( PIN_NMAX * PIN_NMAX ) - 1,
+    EVT_COMMAND_RANGE( ID_MATRIX_0, ID_MATRIX_0 + ( PINTYPE_COUNT * PINTYPE_COUNT ) - 1,
                        wxEVT_COMMAND_BUTTON_CLICKED, DIALOG_ERC::ChangeErrorLevel )
 END_EVENT_TABLE()
 
@@ -91,9 +91,9 @@ void DIALOG_ERC::Init()
 {
     m_initialized = false;
 
-    for( int ii = 0; ii < PIN_NMAX; ii++ )
+    for( int ii = 0; ii < PINTYPE_COUNT; ii++ )
     {
-        for( int jj = 0; jj < PIN_NMAX; jj++ )
+        for( int jj = 0; jj < PINTYPE_COUNT; jj++ )
             m_buttonList[ii][jj] = NULL;
     }
 
@@ -290,7 +290,7 @@ void DIALOG_ERC::ReBuildMatrixPanel()
     if( m_initialized == false )
     {
         // Print row labels
-        for( int ii = 0; ii < PIN_NMAX; ii++ )
+        for( int ii = 0; ii < PINTYPE_COUNT; ii++ )
         {
             int y = pos.y + (ii * bitmap_size.y);
             text = new wxStaticText( m_matrixPanel, -1, CommentERC_H[ii],
@@ -305,7 +305,7 @@ void DIALOG_ERC::ReBuildMatrixPanel()
     else
         pos = m_buttonList[0][0]->GetPosition();
 
-    for( int ii = 0; ii < PIN_NMAX; ii++ )
+    for( int ii = 0; ii < PINTYPE_COUNT; ii++ )
     {
         int y = pos.y + (ii * bitmap_size.y);
 
@@ -323,7 +323,7 @@ void DIALOG_ERC::ReBuildMatrixPanel()
                 text     = new wxStaticText( m_matrixPanel, -1, CommentERC_V[ii], txtpos );
             }
 
-            int event_id = ID_MATRIX_0 + ii + ( jj * PIN_NMAX );
+            int event_id = ID_MATRIX_0 + ii + ( jj * PINTYPE_COUNT );
             BITMAP_DEF bitmap_butt = erc_green_xpm;
 
             delete m_buttonList[ii][jj];
@@ -420,7 +420,7 @@ void DIALOG_ERC::ChangeErrorLevel( wxCommandEvent& event )
     wxBitmapButton* butt = (wxBitmapButton*) event.GetEventObject();
     pos  = butt->GetPosition();
 
-    x = ii / PIN_NMAX; y = ii % PIN_NMAX;
+    x = ii / PINTYPE_COUNT; y = ii % PINTYPE_COUNT;
 
     level = DiagErc[y][x];
 
diff --git a/eeschema/dialogs/dialog_erc.h b/eeschema/dialogs/dialog_erc.h
index d7d9ff8..9cce8b1 100644
--- a/eeschema/dialogs/dialog_erc.h
+++ b/eeschema/dialogs/dialog_erc.h
@@ -27,7 +27,7 @@
 
 #include <wx/htmllbox.h>
 #include <vector>
-#include <lib_pin.h>        // For PIN_NMAX definition
+#include <lib_pin.h>        // For PINTYPE_COUNT definition
 
 #include <dialog_erc_base.h>
 #include "dialog_erc_listbox.h"
@@ -40,7 +40,7 @@ class DIALOG_ERC : public DIALOG_ERC_BASE
 
 private:
     SCH_EDIT_FRAME* m_parent;
-    wxBitmapButton* m_buttonList[PIN_NMAX][PIN_NMAX];
+    wxBitmapButton* m_buttonList[PINTYPE_COUNT][PINTYPE_COUNT];
     bool            m_initialized;
     const SCH_MARKER* m_lastMarkerFound;
     static bool     m_writeErcFile;
diff --git a/eeschema/dialogs/dialog_lib_edit_pin.cpp b/eeschema/dialogs/dialog_lib_edit_pin.cpp
index 736d145..bdcf707 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 a7ddedb..ba4063e 100644
--- a/eeschema/dialogs/dialog_lib_edit_pin.h
+++ b/eeschema/dialogs/dialog_lib_edit_pin.h
@@ -32,6 +32,7 @@
 
 #include <wx/bmpcbox.h>
 #include <pin_shape_combobox.h>
+#include <pin_type_combobox.h>
 
 #include <dialog_lib_edit_pin_base.h>
 
@@ -60,17 +61,14 @@ public:
     }
     int GetOrientation( void ) { return m_choiceOrientation->GetSelection(); }
 
-    void SetElectricalTypeList( const wxArrayString& list, const BITMAP_DEF* aBitmaps );
-    void SetElectricalType( int type )
+    void SetElectricalType( ELECTRICAL_PINTYPE type )
     {
         m_choiceElectricalType->SetSelection( type );
     }
 
     ELECTRICAL_PINTYPE GetElectricalType( void )
     {
-        // m_choiceElectricalType is expected having the eletrical type names
-        // order indentical to the ELECTRICAL_PINTYPE enum
-        return (ELECTRICAL_PINTYPE)m_choiceElectricalType->GetSelection();
+        return m_choiceElectricalType->GetSelection();
     }
 
     void SetStyle( GRAPHIC_PINSHAPE style ) { m_choiceStyle->SetSelection( style ); }
diff --git a/eeschema/dialogs/dialog_lib_edit_pin_base.cpp b/eeschema/dialogs/dialog_lib_edit_pin_base.cpp
index af770d7..920a586 100644
--- a/eeschema/dialogs/dialog_lib_edit_pin_base.cpp
+++ b/eeschema/dialogs/dialog_lib_edit_pin_base.cpp
@@ -6,6 +6,7 @@
 ///////////////////////////////////////////////////////////////////////////
 
 #include "pin_shape_combobox.h"
+#include "pin_type_combobox.h"
 #include "wx/bmpcbox.h"
 
 #include "dialog_lib_edit_pin_base.h"
@@ -62,7 +63,7 @@ DIALOG_LIB_EDIT_PIN_BASE::DIALOG_LIB_EDIT_PIN_BASE( wxWindow* parent, wxWindowID
 	
 	fgSizerPins->Add( m_staticTextEType, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 );
 	
-	m_choiceElectricalType = new wxBitmapComboBox( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, NULL, wxCB_READONLY ); 
+	m_choiceElectricalType = new PinTypeComboBox( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, NULL, wxCB_READONLY ); 
 	fgSizerPins->Add( m_choiceElectricalType, 0, wxEXPAND|wxTOP|wxBOTTOM, 5 );
 	
 	m_staticTextGstyle = new wxStaticText( this, wxID_ANY, _("Graphic &Style:"), wxDefaultPosition, wxDefaultSize, 0 );
diff --git a/eeschema/dialogs/dialog_lib_edit_pin_base.fbp b/eeschema/dialogs/dialog_lib_edit_pin_base.fbp
index f1647ae..43b1deb 100644
--- a/eeschema/dialogs/dialog_lib_edit_pin_base.fbp
+++ b/eeschema/dialogs/dialog_lib_edit_pin_base.fbp
@@ -784,7 +784,7 @@
                                                 <property name="show">1</property>
                                                 <property name="size"></property>
                                                 <property name="style">wxCB_READONLY</property>
-                                                <property name="subclass">wxBitmapComboBox; wx/bmpcbox.h</property>
+                                                <property name="subclass">PinTypeComboBox; pin_type_combobox.h</property>
                                                 <property name="toolbar_pane">0</property>
                                                 <property name="tooltip"></property>
                                                 <property name="validator_data_type"></property>
diff --git a/eeschema/dialogs/dialog_lib_edit_pin_base.h b/eeschema/dialogs/dialog_lib_edit_pin_base.h
index 890623b..e8b46e9 100644
--- a/eeschema/dialogs/dialog_lib_edit_pin_base.h
+++ b/eeschema/dialogs/dialog_lib_edit_pin_base.h
@@ -13,6 +13,7 @@
 #include <wx/intl.h>
 class DIALOG_SHIM;
 class PinShapeComboBox;
+class PinTypeComboBox;
 class wxBitmapComboBox;
 
 #include "dialog_shim.h"
@@ -65,7 +66,7 @@ class DIALOG_LIB_EDIT_PIN_BASE : public DIALOG_SHIM
 		wxStaticText* m_staticTextOrient;
 		wxBitmapComboBox* m_choiceOrientation;
 		wxStaticText* m_staticTextEType;
-		wxBitmapComboBox* m_choiceElectricalType;
+		PinTypeComboBox* m_choiceElectricalType;
 		wxStaticText* m_staticTextGstyle;
 		PinShapeComboBox* m_choiceStyle;
 		wxCheckBox* m_checkApplyToAllParts;
diff --git a/eeschema/erc.cpp b/eeschema/erc.cpp
index 60eb82e..a9ef183 100644
--- a/eeschema/erc.cpp
+++ b/eeschema/erc.cpp
@@ -121,7 +121,7 @@ const wxString CommentERC_V[] =
  *  at start up: must be loaded by DefaultDiagErc
  *  Can be modified in dialog ERC
  */
-int  DiagErc[PIN_NMAX][PIN_NMAX];
+int  DiagErc[PINTYPE_COUNT][PINTYPE_COUNT];
 
 /**
  * Default Look up table which gives the ERC error level for a pair of connected pins
@@ -130,7 +130,7 @@ int  DiagErc[PIN_NMAX][PIN_NMAX];
  *  note also, to avoid inconsistancy:
  *    DefaultDiagErc[i][j] = DefaultDiagErc[j][i]
  */
-int DefaultDiagErc[PIN_NMAX][PIN_NMAX] =
+int DefaultDiagErc[PINTYPE_COUNT][PINTYPE_COUNT] =
 {
 /*         I,   O,    Bi,   3S,   Pas,  UnS,  PwrI, PwrO, OC,   OE,   NC */
 /* I */  { OK,  OK,   OK,   OK,   OK,   WAR,  OK,   OK,   OK,   OK,   ERR },
@@ -157,7 +157,7 @@ int DefaultDiagErc[PIN_NMAX][PIN_NMAX] =
  * in net.  Nets are OK when their final state is NET_NC or DRV.   Nets with the state
  * NOD have no valid source signal.
  */
-static int MinimalReq[PIN_NMAX][PIN_NMAX] =
+static int MinimalReq[PINTYPE_COUNT][PINTYPE_COUNT] =
 {
 /*         In   Out, Bi,  3S,  Pas, UnS, PwrI,PwrO,OC,  OE,  NC */
 /* In*/  { NOD, DRV, DRV, DRV, DRV, DRV, NOD, DRV, DRV, DRV, NPI },
@@ -228,9 +228,9 @@ int TestDuplicateSheetNames( bool aCreateMarker )
 void Diagnose( NETLIST_OBJECT* aNetItemRef, NETLIST_OBJECT* aNetItemTst,
                int aMinConn, int aDiag )
 {
-    SCH_MARKER* marker = NULL;
-    SCH_SCREEN* screen;
-    int         ii, jj;
+    SCH_MARKER*     marker = NULL;
+    SCH_SCREEN*     screen;
+    ELECTRICAL_PINTYPE ii, jj;
 
     if( aDiag == OK )
         return;
@@ -297,7 +297,7 @@ void Diagnose( NETLIST_OBJECT* aNetItemRef, NETLIST_OBJECT* aNetItemTst,
         {
             msg.Printf( _( "Pin %s (%s) of component %s is unconnected." ),
                         GetChars( string_pinnum ),
-                        GetChars( LIB_PIN::GetElectricalTypeName( ii ) ),
+                        GetChars( GetText( ii ) ),
                         GetChars( cmp_ref ) );
             marker->SetData( ERCE_PIN_NOT_CONNECTED,
                              aNetItemRef->m_Start,
@@ -314,7 +314,7 @@ void Diagnose( NETLIST_OBJECT* aNetItemRef, NETLIST_OBJECT* aNetItemTst,
 
             msg.Printf( _( "Pin %s (%s) of component %s is not driven (Net %d)." ),
                         GetChars( string_pinnum ),
-                        GetChars( LIB_PIN::GetElectricalTypeName( ii ) ),
+                        GetChars( GetText( ii ) ),
                         GetChars( cmp_ref ),
                         aNetItemRef->GetNet() );
             marker->SetData( ERCE_PIN_NOT_DRIVEN,
@@ -356,12 +356,12 @@ void Diagnose( NETLIST_OBJECT* aNetItemRef, NETLIST_OBJECT* aNetItemTst,
 
         msg.Printf( _( "Pin %s (%s) of component %s is connected to " ),
                     GetChars( string_pinnum ),
-                    GetChars( LIB_PIN::GetElectricalTypeName( ii ) ),
+                    GetChars( GetText( ii ) ),
                     GetChars( cmp_ref ) );
         marker->SetData( errortype, aNetItemRef->m_Start, msg, aNetItemRef->m_Start );
         msg.Printf( _( "pin %s (%s) of component %s (net %d)." ),
                     GetChars( alt_string_pinnum ),
-                    GetChars( LIB_PIN::GetElectricalTypeName( jj ) ),
+                    GetChars( GetText( jj ) ),
                     GetChars( alt_cmp ),
                     aNetItemRef->GetNet() );
         marker->SetAuxiliaryData( msg, aNetItemTst->m_Start );
@@ -374,7 +374,7 @@ void TestOthersItems( NETLIST_OBJECT_LIST* aList,
                       int* aMinConnexion )
 {
     unsigned netItemTst = aNetStart;
-    int jj;
+    ELECTRICAL_PINTYPE jj;
     int erc = OK;
 
     /* Analysis of the table of connections. */
diff --git a/eeschema/lib_pin.cpp b/eeschema/lib_pin.cpp
index 976f11e..0ca0d87 100644
--- a/eeschema/lib_pin.cpp
+++ b/eeschema/lib_pin.cpp
@@ -70,28 +70,10 @@ static const BITMAP_DEF iconsPinsOrientations[] =
 };
 
 
-// bitmaps to show pins electrical type in dialog editor
-// must have same order than enum ELECTRICAL_PINTYPE (see lib_pin.h)
-static const BITMAP_DEF iconsPinsElectricalType[] =
+const wxString LIB_PIN::GetCanonicalElectricalTypeName( ELECTRICAL_PINTYPE aType )
 {
-    pintype_input_xpm,
-    pintype_output_xpm,
-    pintype_bidi_xpm,
-    pintype_3states_xpm,
-    pintype_passive_xpm,
-    pintype_notspecif_xpm,
-    pintype_powerinput_xpm,
-    pintype_poweroutput_xpm,
-    pintype_opencoll_xpm,
-    pintype_openemit_xpm,
-    pintype_noconnect_xpm
-};
-
-#define PIN_ELECTRICAL_TYPE_CNT DIM( iconsPinsElectricalType )
+    assert( aType >= 0 && aType < (int) PINTYPE_COUNT );
 
-
-const wxString LIB_PIN::GetCanonicalElectricalTypeName( unsigned aType )
-{
     // These strings are the canonical name of the electrictal type
     // Not translated, no space in name, only ASCII chars.
     // to use when the string name must be known and well defined
@@ -108,12 +90,11 @@ const wxString LIB_PIN::GetCanonicalElectricalTypeName( unsigned aType )
         wxT( "power_out" ),
         wxT( "openCol" ),
         wxT( "openEm" ),
-        wxT( "NotConnected" ),
-        wxT( "???" )
+        wxT( "NotConnected" )
     };
 
-    if( aType > PIN_NMAX )
-        aType = PIN_NMAX;
+    if( aType > (int) PINTYPE_COUNT )
+        return wxT( "???" );
 
     return msgPinElectricType[ aType ];
 }
@@ -144,30 +125,6 @@ static const wxString getPinOrientationName( unsigned aPinOrientationCode )
     return pin_orientation_names[ aPinOrientationCode ];
 }
 
-const wxString LIB_PIN::GetElectricalTypeName( unsigned aPinsElectricalType )
-{
-    const wxString pin_electrical_type_names[] =
-    {   // Keep these translated strings not static
-        _( "Input" ),
-        _( "Output" ),
-        _( "Bidirectional" ),
-        _( "Tri-state" ),
-        _( "Passive" ),
-        _( "Unspecified" ),
-        _( "Power input" ),
-        _( "Power output" ),
-        _( "Open collector" ),
-        _( "Open emitter" ),
-        _( "Not connected" ),
-        wxT( "???" )
-    };
-
-    if( aPinsElectricalType > PIN_ELECTRICAL_TYPE_CNT )
-        aPinsElectricalType = PIN_ELECTRICAL_TYPE_CNT;
-
-    return pin_electrical_type_names[ aPinsElectricalType ];
-}
-
 /// Utility for getting the size of the 'internal' pin decorators (as a radius)
 // i.e. the clock symbols (falling clock is actually external but is of
 // the same kind)
@@ -354,10 +311,12 @@ void LIB_PIN::SetShape( GRAPHIC_PINSHAPE aShape )
 
 void LIB_PIN::SetType( ELECTRICAL_PINTYPE aType )
 {
+    assert( aType >= 0 && aType < (int) PINTYPE_COUNT );
+
     if( aType < PIN_INPUT )
         aType = PIN_INPUT;
 
-    if( aType >= PIN_NMAX )
+    if( aType >= PINTYPE_COUNT )
         aType = PIN_NC;
 
     if( m_type != aType )
@@ -2019,7 +1978,7 @@ void LIB_PIN::GetMsgPanelInfo( MSG_PANEL_ITEMS& aList )
     aList.push_back( MSG_PANEL_ITEM( _( "Number" ), text, DARKCYAN ) );
 
     aList.push_back( MSG_PANEL_ITEM( _( "Type" ),
-                                     LIB_PIN::GetElectricalTypeName( m_type ),
+                                     GetText( m_type ),
                                      RED ) );
 
     text = GetText( m_shape );
@@ -2217,23 +2176,6 @@ void LIB_PIN::Rotate()
 }
 
 
-wxArrayString LIB_PIN::GetElectricalTypeNames( void )
-{
-    wxArrayString tmp;
-
-    for( unsigned ii = 0; ii < PIN_ELECTRICAL_TYPE_CNT; ii++ )
-        tmp.Add( LIB_PIN::GetElectricalTypeName( ii ) );
-
-    return tmp;
-}
-
-
-const BITMAP_DEF* LIB_PIN::GetElectricalTypeSymbols()
-{
-    return iconsPinsElectricalType;
-}
-
-
 const BITMAP_DEF* LIB_PIN::GetOrientationSymbols()
 {
     return iconsPinsOrientations;
@@ -2242,7 +2184,7 @@ const BITMAP_DEF* LIB_PIN::GetOrientationSymbols()
 
 BITMAP_DEF LIB_PIN::GetMenuImage() const
 {
-    return iconsPinsElectricalType[m_type];
+    return GetBitmap( m_type );
 }
 
 
diff --git a/eeschema/lib_pin.h b/eeschema/lib_pin.h
index a0adef3..7c0bb4b 100644
--- a/eeschema/lib_pin.h
+++ b/eeschema/lib_pin.h
@@ -33,28 +33,10 @@
 #include <lib_draw_item.h>
 
 #include "pin_shape.h"
+#include "pin_type.h"
 
 #define TARGET_PIN_RADIUS   12  // Circle diameter drawn at the active end of pins
 
-/**
- * The component library pin object electrical types used in ERC tests.
- */
-enum ELECTRICAL_PINTYPE {
-    PIN_INPUT,
-    PIN_OUTPUT,
-    PIN_BIDI,
-    PIN_TRISTATE,
-    PIN_PASSIVE,
-    PIN_UNSPECIFIED,
-    PIN_POWER_IN,
-    PIN_POWER_OUT,
-    PIN_OPENCOLLECTOR,
-    PIN_OPENEMITTER,
-    PIN_NC,             /* No connect */
-    PIN_NMAX            /* End of List (not used as pin type) */
-};
-
-
 /* Pin visibility flag bit. */
 #define PIN_INVISIBLE 1    /* Set makes pin invisible */
 
@@ -274,7 +256,7 @@ public:
      * @param aType is the electrical type (see enum ELECTRICAL_PINTYPE )
      * @return The electrical name for a pin type (see enun MsgPinElectricType for names).
      */
-    static const wxString GetCanonicalElectricalTypeName( unsigned aType );
+    static const wxString GetCanonicalElectricalTypeName( ELECTRICAL_PINTYPE aType );
 
     /**
      * return a string giving the electrical type of the pin.
@@ -287,19 +269,12 @@ public:
     }
 
     /**
-     * return a translated string for messages giving the electrical type of a pin.
-     * @param aType is the electrical type (see enum ELECTRICAL_PINTYPE )
-     * @return The electrical name of the pin (see enun MsgPinElectricType for names).
-     */
-    static const wxString GetElectricalTypeName( unsigned aType );
-
-    /**
      * return a translated string for messages giving the electrical type of the pin.
      * @return The electrical name of the pin.
      */
     wxString const GetElectricalTypeName() const
     {
-        return GetElectricalTypeName( m_type );
+        return GetText( m_type );
     }
 
     /**
@@ -465,20 +440,6 @@ public:
      */
     static int GetOrientationCodeIndex( int aCode );
 
-    /**
-     * Get a list of pin electrical type names.
-     *
-     * @return  List of valid pin electrical type names.
-     */
-    static wxArrayString GetElectricalTypeNames();
-
-    /**
-     * Get a list of pin electrical bitmaps for menus and dialogs.
-     *
-     * @return  List of valid pin electrical type bitmaps symbols in .xpm format
-     */
-    static const BITMAP_DEF* GetElectricalTypeSymbols();
-
     void SetOffset( const wxPoint& aOffset );
 
     bool Inside( EDA_RECT& aRect ) const;
diff --git a/eeschema/pin_type.cpp b/eeschema/pin_type.cpp
new file mode 100644
index 0000000..5b753a9
--- /dev/null
+++ b/eeschema/pin_type.cpp
@@ -0,0 +1,116 @@
+/*
+ * This program source code file is part of KiCad, a free EDA CAD application.
+ *
+ * Copyright (C) 2004-2015 KiCad Developers, see change_log.txt for contributors.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, you may find one here:
+ * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
+ * or you may search the http://www.gnu.org website for the version 2 license,
+ * or you may write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
+ */
+
+/**
+ * @file pin_type.cpp
+ * @brief Electrical pin type handling
+ */
+
+#include "pin_type.h"
+
+#include <macros.h>
+
+wxString GetText( ELECTRICAL_PINTYPE aType )
+{
+    switch( aType )
+    {
+    case PIN_INPUT:
+        return _( "Input" );
+
+    case PIN_OUTPUT:
+        return _( "Output" );
+
+    case PIN_BIDI:
+        return _( "Bidirectional" );
+
+    case PIN_TRISTATE:
+        return _( "Tri-state" );
+
+    case PIN_PASSIVE:
+        return _( "Passive" );
+
+    case PIN_UNSPECIFIED:
+        return _( "Unspecified" );
+
+    case PIN_POWER_IN:
+        return _( "Power input" );
+
+    case PIN_POWER_OUT:
+        return _( "Power output" );
+
+    case PIN_OPENCOLLECTOR:
+        return _( "Open collector" );
+
+    case PIN_OPENEMITTER:
+        return _( "Open emitter" );
+
+    case PIN_NC:
+        return _( "Not connected" );
+    };
+
+    assert( !"invalid pin type" );
+    return wxT( "???" );
+}
+
+
+BITMAP_DEF GetBitmap( ELECTRICAL_PINTYPE aType )
+{
+    switch( aType )
+    {
+    case PIN_INPUT:
+        return pintype_input_xpm;
+
+    case PIN_OUTPUT:
+        return pintype_output_xpm;
+
+    case PIN_BIDI:
+        return pintype_bidi_xpm;
+
+    case PIN_TRISTATE:
+        return pintype_3states_xpm;
+
+    case PIN_PASSIVE:
+        return pintype_passive_xpm;
+
+    case PIN_UNSPECIFIED:
+        return pintype_notspecif_xpm;
+
+    case PIN_POWER_IN:
+        return pintype_powerinput_xpm;
+
+    case PIN_POWER_OUT:
+        return pintype_poweroutput_xpm;
+
+    case PIN_OPENCOLLECTOR:
+        return pintype_opencoll_xpm;
+
+    case PIN_OPENEMITTER:
+        return pintype_openemit_xpm;
+
+    case PIN_NC:
+        return pintype_noconnect_xpm;
+    };
+
+    assert( !"invalid pin type" );
+    return NULL;
+}
diff --git a/eeschema/pin_type.h b/eeschema/pin_type.h
new file mode 100644
index 0000000..b8975c5
--- /dev/null
+++ b/eeschema/pin_type.h
@@ -0,0 +1,59 @@
+/*
+ * This program source code file is part of KiCad, a free EDA CAD application.
+ *
+ * Copyright (C) 2004-2015 KiCad Developers, see change_log.txt for contributors.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, you may find one here:
+ * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
+ * or you may search the http://www.gnu.org website for the version 2 license,
+ * or you may write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
+ */
+
+/**
+ * @file pin_type.h
+ * @brief Electrical pin type handling
+ */
+#ifndef PIN_TYPE_H_
+#define PIN_TYPE_H_
+
+#include <wx/string.h>
+#include <bitmaps.h>
+
+/**
+ * The component library pin object electrical types used in ERC tests.
+ */
+enum ELECTRICAL_PINTYPE {
+    PIN_INPUT,
+    PIN_OUTPUT,
+    PIN_BIDI,
+    PIN_TRISTATE,
+    PIN_PASSIVE,
+    PIN_UNSPECIFIED,
+    PIN_POWER_IN,
+    PIN_POWER_OUT,
+    PIN_OPENCOLLECTOR,
+    PIN_OPENEMITTER,
+    PIN_NC              /* No connect */
+};
+
+enum {
+    PINTYPE_COUNT = PIN_NC + 1
+};
+
+// UI
+wxString GetText( ELECTRICAL_PINTYPE );
+BITMAP_DEF GetBitmap( ELECTRICAL_PINTYPE );
+
+#endif
diff --git a/eeschema/pinedit.cpp b/eeschema/pinedit.cpp
index c8640bd..30b4d99 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
new file mode 100644
index 0000000..70dd5bd
--- /dev/null
+++ b/eeschema/widgets/pin_type_combobox.cpp
@@ -0,0 +1,69 @@
+/*
+ * This program source code file is part of KiCad, a free EDA CAD application.
+ *
+ * Copyright (C) 2015 Simon Richter <Simon.Richter@xxxxxxxxxx>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, you may find one here:
+ * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
+ * or you may search the http://www.gnu.org website for the version 2 license,
+ * or you may write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
+ */
+
+/**
+ * @file pin_type_combobox.cpp
+ * @brief ComboBox widget for pin type
+ */
+
+#include "pin_type_combobox.h"
+
+#include <lib_pin.h>
+
+PinTypeComboBox::PinTypeComboBox( wxWindow* parent,
+        wxWindowID id,
+        const wxString& value,
+        const wxPoint& pos,
+        const wxSize& size,
+        int n,
+        const wxString choices[],
+        long style,
+        const wxValidator& validator,
+        const wxString& name ) :
+    wxBitmapComboBox( parent, id, value, pos, size, n, choices, style, validator, name )
+{
+    for( unsigned ii = 0; ii < PINTYPE_COUNT; ++ii )
+    {
+        ELECTRICAL_PINTYPE type = static_cast<ELECTRICAL_PINTYPE>( ii );
+
+        wxString text = GetText( type );
+        BITMAP_DEF bitmap = GetBitmap( type );
+
+        if( bitmap == NULL )
+            Append( text );
+        else
+            Insert( text, KiBitmap( bitmap ), ii );
+    }
+}
+
+
+ELECTRICAL_PINTYPE PinTypeComboBox::GetSelection()
+{
+    return static_cast<ELECTRICAL_PINTYPE>( wxBitmapComboBox::GetSelection() );
+}
+
+
+void PinTypeComboBox::SetSelection( ELECTRICAL_PINTYPE aType )
+{
+    wxBitmapComboBox::SetSelection( aType );
+}
diff --git a/eeschema/widgets/pin_type_combobox.h b/eeschema/widgets/pin_type_combobox.h
new file mode 100644
index 0000000..c94c5d6
--- /dev/null
+++ b/eeschema/widgets/pin_type_combobox.h
@@ -0,0 +1,51 @@
+/*
+ * This program source code file is part of KiCad, a free EDA CAD application.
+ *
+ * Copyright (C) 2015 Simon Richter <Simon.Richter@xxxxxxxxxx>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, you may find one here:
+ * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
+ * or you may search the http://www.gnu.org website for the version 2 license,
+ * or you may write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
+ */
+
+/**
+ * @file pin_type_combobox.h
+ * @brief ComboBox widget for pin type
+ */
+
+#include <wx/bmpcbox.h>
+
+#include <pin_type.h>
+
+class PinTypeComboBox : public wxBitmapComboBox
+{
+public:
+    /// @todo C++11: replace with forwarder
+
+    PinTypeComboBox( wxWindow* parent,
+            wxWindowID id = wxID_ANY,
+            const wxString& value = wxEmptyString,
+            const wxPoint& pos = wxDefaultPosition,
+            const wxSize& size = wxDefaultSize,
+            int n = 0,
+            const wxString choices[] = NULL,
+            long style = 0,
+            const wxValidator& validator = wxDefaultValidator,
+            const wxString& name = wxBitmapComboBoxNameStr );
+
+    ELECTRICAL_PINTYPE  GetSelection();
+    void                SetSelection( ELECTRICAL_PINTYPE aType );
+};

Follow ups

References