From 128e3ff123038ab881418e3cbfd645d24ea75250 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Br=C3=BCns?= Date: Sun, 26 Jul 2020 08:04:23 +0200 Subject: [PATCH 1/6] Make the wxART_* constants const wxStrings with static storage duration The pre-3.1.4 definitions of the constants were just string literals, while the type were wxString typedefs. To avoid implicit conversion these were converted to actual wxStrings. While the interface now matched the implementation, this has several drawbacks: - every use of the "constant" now is a string construction at runtime - the constant now is an rvalue, i.e. it is impossible to take its address. The latter breaks its use from wxPython. The IDs are moved to a separate file which can be included multiple times, once from the header to have the declarations in place, and once to instantiate the wxStrings. Using a common file avoids the declaration and definition going out of sync. --- Makefile.in | 1 + build/bakefiles/files.bkl | 1 + build/cmake/files.cmake | 1 + include/wx/artids.h | 96 ++++++++++++++++++++++++++++ include/wx/artprov.h | 90 +++------------------------ interface/wx/artprov.h | 128 +++++++++++++++++++------------------- src/common/artprov.cpp | 6 ++ 7 files changed, 176 insertions(+), 147 deletions(-) create mode 100644 include/wx/artids.h diff --git a/Makefile.in b/Makefile.in index 4b0c2dd420..1bb35de7ee 100644 --- a/Makefile.in +++ b/Makefile.in @@ -3820,6 +3820,7 @@ COND_USE_GUI_1_ALL_GUI_HEADERS = \ wx/anidecod.h \ wx/animdecod.h \ wx/appprogress.h \ + wx/artids.h \ wx/artprov.h \ wx/bitmap.h \ wx/bookctrl.h \ diff --git a/build/bakefiles/files.bkl b/build/bakefiles/files.bkl index b5c240db5f..03af3f1767 100644 --- a/build/bakefiles/files.bkl +++ b/build/bakefiles/files.bkl @@ -1131,6 +1131,7 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file! wx/anidecod.h wx/animdecod.h wx/appprogress.h + wx/artids.h wx/artprov.h wx/bitmap.h wx/bookctrl.h diff --git a/build/cmake/files.cmake b/build/cmake/files.cmake index f3db68b0bd..01e540ee82 100644 --- a/build/cmake/files.cmake +++ b/build/cmake/files.cmake @@ -1039,6 +1039,7 @@ set(GUI_CMN_HDR wx/anidecod.h wx/animdecod.h wx/appprogress.h + wx/artids.h wx/artprov.h wx/bitmap.h wx/bookctrl.h diff --git a/include/wx/artids.h b/include/wx/artids.h new file mode 100644 index 0000000000..49afaefeea --- /dev/null +++ b/include/wx/artids.h @@ -0,0 +1,96 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: wx/artids.h +// Purpose: wxArtProvider client and art IDs +// Author: Stefan Brüns +// Modified by: +// Created: 2020-07-31 (extracted from artprov.h) +// Copyright: (c) Stefan Brüns +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +// This file deliberately omits include guards so it can +// be included and processed multiple times + +// ---------------------------------------------------------------------------- +// Art clients +// ---------------------------------------------------------------------------- + +wxART_MAKE_CLIENT_ID(wxART_TOOLBAR) +wxART_MAKE_CLIENT_ID(wxART_MENU) +wxART_MAKE_CLIENT_ID(wxART_FRAME_ICON) + +wxART_MAKE_CLIENT_ID(wxART_CMN_DIALOG) +wxART_MAKE_CLIENT_ID(wxART_HELP_BROWSER) +wxART_MAKE_CLIENT_ID(wxART_MESSAGE_BOX) +wxART_MAKE_CLIENT_ID(wxART_BUTTON) +wxART_MAKE_CLIENT_ID(wxART_LIST) + +wxART_MAKE_CLIENT_ID(wxART_OTHER) + +// ---------------------------------------------------------------------------- +// Art IDs +// ---------------------------------------------------------------------------- + +wxART_MAKE_ART_ID(wxART_ADD_BOOKMARK) +wxART_MAKE_ART_ID(wxART_DEL_BOOKMARK) +wxART_MAKE_ART_ID(wxART_HELP_SIDE_PANEL) +wxART_MAKE_ART_ID(wxART_HELP_SETTINGS) +wxART_MAKE_ART_ID(wxART_HELP_BOOK) +wxART_MAKE_ART_ID(wxART_HELP_FOLDER) +wxART_MAKE_ART_ID(wxART_HELP_PAGE) +wxART_MAKE_ART_ID(wxART_GO_BACK) +wxART_MAKE_ART_ID(wxART_GO_FORWARD) +wxART_MAKE_ART_ID(wxART_GO_UP) +wxART_MAKE_ART_ID(wxART_GO_DOWN) +wxART_MAKE_ART_ID(wxART_GO_TO_PARENT) +wxART_MAKE_ART_ID(wxART_GO_HOME) +wxART_MAKE_ART_ID(wxART_GOTO_FIRST) +wxART_MAKE_ART_ID(wxART_GOTO_LAST) +wxART_MAKE_ART_ID(wxART_FILE_OPEN) +wxART_MAKE_ART_ID(wxART_FILE_SAVE) +wxART_MAKE_ART_ID(wxART_FILE_SAVE_AS) +wxART_MAKE_ART_ID(wxART_PRINT) +wxART_MAKE_ART_ID(wxART_HELP) +wxART_MAKE_ART_ID(wxART_TIP) +wxART_MAKE_ART_ID(wxART_REPORT_VIEW) +wxART_MAKE_ART_ID(wxART_LIST_VIEW) +wxART_MAKE_ART_ID(wxART_NEW_DIR) +wxART_MAKE_ART_ID(wxART_HARDDISK) +wxART_MAKE_ART_ID(wxART_FLOPPY) +wxART_MAKE_ART_ID(wxART_CDROM) +wxART_MAKE_ART_ID(wxART_REMOVABLE) +wxART_MAKE_ART_ID(wxART_FOLDER) +wxART_MAKE_ART_ID(wxART_FOLDER_OPEN) +wxART_MAKE_ART_ID(wxART_GO_DIR_UP) +wxART_MAKE_ART_ID(wxART_EXECUTABLE_FILE) +wxART_MAKE_ART_ID(wxART_NORMAL_FILE) +wxART_MAKE_ART_ID(wxART_TICK_MARK) +wxART_MAKE_ART_ID(wxART_CROSS_MARK) +wxART_MAKE_ART_ID(wxART_ERROR) +wxART_MAKE_ART_ID(wxART_QUESTION) +wxART_MAKE_ART_ID(wxART_WARNING) +wxART_MAKE_ART_ID(wxART_INFORMATION) +wxART_MAKE_ART_ID(wxART_MISSING_IMAGE) + +wxART_MAKE_ART_ID(wxART_COPY) +wxART_MAKE_ART_ID(wxART_CUT) +wxART_MAKE_ART_ID(wxART_PASTE) +wxART_MAKE_ART_ID(wxART_DELETE) +wxART_MAKE_ART_ID(wxART_NEW) + +wxART_MAKE_ART_ID(wxART_UNDO) +wxART_MAKE_ART_ID(wxART_REDO) + +wxART_MAKE_ART_ID(wxART_PLUS) +wxART_MAKE_ART_ID(wxART_MINUS) + +wxART_MAKE_ART_ID(wxART_CLOSE) +wxART_MAKE_ART_ID(wxART_QUIT) + +wxART_MAKE_ART_ID(wxART_FIND) +wxART_MAKE_ART_ID(wxART_FIND_AND_REPLACE) + +wxART_MAKE_ART_ID(wxART_FULL_SCREEN) + +wxART_MAKE_ART_ID(wxART_EDIT) + diff --git a/include/wx/artprov.h b/include/wx/artprov.h index b54597659b..0746af3808 100644 --- a/include/wx/artprov.h +++ b/include/wx/artprov.h @@ -28,92 +28,16 @@ typedef wxString wxArtClient; typedef wxString wxArtID; #define wxART_MAKE_CLIENT_ID_FROM_STR(id) ((id) + wxASCII_STR("_C")) -#define wxART_MAKE_CLIENT_ID(id) wxASCII_STR(#id "_C") #define wxART_MAKE_ART_ID_FROM_STR(id) (id) -#define wxART_MAKE_ART_ID(id) wxASCII_STR(#id) -// ---------------------------------------------------------------------------- -// Art clients -// ---------------------------------------------------------------------------- +#define wxART_MAKE_CLIENT_ID(id) \ + extern WXDLLIMPEXP_DATA_CORE(const wxArtClient) id; +#define wxART_MAKE_ART_ID(id) \ + extern WXDLLIMPEXP_DATA_CORE(const wxArtID) id; -#define wxART_TOOLBAR wxART_MAKE_CLIENT_ID(wxART_TOOLBAR) -#define wxART_MENU wxART_MAKE_CLIENT_ID(wxART_MENU) -#define wxART_FRAME_ICON wxART_MAKE_CLIENT_ID(wxART_FRAME_ICON) - -#define wxART_CMN_DIALOG wxART_MAKE_CLIENT_ID(wxART_CMN_DIALOG) -#define wxART_HELP_BROWSER wxART_MAKE_CLIENT_ID(wxART_HELP_BROWSER) -#define wxART_MESSAGE_BOX wxART_MAKE_CLIENT_ID(wxART_MESSAGE_BOX) -#define wxART_BUTTON wxART_MAKE_CLIENT_ID(wxART_BUTTON) -#define wxART_LIST wxART_MAKE_CLIENT_ID(wxART_LIST) - -#define wxART_OTHER wxART_MAKE_CLIENT_ID(wxART_OTHER) - -// ---------------------------------------------------------------------------- -// Art IDs -// ---------------------------------------------------------------------------- - -#define wxART_ADD_BOOKMARK wxART_MAKE_ART_ID(wxART_ADD_BOOKMARK) -#define wxART_DEL_BOOKMARK wxART_MAKE_ART_ID(wxART_DEL_BOOKMARK) -#define wxART_HELP_SIDE_PANEL wxART_MAKE_ART_ID(wxART_HELP_SIDE_PANEL) -#define wxART_HELP_SETTINGS wxART_MAKE_ART_ID(wxART_HELP_SETTINGS) -#define wxART_HELP_BOOK wxART_MAKE_ART_ID(wxART_HELP_BOOK) -#define wxART_HELP_FOLDER wxART_MAKE_ART_ID(wxART_HELP_FOLDER) -#define wxART_HELP_PAGE wxART_MAKE_ART_ID(wxART_HELP_PAGE) -#define wxART_GO_BACK wxART_MAKE_ART_ID(wxART_GO_BACK) -#define wxART_GO_FORWARD wxART_MAKE_ART_ID(wxART_GO_FORWARD) -#define wxART_GO_UP wxART_MAKE_ART_ID(wxART_GO_UP) -#define wxART_GO_DOWN wxART_MAKE_ART_ID(wxART_GO_DOWN) -#define wxART_GO_TO_PARENT wxART_MAKE_ART_ID(wxART_GO_TO_PARENT) -#define wxART_GO_HOME wxART_MAKE_ART_ID(wxART_GO_HOME) -#define wxART_GOTO_FIRST wxART_MAKE_ART_ID(wxART_GOTO_FIRST) -#define wxART_GOTO_LAST wxART_MAKE_ART_ID(wxART_GOTO_LAST) -#define wxART_FILE_OPEN wxART_MAKE_ART_ID(wxART_FILE_OPEN) -#define wxART_FILE_SAVE wxART_MAKE_ART_ID(wxART_FILE_SAVE) -#define wxART_FILE_SAVE_AS wxART_MAKE_ART_ID(wxART_FILE_SAVE_AS) -#define wxART_PRINT wxART_MAKE_ART_ID(wxART_PRINT) -#define wxART_HELP wxART_MAKE_ART_ID(wxART_HELP) -#define wxART_TIP wxART_MAKE_ART_ID(wxART_TIP) -#define wxART_REPORT_VIEW wxART_MAKE_ART_ID(wxART_REPORT_VIEW) -#define wxART_LIST_VIEW wxART_MAKE_ART_ID(wxART_LIST_VIEW) -#define wxART_NEW_DIR wxART_MAKE_ART_ID(wxART_NEW_DIR) -#define wxART_HARDDISK wxART_MAKE_ART_ID(wxART_HARDDISK) -#define wxART_FLOPPY wxART_MAKE_ART_ID(wxART_FLOPPY) -#define wxART_CDROM wxART_MAKE_ART_ID(wxART_CDROM) -#define wxART_REMOVABLE wxART_MAKE_ART_ID(wxART_REMOVABLE) -#define wxART_FOLDER wxART_MAKE_ART_ID(wxART_FOLDER) -#define wxART_FOLDER_OPEN wxART_MAKE_ART_ID(wxART_FOLDER_OPEN) -#define wxART_GO_DIR_UP wxART_MAKE_ART_ID(wxART_GO_DIR_UP) -#define wxART_EXECUTABLE_FILE wxART_MAKE_ART_ID(wxART_EXECUTABLE_FILE) -#define wxART_NORMAL_FILE wxART_MAKE_ART_ID(wxART_NORMAL_FILE) -#define wxART_TICK_MARK wxART_MAKE_ART_ID(wxART_TICK_MARK) -#define wxART_CROSS_MARK wxART_MAKE_ART_ID(wxART_CROSS_MARK) -#define wxART_ERROR wxART_MAKE_ART_ID(wxART_ERROR) -#define wxART_QUESTION wxART_MAKE_ART_ID(wxART_QUESTION) -#define wxART_WARNING wxART_MAKE_ART_ID(wxART_WARNING) -#define wxART_INFORMATION wxART_MAKE_ART_ID(wxART_INFORMATION) -#define wxART_MISSING_IMAGE wxART_MAKE_ART_ID(wxART_MISSING_IMAGE) - -#define wxART_COPY wxART_MAKE_ART_ID(wxART_COPY) -#define wxART_CUT wxART_MAKE_ART_ID(wxART_CUT) -#define wxART_PASTE wxART_MAKE_ART_ID(wxART_PASTE) -#define wxART_DELETE wxART_MAKE_ART_ID(wxART_DELETE) -#define wxART_NEW wxART_MAKE_ART_ID(wxART_NEW) - -#define wxART_UNDO wxART_MAKE_ART_ID(wxART_UNDO) -#define wxART_REDO wxART_MAKE_ART_ID(wxART_REDO) - -#define wxART_PLUS wxART_MAKE_ART_ID(wxART_PLUS) -#define wxART_MINUS wxART_MAKE_ART_ID(wxART_MINUS) - -#define wxART_CLOSE wxART_MAKE_ART_ID(wxART_CLOSE) -#define wxART_QUIT wxART_MAKE_ART_ID(wxART_QUIT) - -#define wxART_FIND wxART_MAKE_ART_ID(wxART_FIND) -#define wxART_FIND_AND_REPLACE wxART_MAKE_ART_ID(wxART_FIND_AND_REPLACE) - -#define wxART_FULL_SCREEN wxART_MAKE_ART_ID(wxART_FULL_SCREEN) - -#define wxART_EDIT wxART_MAKE_ART_ID(wxART_EDIT) +#include "wx/artids.h" +#undef wxART_MAKE_ART_ID +#undef wxART_MAKE_CLIENT_ID // ---------------------------------------------------------------------------- // wxArtProvider class diff --git a/interface/wx/artprov.h b/interface/wx/artprov.h index e8c848452f..477c59c37e 100644 --- a/interface/wx/artprov.h +++ b/interface/wx/artprov.h @@ -16,80 +16,80 @@ typedef wxString wxArtClient; typedef wxString wxArtID; -wxArtClient wxART_TOOLBAR; -wxArtClient wxART_MENU; -wxArtClient wxART_FRAME_ICON; +const wxArtClient wxART_TOOLBAR; +const wxArtClient wxART_MENU; +const wxArtClient wxART_FRAME_ICON; -wxArtClient wxART_CMN_DIALOG; -wxArtClient wxART_HELP_BROWSER; -wxArtClient wxART_MESSAGE_BOX; -wxArtClient wxART_BUTTON; -wxArtClient wxART_LIST; +const wxArtClient wxART_CMN_DIALOG; +const wxArtClient wxART_HELP_BROWSER; +const wxArtClient wxART_MESSAGE_BOX; +const wxArtClient wxART_BUTTON; +const wxArtClient wxART_LIST; -wxArtClient wxART_OTHER; +const wxArtClient wxART_OTHER; -wxArtID wxART_ADD_BOOKMARK; -wxArtID wxART_DEL_BOOKMARK; -wxArtID wxART_HELP_SIDE_PANEL; -wxArtID wxART_HELP_SETTINGS; -wxArtID wxART_HELP_BOOK; -wxArtID wxART_HELP_FOLDER; -wxArtID wxART_HELP_PAGE; -wxArtID wxART_GO_BACK; -wxArtID wxART_GO_FORWARD; -wxArtID wxART_GO_UP; -wxArtID wxART_GO_DOWN; -wxArtID wxART_GO_TO_PARENT; -wxArtID wxART_GO_HOME; -wxArtID wxART_GOTO_FIRST; -wxArtID wxART_GOTO_LAST; -wxArtID wxART_FILE_OPEN; -wxArtID wxART_FILE_SAVE; -wxArtID wxART_FILE_SAVE_AS; -wxArtID wxART_PRINT; -wxArtID wxART_HELP; -wxArtID wxART_TIP; -wxArtID wxART_REPORT_VIEW; -wxArtID wxART_LIST_VIEW; -wxArtID wxART_NEW_DIR; -wxArtID wxART_HARDDISK; -wxArtID wxART_FLOPPY; -wxArtID wxART_CDROM; -wxArtID wxART_REMOVABLE; -wxArtID wxART_FOLDER; -wxArtID wxART_FOLDER_OPEN; -wxArtID wxART_GO_DIR_UP; -wxArtID wxART_EXECUTABLE_FILE; -wxArtID wxART_NORMAL_FILE; -wxArtID wxART_TICK_MARK; -wxArtID wxART_CROSS_MARK; -wxArtID wxART_ERROR; -wxArtID wxART_QUESTION; -wxArtID wxART_WARNING; -wxArtID wxART_INFORMATION; -wxArtID wxART_MISSING_IMAGE; +const wxArtID wxART_ADD_BOOKMARK; +const wxArtID wxART_DEL_BOOKMARK; +const wxArtID wxART_HELP_SIDE_PANEL; +const wxArtID wxART_HELP_SETTINGS; +const wxArtID wxART_HELP_BOOK; +const wxArtID wxART_HELP_FOLDER; +const wxArtID wxART_HELP_PAGE; +const wxArtID wxART_GO_BACK; +const wxArtID wxART_GO_FORWARD; +const wxArtID wxART_GO_UP; +const wxArtID wxART_GO_DOWN; +const wxArtID wxART_GO_TO_PARENT; +const wxArtID wxART_GO_HOME; +const wxArtID wxART_GOTO_FIRST; +const wxArtID wxART_GOTO_LAST; +const wxArtID wxART_FILE_OPEN; +const wxArtID wxART_FILE_SAVE; +const wxArtID wxART_FILE_SAVE_AS; +const wxArtID wxART_PRINT; +const wxArtID wxART_HELP; +const wxArtID wxART_TIP; +const wxArtID wxART_REPORT_VIEW; +const wxArtID wxART_LIST_VIEW; +const wxArtID wxART_NEW_DIR; +const wxArtID wxART_HARDDISK; +const wxArtID wxART_FLOPPY; +const wxArtID wxART_CDROM; +const wxArtID wxART_REMOVABLE; +const wxArtID wxART_FOLDER; +const wxArtID wxART_FOLDER_OPEN; +const wxArtID wxART_GO_DIR_UP; +const wxArtID wxART_EXECUTABLE_FILE; +const wxArtID wxART_NORMAL_FILE; +const wxArtID wxART_TICK_MARK; +const wxArtID wxART_CROSS_MARK; +const wxArtID wxART_ERROR; +const wxArtID wxART_QUESTION; +const wxArtID wxART_WARNING; +const wxArtID wxART_INFORMATION; +const wxArtID wxART_MISSING_IMAGE; -wxArtID wxART_COPY; -wxArtID wxART_CUT; -wxArtID wxART_PASTE; -wxArtID wxART_DELETE; -wxArtID wxART_NEW; +const wxArtID wxART_COPY; +const wxArtID wxART_CUT; +const wxArtID wxART_PASTE; +const wxArtID wxART_DELETE; +const wxArtID wxART_NEW; -wxArtID wxART_UNDO; -wxArtID wxART_REDO; +const wxArtID wxART_UNDO; +const wxArtID wxART_REDO; -wxArtID wxART_PLUS; -wxArtID wxART_MINUS; +const wxArtID wxART_PLUS; +const wxArtID wxART_MINUS; -wxArtID wxART_CLOSE; -wxArtID wxART_QUIT; +const wxArtID wxART_CLOSE; +const wxArtID wxART_QUIT; -wxArtID wxART_FIND; -wxArtID wxART_FIND_AND_REPLACE; +const wxArtID wxART_FIND; +const wxArtID wxART_FIND_AND_REPLACE; -wxArtID wxART_FULL_SCREEN; -wxArtID wxART_EDIT; +const wxArtID wxART_FULL_SCREEN; +const wxArtID wxART_EDIT; /** diff --git a/src/common/artprov.cpp b/src/common/artprov.cpp index e7466eee26..7ef0aba6aa 100644 --- a/src/common/artprov.cpp +++ b/src/common/artprov.cpp @@ -21,6 +21,12 @@ #include "wx/artprov.h" +#define wxART_MAKE_CLIENT_ID(id) \ + extern WXDLLIMPEXP_DATA_CORE(const wxArtClient) id = wxASCII_STR(#id "_C"); +#define wxART_MAKE_ART_ID(id) \ + extern WXDLLIMPEXP_DATA_CORE(const wxArtID) id = wxASCII_STR(#id); +#include "wx/artids.h" + #ifndef WX_PRECOMP #include "wx/list.h" #include "wx/log.h" From 3f9531fe3184c3af4804a3d0a6e5c6106e7c2ba7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Br=C3=BCns?= Date: Thu, 6 Aug 2020 03:06:31 +0200 Subject: [PATCH 2/6] Use local static variable for ArtID mapping table The instantiation of the global static mapping table may happen before the instantiation of the wxArtIds, i.e. the copy-constructor would access not yet valid wxArtId/wxString instances. Delay the instantiation until the first call to wxArtIDToStock call. This is still not 100% safe, as wxArtIDToStock may be called by a constructor of a static instance, but hopefully nobody does that. --- src/gtk/artgtk.cpp | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/src/gtk/artgtk.cpp b/src/gtk/artgtk.cpp index c4ecdd8b1c..95346e914e 100644 --- a/src/gtk/artgtk.cpp +++ b/src/gtk/artgtk.cpp @@ -52,13 +52,22 @@ protected: namespace { +wxString wxArtIDToStock(const wxArtID& id) +{ + struct wxArtStockMapping + { + wxArtID artId; + wxString stockId; + }; + #ifdef __WXGTK3__ - #define ART(wxId, unused, themeId) wxId, themeId, + #define ART(wxId, unused, themeId) wxArtStockMapping{wxId, themeId}, #else - #define ART(wxId, stockId, unused) wxId, stockId, + #define ART(wxId, stockId, unused) wxArtStockMapping{wxId, stockId}, #endif -const wxString wxId2Gtk[] = { + static const wxArtStockMapping wxId2GtkMap[] = + { ART(wxART_ERROR, GTK_STOCK_DIALOG_ERROR, "dialog-error") ART(wxART_INFORMATION, GTK_STOCK_DIALOG_INFO, "dialog-information") ART(wxART_WARNING, GTK_STOCK_DIALOG_WARNING, "dialog-warning") @@ -122,26 +131,21 @@ const wxString wxId2Gtk[] = { ART(wxART_FIND_AND_REPLACE, GTK_STOCK_FIND_AND_REPLACE, "edit-find-replace") ART(wxART_FULL_SCREEN, GTK_STOCK_FULLSCREEN, "view-fullscreen") ART(wxART_EDIT, "accessories-text-editor", "accessories-text-editor") -}; - + }; #undef ART -wxString wxArtIDToStock(const wxArtID& id) -{ // allow passing GTK+ stock IDs to wxArtProvider -- if a recognized wx // ID wasn't found, pass it to GTK+ in the hope it is a GTK+ or theme // icon name: - wxString ret(id); - for (unsigned i = 0; i < WXSIZEOF(wxId2Gtk); i += 2) + for (unsigned i = 0; i < WXSIZEOF(wxId2GtkMap); i++) { - if (id == wxId2Gtk[i]) + if (id == wxId2GtkMap[i].artId) { - ret = wxId2Gtk[i + 1]; - break; + return wxId2GtkMap[i].stockId; } } - return ret; + return id; } GtkIconSize ArtClientToIconSize(const wxArtClient& client) From b6a369bd867af2175d29fbf11b66c0daf526f8ba Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 17 Aug 2020 01:58:45 +0200 Subject: [PATCH 3/6] Remove trailing blank line from the new wx/artids.h file No real changes. --- include/wx/artids.h | 1 - 1 file changed, 1 deletion(-) diff --git a/include/wx/artids.h b/include/wx/artids.h index 49afaefeea..9855cf4284 100644 --- a/include/wx/artids.h +++ b/include/wx/artids.h @@ -93,4 +93,3 @@ wxART_MAKE_ART_ID(wxART_FIND_AND_REPLACE) wxART_MAKE_ART_ID(wxART_FULL_SCREEN) wxART_MAKE_ART_ID(wxART_EDIT) - From 21b37aa88eea862e4125fc01b61a2450531748af Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 17 Aug 2020 02:01:11 +0200 Subject: [PATCH 4/6] Add ctor to wxArtStockMapping to fix C++98 build Can't use aggregate initialization without C++11. --- src/gtk/artgtk.cpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/gtk/artgtk.cpp b/src/gtk/artgtk.cpp index 95346e914e..ecaa9c1e48 100644 --- a/src/gtk/artgtk.cpp +++ b/src/gtk/artgtk.cpp @@ -56,14 +56,19 @@ wxString wxArtIDToStock(const wxArtID& id) { struct wxArtStockMapping { - wxArtID artId; - wxString stockId; + wxArtStockMapping(const wxArtID& artId, const wxString& stockId) + : m_artId(artId), m_stockId(stockId) + { + } + + wxArtID m_artId; + wxString m_stockId; }; #ifdef __WXGTK3__ - #define ART(wxId, unused, themeId) wxArtStockMapping{wxId, themeId}, + #define ART(wxId, unused, themeId) wxArtStockMapping(wxId, themeId), #else - #define ART(wxId, stockId, unused) wxArtStockMapping{wxId, stockId}, + #define ART(wxId, stockId, unused) wxArtStockMapping(wxId, stockId), #endif static const wxArtStockMapping wxId2GtkMap[] = @@ -140,9 +145,9 @@ wxString wxArtIDToStock(const wxArtID& id) for (unsigned i = 0; i < WXSIZEOF(wxId2GtkMap); i++) { - if (id == wxId2GtkMap[i].artId) + if (id == wxId2GtkMap[i].m_artId) { - return wxId2GtkMap[i].stockId; + return wxId2GtkMap[i].m_stockId; } } return id; From 8e1f2adc3b88259d1fcbb39a1ab1c851ca511def Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 17 Aug 2020 02:03:45 +0200 Subject: [PATCH 5/6] Add wx/artids.h to build/files and rerun upmake and bakefile Finish adding the new file, which was previously added manually to a couple of files, but not everywhere. --- build/files | 1 + build/msw/wx_core.vcxproj | 1 + build/msw/wx_core.vcxproj.filters | 3 +++ build/msw/wx_vc7_core.vcproj | 3 +++ build/msw/wx_vc8_core.vcproj | 4 ++++ build/msw/wx_vc9_core.vcproj | 4 ++++ 6 files changed, 16 insertions(+) diff --git a/build/files b/build/files index 759ab54db1..45114b2546 100644 --- a/build/files +++ b/build/files @@ -936,6 +936,7 @@ GUI_CMN_HDR = wx/animdecod.h wx/anybutton.h wx/appprogress.h + wx/artids.h wx/artprov.h wx/bannerwindow.h wx/bitmap.h diff --git a/build/msw/wx_core.vcxproj b/build/msw/wx_core.vcxproj index 8089f36d7b..aaf22c2c52 100644 --- a/build/msw/wx_core.vcxproj +++ b/build/msw/wx_core.vcxproj @@ -1502,6 +1502,7 @@ + diff --git a/build/msw/wx_core.vcxproj.filters b/build/msw/wx_core.vcxproj.filters index 83c265118a..56115e13ee 100644 --- a/build/msw/wx_core.vcxproj.filters +++ b/build/msw/wx_core.vcxproj.filters @@ -1108,6 +1108,9 @@ Common Headers + + Common Headers + Common Headers diff --git a/build/msw/wx_vc7_core.vcproj b/build/msw/wx_vc7_core.vcproj index ad378068ce..9c89c30fce 100644 --- a/build/msw/wx_vc7_core.vcproj +++ b/build/msw/wx_vc7_core.vcproj @@ -2081,6 +2081,9 @@ + + diff --git a/build/msw/wx_vc8_core.vcproj b/build/msw/wx_vc8_core.vcproj index e956ab6df8..5dc5a817f8 100644 --- a/build/msw/wx_vc8_core.vcproj +++ b/build/msw/wx_vc8_core.vcproj @@ -3276,6 +3276,10 @@ RelativePath="..\..\include\wx\ribbon\art_internal.h" > + + diff --git a/build/msw/wx_vc9_core.vcproj b/build/msw/wx_vc9_core.vcproj index a6d3ec7b1d..fe86df8893 100644 --- a/build/msw/wx_vc9_core.vcproj +++ b/build/msw/wx_vc9_core.vcproj @@ -3272,6 +3272,10 @@ RelativePath="..\..\include\wx\ribbon\art_internal.h" > + + From d5f5376e950d860b796890170664d0d20231c1f1 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 17 Aug 2020 02:04:59 +0200 Subject: [PATCH 6/6] Remove useless "Modified by:" header line This is not needed nor used since a long time any longer. --- include/wx/artids.h | 1 - 1 file changed, 1 deletion(-) diff --git a/include/wx/artids.h b/include/wx/artids.h index 9855cf4284..5d5db302c0 100644 --- a/include/wx/artids.h +++ b/include/wx/artids.h @@ -2,7 +2,6 @@ // Name: wx/artids.h // Purpose: wxArtProvider client and art IDs // Author: Stefan Brüns -// Modified by: // Created: 2020-07-31 (extracted from artprov.h) // Copyright: (c) Stefan Brüns // Licence: wxWindows licence