← Back to team overview

kicad-developers team mailing list archive

[PATCH] Move bitmaps.h out of base_struct.h

 

Hi,

Here is a patch to prevent bitmaps.h being included by nearly every
file in KiCad via base_struct.h.

Prior to this commit, simply touching bitmaps.h would require the
recompilation of over 400 files for pcbnew alone, not counting the
bitmap files themselves, which are fairly quick to build.

After this commit, only 166 files are rebuilt, for all targets, and 46
for just pcbnew and its deps, which is a pretty handy speedup of just
under 90% by file count!

Many of the new includes of bitmaps.h will disappear along with legacy
which will further shrink the impact of touching bitmaps.h.

An additional benefit is that the icon list is now in its own header,
which makes it easier to automate in future.

Cheers,

John
From b72cbf3523c31e6e8af42d514beaa54b6ef5dd2e Mon Sep 17 00:00:00 2001
From: John Beard <john.j.beard@xxxxxxxxx>
Date: Mon, 20 Feb 2017 20:20:39 +0800
Subject: [PATCH] Move bitmaps.h out of base_struct.h

bitmaps.h was included in nearly every file in the project due to it
being included by base_struct.h

Only about 130 files actually use the XPM definitions defined there, and
many of those already included bitmaps.h themselves, or via
menu_helpers.h. However, touching bitmaps.h would result in over 400
rebuilt files for pcbnew alone.

This commit moves the bitmap-related types like BITMAT_DEF out to a new
header, which is still included by base_struct.h, which is less
avoidable for now, it's it's used in the interface.

The icon list is still in bitmaps.h. This has the side effect that's
it's now easier to automatically generate this file.

Many classes in pcbnew and eeschema needed some functions moved
to the implementaitons from the headers too.
---
 3d-viewer/3d_cache/dialogs/panel_prev_model.cpp    |  1 +
 3d-viewer/3d_canvas/eda_3d_canvas.cpp              |  1 +
 .../3d_viewer/dialogs/dialog_3D_view_option.cpp    |  1 +
 3d-viewer/3d_viewer/eda_3d_viewer.cpp              |  1 +
 cvpcb/cvpcb_mainframe.cpp                          |  1 +
 eeschema/controle.cpp                              |  1 +
 eeschema/dialogs/dialog_annotate.cpp               |  1 +
 eeschema/dialogs/dialog_erc.cpp                    |  1 +
 eeschema/dialogs/dialog_lib_edit_pin.cpp           |  1 +
 eeschema/hierarch.cpp                              |  1 +
 eeschema/lib_arc.cpp                               |  7 +++
 eeschema/lib_arc.h                                 |  2 +-
 eeschema/lib_circle.cpp                            |  7 +++
 eeschema/lib_circle.h                              |  2 +-
 eeschema/lib_field.cpp                             |  7 +++
 eeschema/lib_field.h                               |  2 +-
 eeschema/lib_polyline.cpp                          |  7 +++
 eeschema/lib_polyline.h                            |  2 +-
 eeschema/lib_rectangle.cpp                         |  7 +++
 eeschema/lib_rectangle.h                           |  2 +-
 eeschema/lib_text.cpp                              |  7 +++
 eeschema/lib_text.h                                |  2 +-
 eeschema/sch_bitmap.cpp                            |  8 +++
 eeschema/sch_bitmap.h                              |  2 +-
 eeschema/sch_bus_entry.cpp                         |  6 ++
 eeschema/sch_bus_entry.h                           |  2 +-
 eeschema/sch_component.cpp                         |  7 +++
 eeschema/sch_component.h                           |  2 +-
 eeschema/sch_field.cpp                             |  1 +
 eeschema/sch_junction.cpp                          |  6 ++
 eeschema/sch_junction.h                            |  2 +-
 eeschema/sch_marker.cpp                            |  7 +++
 eeschema/sch_marker.h                              |  2 +-
 eeschema/sch_no_connect.cpp                        |  7 +++
 eeschema/sch_no_connect.h                          |  2 +-
 eeschema/sch_sheet.cpp                             |  6 ++
 eeschema/sch_sheet.h                               |  4 +-
 eeschema/sch_sheet_pin.cpp                         |  6 ++
 eeschema/sch_text.cpp                              | 25 ++++++++
 eeschema/sch_text.h                                |  8 +--
 eeschema/tool_lib.cpp                              |  1 +
 eeschema/tool_sch.cpp                              |  1 +
 eeschema/viewlib_frame.cpp                         |  1 +
 gerbview/gerbview_frame.cpp                        |  1 +
 gerbview/toolbars_gerber.cpp                       |  1 +
 include/base_struct.h                              |  2 +-
 include/bitmap_types.h                             | 72 ++++++++++++++++++++++
 include/bitmaps.h                                  | 42 +------------
 kicad/mainframe.cpp                                |  1 +
 pagelayout_editor/pl_editor_frame.cpp              |  1 +
 pcbnew/class_dimension.cpp                         |  7 +++
 pcbnew/class_dimension.h                           |  2 +-
 pcbnew/class_drawsegment.cpp                       |  7 +++
 pcbnew/class_drawsegment.h                         |  2 +-
 pcbnew/class_edge_mod.cpp                          |  7 +++
 pcbnew/class_edge_mod.h                            |  2 +-
 pcbnew/class_marker_pcb.cpp                        |  7 +++
 pcbnew/class_marker_pcb.h                          |  2 +-
 pcbnew/class_mire.cpp                              |  6 ++
 pcbnew/class_mire.h                                |  2 +-
 pcbnew/class_module.cpp                            |  7 +++
 pcbnew/class_module.h                              |  2 +-
 pcbnew/class_pad.cpp                               |  7 +++
 pcbnew/class_pad.h                                 |  2 +-
 pcbnew/class_pcb_text.cpp                          |  7 +++
 pcbnew/class_pcb_text.h                            |  2 +-
 pcbnew/class_text_mod.cpp                          |  7 +++
 pcbnew/class_text_mod.h                            |  2 +-
 pcbnew/class_track.cpp                             | 20 +++++-
 pcbnew/class_track.h                               |  6 +-
 pcbnew/class_zone.cpp                              |  7 +++
 pcbnew/class_zone.h                                |  6 +-
 .../dialogs/dialog_edit_module_for_BoardEditor.cpp |  1 +
 pcbnew/dialogs/dialog_edit_module_for_Modedit.cpp  |  1 +
 .../dialogs/dialog_pns_length_tuning_settings.cpp  |  1 +
 pcbnew/dialogs/wizard_add_fplib.cpp                |  1 +
 pcbnew/footprint_wizard_frame.cpp                  |  1 +
 pcbnew/menubar_modedit.cpp                         |  1 +
 pcbnew/moduleframe.cpp                             |  1 +
 pcbnew/modview_frame.cpp                           |  1 +
 pcbnew/onrightclick.cpp                            |  1 +
 pcbnew/pcbframe.cpp                                |  1 +
 pcbnew/router/pns_tool_base.cpp                    |  1 +
 pcbnew/router/router_tool.cpp                      |  1 +
 pcbnew/tool_modedit.cpp                            |  1 +
 pcbnew/tool_pcb.cpp                                |  1 +
 pcbnew/tools/grid_menu.cpp                         |  1 +
 pcbnew/tools/pad_tool.cpp                          |  1 +
 pcbnew/tools/pcb_editor_control.cpp                |  1 +
 pcbnew/tools/size_menu.cpp                         |  2 +
 pcbnew/tools/zoom_menu.cpp                         |  1 +
 91 files changed, 353 insertions(+), 76 deletions(-)
 create mode 100644 include/bitmap_types.h

diff --git a/3d-viewer/3d_cache/dialogs/panel_prev_model.cpp b/3d-viewer/3d_cache/dialogs/panel_prev_model.cpp
index b0f9332a8..ddd88a75a 100644
--- a/3d-viewer/3d_cache/dialogs/panel_prev_model.cpp
+++ b/3d-viewer/3d_cache/dialogs/panel_prev_model.cpp
@@ -32,6 +32,7 @@
 #include <common_ogl/cogl_att_list.h>
 #include <cstdlib>
 #include <limits.h>
+#include <bitmaps.h>
 
 #include <wx/valnum.h>
 #include <wx/tglbtn.h>
diff --git a/3d-viewer/3d_canvas/eda_3d_canvas.cpp b/3d-viewer/3d_canvas/eda_3d_canvas.cpp
index 212f951bd..aeffc580c 100644
--- a/3d-viewer/3d_canvas/eda_3d_canvas.cpp
+++ b/3d-viewer/3d_canvas/eda_3d_canvas.cpp
@@ -40,6 +40,7 @@
 #include "status_text_reporter.h"
 #include <gl_context_mgr.h>
 #include <profile.h>        // To use GetRunningMicroSecs or an other profiling utility
+#include <bitmaps.h>
 
 /**
  *  Trace mask used to enable or disable the trace output of this class.
diff --git a/3d-viewer/3d_viewer/dialogs/dialog_3D_view_option.cpp b/3d-viewer/3d_viewer/dialogs/dialog_3D_view_option.cpp
index 257795748..1feadf004 100644
--- a/3d-viewer/3d_viewer/dialogs/dialog_3D_view_option.cpp
+++ b/3d-viewer/3d_viewer/dialogs/dialog_3D_view_option.cpp
@@ -25,6 +25,7 @@
 #include "dialog_3D_view_option_base.h"
 #include <3d_viewer/eda_3d_viewer.h>
 #include <3d_canvas/cinfo3d_visu.h>
+#include <bitmaps.h>
 
 class DIALOG_3D_VIEW_OPTIONS : public DIALOG_3D_VIEW_OPTIONS_BASE
 {
diff --git a/3d-viewer/3d_viewer/eda_3d_viewer.cpp b/3d-viewer/3d_viewer/eda_3d_viewer.cpp
index c3b42f471..e1d85fbf3 100644
--- a/3d-viewer/3d_viewer/eda_3d_viewer.cpp
+++ b/3d-viewer/3d_viewer/eda_3d_viewer.cpp
@@ -37,6 +37,7 @@
 #include  "../common_ogl/cogl_att_list.h"
 #include <hotkeys_basic.h>
 #include <wx/toolbar.h>
+#include <bitmaps.h>
 
 /**
  *  Trace mask used to enable or disable the trace output of this class.
diff --git a/cvpcb/cvpcb_mainframe.cpp b/cvpcb/cvpcb_mainframe.cpp
index f4c6ffeda..af25c93c2 100644
--- a/cvpcb/cvpcb_mainframe.cpp
+++ b/cvpcb/cvpcb_mainframe.cpp
@@ -41,6 +41,7 @@
 #include <wildcards_and_files_ext.h>
 #include <fp_lib_table.h>
 #include <netlist_reader.h>
+#include <bitmaps.h>
 
 #include <cvpcb_mainframe.h>
 #include <cvpcb.h>
diff --git a/eeschema/controle.cpp b/eeschema/controle.cpp
index 1cc80728a..a492b6408 100644
--- a/eeschema/controle.cpp
+++ b/eeschema/controle.cpp
@@ -34,6 +34,7 @@
 #include <schframe.h>
 #include <menus_helpers.h>
 #include <msgpanel.h>
+#include <bitmaps.h>
 
 #include <eeschema_id.h>
 #include <general.h>
diff --git a/eeschema/dialogs/dialog_annotate.cpp b/eeschema/dialogs/dialog_annotate.cpp
index 5ea48defc..d4b92d37f 100644
--- a/eeschema/dialogs/dialog_annotate.cpp
+++ b/eeschema/dialogs/dialog_annotate.cpp
@@ -31,6 +31,7 @@
 #include <fctsys.h>
 #include <schframe.h>
 #include <class_drawpanel.h>
+#include <bitmaps.h>
 
 #include <invoke_sch_dialog.h>
 #include <dialog_annotate_base.h>
diff --git a/eeschema/dialogs/dialog_erc.cpp b/eeschema/dialogs/dialog_erc.cpp
index dc1f9c068..bf7770f6c 100644
--- a/eeschema/dialogs/dialog_erc.cpp
+++ b/eeschema/dialogs/dialog_erc.cpp
@@ -38,6 +38,7 @@
 #include <invoke_sch_dialog.h>
 #include <project.h>
 #include <kiface_i.h>
+#include <bitmaps.h>
 
 #include <netlist.h>
 #include <class_netlist_object.h>
diff --git a/eeschema/dialogs/dialog_lib_edit_pin.cpp b/eeschema/dialogs/dialog_lib_edit_pin.cpp
index 3da3c90ef..d408045e7 100644
--- a/eeschema/dialogs/dialog_lib_edit_pin.cpp
+++ b/eeschema/dialogs/dialog_lib_edit_pin.cpp
@@ -26,6 +26,7 @@
 #include <macros.h>
 #include <gr_basic.h>
 #include <base_units.h>
+#include <bitmaps.h>
 
 #include <libeditframe.h>
 #include <class_libentry.h>
diff --git a/eeschema/hierarch.cpp b/eeschema/hierarch.cpp
index 2d9a84c85..bc871c420 100644
--- a/eeschema/hierarch.cpp
+++ b/eeschema/hierarch.cpp
@@ -32,6 +32,7 @@
 #include <confirm.h>
 #include <id.h>
 #include <schframe.h>
+#include <bitmaps.h>
 
 #include <general.h>
 #include <sch_sheet.h>
diff --git a/eeschema/lib_arc.cpp b/eeschema/lib_arc.cpp
index 68f52ef44..70ece548a 100644
--- a/eeschema/lib_arc.cpp
+++ b/eeschema/lib_arc.cpp
@@ -36,6 +36,7 @@
 #include <richio.h>
 #include <base_units.h>
 #include <msgpanel.h>
+#include <bitmaps.h>
 
 #include <general.h>
 #include <lib_arc.h>
@@ -580,6 +581,12 @@ wxString LIB_ARC::GetSelectMenuText() const
 }
 
 
+BITMAP_DEF LIB_ARC::GetMenuImage() const
+{
+    return add_arc_xpm;
+}
+
+
 void LIB_ARC::BeginEdit( STATUS_FLAGS aEditMode, const wxPoint aPosition )
 {
     wxCHECK_RET( ( aEditMode & ( IS_NEW | IS_MOVED | IS_RESIZED ) ) != 0,
diff --git a/eeschema/lib_arc.h b/eeschema/lib_arc.h
index a59fb03f9..e67accbd6 100644
--- a/eeschema/lib_arc.h
+++ b/eeschema/lib_arc.h
@@ -155,7 +155,7 @@ public:
 
     wxString GetSelectMenuText() const override;
 
-    BITMAP_DEF GetMenuImage() const override { return  add_arc_xpm; }
+    BITMAP_DEF GetMenuImage() const override;
 
     EDA_ITEM* Clone() const override;
 
diff --git a/eeschema/lib_circle.cpp b/eeschema/lib_circle.cpp
index bcf6a4045..59371cf5b 100644
--- a/eeschema/lib_circle.cpp
+++ b/eeschema/lib_circle.cpp
@@ -37,6 +37,7 @@
 #include <richio.h>
 #include <base_units.h>
 #include <msgpanel.h>
+#include <bitmaps.h>
 
 #include <general.h>
 #include <lib_circle.h>
@@ -297,6 +298,12 @@ wxString LIB_CIRCLE::GetSelectMenuText() const
 }
 
 
+BITMAP_DEF LIB_CIRCLE::GetMenuImage() const
+{
+    return add_circle_xpm;
+}
+
+
 void LIB_CIRCLE::BeginEdit( STATUS_FLAGS aEditMode, const wxPoint aPosition )
 {
     wxCHECK_RET( ( aEditMode & ( IS_NEW | IS_MOVED | IS_RESIZED ) ) != 0,
diff --git a/eeschema/lib_circle.h b/eeschema/lib_circle.h
index 0dab47e3e..7f14f563f 100644
--- a/eeschema/lib_circle.h
+++ b/eeschema/lib_circle.h
@@ -104,7 +104,7 @@ public:
 
     wxString GetSelectMenuText() const override;
 
-    BITMAP_DEF GetMenuImage() const override { return  add_circle_xpm; }
+    BITMAP_DEF GetMenuImage() const override;
 
     EDA_ITEM* Clone() const override;
 
diff --git a/eeschema/lib_field.cpp b/eeschema/lib_field.cpp
index a443203ef..676fce090 100644
--- a/eeschema/lib_field.cpp
+++ b/eeschema/lib_field.cpp
@@ -38,6 +38,7 @@
 #include <trigo.h>
 #include <base_units.h>
 #include <msgpanel.h>
+#include <bitmaps.h>
 
 #include <general.h>
 #include <class_libentry.h>
@@ -800,3 +801,9 @@ void LIB_FIELD::GetMsgPanelInfo( MSG_PANEL_ITEMS& aList )
     // Display field text:
     aList.push_back( MSG_PANEL_ITEM( _( "Value" ), GetShownText(), BROWN ) );
 }
+
+
+BITMAP_DEF LIB_FIELD::GetMenuImage() const
+{
+    return move_field_xpm;
+}
diff --git a/eeschema/lib_field.h b/eeschema/lib_field.h
index 0715e984c..5a7ba8f33 100644
--- a/eeschema/lib_field.h
+++ b/eeschema/lib_field.h
@@ -237,7 +237,7 @@ public:
 
     wxString GetSelectMenuText() const override;
 
-    BITMAP_DEF GetMenuImage() const override { return  move_field_xpm; }
+    BITMAP_DEF GetMenuImage() const override;
 
     EDA_ITEM* Clone() const override;
 
diff --git a/eeschema/lib_polyline.cpp b/eeschema/lib_polyline.cpp
index b56895657..3392e7227 100644
--- a/eeschema/lib_polyline.cpp
+++ b/eeschema/lib_polyline.cpp
@@ -36,6 +36,7 @@
 #include <richio.h>
 #include <base_units.h>
 #include <msgpanel.h>
+#include <bitmaps.h>
 
 #include <general.h>
 #include <lib_polyline.h>
@@ -420,6 +421,12 @@ wxString LIB_POLYLINE::GetSelectMenuText() const
 }
 
 
+BITMAP_DEF LIB_POLYLINE::GetMenuImage() const
+{
+    return add_polygon_xpm;
+}
+
+
 void LIB_POLYLINE::BeginEdit( STATUS_FLAGS aEditMode, const wxPoint aPosition )
 {
     wxCHECK_RET( ( aEditMode & ( IS_NEW | IS_MOVED | IS_RESIZED ) ) != 0,
diff --git a/eeschema/lib_polyline.h b/eeschema/lib_polyline.h
index 5b137a059..96f70c664 100644
--- a/eeschema/lib_polyline.h
+++ b/eeschema/lib_polyline.h
@@ -113,7 +113,7 @@ public:
 
     wxString GetSelectMenuText() const override;
 
-    BITMAP_DEF GetMenuImage() const override { return  add_polygon_xpm; }
+    BITMAP_DEF GetMenuImage() const override;
 
     EDA_ITEM* Clone() const override;
 
diff --git a/eeschema/lib_rectangle.cpp b/eeschema/lib_rectangle.cpp
index 74a19876d..7f17d05de 100644
--- a/eeschema/lib_rectangle.cpp
+++ b/eeschema/lib_rectangle.cpp
@@ -36,6 +36,7 @@
 #include <richio.h>
 #include <base_units.h>
 #include <msgpanel.h>
+#include <bitmaps.h>
 
 #include <general.h>
 #include <lib_rectangle.h>
@@ -337,6 +338,12 @@ wxString LIB_RECTANGLE::GetSelectMenuText() const
 }
 
 
+BITMAP_DEF LIB_RECTANGLE::GetMenuImage() const
+{
+    return add_rectangle_xpm;
+}
+
+
 void LIB_RECTANGLE::BeginEdit( STATUS_FLAGS aEditMode, const wxPoint aPosition )
 {
     wxCHECK_RET( ( aEditMode & ( IS_NEW | IS_MOVED | IS_RESIZED ) ) != 0,
diff --git a/eeschema/lib_rectangle.h b/eeschema/lib_rectangle.h
index 8e549d25c..b7ecd2b15 100644
--- a/eeschema/lib_rectangle.h
+++ b/eeschema/lib_rectangle.h
@@ -108,7 +108,7 @@ public:
 
     wxString GetSelectMenuText() const override;
 
-    BITMAP_DEF GetMenuImage() const override { return  add_rectangle_xpm; }
+    BITMAP_DEF GetMenuImage() const override;
 
     EDA_ITEM* Clone() const override;
 
diff --git a/eeschema/lib_text.cpp b/eeschema/lib_text.cpp
index a60c2bbce..d2e8b00f9 100644
--- a/eeschema/lib_text.cpp
+++ b/eeschema/lib_text.cpp
@@ -36,6 +36,7 @@
 #include <richio.h>
 #include <base_units.h>
 #include <msgpanel.h>
+#include <bitmaps.h>
 
 #include <lib_draw_item.h>
 #include <general.h>
@@ -509,6 +510,12 @@ wxString LIB_TEXT::GetSelectMenuText() const
 }
 
 
+BITMAP_DEF LIB_TEXT::GetMenuImage() const
+{
+    return add_text_xpm;
+}
+
+
 void LIB_TEXT::BeginEdit( STATUS_FLAGS aEditMode, const wxPoint aPosition )
 {
     wxCHECK_RET( ( aEditMode & ( IS_NEW | IS_MOVED ) ) != 0,
diff --git a/eeschema/lib_text.h b/eeschema/lib_text.h
index dd389ea16..f48bc08e9 100644
--- a/eeschema/lib_text.h
+++ b/eeschema/lib_text.h
@@ -129,7 +129,7 @@ public:
 
     wxString GetSelectMenuText() const override;
 
-    BITMAP_DEF GetMenuImage() const override { return  add_text_xpm; }
+    BITMAP_DEF GetMenuImage() const override;
 
     EDA_ITEM* Clone() const override;
 
diff --git a/eeschema/sch_bitmap.cpp b/eeschema/sch_bitmap.cpp
index 44e0a52c0..fb71b9dde 100644
--- a/eeschema/sch_bitmap.cpp
+++ b/eeschema/sch_bitmap.cpp
@@ -30,6 +30,8 @@
 #include <class_drawpanel.h>
 #include <trigo.h>
 #include <macros.h>
+#include <bitmaps.h>
+
 #include <sch_bitmap.h>
 
 #include <wx/mstream.h>
@@ -309,3 +311,9 @@ void SCH_BITMAP::Plot( PLOTTER* aPlotter )
 {
     m_image->PlotImage( aPlotter, m_pos, GetLayerColor( GetLayer() ), GetPenSize() );
 }
+
+
+BITMAP_DEF SCH_BITMAP::GetMenuImage() const
+{
+    return image_xpm;
+}
diff --git a/eeschema/sch_bitmap.h b/eeschema/sch_bitmap.h
index e92b9dc0a..542e03f0e 100644
--- a/eeschema/sch_bitmap.h
+++ b/eeschema/sch_bitmap.h
@@ -130,7 +130,7 @@ public:
 
     wxString GetSelectMenuText() const override { return wxString( _( "Image" ) ); }
 
-    BITMAP_DEF GetMenuImage() const override { return image_xpm; }
+    BITMAP_DEF GetMenuImage() const override;
 
     wxPoint GetPosition() const override { return m_pos; }
 
diff --git a/eeschema/sch_bus_entry.cpp b/eeschema/sch_bus_entry.cpp
index 07749cced..5acc9f5df 100644
--- a/eeschema/sch_bus_entry.cpp
+++ b/eeschema/sch_bus_entry.cpp
@@ -35,6 +35,7 @@
 #include <common.h>
 #include <richio.h>
 #include <plot_common.h>
+#include <bitmaps.h>
 
 #include <eeschema_config.h>
 #include <general.h>
@@ -340,6 +341,11 @@ wxString SCH_BUS_BUS_ENTRY::GetSelectMenuText() const
     return wxString( _( "Bus to Bus Entry" ) );
 }
 
+BITMAP_DEF SCH_BUS_ENTRY_BASE::GetMenuImage() const
+{
+    return add_entry_xpm;
+}
+
 
 bool SCH_BUS_ENTRY_BASE::HitTest( const wxPoint& aPosition, int aAccuracy ) const
 {
diff --git a/eeschema/sch_bus_entry.h b/eeschema/sch_bus_entry.h
index 678762c78..c638443bc 100644
--- a/eeschema/sch_bus_entry.h
+++ b/eeschema/sch_bus_entry.h
@@ -113,7 +113,7 @@ public:
 
     void GetConnectionPoints( std::vector< wxPoint >& aPoints ) const override;
 
-    BITMAP_DEF GetMenuImage() const override { return  add_entry_xpm; }
+    BITMAP_DEF GetMenuImage() const override;
 
     wxPoint GetPosition() const override { return m_pos; }
 
diff --git a/eeschema/sch_component.cpp b/eeschema/sch_component.cpp
index 3a4a55ba8..9a91450cd 100644
--- a/eeschema/sch_component.cpp
+++ b/eeschema/sch_component.cpp
@@ -36,6 +36,7 @@
 #include <schframe.h>
 #include <plot_common.h>
 #include <msgpanel.h>
+#include <bitmaps.h>
 
 #include <general.h>
 #include <class_library.h>
@@ -1576,6 +1577,12 @@ void SCH_COMPONENT::GetMsgPanelInfo( MSG_PANEL_ITEMS& aList )
 }
 
 
+BITMAP_DEF SCH_COMPONENT::GetMenuImage() const
+{
+    return add_component_xpm;
+}
+
+
 void SCH_COMPONENT::MirrorY( int aYaxis_position )
 {
     int dx = m_Pos.x;
diff --git a/eeschema/sch_component.h b/eeschema/sch_component.h
index 9d94bbac3..cbec577df 100644
--- a/eeschema/sch_component.h
+++ b/eeschema/sch_component.h
@@ -530,7 +530,7 @@ public:
 
     wxString GetSelectMenuText() const override;
 
-    BITMAP_DEF GetMenuImage() const override { return  add_component_xpm; }
+    BITMAP_DEF GetMenuImage() const override;
 
     void GetNetListItem( NETLIST_OBJECT_LIST& aNetListItems,
                          SCH_SHEET_PATH*      aSheetPath ) override;
diff --git a/eeschema/sch_field.cpp b/eeschema/sch_field.cpp
index 32d2fc4ce..9cfe13f4a 100644
--- a/eeschema/sch_field.cpp
+++ b/eeschema/sch_field.cpp
@@ -43,6 +43,7 @@
 #include <macros.h>
 #include <schframe.h>
 #include <plot_common.h>
+#include <bitmaps.h>
 
 #include <general.h>
 #include <class_library.h>
diff --git a/eeschema/sch_junction.cpp b/eeschema/sch_junction.cpp
index a0b7efc54..4bee5f0ff 100644
--- a/eeschema/sch_junction.cpp
+++ b/eeschema/sch_junction.cpp
@@ -34,6 +34,7 @@
 #include <common.h>
 #include <richio.h>
 #include <plot_common.h>
+#include <bitmaps.h>
 
 #include <sch_junction.h>
 #include <class_netlist_object.h>
@@ -233,3 +234,8 @@ void SCH_JUNCTION::Plot( PLOTTER* aPlotter )
     aPlotter->SetColor( GetLayerColor( GetLayer() ) );
     aPlotter->Circle( m_pos, GetSymbolSize(), FILLED_SHAPE );
 }
+
+BITMAP_DEF SCH_JUNCTION::GetMenuImage() const
+{
+    return add_junction_xpm;
+}
diff --git a/eeschema/sch_junction.h b/eeschema/sch_junction.h
index 6fbb1f8e2..9216a929f 100644
--- a/eeschema/sch_junction.h
+++ b/eeschema/sch_junction.h
@@ -85,7 +85,7 @@ public:
 
     wxString GetSelectMenuText() const override { return wxString( _( "Junction" ) ); }
 
-    BITMAP_DEF GetMenuImage() const override { return  add_junction_xpm; }
+    BITMAP_DEF GetMenuImage() const override;
 
     void GetNetListItem( NETLIST_OBJECT_LIST& aNetListItems, SCH_SHEET_PATH* aSheetPath ) override;
 
diff --git a/eeschema/sch_marker.cpp b/eeschema/sch_marker.cpp
index 334d277d2..d42f1f504 100644
--- a/eeschema/sch_marker.cpp
+++ b/eeschema/sch_marker.cpp
@@ -32,6 +32,7 @@
 #include <class_drawpanel.h>
 #include <trigo.h>
 #include <msgpanel.h>
+#include <bitmaps.h>
 
 #include <general.h>
 #include <sch_marker.h>
@@ -144,6 +145,12 @@ void SCH_MARKER::GetMsgPanelInfo( MSG_PANEL_ITEMS& aList )
 }
 
 
+BITMAP_DEF SCH_MARKER::GetMenuImage() const
+{
+    return erc_xpm;
+}
+
+
 void SCH_MARKER::Rotate( wxPoint aPosition )
 {
     RotatePoint( &m_Pos, aPosition, 900 );
diff --git a/eeschema/sch_marker.h b/eeschema/sch_marker.h
index 08da74190..15e58beff 100644
--- a/eeschema/sch_marker.h
+++ b/eeschema/sch_marker.h
@@ -99,7 +99,7 @@ public:
 
     wxString GetSelectMenuText() const override { return wxString( _( "ERC Marker" ) ); }
 
-    BITMAP_DEF GetMenuImage() const override { return  erc_xpm; }
+    BITMAP_DEF GetMenuImage() const override;
 
     wxPoint GetPosition() const override { return m_Pos; }
 
diff --git a/eeschema/sch_no_connect.cpp b/eeschema/sch_no_connect.cpp
index dd1e97812..623edf457 100644
--- a/eeschema/sch_no_connect.cpp
+++ b/eeschema/sch_no_connect.cpp
@@ -33,6 +33,7 @@
 #include <class_drawpanel.h>
 #include <common.h>
 #include <plot_common.h>
+#include <bitmaps.h>
 
 #include <general.h>
 #include <sch_no_connect.h>
@@ -250,3 +251,9 @@ void SCH_NO_CONNECT::Plot( PLOTTER* aPlotter )
     aPlotter->FinishTo( wxPoint( pX - delta, pY + delta ) );
 }
 
+
+BITMAP_DEF SCH_NO_CONNECT::GetMenuImage() const
+{
+    return noconn_xpm;
+}
+
diff --git a/eeschema/sch_no_connect.h b/eeschema/sch_no_connect.h
index ca83720b0..5360f073c 100644
--- a/eeschema/sch_no_connect.h
+++ b/eeschema/sch_no_connect.h
@@ -87,7 +87,7 @@ public:
 
     wxString GetSelectMenuText() const override { return wxString( _( "No Connect" ) ); }
 
-    BITMAP_DEF GetMenuImage() const override { return noconn_xpm; }
+    BITMAP_DEF GetMenuImage() const override;
 
     void GetNetListItem( NETLIST_OBJECT_LIST& aNetListItems, SCH_SHEET_PATH* aSheetPath ) override;
 
diff --git a/eeschema/sch_sheet.cpp b/eeschema/sch_sheet.cpp
index dc3ece8c9..0ccedbfcd 100644
--- a/eeschema/sch_sheet.cpp
+++ b/eeschema/sch_sheet.cpp
@@ -1077,6 +1077,12 @@ wxString SCH_SHEET::GetSelectMenuText() const
 }
 
 
+BITMAP_DEF SCH_SHEET::GetMenuImage() const
+{
+    return add_hierarchical_subsheet_xpm;
+}
+
+
 bool SCH_SHEET::HitTest( const wxPoint& aPosition, int aAccuracy ) const
 {
     EDA_RECT rect = GetBoundingBox();
diff --git a/eeschema/sch_sheet.h b/eeschema/sch_sheet.h
index ab7159cfd..454de54d0 100644
--- a/eeschema/sch_sheet.h
+++ b/eeschema/sch_sheet.h
@@ -196,7 +196,7 @@ public:
 
     wxString GetSelectMenuText() const override;
 
-    BITMAP_DEF GetMenuImage() const override { return  add_hierar_pin_xpm; }
+    BITMAP_DEF GetMenuImage() const override;
 
     void SetPosition( const wxPoint& aPosition ) override { ConstrainOnEdge( aPosition ); }
 
@@ -572,7 +572,7 @@ public:
 
     wxString GetSelectMenuText() const override;
 
-    BITMAP_DEF GetMenuImage() const override { return add_hierarchical_subsheet_xpm; }
+    BITMAP_DEF GetMenuImage() const override;
 
     void GetNetListItem( NETLIST_OBJECT_LIST& aNetListItems,
                          SCH_SHEET_PATH*      aSheetPath ) override;
diff --git a/eeschema/sch_sheet_pin.cpp b/eeschema/sch_sheet_pin.cpp
index f29c39037..9dcdfb1b9 100644
--- a/eeschema/sch_sheet_pin.cpp
+++ b/eeschema/sch_sheet_pin.cpp
@@ -35,6 +35,7 @@
 #include <trigo.h>
 #include <richio.h>
 #include <schframe.h>
+#include <bitmaps.h>
 
 #include <general.h>
 #include <sch_sheet.h>
@@ -505,6 +506,11 @@ wxString SCH_SHEET_PIN::GetSelectMenuText() const
     return tmp;
 }
 
+BITMAP_DEF SCH_SHEET_PIN::GetMenuImage() const
+{
+    return add_hierar_pin_xpm;
+}
+
 
 bool SCH_SHEET_PIN::HitTest( const wxPoint& aPoint, int aAccuracy ) const
 {
diff --git a/eeschema/sch_text.cpp b/eeschema/sch_text.cpp
index 8e572f597..a9d8982eb 100644
--- a/eeschema/sch_text.cpp
+++ b/eeschema/sch_text.cpp
@@ -38,6 +38,7 @@
 #include <plot_common.h>
 #include <msgpanel.h>
 #include <gal/stroke_font.h>
+#include <bitmaps.h>
 
 #include <protos.h>
 #include <sch_text.h>
@@ -618,6 +619,12 @@ wxString SCH_TEXT::GetSelectMenuText() const
 }
 
 
+BITMAP_DEF SCH_TEXT::GetMenuImage() const
+{
+    return add_text_xpm;
+}
+
+
 void SCH_TEXT::GetNetListItem( NETLIST_OBJECT_LIST& aNetListItems,
                                SCH_SHEET_PATH*      aSheetPath )
 {
@@ -1010,6 +1017,12 @@ wxString SCH_LABEL::GetSelectMenuText() const
 }
 
 
+BITMAP_DEF SCH_LABEL::GetMenuImage() const
+{
+    return add_line_label_xpm;
+}
+
+
 SCH_GLOBALLABEL::SCH_GLOBALLABEL( const wxPoint& pos, const wxString& text ) :
     SCH_TEXT( pos, text, SCH_GLOBAL_LABEL_T )
 {
@@ -1467,6 +1480,12 @@ wxString SCH_GLOBALLABEL::GetSelectMenuText() const
 }
 
 
+BITMAP_DEF SCH_GLOBALLABEL::GetMenuImage() const
+{
+    return add_glabel_xpm;
+}
+
+
 
 SCH_HIERLABEL::SCH_HIERLABEL( const wxPoint& pos, const wxString& text, KICAD_T aType ) :
     SCH_TEXT( pos, text, aType )
@@ -1817,3 +1836,9 @@ wxString SCH_HIERLABEL::GetSelectMenuText() const
     msg.Printf( _( "Hierarchical Label %s" ), GetChars( ShortenedShownText() ) );
     return msg;
 }
+
+
+BITMAP_DEF SCH_HIERLABEL::GetMenuImage() const
+{
+    return add_hierarchical_label_xpm;
+}
diff --git a/eeschema/sch_text.h b/eeschema/sch_text.h
index 24b1aaa74..e0da769d1 100644
--- a/eeschema/sch_text.h
+++ b/eeschema/sch_text.h
@@ -192,7 +192,7 @@ public:
 
     virtual wxString GetSelectMenuText() const override;
 
-    virtual BITMAP_DEF GetMenuImage() const override { return  add_text_xpm; }
+    virtual BITMAP_DEF GetMenuImage() const override;
 
     virtual void GetNetListItem( NETLIST_OBJECT_LIST& aNetListItems,
                                  SCH_SHEET_PATH*      aSheetPath ) override;
@@ -253,7 +253,7 @@ public:
 
     wxString GetSelectMenuText() const override;
 
-    BITMAP_DEF GetMenuImage() const override { return  add_line_label_xpm; }
+    BITMAP_DEF GetMenuImage() const override;
 
     bool IsReplaceable() const override { return true; }
 
@@ -303,7 +303,7 @@ public:
 
     wxString GetSelectMenuText() const override;
 
-    BITMAP_DEF GetMenuImage() const override { return  add_glabel_xpm; }
+    BITMAP_DEF GetMenuImage() const override;
 
     EDA_ITEM* Clone() const override;
 
@@ -353,7 +353,7 @@ public:
 
     wxString GetSelectMenuText() const override;
 
-    BITMAP_DEF GetMenuImage() const override { return  add_hierarchical_label_xpm; }
+    BITMAP_DEF GetMenuImage() const override;
 
     EDA_ITEM* Clone() const override;
 
diff --git a/eeschema/tool_lib.cpp b/eeschema/tool_lib.cpp
index 7f5a25c61..9a133ebf3 100644
--- a/eeschema/tool_lib.cpp
+++ b/eeschema/tool_lib.cpp
@@ -34,6 +34,7 @@
 #include <general.h>
 #include <libeditframe.h>
 #include <dialog_helpers.h>
+#include <bitmaps.h>
 
 #include <help_common_strings.h>
 
diff --git a/eeschema/tool_sch.cpp b/eeschema/tool_sch.cpp
index eccc40ef6..6060e3638 100644
--- a/eeschema/tool_sch.cpp
+++ b/eeschema/tool_sch.cpp
@@ -31,6 +31,7 @@
 #include <class_drawpanel.h>
 #include <schframe.h>
 #include <kiface_i.h>
+#include <bitmaps.h>
 
 #include <general.h>
 #include <hotkeys.h>
diff --git a/eeschema/viewlib_frame.cpp b/eeschema/viewlib_frame.cpp
index 5c2cc3a0c..31dac55ed 100644
--- a/eeschema/viewlib_frame.cpp
+++ b/eeschema/viewlib_frame.cpp
@@ -34,6 +34,7 @@
 #include <class_drawpanel.h>
 #include <schframe.h>
 #include <msgpanel.h>
+#include <bitmaps.h>
 
 #include <general.h>
 #include <viewlib_frame.h>
diff --git a/gerbview/gerbview_frame.cpp b/gerbview/gerbview_frame.cpp
index c94dd1f93..ff537cff9 100644
--- a/gerbview/gerbview_frame.cpp
+++ b/gerbview/gerbview_frame.cpp
@@ -37,6 +37,7 @@
 #include <colors_selection.h>
 #include <class_gbr_layer_box_selector.h>
 #include <msgpanel.h>
+#include <bitmaps.h>
 
 #include <gerbview.h>
 #include <gerbview_frame.h>
diff --git a/gerbview/toolbars_gerber.cpp b/gerbview/toolbars_gerber.cpp
index 1913a75e4..23802f967 100644
--- a/gerbview/toolbars_gerber.cpp
+++ b/gerbview/toolbars_gerber.cpp
@@ -41,6 +41,7 @@
 #include <class_gbr_layer_box_selector.h>
 #include <class_DCodeSelectionbox.h>
 #include <dialog_helpers.h>
+#include <bitmaps.h>
 
 #include <wx/wupdlock.h>
 
diff --git a/include/base_struct.h b/include/base_struct.h
index 61205b0bd..bb12ed768 100644
--- a/include/base_struct.h
+++ b/include/base_struct.h
@@ -35,7 +35,7 @@
 #include <core/typeinfo.h>
 
 #include <colors.h>
-#include <bitmaps.h>
+#include <bitmap_types.h>
 #include <richio.h>
 #include <view/view_item.h>
 #include <class_eda_rect.h>
diff --git a/include/bitmap_types.h b/include/bitmap_types.h
new file mode 100644
index 000000000..81f5fd36d
--- /dev/null
+++ b/include/bitmap_types.h
@@ -0,0 +1,72 @@
+/*
+ * This program source code file is part of KiCad, a free EDA CAD application.
+ *
+ * Copyright (C) 2007-2017 Jean-Pierre Charras, jp.charras at wanadoo.fr
+ * Copyright (C) 1992-2017 KiCad Developers, see CHANGELOG.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
+ */
+
+
+#ifndef BITMAP_TYPES_H_
+#define BITMAP_TYPES_H_
+
+//FIXME: cannot include only this file in wxWidgets 2.9.3
+// test if it works under stable release
+// #include <wx/bitmap.h>   // only to define wxBitmap
+class wxBitmap;     // only to define wxBitmap
+
+#include <config.h>
+
+
+/// PNG memory record (file in memory).
+struct BITMAP_OPAQUE
+{
+    const unsigned char* png;
+    int         byteCount;
+    const char* name;       // for debug, or future lazy dynamic linking
+};
+
+// declared as single element _array_, so its name assigns to pointer
+#define EXTERN_BITMAP(x) extern const BITMAP_OPAQUE x[1];
+
+
+/// a BITMAP_DEF is really a const pointer to an opaque
+/// structure.  So you should never need to use 'const' with it.
+typedef const BITMAP_OPAQUE *BITMAP_DEF;
+
+
+/**
+ * Function KiBitmap
+ * constructs a wxBitmap from a memory record, held in a
+ * BITMAP_DEF.
+ */
+wxBitmap KiBitmap( BITMAP_DEF aBitmap );
+
+
+/**
+ * Function KiBitmapNew
+ * allocates a wxBitmap on heap from a memory record, held in a
+ * BITMAP_DEF.
+ *
+ * @return wxBitmap* - caller owns it.
+ */
+wxBitmap* KiBitmapNew( BITMAP_DEF aBitmap );
+
+
+#endif  // BITMAP_TYPES_H_
diff --git a/include/bitmaps.h b/include/bitmaps.h
index f33dd3ce3..8f63a8449 100644
--- a/include/bitmaps.h
+++ b/include/bitmaps.h
@@ -26,47 +26,7 @@
 #ifndef BITMAPS_H_
 #define BITMAPS_H_
 
-//FIXME: cannot include only this file in wxWidgets 2.9.3
-// test if it works under stable release
-// #include <wx/bitmap.h>   // only to define wxBitmap
-class wxBitmap;     // only to define wxBitmap
-
-#include <config.h>
-
-
-/// PNG memory record (file in memory).
-struct BITMAP_OPAQUE
-{
-    const unsigned char* png;
-    int         byteCount;
-    const char* name;       // for debug, or future lazy dynamic linking
-};
-
-// declared as single element _array_, so its name assigns to pointer
-#define EXTERN_BITMAP(x) extern const BITMAP_OPAQUE x[1];
-
-
-/// a BITMAP_DEF is really a const pointer to an opaque
-/// structure.  So you should never need to use 'const' with it.
-typedef const BITMAP_OPAQUE *BITMAP_DEF;
-
-
-/**
- * Function KiBitmap
- * constructs a wxBitmap from a memory record, held in a
- * BITMAP_DEF.
- */
-wxBitmap KiBitmap( BITMAP_DEF aBitmap );
-
-
-/**
- * Function KiBitmapNew
- * allocates a wxBitmap on heap from a memory record, held in a
- * BITMAP_DEF.
- *
- * @return wxBitmap* - caller owns it.
- */
-wxBitmap* KiBitmapNew( BITMAP_DEF aBitmap );
+#include <bitmap_types.h>
 
 
 // may eventually generate this file automatically.
diff --git a/kicad/mainframe.cpp b/kicad/mainframe.cpp
index fdf5ecdf5..8901ff8f5 100644
--- a/kicad/mainframe.cpp
+++ b/kicad/mainframe.cpp
@@ -35,6 +35,7 @@
 #include <kiway.h>
 #include <kiway_player.h>
 #include <wildcards_and_files_ext.h>
+#include <bitmaps.h>
 
 #include "pgm_kicad.h"
 #include "tree_project_frame.h"
diff --git a/pagelayout_editor/pl_editor_frame.cpp b/pagelayout_editor/pl_editor_frame.cpp
index 58d83b5ce..0586029ac 100644
--- a/pagelayout_editor/pl_editor_frame.cpp
+++ b/pagelayout_editor/pl_editor_frame.cpp
@@ -34,6 +34,7 @@
 #include <macros.h>
 #include <base_units.h>
 #include <msgpanel.h>
+#include <bitmaps.h>
 
 #include <pl_editor_frame.h>
 #include <pl_editor_id.h>
diff --git a/pcbnew/class_dimension.cpp b/pcbnew/class_dimension.cpp
index 0efa9faaf..f2ef40f38 100644
--- a/pcbnew/class_dimension.cpp
+++ b/pcbnew/class_dimension.cpp
@@ -37,6 +37,7 @@
 #include <colors_selection.h>
 #include <kicad_string.h>
 #include <richio.h>
+#include <bitmaps.h>
 
 #include <class_board.h>
 #include <class_pcb_text.h>
@@ -484,6 +485,12 @@ wxString DIMENSION::GetSelectMenuText() const
 }
 
 
+BITMAP_DEF DIMENSION::GetMenuImage() const
+{
+    return add_dimension_xpm;
+}
+
+
 const BOX2I DIMENSION::ViewBBox() const
 {
     BOX2I dimBBox = BOX2I( VECTOR2I( GetBoundingBox().GetPosition() ),
diff --git a/pcbnew/class_dimension.h b/pcbnew/class_dimension.h
index 2ad91ee41..d6012fef8 100644
--- a/pcbnew/class_dimension.h
+++ b/pcbnew/class_dimension.h
@@ -224,7 +224,7 @@ public:
 
     wxString    GetSelectMenuText() const override;
 
-    BITMAP_DEF GetMenuImage() const override { return add_dimension_xpm; }
+    BITMAP_DEF GetMenuImage() const override;
 
     EDA_ITEM*   Clone() const override;
 
diff --git a/pcbnew/class_drawsegment.cpp b/pcbnew/class_drawsegment.cpp
index 50ddf984a..cb7292db8 100644
--- a/pcbnew/class_drawsegment.cpp
+++ b/pcbnew/class_drawsegment.cpp
@@ -39,6 +39,7 @@
 #include <colors_selection.h>
 #include <trigo.h>
 #include <msgpanel.h>
+#include <bitmaps.h>
 
 #include <pcbnew.h>
 
@@ -584,6 +585,12 @@ wxString DRAWSEGMENT::GetSelectMenuText() const
 }
 
 
+BITMAP_DEF DRAWSEGMENT::GetMenuImage() const
+{
+    return add_dashed_line_xpm;
+}
+
+
 EDA_ITEM* DRAWSEGMENT::Clone() const
 {
     return new DRAWSEGMENT( *this );
diff --git a/pcbnew/class_drawsegment.h b/pcbnew/class_drawsegment.h
index 989bb891f..37a856ccc 100644
--- a/pcbnew/class_drawsegment.h
+++ b/pcbnew/class_drawsegment.h
@@ -237,7 +237,7 @@ public:
 
     virtual wxString GetSelectMenuText() const override;
 
-    virtual BITMAP_DEF GetMenuImage() const override { return  add_dashed_line_xpm; }
+    virtual BITMAP_DEF GetMenuImage() const override;
 
     virtual EDA_ITEM* Clone() const override;
 
diff --git a/pcbnew/class_edge_mod.cpp b/pcbnew/class_edge_mod.cpp
index e49f7d7d1..c8b71428a 100644
--- a/pcbnew/class_edge_mod.cpp
+++ b/pcbnew/class_edge_mod.cpp
@@ -44,6 +44,7 @@
 #include <wxBasePcbFrame.h>
 #include <msgpanel.h>
 #include <base_units.h>
+#include <bitmaps.h>
 
 #include <class_board.h>
 #include <class_module.h>
@@ -258,6 +259,12 @@ wxString EDGE_MODULE::GetSelectMenuText() const
 }
 
 
+BITMAP_DEF EDGE_MODULE::GetMenuImage() const
+{
+    return show_mod_edge_xpm;
+}
+
+
 EDA_ITEM* EDGE_MODULE::Clone() const
 {
     return new EDGE_MODULE( *this );
diff --git a/pcbnew/class_edge_mod.h b/pcbnew/class_edge_mod.h
index d3b9d2089..571b69240 100644
--- a/pcbnew/class_edge_mod.h
+++ b/pcbnew/class_edge_mod.h
@@ -122,7 +122,7 @@ public:
 
     wxString GetSelectMenuText() const override;
 
-    BITMAP_DEF GetMenuImage() const override { return  show_mod_edge_xpm; }
+    BITMAP_DEF GetMenuImage() const override;
 
     EDA_ITEM* Clone() const override;
 
diff --git a/pcbnew/class_marker_pcb.cpp b/pcbnew/class_marker_pcb.cpp
index f625d8177..f80a2ee0b 100644
--- a/pcbnew/class_marker_pcb.cpp
+++ b/pcbnew/class_marker_pcb.cpp
@@ -34,6 +34,7 @@
 #include <wxstruct.h>
 #include <trigo.h>
 #include <msgpanel.h>
+#include <bitmaps.h>
 
 #include <pcbnew.h>
 #include <class_marker_pcb.h>
@@ -137,6 +138,12 @@ wxString MARKER_PCB::GetSelectMenuText() const
 }
 
 
+BITMAP_DEF MARKER_PCB::GetMenuImage() const
+{
+    return drc_xpm;
+}
+
+
 void MARKER_PCB::ViewGetLayers( int aLayers[], int& aCount ) const
 {
     aCount = 1;
diff --git a/pcbnew/class_marker_pcb.h b/pcbnew/class_marker_pcb.h
index 4c395d965..bc868f058 100644
--- a/pcbnew/class_marker_pcb.h
+++ b/pcbnew/class_marker_pcb.h
@@ -109,7 +109,7 @@ public:
 
     wxString GetSelectMenuText() const override;
 
-    BITMAP_DEF GetMenuImage() const override { return  drc_xpm; }
+    BITMAP_DEF GetMenuImage() const override;
 
     const BOX2I ViewBBox() const override
     {
diff --git a/pcbnew/class_mire.cpp b/pcbnew/class_mire.cpp
index e447134b6..afe97b208 100644
--- a/pcbnew/class_mire.cpp
+++ b/pcbnew/class_mire.cpp
@@ -38,6 +38,7 @@
 #include <trigo.h>
 #include <macros.h>
 #include <richio.h>
+#include <bitmaps.h>
 
 #include <class_board.h>
 #include <class_mire.h>
@@ -195,6 +196,11 @@ wxString PCB_TARGET::GetSelectMenuText() const
 }
 
 
+BITMAP_DEF PCB_TARGET::GetMenuImage() const
+{
+    return  add_mires_xpm;
+}
+
 EDA_ITEM* PCB_TARGET::Clone() const
 {
     return new PCB_TARGET( *this );
diff --git a/pcbnew/class_mire.h b/pcbnew/class_mire.h
index 8396ad8d5..5d419965e 100644
--- a/pcbnew/class_mire.h
+++ b/pcbnew/class_mire.h
@@ -100,7 +100,7 @@ public:
 
     wxString GetSelectMenuText() const override;
 
-    BITMAP_DEF GetMenuImage() const override { return  add_mires_xpm; }
+    BITMAP_DEF GetMenuImage() const override;
 
     EDA_ITEM* Clone() const override;
 
diff --git a/pcbnew/class_module.cpp b/pcbnew/class_module.cpp
index 40020fd8d..07b992385 100644
--- a/pcbnew/class_module.cpp
+++ b/pcbnew/class_module.cpp
@@ -43,6 +43,7 @@
 #include <filter_reader.h>
 #include <macros.h>
 #include <msgpanel.h>
+#include <bitmaps.h>
 
 #include <class_board.h>
 #include <class_edge_mod.h>
@@ -801,6 +802,12 @@ wxString MODULE::GetSelectMenuText() const
 }
 
 
+BITMAP_DEF MODULE::GetMenuImage() const
+{
+    return module_xpm;
+}
+
+
 EDA_ITEM* MODULE::Clone() const
 {
     return new MODULE( *this );
diff --git a/pcbnew/class_module.h b/pcbnew/class_module.h
index 63a549a86..e64448109 100644
--- a/pcbnew/class_module.h
+++ b/pcbnew/class_module.h
@@ -549,7 +549,7 @@ public:
 
     wxString GetSelectMenuText() const override;
 
-    BITMAP_DEF GetMenuImage() const override { return  module_xpm; }
+    BITMAP_DEF GetMenuImage() const override;
 
     EDA_ITEM* Clone() const override;
 
diff --git a/pcbnew/class_pad.cpp b/pcbnew/class_pad.cpp
index 962ee44ce..7b50e4515 100644
--- a/pcbnew/class_pad.cpp
+++ b/pcbnew/class_pad.cpp
@@ -35,6 +35,7 @@
 #include <macros.h>
 #include <msgpanel.h>
 #include <base_units.h>
+#include <bitmaps.h>
 
 #include <pcbnew.h>
 
@@ -912,6 +913,12 @@ wxString D_PAD::GetSelectMenuText() const
 }
 
 
+BITMAP_DEF D_PAD::GetMenuImage() const
+{
+    return pad_xpm;
+}
+
+
 EDA_ITEM* D_PAD::Clone() const
 {
     return new D_PAD( *this );
diff --git a/pcbnew/class_pad.h b/pcbnew/class_pad.h
index d8c26a8f8..6619d3134 100644
--- a/pcbnew/class_pad.h
+++ b/pcbnew/class_pad.h
@@ -514,7 +514,7 @@ public:
 
     wxString GetSelectMenuText() const override;
 
-    BITMAP_DEF GetMenuImage() const override { return pad_xpm; }
+    BITMAP_DEF GetMenuImage() const override;
 
     /**
      * Function ShowPadShape
diff --git a/pcbnew/class_pcb_text.cpp b/pcbnew/class_pcb_text.cpp
index 82e6ea93b..d2ed8ff01 100644
--- a/pcbnew/class_pcb_text.cpp
+++ b/pcbnew/class_pcb_text.cpp
@@ -42,6 +42,7 @@
 #include <wxBasePcbFrame.h>
 #include <msgpanel.h>
 #include <base_units.h>
+#include <bitmaps.h>
 
 #include <class_board.h>
 #include <class_pcb_text.h>
@@ -186,6 +187,12 @@ wxString TEXTE_PCB::GetSelectMenuText() const
 }
 
 
+BITMAP_DEF TEXTE_PCB::GetMenuImage() const
+{
+    return add_text_xpm;
+}
+
+
 EDA_ITEM* TEXTE_PCB::Clone() const
 {
     return new TEXTE_PCB( *this );
diff --git a/pcbnew/class_pcb_text.h b/pcbnew/class_pcb_text.h
index 677e42a27..3a2e0e54d 100644
--- a/pcbnew/class_pcb_text.h
+++ b/pcbnew/class_pcb_text.h
@@ -133,7 +133,7 @@ public:
 
     wxString GetSelectMenuText() const override;
 
-    BITMAP_DEF GetMenuImage() const override { return  add_text_xpm; }
+    BITMAP_DEF GetMenuImage() const override;
 
     // Virtual function
     const EDA_RECT GetBoundingBox() const override;
diff --git a/pcbnew/class_text_mod.cpp b/pcbnew/class_text_mod.cpp
index 3703d7cfa..2925fce64 100644
--- a/pcbnew/class_text_mod.cpp
+++ b/pcbnew/class_text_mod.cpp
@@ -41,6 +41,7 @@
 #include <wxBasePcbFrame.h>
 #include <msgpanel.h>
 #include <base_units.h>
+#include <bitmaps.h>
 
 #include <class_board.h>
 #include <class_module.h>
@@ -405,6 +406,12 @@ wxString TEXTE_MODULE::GetSelectMenuText() const
 }
 
 
+BITMAP_DEF TEXTE_MODULE::GetMenuImage() const
+{
+    return footprint_text_xpm;
+}
+
+
 EDA_ITEM* TEXTE_MODULE::Clone() const
 {
     return new TEXTE_MODULE( *this );
diff --git a/pcbnew/class_text_mod.h b/pcbnew/class_text_mod.h
index 535f2730b..df07ac8a2 100644
--- a/pcbnew/class_text_mod.h
+++ b/pcbnew/class_text_mod.h
@@ -193,7 +193,7 @@ public:
 
     wxString GetSelectMenuText() const override;
 
-    BITMAP_DEF GetMenuImage() const override { return  footprint_text_xpm; }
+    BITMAP_DEF GetMenuImage() const override;
 
     EDA_ITEM* Clone() const override;
 
diff --git a/pcbnew/class_track.cpp b/pcbnew/class_track.cpp
index 27a622fc0..92dc2d626 100644
--- a/pcbnew/class_track.cpp
+++ b/pcbnew/class_track.cpp
@@ -45,7 +45,7 @@
 #include <pcbnew.h>
 #include <base_units.h>
 #include <msgpanel.h>
-
+#include <bitmaps.h>
 
 /**
  * Function ShowClearance
@@ -149,6 +149,12 @@ wxString SEGZONE::GetSelectMenuText() const
 }
 
 
+BITMAP_DEF SEGZONE::GetMenuImage() const
+{
+    return add_zone_xpm;
+}
+
+
 VIA::VIA( BOARD_ITEM* aParent ) :
     TRACK( aParent, PCB_VIA_T )
 {
@@ -211,6 +217,12 @@ wxString VIA::GetSelectMenuText() const
 }
 
 
+BITMAP_DEF VIA::GetMenuImage() const
+{
+    return via_sketch_xpm;
+}
+
+
 int TRACK::GetClearance( BOARD_CONNECTED_ITEM* aItem ) const
 {
     // Currently tracks have no specific clearance parameter on a per track or per
@@ -1581,6 +1593,12 @@ wxString TRACK::GetSelectMenuText() const
 }
 
 
+BITMAP_DEF TRACK:: GetMenuImage() const
+{
+    return showtrack_xpm;
+}
+
+
 #if defined(DEBUG)
 
 wxString TRACK::ShowState( int stateBits )
diff --git a/pcbnew/class_track.h b/pcbnew/class_track.h
index e18517942..6e2ff54c2 100644
--- a/pcbnew/class_track.h
+++ b/pcbnew/class_track.h
@@ -294,7 +294,7 @@ public:
 
     virtual wxString GetSelectMenuText() const override;
 
-    virtual BITMAP_DEF GetMenuImage() const override { return  showtrack_xpm; }
+    BITMAP_DEF GetMenuImage() const override;
 
     virtual EDA_ITEM* Clone() const override;
 
@@ -366,7 +366,7 @@ public:
     void Draw( EDA_DRAW_PANEL* panel, wxDC* DC,
                GR_DRAWMODE aDrawMode, const wxPoint& aOffset = ZeroOffset ) override;
 
-    BITMAP_DEF GetMenuImage() const override { return  add_zone_xpm; }
+    BITMAP_DEF GetMenuImage() const override;
 
     EDA_ITEM* Clone() const override;
 
@@ -426,7 +426,7 @@ public:
 
     wxString GetSelectMenuText() const override;
 
-    BITMAP_DEF GetMenuImage() const override { return  via_sketch_xpm; }
+    BITMAP_DEF GetMenuImage() const override;
 
     EDA_ITEM* Clone() const override;
 
diff --git a/pcbnew/class_zone.cpp b/pcbnew/class_zone.cpp
index 0ac7966a0..99795a81f 100644
--- a/pcbnew/class_zone.cpp
+++ b/pcbnew/class_zone.cpp
@@ -39,6 +39,7 @@
 #include <macros.h>
 #include <wxBasePcbFrame.h>
 #include <msgpanel.h>
+#include <bitmaps.h>
 
 #include <class_board.h>
 #include <class_zone.h>
@@ -851,3 +852,9 @@ wxString ZONE_CONTAINER::GetSelectMenuText() const
 
     return msg;
 }
+
+
+BITMAP_DEF ZONE_CONTAINER::GetMenuImage() const
+{
+    return add_zone_xpm;
+}
diff --git a/pcbnew/class_zone.h b/pcbnew/class_zone.h
index ab488a196..d4e08d288 100644
--- a/pcbnew/class_zone.h
+++ b/pcbnew/class_zone.h
@@ -515,11 +515,11 @@ public:
         m_FillSegmList.insert( m_FillSegmList.end(), aSegments.begin(), aSegments.end() );
     }
 
-    virtual wxString GetSelectMenuText() const override;
+    wxString GetSelectMenuText() const override;
 
-    virtual BITMAP_DEF GetMenuImage() const override { return  add_zone_xpm; }
+    BITMAP_DEF GetMenuImage() const override;
 
-    virtual EDA_ITEM* Clone() const override;
+    EDA_ITEM* Clone() const override;
 
     /**
      * Accessors to parameters used in Keepout zones:
diff --git a/pcbnew/dialogs/dialog_edit_module_for_BoardEditor.cpp b/pcbnew/dialogs/dialog_edit_module_for_BoardEditor.cpp
index 90f912c80..7bb78c645 100644
--- a/pcbnew/dialogs/dialog_edit_module_for_BoardEditor.cpp
+++ b/pcbnew/dialogs/dialog_edit_module_for_BoardEditor.cpp
@@ -42,6 +42,7 @@
 #include <base_units.h>
 #include <project.h>
 #include <board_commit.h>
+#include <bitmaps.h>
 
 #include <class_module.h>
 #include <class_text_mod.h>
diff --git a/pcbnew/dialogs/dialog_edit_module_for_Modedit.cpp b/pcbnew/dialogs/dialog_edit_module_for_Modedit.cpp
index 04727822f..5b55cb9a5 100644
--- a/pcbnew/dialogs/dialog_edit_module_for_Modedit.cpp
+++ b/pcbnew/dialogs/dialog_edit_module_for_Modedit.cpp
@@ -44,6 +44,7 @@
 #include <validators.h>
 #include <kicad_string.h>
 #include <board_commit.h>
+#include <bitmaps.h>
 
 #include <class_module.h>
 #include <class_text_mod.h>
diff --git a/pcbnew/dialogs/dialog_pns_length_tuning_settings.cpp b/pcbnew/dialogs/dialog_pns_length_tuning_settings.cpp
index b7d238e80..1c490a2fc 100644
--- a/pcbnew/dialogs/dialog_pns_length_tuning_settings.cpp
+++ b/pcbnew/dialogs/dialog_pns_length_tuning_settings.cpp
@@ -25,6 +25,7 @@
 
 #include "dialog_pns_length_tuning_settings.h"
 #include <router/pns_meander_placer.h>
+#include <bitmaps.h>
 
 DIALOG_PNS_LENGTH_TUNING_SETTINGS::DIALOG_PNS_LENGTH_TUNING_SETTINGS( wxWindow* aParent,
                         PNS::MEANDER_SETTINGS& aSettings, PNS::ROUTER_MODE aMode )
diff --git a/pcbnew/dialogs/wizard_add_fplib.cpp b/pcbnew/dialogs/wizard_add_fplib.cpp
index d909759f7..b9c7cb46c 100644
--- a/pcbnew/dialogs/wizard_add_fplib.cpp
+++ b/pcbnew/dialogs/wizard_add_fplib.cpp
@@ -43,6 +43,7 @@
 #include <wizard_add_fplib.h>
 #include <fp_lib_table.h>
 #include <confirm.h>
+#include <bitmaps.h>
 
 #include <class_module.h>
 
diff --git a/pcbnew/footprint_wizard_frame.cpp b/pcbnew/footprint_wizard_frame.cpp
index 351ccabd0..0c025c1d5 100644
--- a/pcbnew/footprint_wizard_frame.cpp
+++ b/pcbnew/footprint_wizard_frame.cpp
@@ -36,6 +36,7 @@
 #include <3d_viewer/eda_3d_viewer.h>
 #include <msgpanel.h>
 #include <macros.h>
+#include <bitmaps.h>
 
 #include <class_board.h>
 #include <class_module.h>
diff --git a/pcbnew/menubar_modedit.cpp b/pcbnew/menubar_modedit.cpp
index 243d28c1d..4eade3e9b 100644
--- a/pcbnew/menubar_modedit.cpp
+++ b/pcbnew/menubar_modedit.cpp
@@ -34,6 +34,7 @@
 #include <pgm_base.h>
 #include <wxPcbStruct.h>
 
+
 #include "help_common_strings.h"
 #include "hotkeys.h"
 #include "module_editor_frame.h"
diff --git a/pcbnew/moduleframe.cpp b/pcbnew/moduleframe.cpp
index 0b39a6e72..d05786f29 100644
--- a/pcbnew/moduleframe.cpp
+++ b/pcbnew/moduleframe.cpp
@@ -42,6 +42,7 @@
 #include <3d_viewer/eda_3d_viewer.h>
 #include <msgpanel.h>
 #include <fp_lib_table.h>
+#include <bitmaps.h>
 
 #include <class_board.h>
 #include <class_module.h>
diff --git a/pcbnew/modview_frame.cpp b/pcbnew/modview_frame.cpp
index 93e43e1a4..6774d319f 100644
--- a/pcbnew/modview_frame.cpp
+++ b/pcbnew/modview_frame.cpp
@@ -39,6 +39,7 @@
 #include <fp_lib_table.h>
 #include <lib_id.h>
 #include <confirm.h>
+#include <bitmaps.h>
 
 #include <class_board.h>
 #include <class_module.h>
diff --git a/pcbnew/onrightclick.cpp b/pcbnew/onrightclick.cpp
index f0027fc44..afb7c4989 100644
--- a/pcbnew/onrightclick.cpp
+++ b/pcbnew/onrightclick.cpp
@@ -33,6 +33,7 @@
 #include <class_drawpanel.h>
 #include <macros.h>
 #include <base_units.h>
+#include <bitmaps.h>
 
 #include <class_board.h>
 #include <class_module.h>
diff --git a/pcbnew/pcbframe.cpp b/pcbnew/pcbframe.cpp
index 11cef6dd4..fb82216b3 100644
--- a/pcbnew/pcbframe.cpp
+++ b/pcbnew/pcbframe.cpp
@@ -41,6 +41,7 @@
 #include <3d_viewer/eda_3d_viewer.h>
 #include <msgpanel.h>
 #include <fp_lib_table.h>
+#include <bitmaps.h>
 
 #include <pcbnew.h>
 #include <pcbnew_id.h>
diff --git a/pcbnew/router/pns_tool_base.cpp b/pcbnew/router/pns_tool_base.cpp
index ad4417810..548431c34 100644
--- a/pcbnew/router/pns_tool_base.cpp
+++ b/pcbnew/router/pns_tool_base.cpp
@@ -38,6 +38,7 @@ using namespace std::placeholders;
 #include <dialogs/dialog_pns_length_tuning_settings.h>
 #include <dialogs/dialog_track_via_size.h>
 #include <base_units.h>
+#include <bitmaps.h>
 
 #include <tool/context_menu.h>
 #include <tools/common_actions.h>
diff --git a/pcbnew/router/router_tool.cpp b/pcbnew/router/router_tool.cpp
index 4793637d0..365653aaa 100644
--- a/pcbnew/router/router_tool.cpp
+++ b/pcbnew/router/router_tool.cpp
@@ -41,6 +41,7 @@ using namespace std::placeholders;
 #include <base_units.h>
 #include <hotkeys.h>
 #include <confirm.h>
+#include <bitmaps.h>
 
 #include <tool/context_menu.h>
 #include <tool/tool_manager.h>
diff --git a/pcbnew/tool_modedit.cpp b/pcbnew/tool_modedit.cpp
index d545044c7..a7953ae9f 100644
--- a/pcbnew/tool_modedit.cpp
+++ b/pcbnew/tool_modedit.cpp
@@ -37,6 +37,7 @@
 #include <dialog_helpers.h>
 #include <pcbnew_id.h>
 #include <hotkeys.h>
+#include <bitmaps.h>
 
 
 void FOOTPRINT_EDIT_FRAME::ReCreateHToolbar()
diff --git a/pcbnew/tool_pcb.cpp b/pcbnew/tool_pcb.cpp
index 513129872..102ac535f 100644
--- a/pcbnew/tool_pcb.cpp
+++ b/pcbnew/tool_pcb.cpp
@@ -38,6 +38,7 @@
 #include <wxPcbStruct.h>
 #include <class_drawpanel.h>
 #include <confirm.h>
+#include <bitmaps.h>
 
 #include <class_board.h>
 
diff --git a/pcbnew/tools/grid_menu.cpp b/pcbnew/tools/grid_menu.cpp
index 0f851e6f5..4b8b77b4a 100644
--- a/pcbnew/tools/grid_menu.cpp
+++ b/pcbnew/tools/grid_menu.cpp
@@ -28,6 +28,7 @@
 #include <draw_frame.h>
 #include <class_base_screen.h>
 #include <tools/common_actions.h>
+#include <bitmaps.h>
 
 #include <functional>
 using namespace std::placeholders;
diff --git a/pcbnew/tools/pad_tool.cpp b/pcbnew/tools/pad_tool.cpp
index 19e9417b0..a885f55c2 100644
--- a/pcbnew/tools/pad_tool.cpp
+++ b/pcbnew/tools/pad_tool.cpp
@@ -29,6 +29,7 @@
 #include <view/view_controls.h>
 #include <view/view.h>
 #include <tool/tool_manager.h>
+#include <bitmaps.h>
 
 #include <class_board_item.h>
 #include <class_module.h>
diff --git a/pcbnew/tools/pcb_editor_control.cpp b/pcbnew/tools/pcb_editor_control.cpp
index 788d77411..cf580c641 100644
--- a/pcbnew/tools/pcb_editor_control.cpp
+++ b/pcbnew/tools/pcb_editor_control.cpp
@@ -46,6 +46,7 @@
 #include <zones_functions_for_undo_redo.h>
 #include <board_commit.h>
 #include <confirm.h>
+#include <bitmaps.h>
 
 #include <view/view_group.h>
 #include <view/view_controls.h>
diff --git a/pcbnew/tools/size_menu.cpp b/pcbnew/tools/size_menu.cpp
index f2e319ee5..2b5a836ef 100644
--- a/pcbnew/tools/size_menu.cpp
+++ b/pcbnew/tools/size_menu.cpp
@@ -23,6 +23,8 @@
 
 #include <class_board.h>
 #include <pcbnew_id.h>
+#include <bitmaps.h>
+
 
 TRACK_VIA_SIZE_MENU::TRACK_VIA_SIZE_MENU( bool aTrackSizes, bool aViaSizes ) :
     m_tracks( aTrackSizes ), m_vias( aViaSizes )
diff --git a/pcbnew/tools/zoom_menu.cpp b/pcbnew/tools/zoom_menu.cpp
index 8f3e614f9..ae7464212 100644
--- a/pcbnew/tools/zoom_menu.cpp
+++ b/pcbnew/tools/zoom_menu.cpp
@@ -27,6 +27,7 @@
 #include <draw_frame.h>
 #include <class_base_screen.h>
 #include <tools/common_actions.h>
+#include <bitmaps.h>
 
 #include <functional>
 using namespace std::placeholders;
-- 
2.11.0


Follow ups