← Back to team overview

kicad-developers team mailing list archive

[PATCH 14/27] PinShape: move bitmap lookup

 

This moves the bitmaps out of the data model as well.
---
 eeschema/lib_pin.cpp                    | 22 --------------------
 eeschema/lib_pin.h                      |  7 -------
 eeschema/pin_shape.cpp                  | 37 +++++++++++++++++++++++++++++++++
 eeschema/pin_shape.h                    |  2 ++
 eeschema/widgets/pin_shape_combobox.cpp |  7 +++----
 5 files changed, 42 insertions(+), 33 deletions(-)

diff --git a/eeschema/lib_pin.cpp b/eeschema/lib_pin.cpp
index fe8f9c5..c53ad64 100644
--- a/eeschema/lib_pin.cpp
+++ b/eeschema/lib_pin.cpp
@@ -70,22 +70,6 @@ static const BITMAP_DEF iconsPinsOrientations[] =
 };
 
 
-// bitmaps to show pins shapes in dialog editor
-// must have same order than pin_style_names
-static BITMAP_DEF iconsPinsShapes[] =
-{
-    pinshape_normal_xpm,
-    pinshape_invert_xpm,
-    pinshape_clock_normal_xpm,
-    pinshape_clock_invert_xpm,
-    pinshape_active_low_input_xpm,
-    pinshape_clock_active_low_xpm,
-    pinshape_active_low_output_xpm,
-    pinshape_clock_fall_xpm,
-    pinshape_nonlogic_xpm
-};
-
-
 // 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[] =
@@ -2247,12 +2231,6 @@ const BITMAP_DEF* LIB_PIN::GetOrientationSymbols()
 }
 
 
-const BITMAP_DEF* LIB_PIN::GetStyleSymbols()
-{
-    return iconsPinsShapes;
-}
-
-
 BITMAP_DEF LIB_PIN::GetMenuImage() const
 {
     return iconsPinsElectricalType[m_type];
diff --git a/eeschema/lib_pin.h b/eeschema/lib_pin.h
index 7338a83..f4b21a8 100644
--- a/eeschema/lib_pin.h
+++ b/eeschema/lib_pin.h
@@ -443,13 +443,6 @@ public:
     static int GetOrientationCodeIndex( int aCode );
 
     /**
-     * Get a list of pin styles bitmaps for menus and dialogs.
-     *
-     * @return  List of valid pin electrical type bitmaps symbols in .xpm format.
-     */
-    static const BITMAP_DEF* GetStyleSymbols();
-
-    /**
      * Get a list of pin electrical type names.
      *
      * @return  List of valid pin electrical type names.
diff --git a/eeschema/pin_shape.cpp b/eeschema/pin_shape.cpp
index 19a7ff2..65eac24 100644
--- a/eeschema/pin_shape.cpp
+++ b/eeschema/pin_shape.cpp
@@ -65,3 +65,40 @@ wxString GetText( PinShape shape )
     assert( !"Invalid pin shape" );
     return wxT( "?" );
 }
+
+
+BITMAP_DEF GetBitmap( PinShape shape )
+{
+    switch( shape )
+    {
+    case PINSHAPE_LINE:
+        return pinshape_normal_xpm;
+
+    case PINSHAPE_INVERTED:
+        return pinshape_invert_xpm;
+
+    case PINSHAPE_CLOCK:
+        return pinshape_clock_normal_xpm;
+
+    case PINSHAPE_INVERTED_CLOCK:
+        return pinshape_clock_invert_xpm;
+
+    case PINSHAPE_INPUT_LOW:
+        return pinshape_active_low_input_xpm;
+
+    case PINSHAPE_CLOCK_LOW:
+        return pinshape_clock_active_low_xpm;
+
+    case PINSHAPE_OUTPUT_LOW:
+        return pinshape_active_low_output_xpm;
+
+    case PINSHAPE_FALLING_EDGE_CLOCK:
+        return pinshape_clock_fall_xpm;
+
+    case PINSHAPE_NONLOGIC:
+        return pinshape_nonlogic_xpm;
+    }
+
+    assert( !"Invalid pin shape" );
+    return 0;
+};
diff --git a/eeschema/pin_shape.h b/eeschema/pin_shape.h
index d5ea11d..9adfd3e 100644
--- a/eeschema/pin_shape.h
+++ b/eeschema/pin_shape.h
@@ -30,6 +30,7 @@
 #define _PIN_SHAPE_H_
 
 #include <wx/string.h>
+#include <bitmaps.h>
 
 enum PinShape
 {
@@ -51,5 +52,6 @@ enum
 
 // UI
 wxString    GetText( PinShape shape );
+BITMAP_DEF  GetBitmap( PinShape shape );
 
 #endif
diff --git a/eeschema/widgets/pin_shape_combobox.cpp b/eeschema/widgets/pin_shape_combobox.cpp
index 6579f0d..b2fae58 100644
--- a/eeschema/widgets/pin_shape_combobox.cpp
+++ b/eeschema/widgets/pin_shape_combobox.cpp
@@ -42,18 +42,17 @@ PinShapeComboBox::PinShapeComboBox( wxWindow* parent,
         const wxString& name ) :
     wxBitmapComboBox( parent, id, value, pos, size, n, choices, style, validator, name )
 {
-    const BITMAP_DEF* bitmaps = LIB_PIN::GetStyleSymbols();
-
     for( unsigned ii = 0; ii < PINSHAPE_COUNT; ++ii )
     {
         PinShape shape = static_cast<PinShape>( ii );
 
         wxString text = GetText( shape );
+        BITMAP_DEF bitmap = GetBitmap( shape );
 
-        if( bitmaps == NULL )
+        if( bitmap == NULL )
             Append( text );
         else
-            Insert( text, KiBitmap( bitmaps[ii] ), ii );
+            Insert( text, KiBitmap( bitmap ), ii );
     }
 }
 

Follow ups

References