kicad-developers team mailing list archive
-
kicad-developers team
-
Mailing list archive
-
Message #17923
[PATCH 24/27] 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 0783110..f3f72ee 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 );
@@ -2181,12 +2161,6 @@ void LIB_PIN::Rotate()
}
-const BITMAP_DEF* LIB_PIN::GetElectricalTypeSymbols()
-{
- return iconsPinsElectricalType;
-}
-
-
const BITMAP_DEF* LIB_PIN::GetOrientationSymbols()
{
return iconsPinsOrientations;
@@ -2195,7 +2169,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 8363ba5..9b6e562 100644
--- a/eeschema/lib_pin.h
+++ b/eeschema/lib_pin.h
@@ -417,14 +417,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/27] My current patch stack
From: Simon Richter, 2015-04-13
-
[PATCH 01/27] Move feature check before dependent tests
From: Simon Richter, 2015-04-13
-
[PATCH 02/27] Use Link Time Optimization with GCC in Release builds
From: Simon Richter, 2015-04-13
-
[PATCH 03/27] Make NETLIST_OBJECT::GetConnectionType() const
From: Simon Richter, 2015-04-13
-
[PATCH 04/27] Remove superfluous cast
From: Simon Richter, 2015-04-13
-
[PATCH 05/27] Separate ElectricPinType and TypeSheetLabel
From: Simon Richter, 2015-04-13
-
[PATCH 06/27] Regenerate "Edit Pin" dialog with newer wxFormBuilder
From: Simon Richter, 2015-04-13
-
[PATCH 07/27] Replace DrawPinShape enum with PinShape
From: Simon Richter, 2015-04-13
-
[PATCH 08/27] PinShapeComboBox: Introduce widget
From: Simon Richter, 2015-04-13
-
[PATCH 09/27] PinShapeComboBox: Fully initialize in c'tor
From: Simon Richter, 2015-04-13
-
[PATCH 10/27] PinShapeComboBox: typesafe Get/Set
From: Simon Richter, 2015-04-13
-
[PATCH 11/27] PinShape: move enum to own header
From: Simon Richter, 2015-04-13
-
[PATCH 12/27] PinShape: move text lookup
From: Simon Richter, 2015-04-13
-
[PATCH 13/27] PinShape: drop list interfaces
From: Simon Richter, 2015-04-13
-
[PATCH 14/27] PinShape: move bitmap lookup
From: Simon Richter, 2015-04-13
-
[PATCH 15/27] ElectricPinType: move definition to pin_type.h
From: Simon Richter, 2015-04-13
-
[PATCH 16/27] ElectricPinType: Use enum rather than int where possible
From: Simon Richter, 2015-04-13
-
[PATCH 17/27] ElectricPinType: Rename PIN_NMAX to PINTYPE_COUNT
From: Simon Richter, 2015-04-13
-
[PATCH 18/27] ElectricPinType: Separate PINTYPE_COUNT from enum
From: Simon Richter, 2015-04-13
-
[PATCH 19/27] PinTypeComboBox: Introduce widget
From: Simon Richter, 2015-04-13
-
[PATCH 20/27] PinTypeComboBox: fully initialize in c'tor
From: Simon Richter, 2015-04-13
-
[PATCH 21/27] PinTypeComboBox: typesafe Get/Set
From: Simon Richter, 2015-04-13
-
[PATCH 22/27] ElectricPinType: move text lookup
From: Simon Richter, 2015-04-13
-
[PATCH 23/27] ElectricPinType: remove list interfaces
From: Simon Richter, 2015-04-13