kicad-developers team mailing list archive
-
kicad-developers team
-
Mailing list archive
-
Message #23205
[PATCH 18/19] ElectricPinType: move bitmap lookup
---
eeschema/lib_pin.cpp | 28 +---------------------
eeschema/lib_pin.h | 8 -------
eeschema/pin_type.cpp | 43 ++++++++++++++++++++++++++++++++++
eeschema/pin_type.h | 2 ++
eeschema/widgets/pin_type_combobox.cpp | 4 +---
5 files changed, 47 insertions(+), 38 deletions(-)
diff --git a/eeschema/lib_pin.cpp b/eeschema/lib_pin.cpp
index d7a83f7..357b322 100644
--- a/eeschema/lib_pin.cpp
+++ b/eeschema/lib_pin.cpp
@@ -70,26 +70,6 @@ static const BITMAP_DEF iconsPinsOrientations[] =
};
-// bitmaps to show pins electrical type in dialog editor
-// must have same order than enum ElectricPinType (see lib_pin.h)
-static const BITMAP_DEF iconsPinsElectricalType[] =
-{
- 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 )
-
-
const wxString LIB_PIN::GetCanonicalElectricalTypeName( ElectricPinType aType )
{
assert( aType >= 0 && aType < (int) PINTYPE_COUNT );
@@ -2190,12 +2170,6 @@ void LIB_PIN::Rotate()
}
-const BITMAP_DEF* LIB_PIN::GetElectricalTypeSymbols()
-{
- return iconsPinsElectricalType;
-}
-
-
const BITMAP_DEF* LIB_PIN::GetOrientationSymbols()
{
return iconsPinsOrientations;
@@ -2204,7 +2178,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 95e241d..94390d8 100644
--- a/eeschema/lib_pin.h
+++ b/eeschema/lib_pin.h
@@ -440,14 +440,6 @@ public:
*/
static int GetOrientationCodeIndex( int aCode );
-
- /**
- * 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
index b80e257..42e4e55 100644
--- a/eeschema/pin_type.cpp
+++ b/eeschema/pin_type.cpp
@@ -71,3 +71,46 @@ wxString GetText( ElectricPinType aType )
assert( !"invalid pin type" );
return wxT( "???" );
}
+
+
+BITMAP_DEF GetBitmap( ElectricPinType 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
index 3910cb2..5c276fb 100644
--- a/eeschema/pin_type.h
+++ b/eeschema/pin_type.h
@@ -29,6 +29,7 @@
#define PIN_TYPE_H_
#include <wx/string.h>
+#include <bitmaps.h>
/**
* The component library pin object electrical types used in ERC tests.
@@ -53,5 +54,6 @@ enum {
// UI
wxString GetText( ElectricPinType );
+BITMAP_DEF GetBitmap( ElectricPinType );
#endif
diff --git a/eeschema/widgets/pin_type_combobox.cpp b/eeschema/widgets/pin_type_combobox.cpp
index 52dc5fb..2b64bbc 100644
--- a/eeschema/widgets/pin_type_combobox.cpp
+++ b/eeschema/widgets/pin_type_combobox.cpp
@@ -42,14 +42,12 @@ PinTypeComboBox::PinTypeComboBox( wxWindow* parent,
const wxString& name ) :
wxBitmapComboBox( parent, id, value, pos, size, n, choices, style, validator, name )
{
- const BITMAP_DEF* bitmaps = LIB_PIN::GetElectricalTypeSymbols();
-
for( unsigned ii = 0; ii < PINTYPE_COUNT; ++ii )
{
ElectricPinType type = static_cast<ElectricPinType>( ii );
wxString text = GetText( type );
- BITMAP_DEF bitmap = bitmaps[ ii ];
+ BITMAP_DEF bitmap = GetBitmap( type );
if( bitmap == NULL )
Append( text );
Follow ups
References
-
[PATCH 00/19] Pin shape and type refactoring
From: Simon Richter, 2016-02-17
-
[PATCH 01/19] Replace DrawPinShape enum with PinShape
From: Simon Richter, 2016-02-17
-
[PATCH 02/19] PinShapeComboBox: Introduce widget
From: Simon Richter, 2016-02-17
-
[PATCH 03/19] PinShapeComboBox: Fully initialize in c'tor
From: Simon Richter, 2016-02-17
-
[PATCH 04/19] PinShapeComboBox: typesafe Get/Set
From: Simon Richter, 2016-02-17
-
[PATCH 05/19] PinShape: move enum to own header
From: Simon Richter, 2016-02-17
-
[PATCH 06/19] PinShape: move text lookup
From: Simon Richter, 2016-02-17
-
[PATCH 07/19] PinShape: drop list interfaces
From: Simon Richter, 2016-02-17
-
[PATCH 08/19] PinShape: move bitmap lookup
From: Simon Richter, 2016-02-17
-
[PATCH 09/19] ElectricPinType: move definition to pin_type.h
From: Simon Richter, 2016-02-17
-
[PATCH 10/19] ElectricPinType: Use enum rather than int where possible
From: Simon Richter, 2016-02-17
-
[PATCH 11/19] ElectricPinType: Rename PIN_NMAX to PINTYPE_COUNT
From: Simon Richter, 2016-02-17
-
[PATCH 12/19] ElectricPinType: Separate PINTYPE_COUNT from enum
From: Simon Richter, 2016-02-17
-
[PATCH 13/19] PinTypeComboBox: Introduce widget
From: Simon Richter, 2016-02-17
-
[PATCH 14/19] PinTypeComboBox: fully initialize in c'tor
From: Simon Richter, 2016-02-17
-
[PATCH 15/19] PinTypeComboBox: typesafe Get/Set
From: Simon Richter, 2016-02-17
-
[PATCH 16/19] ElectricPinType: move text lookup
From: Simon Richter, 2016-02-17
-
[PATCH 17/19] ElectricPinType: remove list interfaces
From: Simon Richter, 2016-02-17