diff --git a/.gitmodules b/.gitmodules index cd26719f6e..eccca68800 100644 --- a/.gitmodules +++ b/.gitmodules @@ -26,3 +26,7 @@ path = 3rdparty/pcre url = https://github.com/wxWidgets/pcre branch = wx +[submodule "3rdparty/nanosvg"] + path = 3rdparty/nanosvg + url = https://github.com/wxWidgets/nanosvg + branch = wx diff --git a/3rdparty/nanosvg b/3rdparty/nanosvg new file mode 160000 index 0000000000..ccdb199513 --- /dev/null +++ b/3rdparty/nanosvg @@ -0,0 +1 @@ +Subproject commit ccdb1995134d340a93fb20e3a3d323ccb3838dd0 diff --git a/Makefile.in b/Makefile.in index 131adf1318..8efbd16eef 100644 --- a/Makefile.in +++ b/Makefile.in @@ -4051,6 +4051,7 @@ COND_USE_GUI_1_ALL_GUI_HEADERS = \ wx/propdlg.h \ wx/generic/creddlgg.h \ wx/creddlg.h \ + wx/bmpbndl.h \ $(LOWLEVEL_HDR) \ $(GUI_CORE_HEADERS) \ wx/mediactrl.h \ @@ -4712,7 +4713,9 @@ COND_USE_GUI_1_WXUNIV_0___CORE_SRC_OBJECTS = \ monodll_laywin.o \ monodll_calctrlg.o \ monodll_creddlgg.o \ - monodll_rowheightcache.o + monodll_rowheightcache.o \ + monodll_common_bmpbndl.o \ + monodll_bmpsvg.o @COND_USE_GUI_1_WXUNIV_0@__CORE_SRC_OBJECTS = $(COND_USE_GUI_1_WXUNIV_0___CORE_SRC_OBJECTS) COND_USE_GUI_1_WXUNIV_1___CORE_SRC_OBJECTS = \ $(__LOWLEVEL_SRC_OBJECTS_1) \ @@ -4974,7 +4977,9 @@ COND_USE_GUI_1_WXUNIV_1___CORE_SRC_OBJECTS = \ monodll_laywin.o \ monodll_calctrlg.o \ monodll_creddlgg.o \ - monodll_rowheightcache.o + monodll_rowheightcache.o \ + monodll_common_bmpbndl.o \ + monodll_bmpsvg.o @COND_USE_GUI_1_WXUNIV_1@__CORE_SRC_OBJECTS = $(COND_USE_GUI_1_WXUNIV_1___CORE_SRC_OBJECTS) COND_TOOLKIT_DFB___LOWLEVEL_SRC_OBJECTS = \ monodll_fontmgrcmn.o \ @@ -5257,7 +5262,8 @@ COND_TOOLKIT_MSW___LOWLEVEL_SRC_OBJECTS = \ monodll_notifmsgrt.o \ monodll_uuid.o \ monodll_msw_evtloop.o \ - monodll_access.o + monodll_access.o \ + monodll_msw_bmpbndl.o @COND_TOOLKIT_MSW@__LOWLEVEL_SRC_OBJECTS = $(COND_TOOLKIT_MSW___LOWLEVEL_SRC_OBJECTS) @COND_TOOLKIT_OSX_COCOA@__LOWLEVEL_SRC_OBJECTS = \ @COND_TOOLKIT_OSX_COCOA@ $(__OSX_LOWLEVEL_SRC_OBJECTS) @@ -6164,7 +6170,8 @@ COND_TOOLKIT_MSW___LOWLEVEL_SRC_OBJECTS_1 = \ monodll_notifmsgrt.o \ monodll_uuid.o \ monodll_msw_evtloop.o \ - monodll_access.o + monodll_access.o \ + monodll_msw_bmpbndl.o @COND_TOOLKIT_MSW@__LOWLEVEL_SRC_OBJECTS_1 = $(COND_TOOLKIT_MSW___LOWLEVEL_SRC_OBJECTS_1) @COND_TOOLKIT_OSX_COCOA@__LOWLEVEL_SRC_OBJECTS_1 = \ @COND_TOOLKIT_OSX_COCOA@ $(__OSX_LOWLEVEL_SRC_OBJECTS) @@ -6709,7 +6716,9 @@ COND_USE_GUI_1_WXUNIV_0___CORE_SRC_OBJECTS_1 = \ monolib_laywin.o \ monolib_calctrlg.o \ monolib_creddlgg.o \ - monolib_rowheightcache.o + monolib_rowheightcache.o \ + monolib_common_bmpbndl.o \ + monolib_bmpsvg.o @COND_USE_GUI_1_WXUNIV_0@__CORE_SRC_OBJECTS_1 = $(COND_USE_GUI_1_WXUNIV_0___CORE_SRC_OBJECTS_1) COND_USE_GUI_1_WXUNIV_1___CORE_SRC_OBJECTS_1 = \ $(__LOWLEVEL_SRC_OBJECTS_3) \ @@ -6971,7 +6980,9 @@ COND_USE_GUI_1_WXUNIV_1___CORE_SRC_OBJECTS_1 = \ monolib_laywin.o \ monolib_calctrlg.o \ monolib_creddlgg.o \ - monolib_rowheightcache.o + monolib_rowheightcache.o \ + monolib_common_bmpbndl.o \ + monolib_bmpsvg.o @COND_USE_GUI_1_WXUNIV_1@__CORE_SRC_OBJECTS_1 = $(COND_USE_GUI_1_WXUNIV_1___CORE_SRC_OBJECTS_1) COND_TOOLKIT_DFB___LOWLEVEL_SRC_OBJECTS_2 = \ monolib_fontmgrcmn.o \ @@ -7254,7 +7265,8 @@ COND_TOOLKIT_MSW___LOWLEVEL_SRC_OBJECTS_2 = \ monolib_notifmsgrt.o \ monolib_uuid.o \ monolib_msw_evtloop.o \ - monolib_access.o + monolib_access.o \ + monolib_msw_bmpbndl.o @COND_TOOLKIT_MSW@__LOWLEVEL_SRC_OBJECTS_2 = $(COND_TOOLKIT_MSW___LOWLEVEL_SRC_OBJECTS_2) @COND_TOOLKIT_OSX_COCOA@__LOWLEVEL_SRC_OBJECTS_2 = \ @COND_TOOLKIT_OSX_COCOA@ $(__OSX_LOWLEVEL_SRC_OBJECTS_17) @@ -8161,7 +8173,8 @@ COND_TOOLKIT_MSW___LOWLEVEL_SRC_OBJECTS_3 = \ monolib_notifmsgrt.o \ monolib_uuid.o \ monolib_msw_evtloop.o \ - monolib_access.o + monolib_access.o \ + monolib_msw_bmpbndl.o @COND_TOOLKIT_MSW@__LOWLEVEL_SRC_OBJECTS_3 = $(COND_TOOLKIT_MSW___LOWLEVEL_SRC_OBJECTS_3) @COND_TOOLKIT_OSX_COCOA@__LOWLEVEL_SRC_OBJECTS_3 = \ @COND_TOOLKIT_OSX_COCOA@ $(__OSX_LOWLEVEL_SRC_OBJECTS_17) @@ -8859,7 +8872,9 @@ COND_USE_GUI_1_WXUNIV_0___CORE_SRC_OBJECTS_2 = \ coredll_laywin.o \ coredll_calctrlg.o \ coredll_creddlgg.o \ - coredll_rowheightcache.o + coredll_rowheightcache.o \ + coredll_common_bmpbndl.o \ + coredll_bmpsvg.o @COND_USE_GUI_1_WXUNIV_0@__CORE_SRC_OBJECTS_2 = $(COND_USE_GUI_1_WXUNIV_0___CORE_SRC_OBJECTS_2) COND_USE_GUI_1_WXUNIV_1___CORE_SRC_OBJECTS_2 = \ $(__LOWLEVEL_SRC_OBJECTS_5) \ @@ -9121,7 +9136,9 @@ COND_USE_GUI_1_WXUNIV_1___CORE_SRC_OBJECTS_2 = \ coredll_laywin.o \ coredll_calctrlg.o \ coredll_creddlgg.o \ - coredll_rowheightcache.o + coredll_rowheightcache.o \ + coredll_common_bmpbndl.o \ + coredll_bmpsvg.o @COND_USE_GUI_1_WXUNIV_1@__CORE_SRC_OBJECTS_2 = $(COND_USE_GUI_1_WXUNIV_1___CORE_SRC_OBJECTS_2) COND_TOOLKIT_DFB___LOWLEVEL_SRC_OBJECTS_4 = \ coredll_fontmgrcmn.o \ @@ -9404,7 +9421,8 @@ COND_TOOLKIT_MSW___LOWLEVEL_SRC_OBJECTS_4 = \ coredll_notifmsgrt.o \ coredll_uuid.o \ coredll_msw_evtloop.o \ - coredll_access.o + coredll_access.o \ + coredll_msw_bmpbndl.o @COND_TOOLKIT_MSW@__LOWLEVEL_SRC_OBJECTS_4 = $(COND_TOOLKIT_MSW___LOWLEVEL_SRC_OBJECTS_4) @COND_TOOLKIT_OSX_COCOA@__LOWLEVEL_SRC_OBJECTS_4 = \ @COND_TOOLKIT_OSX_COCOA@ $(__OSX_LOWLEVEL_SRC_OBJECTS_1_1) @@ -10311,7 +10329,8 @@ COND_TOOLKIT_MSW___LOWLEVEL_SRC_OBJECTS_5 = \ coredll_notifmsgrt.o \ coredll_uuid.o \ coredll_msw_evtloop.o \ - coredll_access.o + coredll_access.o \ + coredll_msw_bmpbndl.o @COND_TOOLKIT_MSW@__LOWLEVEL_SRC_OBJECTS_5 = $(COND_TOOLKIT_MSW___LOWLEVEL_SRC_OBJECTS_5) @COND_TOOLKIT_OSX_COCOA@__LOWLEVEL_SRC_OBJECTS_5 = \ @COND_TOOLKIT_OSX_COCOA@ $(__OSX_LOWLEVEL_SRC_OBJECTS_1_1) @@ -10584,7 +10603,9 @@ COND_USE_GUI_1_WXUNIV_0___CORE_SRC_OBJECTS_3 = \ corelib_laywin.o \ corelib_calctrlg.o \ corelib_creddlgg.o \ - corelib_rowheightcache.o + corelib_rowheightcache.o \ + corelib_common_bmpbndl.o \ + corelib_bmpsvg.o @COND_USE_GUI_1_WXUNIV_0@__CORE_SRC_OBJECTS_3 = $(COND_USE_GUI_1_WXUNIV_0___CORE_SRC_OBJECTS_3) COND_USE_GUI_1_WXUNIV_1___CORE_SRC_OBJECTS_3 = \ $(__LOWLEVEL_SRC_OBJECTS_7) \ @@ -10846,7 +10867,9 @@ COND_USE_GUI_1_WXUNIV_1___CORE_SRC_OBJECTS_3 = \ corelib_laywin.o \ corelib_calctrlg.o \ corelib_creddlgg.o \ - corelib_rowheightcache.o + corelib_rowheightcache.o \ + corelib_common_bmpbndl.o \ + corelib_bmpsvg.o @COND_USE_GUI_1_WXUNIV_1@__CORE_SRC_OBJECTS_3 = $(COND_USE_GUI_1_WXUNIV_1___CORE_SRC_OBJECTS_3) COND_TOOLKIT_DFB___LOWLEVEL_SRC_OBJECTS_6 = \ corelib_fontmgrcmn.o \ @@ -11129,7 +11152,8 @@ COND_TOOLKIT_MSW___LOWLEVEL_SRC_OBJECTS_6 = \ corelib_notifmsgrt.o \ corelib_uuid.o \ corelib_msw_evtloop.o \ - corelib_access.o + corelib_access.o \ + corelib_msw_bmpbndl.o @COND_TOOLKIT_MSW@__LOWLEVEL_SRC_OBJECTS_6 = $(COND_TOOLKIT_MSW___LOWLEVEL_SRC_OBJECTS_6) @COND_TOOLKIT_OSX_COCOA@__LOWLEVEL_SRC_OBJECTS_6 = \ @COND_TOOLKIT_OSX_COCOA@ $(__OSX_LOWLEVEL_SRC_OBJECTS_1_4) @@ -12036,7 +12060,8 @@ COND_TOOLKIT_MSW___LOWLEVEL_SRC_OBJECTS_7 = \ corelib_notifmsgrt.o \ corelib_uuid.o \ corelib_msw_evtloop.o \ - corelib_access.o + corelib_access.o \ + corelib_msw_bmpbndl.o @COND_TOOLKIT_MSW@__LOWLEVEL_SRC_OBJECTS_7 = $(COND_TOOLKIT_MSW___LOWLEVEL_SRC_OBJECTS_7) @COND_TOOLKIT_OSX_COCOA@__LOWLEVEL_SRC_OBJECTS_7 = \ @COND_TOOLKIT_OSX_COCOA@ $(__OSX_LOWLEVEL_SRC_OBJECTS_1_4) @@ -13452,7 +13477,8 @@ COND_PLATFORM_MACOSX_1___OSX_LOWLEVEL_SRC_OBJECTS = \ monodll_hid.o \ monodll_printmac.o \ monodll_core_timer.o \ - monodll_utilsexc_cf.o + monodll_utilsexc_cf.o \ + monodll_core_bmpbndl.o @COND_PLATFORM_MACOSX_1@__OSX_LOWLEVEL_SRC_OBJECTS = $(COND_PLATFORM_MACOSX_1___OSX_LOWLEVEL_SRC_OBJECTS) @COND_PLATFORM_MACOSX_1@__PLATFORM_SRC_OBJECTS_0 = monolib_unix_apptraits.o @COND_PLATFORM_UNIX_1@__PLATFORM_SRC_OBJECTS_0 = monolib_unix_apptraits.o @@ -13589,7 +13615,8 @@ COND_PLATFORM_MACOSX_1___OSX_LOWLEVEL_SRC_OBJECTS_17 = \ monolib_hid.o \ monolib_printmac.o \ monolib_core_timer.o \ - monolib_utilsexc_cf.o + monolib_utilsexc_cf.o \ + monolib_core_bmpbndl.o @COND_PLATFORM_MACOSX_1@__OSX_LOWLEVEL_SRC_OBJECTS_17 = $(COND_PLATFORM_MACOSX_1___OSX_LOWLEVEL_SRC_OBJECTS_17) @COND_PLATFORM_MACOSX_1@__PLATFORM_SRC_OBJECTS_8 = coredll_unix_apptraits.o @COND_PLATFORM_UNIX_1@__PLATFORM_SRC_OBJECTS_8 = coredll_unix_apptraits.o @@ -13726,7 +13753,8 @@ COND_PLATFORM_MACOSX_1___OSX_LOWLEVEL_SRC_OBJECTS_1_1 = \ coredll_hid.o \ coredll_printmac.o \ coredll_core_timer.o \ - coredll_utilsexc_cf.o + coredll_utilsexc_cf.o \ + coredll_core_bmpbndl.o @COND_PLATFORM_MACOSX_1@__OSX_LOWLEVEL_SRC_OBJECTS_1_1 = $(COND_PLATFORM_MACOSX_1___OSX_LOWLEVEL_SRC_OBJECTS_1_1) @COND_PLATFORM_MACOSX_1@__PLATFORM_SRC_OBJECTS_9 = corelib_unix_apptraits.o @COND_PLATFORM_UNIX_1@__PLATFORM_SRC_OBJECTS_9 = corelib_unix_apptraits.o @@ -13863,7 +13891,8 @@ COND_PLATFORM_MACOSX_1___OSX_LOWLEVEL_SRC_OBJECTS_1_4 = \ corelib_hid.o \ corelib_printmac.o \ corelib_core_timer.o \ - corelib_utilsexc_cf.o + corelib_utilsexc_cf.o \ + corelib_core_bmpbndl.o @COND_PLATFORM_MACOSX_1@__OSX_LOWLEVEL_SRC_OBJECTS_1_4 = $(COND_PLATFORM_MACOSX_1___OSX_LOWLEVEL_SRC_OBJECTS_1_4) @COND_TOOLKIT_MSW@__webview_additional_include_wrl_p = \ @COND_TOOLKIT_MSW@ -I$(top_srcdir)/include/wx/msw/wrl @@ -19033,6 +19062,9 @@ monodll_sound_sdl.o: $(srcdir)/src/unix/sound_sdl.cpp $(MONODLL_ODEP) @COND_TOOLKIT_MSW_USE_GUI_1@monodll_access.o: $(srcdir)/src/msw/ole/access.cpp $(MONODLL_ODEP) @COND_TOOLKIT_MSW_USE_GUI_1@ $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/msw/ole/access.cpp +@COND_TOOLKIT_MSW_USE_GUI_1@monodll_msw_bmpbndl.o: $(srcdir)/src/msw/bmpbndl.cpp $(MONODLL_ODEP) +@COND_TOOLKIT_MSW_USE_GUI_1@ $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/msw/bmpbndl.cpp + @COND_PLATFORM_MACOSX_1_TOOLKIT_OSX_COCOA_USE_GUI_1@monodll_artmac.o: $(srcdir)/src/osx/artmac.cpp $(MONODLL_ODEP) @COND_PLATFORM_MACOSX_1_TOOLKIT_OSX_COCOA_USE_GUI_1@ $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/osx/artmac.cpp @@ -19153,6 +19185,12 @@ monodll_sound_sdl.o: $(srcdir)/src/unix/sound_sdl.cpp $(MONODLL_ODEP) @COND_PLATFORM_MACOSX_1_TOOLKIT_OSX_IPHONE_USE_GUI_1@monodll_utilsexc_cf.o: $(srcdir)/src/osx/core/utilsexc_cf.cpp $(MONODLL_ODEP) @COND_PLATFORM_MACOSX_1_TOOLKIT_OSX_IPHONE_USE_GUI_1@ $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/osx/core/utilsexc_cf.cpp +@COND_PLATFORM_MACOSX_1_TOOLKIT_OSX_COCOA_USE_GUI_1@monodll_core_bmpbndl.o: $(srcdir)/src/osx/core/bmpbndl.mm $(MONODLL_ODEP) +@COND_PLATFORM_MACOSX_1_TOOLKIT_OSX_COCOA_USE_GUI_1@ $(CXXC) -c -o $@ $(MONODLL_OBJCXXFLAGS) $(srcdir)/src/osx/core/bmpbndl.mm + +@COND_PLATFORM_MACOSX_1_TOOLKIT_OSX_IPHONE_USE_GUI_1@monodll_core_bmpbndl.o: $(srcdir)/src/osx/core/bmpbndl.mm $(MONODLL_ODEP) +@COND_PLATFORM_MACOSX_1_TOOLKIT_OSX_IPHONE_USE_GUI_1@ $(CXXC) -c -o $@ $(MONODLL_OBJCXXFLAGS) $(srcdir)/src/osx/core/bmpbndl.mm + @COND_TOOLKIT_X11_USE_GUI_1@monodll_generic_timer.o: $(srcdir)/src/generic/timer.cpp $(MONODLL_ODEP) @COND_TOOLKIT_X11_USE_GUI_1@ $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/generic/timer.cpp @@ -21022,6 +21060,12 @@ monodll_sound_sdl.o: $(srcdir)/src/unix/sound_sdl.cpp $(MONODLL_ODEP) @COND_USE_GUI_1@monodll_rowheightcache.o: $(srcdir)/src/generic/rowheightcache.cpp $(MONODLL_ODEP) @COND_USE_GUI_1@ $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/generic/rowheightcache.cpp +@COND_USE_GUI_1@monodll_common_bmpbndl.o: $(srcdir)/src/common/bmpbndl.cpp $(MONODLL_ODEP) +@COND_USE_GUI_1@ $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/common/bmpbndl.cpp + +@COND_USE_GUI_1@monodll_bmpsvg.o: $(srcdir)/src/generic/bmpsvg.cpp $(MONODLL_ODEP) +@COND_USE_GUI_1@ $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/generic/bmpsvg.cpp + @COND_TOOLKIT_OSX_COCOA_USE_GUI_1@monodll_osx_cocoa_mediactrl.o: $(srcdir)/src/osx/cocoa/mediactrl.mm $(MONODLL_ODEP) @COND_TOOLKIT_OSX_COCOA_USE_GUI_1@ $(CXXC) -c -o $@ $(MONODLL_OBJCXXFLAGS) $(srcdir)/src/osx/cocoa/mediactrl.mm @@ -24325,6 +24369,9 @@ monolib_sound_sdl.o: $(srcdir)/src/unix/sound_sdl.cpp $(MONOLIB_ODEP) @COND_TOOLKIT_MSW_USE_GUI_1@monolib_access.o: $(srcdir)/src/msw/ole/access.cpp $(MONOLIB_ODEP) @COND_TOOLKIT_MSW_USE_GUI_1@ $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/msw/ole/access.cpp +@COND_TOOLKIT_MSW_USE_GUI_1@monolib_msw_bmpbndl.o: $(srcdir)/src/msw/bmpbndl.cpp $(MONOLIB_ODEP) +@COND_TOOLKIT_MSW_USE_GUI_1@ $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/msw/bmpbndl.cpp + @COND_PLATFORM_MACOSX_1_TOOLKIT_OSX_COCOA_USE_GUI_1@monolib_artmac.o: $(srcdir)/src/osx/artmac.cpp $(MONOLIB_ODEP) @COND_PLATFORM_MACOSX_1_TOOLKIT_OSX_COCOA_USE_GUI_1@ $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/osx/artmac.cpp @@ -24445,6 +24492,12 @@ monolib_sound_sdl.o: $(srcdir)/src/unix/sound_sdl.cpp $(MONOLIB_ODEP) @COND_PLATFORM_MACOSX_1_TOOLKIT_OSX_IPHONE_USE_GUI_1@monolib_utilsexc_cf.o: $(srcdir)/src/osx/core/utilsexc_cf.cpp $(MONOLIB_ODEP) @COND_PLATFORM_MACOSX_1_TOOLKIT_OSX_IPHONE_USE_GUI_1@ $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/osx/core/utilsexc_cf.cpp +@COND_PLATFORM_MACOSX_1_TOOLKIT_OSX_COCOA_USE_GUI_1@monolib_core_bmpbndl.o: $(srcdir)/src/osx/core/bmpbndl.mm $(MONOLIB_ODEP) +@COND_PLATFORM_MACOSX_1_TOOLKIT_OSX_COCOA_USE_GUI_1@ $(CXXC) -c -o $@ $(MONOLIB_OBJCXXFLAGS) $(srcdir)/src/osx/core/bmpbndl.mm + +@COND_PLATFORM_MACOSX_1_TOOLKIT_OSX_IPHONE_USE_GUI_1@monolib_core_bmpbndl.o: $(srcdir)/src/osx/core/bmpbndl.mm $(MONOLIB_ODEP) +@COND_PLATFORM_MACOSX_1_TOOLKIT_OSX_IPHONE_USE_GUI_1@ $(CXXC) -c -o $@ $(MONOLIB_OBJCXXFLAGS) $(srcdir)/src/osx/core/bmpbndl.mm + @COND_TOOLKIT_X11_USE_GUI_1@monolib_generic_timer.o: $(srcdir)/src/generic/timer.cpp $(MONOLIB_ODEP) @COND_TOOLKIT_X11_USE_GUI_1@ $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/generic/timer.cpp @@ -26314,6 +26367,12 @@ monolib_sound_sdl.o: $(srcdir)/src/unix/sound_sdl.cpp $(MONOLIB_ODEP) @COND_USE_GUI_1@monolib_rowheightcache.o: $(srcdir)/src/generic/rowheightcache.cpp $(MONOLIB_ODEP) @COND_USE_GUI_1@ $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/generic/rowheightcache.cpp +@COND_USE_GUI_1@monolib_common_bmpbndl.o: $(srcdir)/src/common/bmpbndl.cpp $(MONOLIB_ODEP) +@COND_USE_GUI_1@ $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/common/bmpbndl.cpp + +@COND_USE_GUI_1@monolib_bmpsvg.o: $(srcdir)/src/generic/bmpsvg.cpp $(MONOLIB_ODEP) +@COND_USE_GUI_1@ $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/generic/bmpsvg.cpp + @COND_TOOLKIT_OSX_COCOA_USE_GUI_1@monolib_osx_cocoa_mediactrl.o: $(srcdir)/src/osx/cocoa/mediactrl.mm $(MONOLIB_ODEP) @COND_TOOLKIT_OSX_COCOA_USE_GUI_1@ $(CXXC) -c -o $@ $(MONOLIB_OBJCXXFLAGS) $(srcdir)/src/osx/cocoa/mediactrl.mm @@ -29719,6 +29778,9 @@ coredll_sound_sdl.o: $(srcdir)/src/unix/sound_sdl.cpp $(COREDLL_ODEP) @COND_TOOLKIT_MSW_USE_GUI_1@coredll_access.o: $(srcdir)/src/msw/ole/access.cpp $(COREDLL_ODEP) @COND_TOOLKIT_MSW_USE_GUI_1@ $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $(srcdir)/src/msw/ole/access.cpp +@COND_TOOLKIT_MSW_USE_GUI_1@coredll_msw_bmpbndl.o: $(srcdir)/src/msw/bmpbndl.cpp $(COREDLL_ODEP) +@COND_TOOLKIT_MSW_USE_GUI_1@ $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $(srcdir)/src/msw/bmpbndl.cpp + @COND_PLATFORM_MACOSX_1_TOOLKIT_OSX_COCOA_USE_GUI_1@coredll_artmac.o: $(srcdir)/src/osx/artmac.cpp $(COREDLL_ODEP) @COND_PLATFORM_MACOSX_1_TOOLKIT_OSX_COCOA_USE_GUI_1@ $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $(srcdir)/src/osx/artmac.cpp @@ -29839,6 +29901,12 @@ coredll_sound_sdl.o: $(srcdir)/src/unix/sound_sdl.cpp $(COREDLL_ODEP) @COND_PLATFORM_MACOSX_1_TOOLKIT_OSX_IPHONE_USE_GUI_1@coredll_utilsexc_cf.o: $(srcdir)/src/osx/core/utilsexc_cf.cpp $(COREDLL_ODEP) @COND_PLATFORM_MACOSX_1_TOOLKIT_OSX_IPHONE_USE_GUI_1@ $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $(srcdir)/src/osx/core/utilsexc_cf.cpp +@COND_PLATFORM_MACOSX_1_TOOLKIT_OSX_COCOA_USE_GUI_1@coredll_core_bmpbndl.o: $(srcdir)/src/osx/core/bmpbndl.mm $(COREDLL_ODEP) +@COND_PLATFORM_MACOSX_1_TOOLKIT_OSX_COCOA_USE_GUI_1@ $(CXXC) -c -o $@ $(COREDLL_OBJCXXFLAGS) $(srcdir)/src/osx/core/bmpbndl.mm + +@COND_PLATFORM_MACOSX_1_TOOLKIT_OSX_IPHONE_USE_GUI_1@coredll_core_bmpbndl.o: $(srcdir)/src/osx/core/bmpbndl.mm $(COREDLL_ODEP) +@COND_PLATFORM_MACOSX_1_TOOLKIT_OSX_IPHONE_USE_GUI_1@ $(CXXC) -c -o $@ $(COREDLL_OBJCXXFLAGS) $(srcdir)/src/osx/core/bmpbndl.mm + @COND_TOOLKIT_X11_USE_GUI_1@coredll_generic_timer.o: $(srcdir)/src/generic/timer.cpp $(COREDLL_ODEP) @COND_TOOLKIT_X11_USE_GUI_1@ $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $(srcdir)/src/generic/timer.cpp @@ -31708,6 +31776,12 @@ coredll_sound_sdl.o: $(srcdir)/src/unix/sound_sdl.cpp $(COREDLL_ODEP) @COND_USE_GUI_1@coredll_rowheightcache.o: $(srcdir)/src/generic/rowheightcache.cpp $(COREDLL_ODEP) @COND_USE_GUI_1@ $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $(srcdir)/src/generic/rowheightcache.cpp +@COND_USE_GUI_1@coredll_common_bmpbndl.o: $(srcdir)/src/common/bmpbndl.cpp $(COREDLL_ODEP) +@COND_USE_GUI_1@ $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $(srcdir)/src/common/bmpbndl.cpp + +@COND_USE_GUI_1@coredll_bmpsvg.o: $(srcdir)/src/generic/bmpsvg.cpp $(COREDLL_ODEP) +@COND_USE_GUI_1@ $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $(srcdir)/src/generic/bmpsvg.cpp + corelib_event.o: $(srcdir)/src/common/event.cpp $(CORELIB_ODEP) $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $(srcdir)/src/common/event.cpp @@ -33973,6 +34047,9 @@ corelib_sound_sdl.o: $(srcdir)/src/unix/sound_sdl.cpp $(CORELIB_ODEP) @COND_TOOLKIT_MSW_USE_GUI_1@corelib_access.o: $(srcdir)/src/msw/ole/access.cpp $(CORELIB_ODEP) @COND_TOOLKIT_MSW_USE_GUI_1@ $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $(srcdir)/src/msw/ole/access.cpp +@COND_TOOLKIT_MSW_USE_GUI_1@corelib_msw_bmpbndl.o: $(srcdir)/src/msw/bmpbndl.cpp $(CORELIB_ODEP) +@COND_TOOLKIT_MSW_USE_GUI_1@ $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $(srcdir)/src/msw/bmpbndl.cpp + @COND_PLATFORM_MACOSX_1_TOOLKIT_OSX_COCOA_USE_GUI_1@corelib_artmac.o: $(srcdir)/src/osx/artmac.cpp $(CORELIB_ODEP) @COND_PLATFORM_MACOSX_1_TOOLKIT_OSX_COCOA_USE_GUI_1@ $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $(srcdir)/src/osx/artmac.cpp @@ -34093,6 +34170,12 @@ corelib_sound_sdl.o: $(srcdir)/src/unix/sound_sdl.cpp $(CORELIB_ODEP) @COND_PLATFORM_MACOSX_1_TOOLKIT_OSX_IPHONE_USE_GUI_1@corelib_utilsexc_cf.o: $(srcdir)/src/osx/core/utilsexc_cf.cpp $(CORELIB_ODEP) @COND_PLATFORM_MACOSX_1_TOOLKIT_OSX_IPHONE_USE_GUI_1@ $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $(srcdir)/src/osx/core/utilsexc_cf.cpp +@COND_PLATFORM_MACOSX_1_TOOLKIT_OSX_COCOA_USE_GUI_1@corelib_core_bmpbndl.o: $(srcdir)/src/osx/core/bmpbndl.mm $(CORELIB_ODEP) +@COND_PLATFORM_MACOSX_1_TOOLKIT_OSX_COCOA_USE_GUI_1@ $(CXXC) -c -o $@ $(CORELIB_OBJCXXFLAGS) $(srcdir)/src/osx/core/bmpbndl.mm + +@COND_PLATFORM_MACOSX_1_TOOLKIT_OSX_IPHONE_USE_GUI_1@corelib_core_bmpbndl.o: $(srcdir)/src/osx/core/bmpbndl.mm $(CORELIB_ODEP) +@COND_PLATFORM_MACOSX_1_TOOLKIT_OSX_IPHONE_USE_GUI_1@ $(CXXC) -c -o $@ $(CORELIB_OBJCXXFLAGS) $(srcdir)/src/osx/core/bmpbndl.mm + @COND_TOOLKIT_X11_USE_GUI_1@corelib_generic_timer.o: $(srcdir)/src/generic/timer.cpp $(CORELIB_ODEP) @COND_TOOLKIT_X11_USE_GUI_1@ $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $(srcdir)/src/generic/timer.cpp @@ -35962,6 +36045,12 @@ corelib_sound_sdl.o: $(srcdir)/src/unix/sound_sdl.cpp $(CORELIB_ODEP) @COND_USE_GUI_1@corelib_rowheightcache.o: $(srcdir)/src/generic/rowheightcache.cpp $(CORELIB_ODEP) @COND_USE_GUI_1@ $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $(srcdir)/src/generic/rowheightcache.cpp +@COND_USE_GUI_1@corelib_common_bmpbndl.o: $(srcdir)/src/common/bmpbndl.cpp $(CORELIB_ODEP) +@COND_USE_GUI_1@ $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $(srcdir)/src/common/bmpbndl.cpp + +@COND_USE_GUI_1@corelib_bmpsvg.o: $(srcdir)/src/generic/bmpsvg.cpp $(CORELIB_ODEP) +@COND_USE_GUI_1@ $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $(srcdir)/src/generic/bmpsvg.cpp + advdll_version_rc.o: $(srcdir)/src/msw/version.rc $(ADVDLL_ODEP) $(WINDRES) -i$< -o$@ $(__INC_TIFF_BUILD_p_54) $(__INC_TIFF_p_54) $(__INC_JPEG_p_54) $(__INC_PNG_p_53) $(__INC_ZLIB_p_67) $(__INC_REGEX_p_65) $(__INC_EXPAT_p_65) --define __WX$(TOOLKIT)__ $(__WXUNIV_DEFINE_p_66) $(__DEBUG_DEFINE_p_66) $(__EXCEPTIONS_DEFINE_p_65) $(__RTTI_DEFINE_p_65) $(__THREAD_DEFINE_p_65) --define WXBUILDING --define WXDLLNAME=$(WXDLLNAMEPREFIXGUI)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_adv$(WXCOMPILER)$(VENDORTAG)$(WXDLLVERSIONTAG) $(__RCDEFDIR_p) --include-dir $(top_srcdir)/include --define WXUSINGDLL --define WXMAKINGDLL_ADV diff --git a/build/bakefiles/files.bkl b/build/bakefiles/files.bkl index 07dc81feaf..7abc8b4024 100644 --- a/build/bakefiles/files.bkl +++ b/build/bakefiles/files.bkl @@ -1015,6 +1015,8 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file! src/generic/calctrlg.cpp src/generic/creddlgg.cpp src/generic/rowheightcache.cpp + src/common/bmpbndl.cpp + src/generic/bmpsvg.cpp wx/affinematrix2dbase.h @@ -1306,6 +1308,7 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file! wx/propdlg.h wx/generic/creddlgg.h wx/creddlg.h + wx/bmpbndl.h @@ -2087,6 +2090,7 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file! src/msw/ole/uuid.cpp src/msw/evtloop.cpp src/msw/ole/access.cpp + src/msw/bmpbndl.cpp wx/msw/nonownedwnd.h @@ -2420,6 +2424,7 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file! src/osx/core/printmac.cpp src/osx/core/timer.cpp src/osx/core/utilsexc_cf.cpp + src/osx/core/bmpbndl.mm diff --git a/build/cmake/files.cmake b/build/cmake/files.cmake index 303cc22a0d..c1fdf4f2ee 100644 --- a/build/cmake/files.cmake +++ b/build/cmake/files.cmake @@ -918,6 +918,8 @@ set(GUI_CMN_SRC src/generic/creddlgg.cpp src/generic/rowheightcache.cpp src/generic/animateg.cpp + src/common/bmpbndl.cpp + src/generic/bmpsvg.cpp ) set(GUI_CMN_HDR @@ -1209,6 +1211,7 @@ set(GUI_CMN_HDR wx/creddlg.h wx/generic/creddlgg.h wx/generic/animate.h + wx/bmpbndl.h ) set(UNIX_SRC @@ -1961,6 +1964,7 @@ set(MSW_LOWLEVEL_SRC src/msw/richtooltip.cpp src/msw/evtloop.cpp src/msw/ole/access.cpp + src/msw/bmpbndl.cpp ) set(MSW_LOWLEVEL_HDR @@ -2298,6 +2302,7 @@ set(OSX_LOWLEVEL_SRC src/osx/core/timer.cpp src/osx/core/utilsexc_cf.cpp #TODO: + src/osx/core/bmpbndl.mm ) set(OSX_LOWLEVEL_HDR diff --git a/build/files b/build/files index 7b6c96225f..6e91285cdb 100644 --- a/build/files +++ b/build/files @@ -741,6 +741,7 @@ GUI_CMN_SRC = src/common/artstd.cpp src/common/arttango.cpp src/common/bmpbase.cpp + src/common/bmpbndl.cpp src/common/bmpbtncmn.cpp src/common/bmpcboxcmn.cpp src/common/bookctrl.cpp @@ -871,6 +872,7 @@ GUI_CMN_SRC = src/generic/animateg.cpp src/generic/bannerwindow.cpp src/generic/bmpcboxg.cpp + src/generic/bmpsvg.cpp src/generic/busyinfo.cpp src/generic/buttonbar.cpp src/generic/calctrlg.cpp @@ -950,6 +952,7 @@ GUI_CMN_HDR = wx/artprov.h wx/bannerwindow.h wx/bitmap.h + wx/bmpbndl.h wx/bmpbuttn.h wx/bmpcbox.h wx/bookctrl.h @@ -1901,6 +1904,7 @@ MSW_LOWLEVEL_SRC = src/msw/aboutdlg.cpp src/msw/app.cpp src/msw/bitmap.cpp + src/msw/bmpbndl.cpp src/msw/brush.cpp src/msw/caret.cpp src/msw/clipbrd.cpp @@ -2276,6 +2280,7 @@ OSX_LOWLEVEL_SRC = src/osx/window_osx.cpp src/osx/core/bitmap.cpp + src/osx/core/bmpbndl.mm src/osx/core/colour.cpp src/osx/core/dcmemory.cpp src/osx/core/fontenum.cpp diff --git a/build/msw/makefile.gcc b/build/msw/makefile.gcc index 478e430068..f492cbb251 100644 --- a/build/msw/makefile.gcc +++ b/build/msw/makefile.gcc @@ -1931,6 +1931,7 @@ ____CORE_SRC_FILENAMES_OBJECTS = \ $(OBJS)\monodll_uuid.o \ $(OBJS)\monodll_evtloop.o \ $(OBJS)\monodll_access.o \ + $(OBJS)\monodll_msw_bmpbndl.o \ $(OBJS)\monodll_clrpickerg.o \ $(OBJS)\monodll_collpaneg.o \ $(OBJS)\monodll_filepickerg.o \ @@ -2203,7 +2204,9 @@ ____CORE_SRC_FILENAMES_OBJECTS = \ $(OBJS)\monodll_laywin.o \ $(OBJS)\monodll_calctrlg.o \ $(OBJS)\monodll_creddlgg.o \ - $(OBJS)\monodll_rowheightcache.o + $(OBJS)\monodll_rowheightcache.o \ + $(OBJS)\monodll_common_bmpbndl.o \ + $(OBJS)\monodll_bmpsvg.o endif endif ifeq ($(USE_GUI),1) @@ -2276,6 +2279,7 @@ ____CORE_SRC_FILENAMES_OBJECTS = \ $(OBJS)\monodll_uuid.o \ $(OBJS)\monodll_evtloop.o \ $(OBJS)\monodll_access.o \ + $(OBJS)\monodll_msw_bmpbndl.o \ $(OBJS)\monodll_generic_accel.o \ $(OBJS)\monodll_clrpickerg.o \ $(OBJS)\monodll_collpaneg.o \ @@ -2533,7 +2537,9 @@ ____CORE_SRC_FILENAMES_OBJECTS = \ $(OBJS)\monodll_laywin.o \ $(OBJS)\monodll_calctrlg.o \ $(OBJS)\monodll_creddlgg.o \ - $(OBJS)\monodll_rowheightcache.o + $(OBJS)\monodll_rowheightcache.o \ + $(OBJS)\monodll_common_bmpbndl.o \ + $(OBJS)\monodll_bmpsvg.o endif endif ifeq ($(USE_STC),1) @@ -2774,6 +2780,7 @@ ____CORE_SRC_FILENAMES_1_OBJECTS = \ $(OBJS)\monolib_uuid.o \ $(OBJS)\monolib_evtloop.o \ $(OBJS)\monolib_access.o \ + $(OBJS)\monolib_msw_bmpbndl.o \ $(OBJS)\monolib_clrpickerg.o \ $(OBJS)\monolib_collpaneg.o \ $(OBJS)\monolib_filepickerg.o \ @@ -3046,7 +3053,9 @@ ____CORE_SRC_FILENAMES_1_OBJECTS = \ $(OBJS)\monolib_laywin.o \ $(OBJS)\monolib_calctrlg.o \ $(OBJS)\monolib_creddlgg.o \ - $(OBJS)\monolib_rowheightcache.o + $(OBJS)\monolib_rowheightcache.o \ + $(OBJS)\monolib_common_bmpbndl.o \ + $(OBJS)\monolib_bmpsvg.o endif endif ifeq ($(USE_GUI),1) @@ -3119,6 +3128,7 @@ ____CORE_SRC_FILENAMES_1_OBJECTS = \ $(OBJS)\monolib_uuid.o \ $(OBJS)\monolib_evtloop.o \ $(OBJS)\monolib_access.o \ + $(OBJS)\monolib_msw_bmpbndl.o \ $(OBJS)\monolib_generic_accel.o \ $(OBJS)\monolib_clrpickerg.o \ $(OBJS)\monolib_collpaneg.o \ @@ -3376,7 +3386,9 @@ ____CORE_SRC_FILENAMES_1_OBJECTS = \ $(OBJS)\monolib_laywin.o \ $(OBJS)\monolib_calctrlg.o \ $(OBJS)\monolib_creddlgg.o \ - $(OBJS)\monolib_rowheightcache.o + $(OBJS)\monolib_rowheightcache.o \ + $(OBJS)\monolib_common_bmpbndl.o \ + $(OBJS)\monolib_bmpsvg.o endif endif ifeq ($(USE_STC),1) @@ -3500,6 +3512,7 @@ ____CORE_SRC_FILENAMES_2_OBJECTS = \ $(OBJS)\coredll_uuid.o \ $(OBJS)\coredll_evtloop.o \ $(OBJS)\coredll_access.o \ + $(OBJS)\coredll_msw_bmpbndl.o \ $(OBJS)\coredll_clrpickerg.o \ $(OBJS)\coredll_collpaneg.o \ $(OBJS)\coredll_filepickerg.o \ @@ -3772,7 +3785,9 @@ ____CORE_SRC_FILENAMES_2_OBJECTS = \ $(OBJS)\coredll_laywin.o \ $(OBJS)\coredll_calctrlg.o \ $(OBJS)\coredll_creddlgg.o \ - $(OBJS)\coredll_rowheightcache.o + $(OBJS)\coredll_rowheightcache.o \ + $(OBJS)\coredll_common_bmpbndl.o \ + $(OBJS)\coredll_bmpsvg.o endif endif ifeq ($(USE_GUI),1) @@ -3845,6 +3860,7 @@ ____CORE_SRC_FILENAMES_2_OBJECTS = \ $(OBJS)\coredll_uuid.o \ $(OBJS)\coredll_evtloop.o \ $(OBJS)\coredll_access.o \ + $(OBJS)\coredll_msw_bmpbndl.o \ $(OBJS)\coredll_generic_accel.o \ $(OBJS)\coredll_clrpickerg.o \ $(OBJS)\coredll_collpaneg.o \ @@ -4102,7 +4118,9 @@ ____CORE_SRC_FILENAMES_2_OBJECTS = \ $(OBJS)\coredll_laywin.o \ $(OBJS)\coredll_calctrlg.o \ $(OBJS)\coredll_creddlgg.o \ - $(OBJS)\coredll_rowheightcache.o + $(OBJS)\coredll_rowheightcache.o \ + $(OBJS)\coredll_common_bmpbndl.o \ + $(OBJS)\coredll_bmpsvg.o endif endif ifeq ($(MONOLITHIC),0) @@ -4183,6 +4201,7 @@ ____CORE_SRC_FILENAMES_3_OBJECTS = \ $(OBJS)\corelib_uuid.o \ $(OBJS)\corelib_evtloop.o \ $(OBJS)\corelib_access.o \ + $(OBJS)\corelib_msw_bmpbndl.o \ $(OBJS)\corelib_clrpickerg.o \ $(OBJS)\corelib_collpaneg.o \ $(OBJS)\corelib_filepickerg.o \ @@ -4455,7 +4474,9 @@ ____CORE_SRC_FILENAMES_3_OBJECTS = \ $(OBJS)\corelib_laywin.o \ $(OBJS)\corelib_calctrlg.o \ $(OBJS)\corelib_creddlgg.o \ - $(OBJS)\corelib_rowheightcache.o + $(OBJS)\corelib_rowheightcache.o \ + $(OBJS)\corelib_common_bmpbndl.o \ + $(OBJS)\corelib_bmpsvg.o endif endif ifeq ($(USE_GUI),1) @@ -4528,6 +4549,7 @@ ____CORE_SRC_FILENAMES_3_OBJECTS = \ $(OBJS)\corelib_uuid.o \ $(OBJS)\corelib_evtloop.o \ $(OBJS)\corelib_access.o \ + $(OBJS)\corelib_msw_bmpbndl.o \ $(OBJS)\corelib_generic_accel.o \ $(OBJS)\corelib_clrpickerg.o \ $(OBJS)\corelib_collpaneg.o \ @@ -4785,7 +4807,9 @@ ____CORE_SRC_FILENAMES_3_OBJECTS = \ $(OBJS)\corelib_laywin.o \ $(OBJS)\corelib_calctrlg.o \ $(OBJS)\corelib_creddlgg.o \ - $(OBJS)\corelib_rowheightcache.o + $(OBJS)\corelib_rowheightcache.o \ + $(OBJS)\corelib_common_bmpbndl.o \ + $(OBJS)\corelib_bmpsvg.o endif endif ifeq ($(SHARED),1) @@ -8418,6 +8442,11 @@ $(OBJS)\monodll_access.o: ../../src/msw/ole/access.cpp $(CXX) -c -o $@ $(MONODLL_CXXFLAGS) $(CPPDEPS) $< endif +ifeq ($(USE_GUI),1) +$(OBJS)\monodll_msw_bmpbndl.o: ../../src/msw/bmpbndl.cpp + $(CXX) -c -o $@ $(MONODLL_CXXFLAGS) $(CPPDEPS) $< +endif + ifeq ($(USE_GUI),1) $(OBJS)\monodll_clrpickerg.o: ../../src/generic/clrpickerg.cpp $(CXX) -c -o $@ $(MONODLL_CXXFLAGS) $(CPPDEPS) $< @@ -9463,6 +9492,16 @@ $(OBJS)\monodll_rowheightcache.o: ../../src/generic/rowheightcache.cpp $(CXX) -c -o $@ $(MONODLL_CXXFLAGS) $(CPPDEPS) $< endif +ifeq ($(USE_GUI),1) +$(OBJS)\monodll_common_bmpbndl.o: ../../src/common/bmpbndl.cpp + $(CXX) -c -o $@ $(MONODLL_CXXFLAGS) $(CPPDEPS) $< +endif + +ifeq ($(USE_GUI),1) +$(OBJS)\monodll_bmpsvg.o: ../../src/generic/bmpsvg.cpp + $(CXX) -c -o $@ $(MONODLL_CXXFLAGS) $(CPPDEPS) $< +endif + $(OBJS)\monodll_version_rc.o: ../../src/msw/version.rc $(WINDRES) -i$< -o$@ --include-dir ../../src/tiff/libtiff --include-dir ../../src/jpeg --include-dir ../../src/png --include-dir ../../src/zlib --include-dir ../../3rdparty/pcre/src/wx --include-dir ../../src/expat/expat/lib --define __WXMSW__ $(__WXUNIV_DEFINE_p_66) $(__DEBUG_DEFINE_p_66) $(__NDEBUG_DEFINE_p_65) $(__EXCEPTIONS_DEFINE_p_65) $(__RTTI_DEFINE_p_65) $(__THREAD_DEFINE_p_65) $(__UNICODE_DEFINE_p_67) --include-dir $(SETUPHDIR) --include-dir ../../include $(__CAIRO_INCLUDEDIR_p) --define WXBUILDING --define WXDLLNAME=wx$(PORTNAME)$(WXUNIVNAME)$(WX_VERSION_NODOT)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)$(WXCOMPILER)$(VENDORTAG) --include-dir ../../src/stc/scintilla/include --include-dir ../../src/stc/scintilla/lexlib --include-dir ../../src/stc/scintilla/src --define __WX__ --define SCI_LEXER --define NO_CXX11_REGEX --define LINK_LEXERS --define wxUSE_BASE=1 --define WXMAKINGDLL @@ -10995,6 +11034,11 @@ $(OBJS)\monolib_access.o: ../../src/msw/ole/access.cpp $(CXX) -c -o $@ $(MONOLIB_CXXFLAGS) $(CPPDEPS) $< endif +ifeq ($(USE_GUI),1) +$(OBJS)\monolib_msw_bmpbndl.o: ../../src/msw/bmpbndl.cpp + $(CXX) -c -o $@ $(MONOLIB_CXXFLAGS) $(CPPDEPS) $< +endif + ifeq ($(USE_GUI),1) $(OBJS)\monolib_clrpickerg.o: ../../src/generic/clrpickerg.cpp $(CXX) -c -o $@ $(MONOLIB_CXXFLAGS) $(CPPDEPS) $< @@ -12040,6 +12084,16 @@ $(OBJS)\monolib_rowheightcache.o: ../../src/generic/rowheightcache.cpp $(CXX) -c -o $@ $(MONOLIB_CXXFLAGS) $(CPPDEPS) $< endif +ifeq ($(USE_GUI),1) +$(OBJS)\monolib_common_bmpbndl.o: ../../src/common/bmpbndl.cpp + $(CXX) -c -o $@ $(MONOLIB_CXXFLAGS) $(CPPDEPS) $< +endif + +ifeq ($(USE_GUI),1) +$(OBJS)\monolib_bmpsvg.o: ../../src/generic/bmpsvg.cpp + $(CXX) -c -o $@ $(MONOLIB_CXXFLAGS) $(CPPDEPS) $< +endif + $(OBJS)\basedll_dummy.o: ../../src/common/dummy.cpp $(CXX) -c -o $@ $(BASEDLL_CXXFLAGS) $(CPPDEPS) $< @@ -13542,6 +13596,11 @@ $(OBJS)\coredll_access.o: ../../src/msw/ole/access.cpp $(CXX) -c -o $@ $(COREDLL_CXXFLAGS) $(CPPDEPS) $< endif +ifeq ($(USE_GUI),1) +$(OBJS)\coredll_msw_bmpbndl.o: ../../src/msw/bmpbndl.cpp + $(CXX) -c -o $@ $(COREDLL_CXXFLAGS) $(CPPDEPS) $< +endif + ifeq ($(USE_GUI),1) $(OBJS)\coredll_clrpickerg.o: ../../src/generic/clrpickerg.cpp $(CXX) -c -o $@ $(COREDLL_CXXFLAGS) $(CPPDEPS) $< @@ -14587,6 +14646,16 @@ $(OBJS)\coredll_rowheightcache.o: ../../src/generic/rowheightcache.cpp $(CXX) -c -o $@ $(COREDLL_CXXFLAGS) $(CPPDEPS) $< endif +ifeq ($(USE_GUI),1) +$(OBJS)\coredll_common_bmpbndl.o: ../../src/common/bmpbndl.cpp + $(CXX) -c -o $@ $(COREDLL_CXXFLAGS) $(CPPDEPS) $< +endif + +ifeq ($(USE_GUI),1) +$(OBJS)\coredll_bmpsvg.o: ../../src/generic/bmpsvg.cpp + $(CXX) -c -o $@ $(COREDLL_CXXFLAGS) $(CPPDEPS) $< +endif + $(OBJS)\corelib_dummy.o: ../../src/common/dummy.cpp $(CXX) -c -o $@ $(CORELIB_CXXFLAGS) $(CPPDEPS) $< @@ -15282,6 +15351,11 @@ $(OBJS)\corelib_access.o: ../../src/msw/ole/access.cpp $(CXX) -c -o $@ $(CORELIB_CXXFLAGS) $(CPPDEPS) $< endif +ifeq ($(USE_GUI),1) +$(OBJS)\corelib_msw_bmpbndl.o: ../../src/msw/bmpbndl.cpp + $(CXX) -c -o $@ $(CORELIB_CXXFLAGS) $(CPPDEPS) $< +endif + ifeq ($(USE_GUI),1) $(OBJS)\corelib_clrpickerg.o: ../../src/generic/clrpickerg.cpp $(CXX) -c -o $@ $(CORELIB_CXXFLAGS) $(CPPDEPS) $< @@ -16327,6 +16401,16 @@ $(OBJS)\corelib_rowheightcache.o: ../../src/generic/rowheightcache.cpp $(CXX) -c -o $@ $(CORELIB_CXXFLAGS) $(CPPDEPS) $< endif +ifeq ($(USE_GUI),1) +$(OBJS)\corelib_common_bmpbndl.o: ../../src/common/bmpbndl.cpp + $(CXX) -c -o $@ $(CORELIB_CXXFLAGS) $(CPPDEPS) $< +endif + +ifeq ($(USE_GUI),1) +$(OBJS)\corelib_bmpsvg.o: ../../src/generic/bmpsvg.cpp + $(CXX) -c -o $@ $(CORELIB_CXXFLAGS) $(CPPDEPS) $< +endif + $(OBJS)\advdll_dummy.o: ../../src/common/dummy.cpp $(CXX) -c -o $@ $(ADVDLL_CXXFLAGS) $(CPPDEPS) $< diff --git a/build/msw/makefile.vc b/build/msw/makefile.vc index 8f0b989f49..2f8fcf89ad 100644 --- a/build/msw/makefile.vc +++ b/build/msw/makefile.vc @@ -2261,6 +2261,7 @@ ____CORE_SRC_FILENAMES_OBJECTS = \ $(OBJS)\monodll_uuid.obj \ $(OBJS)\monodll_evtloop.obj \ $(OBJS)\monodll_access.obj \ + $(OBJS)\monodll_msw_bmpbndl.obj \ $(OBJS)\monodll_clrpickerg.obj \ $(OBJS)\monodll_collpaneg.obj \ $(OBJS)\monodll_filepickerg.obj \ @@ -2533,7 +2534,9 @@ ____CORE_SRC_FILENAMES_OBJECTS = \ $(OBJS)\monodll_laywin.obj \ $(OBJS)\monodll_calctrlg.obj \ $(OBJS)\monodll_creddlgg.obj \ - $(OBJS)\monodll_rowheightcache.obj + $(OBJS)\monodll_rowheightcache.obj \ + $(OBJS)\monodll_common_bmpbndl.obj \ + $(OBJS)\monodll_bmpsvg.obj !endif !if "$(USE_GUI)" == "1" && "$(WXUNIV)" == "1" ____CORE_SRC_FILENAMES_OBJECTS = \ @@ -2604,6 +2607,7 @@ ____CORE_SRC_FILENAMES_OBJECTS = \ $(OBJS)\monodll_uuid.obj \ $(OBJS)\monodll_evtloop.obj \ $(OBJS)\monodll_access.obj \ + $(OBJS)\monodll_msw_bmpbndl.obj \ $(OBJS)\monodll_generic_accel.obj \ $(OBJS)\monodll_clrpickerg.obj \ $(OBJS)\monodll_collpaneg.obj \ @@ -2861,7 +2865,9 @@ ____CORE_SRC_FILENAMES_OBJECTS = \ $(OBJS)\monodll_laywin.obj \ $(OBJS)\monodll_calctrlg.obj \ $(OBJS)\monodll_creddlgg.obj \ - $(OBJS)\monodll_rowheightcache.obj + $(OBJS)\monodll_rowheightcache.obj \ + $(OBJS)\monodll_common_bmpbndl.obj \ + $(OBJS)\monodll_bmpsvg.obj !endif !if "$(USE_STC)" == "1" ____MONOLIB_STC_SRC_FILENAMES_OBJECTS = \ @@ -3104,6 +3110,7 @@ ____CORE_SRC_FILENAMES_1_OBJECTS = \ $(OBJS)\monolib_uuid.obj \ $(OBJS)\monolib_evtloop.obj \ $(OBJS)\monolib_access.obj \ + $(OBJS)\monolib_msw_bmpbndl.obj \ $(OBJS)\monolib_clrpickerg.obj \ $(OBJS)\monolib_collpaneg.obj \ $(OBJS)\monolib_filepickerg.obj \ @@ -3376,7 +3383,9 @@ ____CORE_SRC_FILENAMES_1_OBJECTS = \ $(OBJS)\monolib_laywin.obj \ $(OBJS)\monolib_calctrlg.obj \ $(OBJS)\monolib_creddlgg.obj \ - $(OBJS)\monolib_rowheightcache.obj + $(OBJS)\monolib_rowheightcache.obj \ + $(OBJS)\monolib_common_bmpbndl.obj \ + $(OBJS)\monolib_bmpsvg.obj !endif !if "$(USE_GUI)" == "1" && "$(WXUNIV)" == "1" ____CORE_SRC_FILENAMES_1_OBJECTS = \ @@ -3447,6 +3456,7 @@ ____CORE_SRC_FILENAMES_1_OBJECTS = \ $(OBJS)\monolib_uuid.obj \ $(OBJS)\monolib_evtloop.obj \ $(OBJS)\monolib_access.obj \ + $(OBJS)\monolib_msw_bmpbndl.obj \ $(OBJS)\monolib_generic_accel.obj \ $(OBJS)\monolib_clrpickerg.obj \ $(OBJS)\monolib_collpaneg.obj \ @@ -3704,7 +3714,9 @@ ____CORE_SRC_FILENAMES_1_OBJECTS = \ $(OBJS)\monolib_laywin.obj \ $(OBJS)\monolib_calctrlg.obj \ $(OBJS)\monolib_creddlgg.obj \ - $(OBJS)\monolib_rowheightcache.obj + $(OBJS)\monolib_rowheightcache.obj \ + $(OBJS)\monolib_common_bmpbndl.obj \ + $(OBJS)\monolib_bmpsvg.obj !endif !if "$(USE_STC)" == "1" ____MONOLIB_STC_SRC_FILENAMES_1_OBJECTS = \ @@ -3880,6 +3892,7 @@ ____CORE_SRC_FILENAMES_2_OBJECTS = \ $(OBJS)\coredll_uuid.obj \ $(OBJS)\coredll_evtloop.obj \ $(OBJS)\coredll_access.obj \ + $(OBJS)\coredll_msw_bmpbndl.obj \ $(OBJS)\coredll_clrpickerg.obj \ $(OBJS)\coredll_collpaneg.obj \ $(OBJS)\coredll_filepickerg.obj \ @@ -4152,7 +4165,9 @@ ____CORE_SRC_FILENAMES_2_OBJECTS = \ $(OBJS)\coredll_laywin.obj \ $(OBJS)\coredll_calctrlg.obj \ $(OBJS)\coredll_creddlgg.obj \ - $(OBJS)\coredll_rowheightcache.obj + $(OBJS)\coredll_rowheightcache.obj \ + $(OBJS)\coredll_common_bmpbndl.obj \ + $(OBJS)\coredll_bmpsvg.obj !endif !if "$(USE_GUI)" == "1" && "$(WXUNIV)" == "1" ____CORE_SRC_FILENAMES_2_OBJECTS = \ @@ -4223,6 +4238,7 @@ ____CORE_SRC_FILENAMES_2_OBJECTS = \ $(OBJS)\coredll_uuid.obj \ $(OBJS)\coredll_evtloop.obj \ $(OBJS)\coredll_access.obj \ + $(OBJS)\coredll_msw_bmpbndl.obj \ $(OBJS)\coredll_generic_accel.obj \ $(OBJS)\coredll_clrpickerg.obj \ $(OBJS)\coredll_collpaneg.obj \ @@ -4480,7 +4496,9 @@ ____CORE_SRC_FILENAMES_2_OBJECTS = \ $(OBJS)\coredll_laywin.obj \ $(OBJS)\coredll_calctrlg.obj \ $(OBJS)\coredll_creddlgg.obj \ - $(OBJS)\coredll_rowheightcache.obj + $(OBJS)\coredll_rowheightcache.obj \ + $(OBJS)\coredll_common_bmpbndl.obj \ + $(OBJS)\coredll_bmpsvg.obj !endif !if "$(MONOLITHIC)" == "0" && "$(SHARED)" == "0" && "$(USE_GUI)" == "1" __corelib___depname = \ @@ -4561,6 +4579,7 @@ ____CORE_SRC_FILENAMES_3_OBJECTS = \ $(OBJS)\corelib_uuid.obj \ $(OBJS)\corelib_evtloop.obj \ $(OBJS)\corelib_access.obj \ + $(OBJS)\corelib_msw_bmpbndl.obj \ $(OBJS)\corelib_clrpickerg.obj \ $(OBJS)\corelib_collpaneg.obj \ $(OBJS)\corelib_filepickerg.obj \ @@ -4833,7 +4852,9 @@ ____CORE_SRC_FILENAMES_3_OBJECTS = \ $(OBJS)\corelib_laywin.obj \ $(OBJS)\corelib_calctrlg.obj \ $(OBJS)\corelib_creddlgg.obj \ - $(OBJS)\corelib_rowheightcache.obj + $(OBJS)\corelib_rowheightcache.obj \ + $(OBJS)\corelib_common_bmpbndl.obj \ + $(OBJS)\corelib_bmpsvg.obj !endif !if "$(USE_GUI)" == "1" && "$(WXUNIV)" == "1" ____CORE_SRC_FILENAMES_3_OBJECTS = \ @@ -4904,6 +4925,7 @@ ____CORE_SRC_FILENAMES_3_OBJECTS = \ $(OBJS)\corelib_uuid.obj \ $(OBJS)\corelib_evtloop.obj \ $(OBJS)\corelib_access.obj \ + $(OBJS)\corelib_msw_bmpbndl.obj \ $(OBJS)\corelib_generic_accel.obj \ $(OBJS)\corelib_clrpickerg.obj \ $(OBJS)\corelib_collpaneg.obj \ @@ -5161,7 +5183,9 @@ ____CORE_SRC_FILENAMES_3_OBJECTS = \ $(OBJS)\corelib_laywin.obj \ $(OBJS)\corelib_calctrlg.obj \ $(OBJS)\corelib_creddlgg.obj \ - $(OBJS)\corelib_rowheightcache.obj + $(OBJS)\corelib_rowheightcache.obj \ + $(OBJS)\corelib_common_bmpbndl.obj \ + $(OBJS)\corelib_bmpsvg.obj !endif !if "$(SHARED)" == "1" ____wxcore_namedll_DEP = $(__coredll___depname) @@ -8849,6 +8873,11 @@ $(OBJS)\monodll_access.obj: ..\..\src\msw\ole\access.cpp $(CXX) /c /nologo /TP /Fo$@ $(MONODLL_CXXFLAGS) ..\..\src\msw\ole\access.cpp !endif +!if "$(USE_GUI)" == "1" +$(OBJS)\monodll_msw_bmpbndl.obj: ..\..\src\msw\bmpbndl.cpp + $(CXX) /c /nologo /TP /Fo$@ $(MONODLL_CXXFLAGS) ..\..\src\msw\bmpbndl.cpp +!endif + !if "$(USE_GUI)" == "1" $(OBJS)\monodll_clrpickerg.obj: ..\..\src\generic\clrpickerg.cpp $(CXX) /c /nologo /TP /Fo$@ $(MONODLL_CXXFLAGS) ..\..\src\generic\clrpickerg.cpp @@ -9894,6 +9923,16 @@ $(OBJS)\monodll_rowheightcache.obj: ..\..\src\generic\rowheightcache.cpp $(CXX) /c /nologo /TP /Fo$@ $(MONODLL_CXXFLAGS) ..\..\src\generic\rowheightcache.cpp !endif +!if "$(USE_GUI)" == "1" +$(OBJS)\monodll_common_bmpbndl.obj: ..\..\src\common\bmpbndl.cpp + $(CXX) /c /nologo /TP /Fo$@ $(MONODLL_CXXFLAGS) ..\..\src\common\bmpbndl.cpp +!endif + +!if "$(USE_GUI)" == "1" +$(OBJS)\monodll_bmpsvg.obj: ..\..\src\generic\bmpsvg.cpp + $(CXX) /c /nologo /TP /Fo$@ $(MONODLL_CXXFLAGS) ..\..\src\generic\bmpsvg.cpp +!endif + $(OBJS)\monodll_version.res: ..\..\src\msw\version.rc rc /fo$@ /d WIN32 /i ..\..\src\tiff\libtiff /i ..\..\src\jpeg /i ..\..\src\png /i ..\..\src\zlib /i ..\..\3rdparty\pcre\src\wx /i ..\..\src\expat\expat\lib $(____DEBUGRUNTIME_6) /d _CRT_SECURE_NO_DEPRECATE=1 /d _CRT_NON_CONFORMING_SWPRINTFS=1 /d _SCL_SECURE_NO_WARNINGS=1 $(__NO_VC_CRTDBG_p_72) $(__TARGET_CPU_COMPFLAG_p_72) /d __WXMSW__ $(__WXUNIV_DEFINE_p_66) $(__DEBUG_DEFINE_p_66) $(__NDEBUG_DEFINE_p_65) $(__EXCEPTIONS_DEFINE_p_65) $(__RTTI_DEFINE_p_65) $(__THREAD_DEFINE_p_65) $(__UNICODE_DEFINE_p_67) /i $(SETUPHDIR) /i ..\..\include $(____CAIRO_INCLUDEDIR_FILENAMES_4) /d WXBUILDING /d WXDLLNAME=wx$(PORTNAME)$(WXUNIVNAME)$(WX_VERSION_NODOT)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)$(WXCOMPILER)$(VENDORTAG) /i ..\..\src\stc\scintilla\include /i ..\..\src\stc\scintilla\lexlib /i ..\..\src\stc\scintilla\src /d __WX__ /d SCI_LEXER /d NO_CXX11_REGEX /d LINK_LEXERS /d wxUSE_BASE=1 /d WXMAKINGDLL ..\..\src\msw\version.rc @@ -11426,6 +11465,11 @@ $(OBJS)\monolib_access.obj: ..\..\src\msw\ole\access.cpp $(CXX) /c /nologo /TP /Fo$@ $(MONOLIB_CXXFLAGS) ..\..\src\msw\ole\access.cpp !endif +!if "$(USE_GUI)" == "1" +$(OBJS)\monolib_msw_bmpbndl.obj: ..\..\src\msw\bmpbndl.cpp + $(CXX) /c /nologo /TP /Fo$@ $(MONOLIB_CXXFLAGS) ..\..\src\msw\bmpbndl.cpp +!endif + !if "$(USE_GUI)" == "1" $(OBJS)\monolib_clrpickerg.obj: ..\..\src\generic\clrpickerg.cpp $(CXX) /c /nologo /TP /Fo$@ $(MONOLIB_CXXFLAGS) ..\..\src\generic\clrpickerg.cpp @@ -12471,6 +12515,16 @@ $(OBJS)\monolib_rowheightcache.obj: ..\..\src\generic\rowheightcache.cpp $(CXX) /c /nologo /TP /Fo$@ $(MONOLIB_CXXFLAGS) ..\..\src\generic\rowheightcache.cpp !endif +!if "$(USE_GUI)" == "1" +$(OBJS)\monolib_common_bmpbndl.obj: ..\..\src\common\bmpbndl.cpp + $(CXX) /c /nologo /TP /Fo$@ $(MONOLIB_CXXFLAGS) ..\..\src\common\bmpbndl.cpp +!endif + +!if "$(USE_GUI)" == "1" +$(OBJS)\monolib_bmpsvg.obj: ..\..\src\generic\bmpsvg.cpp + $(CXX) /c /nologo /TP /Fo$@ $(MONOLIB_CXXFLAGS) ..\..\src\generic\bmpsvg.cpp +!endif + $(OBJS)\basedll_dummy.obj: ..\..\src\common\dummy.cpp $(CXX) /c /nologo /TP /Fo$@ $(BASEDLL_CXXFLAGS) /Ycwx/wxprec.h ..\..\src\common\dummy.cpp @@ -13973,6 +14027,11 @@ $(OBJS)\coredll_access.obj: ..\..\src\msw\ole\access.cpp $(CXX) /c /nologo /TP /Fo$@ $(COREDLL_CXXFLAGS) ..\..\src\msw\ole\access.cpp !endif +!if "$(USE_GUI)" == "1" +$(OBJS)\coredll_msw_bmpbndl.obj: ..\..\src\msw\bmpbndl.cpp + $(CXX) /c /nologo /TP /Fo$@ $(COREDLL_CXXFLAGS) ..\..\src\msw\bmpbndl.cpp +!endif + !if "$(USE_GUI)" == "1" $(OBJS)\coredll_clrpickerg.obj: ..\..\src\generic\clrpickerg.cpp $(CXX) /c /nologo /TP /Fo$@ $(COREDLL_CXXFLAGS) ..\..\src\generic\clrpickerg.cpp @@ -15018,6 +15077,16 @@ $(OBJS)\coredll_rowheightcache.obj: ..\..\src\generic\rowheightcache.cpp $(CXX) /c /nologo /TP /Fo$@ $(COREDLL_CXXFLAGS) ..\..\src\generic\rowheightcache.cpp !endif +!if "$(USE_GUI)" == "1" +$(OBJS)\coredll_common_bmpbndl.obj: ..\..\src\common\bmpbndl.cpp + $(CXX) /c /nologo /TP /Fo$@ $(COREDLL_CXXFLAGS) ..\..\src\common\bmpbndl.cpp +!endif + +!if "$(USE_GUI)" == "1" +$(OBJS)\coredll_bmpsvg.obj: ..\..\src\generic\bmpsvg.cpp + $(CXX) /c /nologo /TP /Fo$@ $(COREDLL_CXXFLAGS) ..\..\src\generic\bmpsvg.cpp +!endif + $(OBJS)\corelib_dummy.obj: ..\..\src\common\dummy.cpp $(CXX) /c /nologo /TP /Fo$@ $(CORELIB_CXXFLAGS) /Ycwx/wxprec.h ..\..\src\common\dummy.cpp @@ -15713,6 +15782,11 @@ $(OBJS)\corelib_access.obj: ..\..\src\msw\ole\access.cpp $(CXX) /c /nologo /TP /Fo$@ $(CORELIB_CXXFLAGS) ..\..\src\msw\ole\access.cpp !endif +!if "$(USE_GUI)" == "1" +$(OBJS)\corelib_msw_bmpbndl.obj: ..\..\src\msw\bmpbndl.cpp + $(CXX) /c /nologo /TP /Fo$@ $(CORELIB_CXXFLAGS) ..\..\src\msw\bmpbndl.cpp +!endif + !if "$(USE_GUI)" == "1" $(OBJS)\corelib_clrpickerg.obj: ..\..\src\generic\clrpickerg.cpp $(CXX) /c /nologo /TP /Fo$@ $(CORELIB_CXXFLAGS) ..\..\src\generic\clrpickerg.cpp @@ -16758,6 +16832,16 @@ $(OBJS)\corelib_rowheightcache.obj: ..\..\src\generic\rowheightcache.cpp $(CXX) /c /nologo /TP /Fo$@ $(CORELIB_CXXFLAGS) ..\..\src\generic\rowheightcache.cpp !endif +!if "$(USE_GUI)" == "1" +$(OBJS)\corelib_common_bmpbndl.obj: ..\..\src\common\bmpbndl.cpp + $(CXX) /c /nologo /TP /Fo$@ $(CORELIB_CXXFLAGS) ..\..\src\common\bmpbndl.cpp +!endif + +!if "$(USE_GUI)" == "1" +$(OBJS)\corelib_bmpsvg.obj: ..\..\src\generic\bmpsvg.cpp + $(CXX) /c /nologo /TP /Fo$@ $(CORELIB_CXXFLAGS) ..\..\src\generic\bmpsvg.cpp +!endif + $(OBJS)\advdll_dummy.obj: ..\..\src\common\dummy.cpp $(CXX) /c /nologo /TP /Fo$@ $(ADVDLL_CXXFLAGS) /Ycwx/wxprec.h ..\..\src\common\dummy.cpp diff --git a/build/msw/wx_core.vcxproj b/build/msw/wx_core.vcxproj index 9307008fef..36eb3274d4 100644 --- a/build/msw/wx_core.vcxproj +++ b/build/msw/wx_core.vcxproj @@ -459,6 +459,7 @@ + @@ -591,6 +592,7 @@ + $(IntDir)msw_%(Filename).obj @@ -602,6 +604,16 @@ $(IntDir)msw_%(Filename).obj $(IntDir)msw_%(Filename).obj + + $(IntDir)msw_%(Filename).obj + $(IntDir)msw_%(Filename).obj + $(IntDir)msw_%(Filename).obj + $(IntDir)msw_%(Filename).obj + $(IntDir)msw_%(Filename).obj + $(IntDir)msw_%(Filename).obj + $(IntDir)msw_%(Filename).obj + $(IntDir)msw_%(Filename).obj + @@ -1087,6 +1099,7 @@ true true + @@ -1509,4 +1522,4 @@ - + \ No newline at end of file diff --git a/build/msw/wx_core.vcxproj.filters b/build/msw/wx_core.vcxproj.filters index 53d84d94a5..60190f8aa9 100644 --- a/build/msw/wx_core.vcxproj.filters +++ b/build/msw/wx_core.vcxproj.filters @@ -1068,6 +1068,15 @@ Common Sources + + Common Sources + + + MSW Sources + + + Generic Sources + @@ -2299,6 +2308,9 @@ Common Headers + + Common Headers + diff --git a/build/msw/wx_vc8_core.vcproj b/build/msw/wx_vc8_core.vcproj index 09618dfcda..011a5df729 100644 --- a/build/msw/wx_vc8_core.vcproj +++ b/build/msw/wx_vc8_core.vcproj @@ -785,6 +785,74 @@ RelativePath="..\..\src\common\bmpbase.cpp" > + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -1422,6 +1490,74 @@ RelativePath="..\..\src\msw\bitmap.cpp" > + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -1951,6 +2087,10 @@ RelativePath="..\..\src\generic\bmpcboxg.cpp" > + + @@ -3316,6 +3456,10 @@ RelativePath="..\..\include\wx\bitmap.h" > + + diff --git a/build/msw/wx_vc9_core.vcproj b/build/msw/wx_vc9_core.vcproj index 8beb7d2ef1..a19fd2073a 100644 --- a/build/msw/wx_vc9_core.vcproj +++ b/build/msw/wx_vc9_core.vcproj @@ -781,6 +781,74 @@ RelativePath="..\..\src\common\bmpbase.cpp" > + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -1418,6 +1486,74 @@ RelativePath="..\..\src\msw\bitmap.cpp" > + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -1947,6 +2083,10 @@ RelativePath="..\..\src\generic\bmpcboxg.cpp" > + + @@ -3312,6 +3452,10 @@ RelativePath="..\..\include\wx\bitmap.h" > + + diff --git a/docs/doxygen/mainpages/const_cpp.h b/docs/doxygen/mainpages/const_cpp.h index e519d217e5..0c9fdd9b8b 100644 --- a/docs/doxygen/mainpages/const_cpp.h +++ b/docs/doxygen/mainpages/const_cpp.h @@ -209,6 +209,7 @@ Currently the following symbols exist: @itemdef{wxHAS_REGEX_ADVANCED, Defined if advanced syntax is available in wxRegEx. This is always the case in wxWidgets 3.1.6 and later, so this symbol doesn't need to be tested any more.} +@itemdef{wxHAS_SVG, Defined if SVG support (currently only via wxBitmapBundle::FromSVG()) is available.} @itemdef{wxHAS_TASK_BAR_ICON, Defined if wxTaskBarIcon is available on the current platform.} @itemdef{wxHAS_WINDOW_LABEL_IN_STATIC_BOX, Defined if wxStaticBox::Create() overload taking @c wxWindow* instead of the text label is available on the current platform.} diff --git a/include/wx/artprov.h b/include/wx/artprov.h index 85fb9f6565..7bf65efbc4 100644 --- a/include/wx/artprov.h +++ b/include/wx/artprov.h @@ -15,6 +15,7 @@ #include "wx/bitmap.h" #include "wx/icon.h" #include "wx/iconbndl.h" +#include "wx/bmpbndl.h" class WXDLLIMPEXP_FWD_CORE wxArtProvidersList; class WXDLLIMPEXP_FWD_CORE wxArtProviderCache; @@ -157,6 +158,14 @@ public: const wxArtClient& client = wxASCII_STR(wxART_OTHER), const wxSize& size = wxDefaultSize); + // Query the providers for bitmapbundle with given ID and return it. + // If none is available, then the search for a bitmap with the same properties + // is performed. If successful, the bitmap is wrapped into a bitmap bundle. + static wxBitmapBundle + GetBitmapBundle(const wxArtID& id, + const wxArtClient& client = wxASCII_STR(wxART_OTHER), + const wxSize& size = wxDefaultSize); + // Query the providers for icon with given ID and return it. Return // wxNullIcon if no provider provides it. static wxIcon GetIcon(const wxArtID& id, @@ -225,6 +234,15 @@ protected: return wxNullBitmap; } + // Derived classes must override CreateBitmapBundle if they provide + // a bundle that cannot be represented through an ordinary bitmap. + virtual wxBitmapBundle CreateBitmapBundle(const wxArtID& id, + const wxArtClient& client, + const wxSize& size) + { + return wxBitmapBundle(CreateBitmap(id, client, size)); + } + virtual wxIconBundle CreateIconBundle(const wxArtID& WXUNUSED(id), const wxArtClient& WXUNUSED(client)) { diff --git a/include/wx/bmpbndl.h b/include/wx/bmpbndl.h new file mode 100644 index 0000000000..70794bf756 --- /dev/null +++ b/include/wx/bmpbndl.h @@ -0,0 +1,189 @@ +/////////////////////////////////////////////////////////////////////////////// +// Name: wx/bmpbndl.h +// Purpose: Declaration of wxBitmapBundle class. +// Author: Vadim Zeitlin +// Created: 2021-09-22 +// Copyright: (c) 2021 Vadim Zeitlin +// Licence: wxWindows licence +/////////////////////////////////////////////////////////////////////////////// + +#ifndef _WX_BMPBNDL_H_ +#define _WX_BMPBNDL_H_ + +#include "wx/bitmap.h" +#include "wx/object.h" +#include "wx/vector.h" + +class wxBitmapBundleImpl; + +// It should be possible to implement SVG rasterizing without raw bitmap +// support using wxDC::DrawSpline(), but currently we don't do it and so +// FromSVG() is only available in the ports providing raw bitmap access. +#ifdef wxHAS_RAW_BITMAP + #define wxHAS_SVG +#endif + +// ---------------------------------------------------------------------------- +// wxBitmapBundle provides 1 or more versions of a bitmap, all bundled together +// ---------------------------------------------------------------------------- + +// This class has value semantics and can be copied cheaply. + +class WXDLLIMPEXP_CORE wxBitmapBundle +{ +public: + // Default ctor constructs an empty bundle which can't be used for + // anything, but can be assigned something later. + wxBitmapBundle(); + + // This conversion ctor from a single bitmap does the same thing as + // FromBitmap() and only exists for interoperability with the existing code + // using wxBitmap. + wxBitmapBundle(const wxBitmap& bitmap); + + // Another conversion ctor from a single image: this one is needed to allow + // passing wxImage to the functions that used to take wxBitmap but now take + // wxBitmapBundle. + wxBitmapBundle(const wxImage& image); + + // Default copy ctor and assignment operator and dtor would be ok, but need + // to be defined out of line, where wxBitmapBundleImpl is fully declared. + + wxBitmapBundle(const wxBitmapBundle& other); + wxBitmapBundle& operator=(const wxBitmapBundle& other); + + ~wxBitmapBundle(); + + + // Create from the given collection of bitmaps (all of which must be valid, + // but if the vector itself is empty, empty bundle is returned). + static wxBitmapBundle FromBitmaps(const wxVector& bitmaps); + static wxBitmapBundle FromBitmaps(const wxBitmap& bitmap1, + const wxBitmap& bitmap2); + + // Create from a single bitmap (this is only useful for compatibility + // with the existing code). Returns empty bundle if bitmap is invalid. + static wxBitmapBundle FromBitmap(const wxBitmap& bitmap); + static wxBitmapBundle FromImage(const wxImage& image); + + // It should be possible to implement SVG rasterizing without raw bitmap + // support using wxDC::DrawSpline(), but currently we don't do it and so + // FromSVG() is only available in the ports providing raw bitmap access. +#ifdef wxHAS_SVG + // Create from the SVG data (data is supposed to be in UTF-8 encoding). + // Notice that the data here is non-const because it can be temporarily + // modified while parsing it. + static wxBitmapBundle FromSVG(char* data, const wxSize sizeDef); + + // This overload currently makes a copy of the data. + static wxBitmapBundle FromSVG(const char* data, const wxSize sizeDef); +#endif // wxHAS_SVG + + // Create from the resources: all existing versions of the bitmap of the + // form name_2x or name@2x (and also using other factors) will be used. + static wxBitmapBundle FromResources(const wxString& name); + + // Create from existing implementation + static wxBitmapBundle FromImpl(wxBitmapBundleImpl* impl); + + // Check if bitmap bundle is non-empty. + bool IsOk() const { return m_impl; } + + // Get the size of the bitmap represented by this bundle when using the + // default DPI, i.e. 100% scaling. Returns invalid size for empty bundle. + wxSize GetDefaultSize() const; + + // Get bitmap of the specified size, creating a new bitmap from the closest + // available size by rescaling it if necessary. + // + // If size == wxDefaultSize, GetDefaultSize() is used for it instead. + wxBitmap GetBitmap(const wxSize size) const; + + // Access implementation + wxBitmapBundleImpl* GetImpl() const { return m_impl.get(); } + +private: + typedef wxObjectDataPtr wxBitmapBundleImplPtr; + + // Private ctor used by static factory functions to create objects of this + // class. It takes ownership of the pointer (which must be non-null). + explicit wxBitmapBundle(wxBitmapBundleImpl* impl); + + wxBitmapBundleImplPtr m_impl; +}; + +// This macro can be used to create a bundle from resources on the platforms +// that support it and from name_png and name_2x_png on the other ones. +#ifdef wxHAS_IMAGE_RESOURCES + #define wxBITMAP_BUNDLE_2(name) wxBitmapBundle::FromResources(#name) +#else + #define wxBITMAP_BUNDLE_2(name) \ + wxBitmapBundle::FromBitmaps(wxBITMAP_PNG_FROM_DATA(name), \ + wxBITMAP_PNG_FROM_DATA(name##_2x)) +#endif + +// Inline functions implementation. + +/* static */ inline +wxBitmapBundle wxBitmapBundle::FromBitmaps(const wxBitmap& bitmap1, + const wxBitmap& bitmap2) +{ + wxVector bitmaps; + if ( bitmap1.IsOk() ) + bitmaps.push_back(bitmap1); + if ( bitmap2.IsOk() ) + bitmaps.push_back(bitmap2); + return FromBitmaps(bitmaps); +} + +/* static */ inline +wxBitmapBundle wxBitmapBundle::FromBitmap(const wxBitmap& bitmap) +{ + if ( !bitmap.IsOk() ) + return wxBitmapBundle(); + + wxVector bitmaps; + bitmaps.push_back(bitmap); + return FromBitmaps(bitmaps); +} + +/* static */ inline +wxBitmapBundle wxBitmapBundle::FromImage(const wxImage& image) +{ + if ( !image.IsOk() ) + return wxBitmapBundle(); + + return FromBitmap(wxBitmap(image)); +} + +// ---------------------------------------------------------------------------- +// wxBitmapBundleImpl is the base class for all wxBitmapBundle implementations +// ---------------------------------------------------------------------------- + +// This class inherits from wxRefCounter to make it possible to use it with +// wxObjectDataPtr in wxBitmapBundle. +// +// It doesn't need to be used directly, but may be inherited from in order to +// implement custom bitmap bundles. +class wxBitmapBundleImpl : public wxRefCounter +{ +public: + // Return the size of the bitmaps represented by this bundle in the default + // DPI (a.k.a. 100% resolution). + // + // Must always return a valid size. + virtual wxSize GetDefaultSize() const = 0; + + // Retrieve the bitmap of exactly the given size. + // + // Note that this function is non-const because it may generate the bitmap + // on demand and cache it. + virtual wxBitmap GetBitmap(const wxSize size) = 0; + +#ifdef __WXOSX__ + // returns the native representation of the bitmap bundle + virtual WXImage OSXGetImage() const { return NULL; } +#endif +}; + +#endif // _WX_BMPBNDL_H_ diff --git a/include/wx/generic/buttonbar.h b/include/wx/generic/buttonbar.h index 24de813d57..2d8d6e0506 100644 --- a/include/wx/generic/buttonbar.h +++ b/include/wx/generic/buttonbar.h @@ -66,8 +66,8 @@ protected: virtual wxToolBarToolBase *CreateTool(int id, const wxString& label, - const wxBitmap& bmpNormal, - const wxBitmap& bmpDisabled, + const wxBitmapBundle& bmpNormal, + const wxBitmapBundle& bmpDisabled, wxItemKind kind, wxObject *clientData, const wxString& shortHelp, diff --git a/include/wx/gtk/toolbar.h b/include/wx/gtk/toolbar.h index 4ef2756009..105fea9da4 100644 --- a/include/wx/gtk/toolbar.h +++ b/include/wx/gtk/toolbar.h @@ -47,8 +47,8 @@ public: virtual void SetWindowStyleFlag( long style ) wxOVERRIDE; - virtual void SetToolNormalBitmap(int id, const wxBitmap& bitmap) wxOVERRIDE; - virtual void SetToolDisabledBitmap(int id, const wxBitmap& bitmap) wxOVERRIDE; + virtual void SetToolNormalBitmap(int id, const wxBitmapBundle& bitmap) wxOVERRIDE; + virtual void SetToolDisabledBitmap(int id, const wxBitmapBundle& bitmap) wxOVERRIDE; virtual bool Realize() wxOVERRIDE; @@ -57,8 +57,8 @@ public: virtual wxToolBarToolBase *CreateTool(int id, const wxString& label, - const wxBitmap& bitmap1, - const wxBitmap& bitmap2 = wxNullBitmap, + const wxBitmapBundle& bitmap1, + const wxBitmapBundle& bitmap2 = wxNullBitmap, wxItemKind kind = wxITEM_NORMAL, wxObject *clientData = NULL, const wxString& shortHelpString = wxEmptyString, diff --git a/include/wx/gtk1/toolbar.h b/include/wx/gtk1/toolbar.h index ab23653354..fdaf1b7786 100644 --- a/include/wx/gtk1/toolbar.h +++ b/include/wx/gtk1/toolbar.h @@ -83,8 +83,8 @@ protected: virtual wxToolBarToolBase *CreateTool(int id, const wxString& label, - const wxBitmap& bitmap1, - const wxBitmap& bitmap2, + const wxBitmapBundle& bitmap1, + const wxBitmapBundle& bitmap2, wxItemKind kind, wxObject *clientData, const wxString& shortHelpString, diff --git a/include/wx/motif/toolbar.h b/include/wx/motif/toolbar.h index 5f4d3da9bd..1374745ca3 100644 --- a/include/wx/motif/toolbar.h +++ b/include/wx/motif/toolbar.h @@ -62,8 +62,8 @@ private: virtual wxToolBarToolBase *CreateTool(int id, const wxString& label, - const wxBitmap& bmpNormal, - const wxBitmap& bmpDisabled, + const wxBitmapBundle& bmpNormal, + const wxBitmapBundle& bmpDisabled, wxItemKind kind, wxObject *clientData, const wxString& shortHelp, diff --git a/include/wx/msw/toolbar.h b/include/wx/msw/toolbar.h index f01cd4e856..a86a4742f0 100644 --- a/include/wx/msw/toolbar.h +++ b/include/wx/msw/toolbar.h @@ -53,8 +53,8 @@ public: virtual void SetRows(int nRows) wxOVERRIDE; - virtual void SetToolNormalBitmap(int id, const wxBitmap& bitmap) wxOVERRIDE; - virtual void SetToolDisabledBitmap(int id, const wxBitmap& bitmap) wxOVERRIDE; + virtual void SetToolNormalBitmap(int id, const wxBitmapBundle& bitmap) wxOVERRIDE; + virtual void SetToolDisabledBitmap(int id, const wxBitmapBundle& bitmap) wxOVERRIDE; virtual void SetToolPacking(int packing) wxOVERRIDE; @@ -89,8 +89,8 @@ public: virtual wxToolBarToolBase *CreateTool(int id, const wxString& label, - const wxBitmap& bmpNormal, - const wxBitmap& bmpDisabled = wxNullBitmap, + const wxBitmapBundle& bmpNormal, + const wxBitmapBundle& bmpDisabled = wxNullBitmap, wxItemKind kind = wxITEM_NORMAL, wxObject *clientData = NULL, const wxString& shortHelp = wxEmptyString, diff --git a/include/wx/osx/cocoa/private.h b/include/wx/osx/cocoa/private.h index 1538f6d5d0..c00166e1ae 100644 --- a/include/wx/osx/cocoa/private.h +++ b/include/wx/osx/cocoa/private.h @@ -23,6 +23,8 @@ // shared between Cocoa and Carbon // +#include "wx/bmpbndl.h" + // bring in theming types without pulling in the headers #if wxUSE_GUI @@ -42,7 +44,7 @@ WX_NSImage WXDLLIMPEXP_CORE wxOSXGetNSImageFromIconRef( WXHICON iconref ); WX_NSImage WXDLLIMPEXP_CORE wxOSXGetNSImageFromCFURL( CFURLRef urlref ); WX_NSImage WXDLLIMPEXP_CORE wxOSXGetIconForType(OSType type ); void WXDLLIMPEXP_CORE wxOSXSetImageSize(WX_NSImage image, CGFloat width, CGFloat height); -wxBitmap WXDLLIMPEXP_CORE wxOSXCreateSystemBitmap(const wxString& id, const wxString &client, const wxSize& size); +wxBitmapBundle WXDLLIMPEXP_CORE wxOSXCreateSystemBitmapBundle(const wxString& id, const wxString &client, const wxSize& size); WXWindow WXDLLIMPEXP_CORE wxOSXGetMainWindow(); WXWindow WXDLLIMPEXP_CORE wxOSXGetKeyWindow(); WXImage WXDLLIMPEXP_CORE wxOSXGetNSImageFromNSCursor(const WXHCURSOR cursor); diff --git a/include/wx/osx/iphone/private.h b/include/wx/osx/iphone/private.h index 42a4557879..1acf0dd175 100644 --- a/include/wx/osx/iphone/private.h +++ b/include/wx/osx/iphone/private.h @@ -24,6 +24,8 @@ #if wxUSE_GUI +#include "wx/bmpbndl.h" + typedef CGRect WXRect; OSStatus WXDLLIMPEXP_CORE wxMacDrawCGImage( @@ -32,7 +34,7 @@ OSStatus WXDLLIMPEXP_CORE wxMacDrawCGImage( CGImageRef inImage) ; WX_UIImage WXDLLIMPEXP_CORE wxOSXGetUIImageFromCGImage( CGImageRef image ); -wxBitmap WXDLLIMPEXP_CORE wxOSXCreateSystemBitmap(const wxString& id, const wxString &client, const wxSize& size); +wxBitmapBundle WXDLLIMPEXP_CORE wxOSXCreateSystemBitmapBundle(const wxString& id, const wxString &client, const wxSize& size); class WXDLLIMPEXP_CORE wxWidgetIPhoneImpl : public wxWidgetImpl { diff --git a/include/wx/osx/toolbar.h b/include/wx/osx/toolbar.h index 983d1ec49b..eb2ad41075 100644 --- a/include/wx/osx/toolbar.h +++ b/include/wx/osx/toolbar.h @@ -58,8 +58,9 @@ public: virtual void SetRows(int nRows) wxOVERRIDE; - virtual void SetToolNormalBitmap(int id, const wxBitmap& bitmap) wxOVERRIDE; - virtual void SetToolDisabledBitmap(int id, const wxBitmap& bitmap) wxOVERRIDE; + + virtual void SetToolNormalBitmap(int id, const wxBitmapBundle& bitmap) wxOVERRIDE; + virtual void SetToolDisabledBitmap(int id, const wxBitmapBundle& bitmap) wxOVERRIDE; #ifndef __WXOSX_IPHONE__ // Add all the buttons @@ -83,8 +84,8 @@ public: virtual wxToolBarToolBase *CreateTool(int id, const wxString& label, - const wxBitmap& bmpNormal, - const wxBitmap& bmpDisabled = wxNullBitmap, + const wxBitmapBundle& bmpNormal, + const wxBitmapBundle& bmpDisabled = wxNullBitmap, wxItemKind kind = wxITEM_NORMAL, wxObject *clientData = NULL, const wxString& shortHelp = wxEmptyString, diff --git a/include/wx/preferences.h b/include/wx/preferences.h index 40dac7a0bd..88c8138d50 100644 --- a/include/wx/preferences.h +++ b/include/wx/preferences.h @@ -15,6 +15,7 @@ #if wxUSE_PREFERENCES_EDITOR #include "wx/bitmap.h" +#include "wx/bmpbndl.h" #include "wx/vector.h" class WXDLLIMPEXP_FWD_CORE wxWindow; diff --git a/include/wx/private/bmpbndl.h b/include/wx/private/bmpbndl.h new file mode 100644 index 0000000000..6c25a51e62 --- /dev/null +++ b/include/wx/private/bmpbndl.h @@ -0,0 +1,28 @@ +/////////////////////////////////////////////////////////////////////////////// +// Name: wx/private/bmpbndl.h +// Purpose: wxBitmapBundleImpl declaration. +// Author: Vadim Zeitlin +// Created: 2021-09-22 +// Copyright: (c) 2021 Vadim Zeitlin +// Licence: wxWindows licence +/////////////////////////////////////////////////////////////////////////////// + +#ifndef _WX_PRIVATE_BMPBNDL_H_ +#define _WX_PRIVATE_BMPBNDL_H_ + +#include "wx/bmpbndl.h" + +#ifdef __WXOSX__ + +// this methods are wx-private, may change in the future + +WXImage WXDLLIMPEXP_CORE wxOSXGetImageFromBundle(const wxBitmapBundle& bundle); +wxBitmapBundle WXDLLIMPEXP_CORE wxOSXMakeBundleFromImage(WXImage image); +WXImage WXDLLIMPEXP_CORE wxOSXImageFromBitmap(const wxBitmap& bmp); +#if wxOSX_USE_COCOA +void WXDLLIMPEXP_CORE wxOSXAddBitmapToImage(WXImage image, const wxBitmap& bmp); +#endif + +#endif + +#endif // _WX_PRIVATE_BMPBNDL_H_ diff --git a/include/wx/qt/toolbar.h b/include/wx/qt/toolbar.h index 7ae8a8af4a..d2de81bf70 100644 --- a/include/wx/qt/toolbar.h +++ b/include/wx/qt/toolbar.h @@ -43,15 +43,15 @@ public: virtual void SetWindowStyleFlag( long style ) wxOVERRIDE; virtual void SetToolShortHelp(int id, const wxString& helpString) wxOVERRIDE; - virtual void SetToolNormalBitmap(int id, const wxBitmap& bitmap) wxOVERRIDE; - virtual void SetToolDisabledBitmap(int id, const wxBitmap& bitmap) wxOVERRIDE; + virtual void SetToolNormalBitmap(int id, const wxBitmapBundle& bitmap) wxOVERRIDE; + virtual void SetToolDisabledBitmap(int id, const wxBitmapBundle& bitmap) wxOVERRIDE; virtual bool Realize() wxOVERRIDE; virtual wxToolBarToolBase *CreateTool(int toolid, const wxString& label, - const wxBitmap& bmpNormal, - const wxBitmap& bmpDisabled = wxNullBitmap, + const wxBitmapBundle& bmpNormal, + const wxBitmapBundle& bmpDisabled = wxNullBitmap, wxItemKind kind = wxITEM_NORMAL, wxObject *clientData = NULL, const wxString& shortHelp = wxEmptyString, diff --git a/include/wx/tbarbase.h b/include/wx/tbarbase.h index a4b380d6ee..c489d4c068 100644 --- a/include/wx/tbarbase.h +++ b/include/wx/tbarbase.h @@ -20,6 +20,7 @@ #if wxUSE_TOOLBAR #include "wx/bitmap.h" +#include "wx/bmpbndl.h" #include "wx/list.h" #include "wx/control.h" @@ -63,8 +64,8 @@ public: wxToolBarToolBase(wxToolBarBase *tbar = NULL, int toolid = wxID_SEPARATOR, const wxString& label = wxEmptyString, - const wxBitmap& bmpNormal = wxNullBitmap, - const wxBitmap& bmpDisabled = wxNullBitmap, + const wxBitmapBundle& bmpNormal = wxNullBitmap, + const wxBitmapBundle& bmpDisabled = wxNullBitmap, wxItemKind kind = wxITEM_NORMAL, wxObject *clientData = NULL, const wxString& shortHelpString = wxEmptyString, @@ -145,11 +146,13 @@ public: { return m_kind == wxITEM_CHECK || m_kind == wxITEM_RADIO; } // attributes - const wxBitmap& GetNormalBitmap() const { return m_bmpNormal; } - const wxBitmap& GetDisabledBitmap() const { return m_bmpDisabled; } + wxBitmap GetNormalBitmap(const wxSize& size = wxDefaultSize) const + { return m_bmpNormal.GetBitmap(size); } + wxBitmap GetDisabledBitmap(const wxSize& size = wxDefaultSize) const + { return m_bmpDisabled.GetBitmap(size); } - const wxBitmap& GetBitmap() const - { return IsEnabled() ? GetNormalBitmap() : GetDisabledBitmap(); } + wxBitmap GetBitmap(const wxSize& size = wxDefaultSize) const + { return IsEnabled() ? GetNormalBitmap(size) : GetDisabledBitmap(size); } const wxString& GetLabel() const { return m_label; } @@ -177,8 +180,8 @@ public: void Toggle() { Toggle(!IsToggled()); } - void SetNormalBitmap(const wxBitmap& bmp) { m_bmpNormal = bmp; } - void SetDisabledBitmap(const wxBitmap& bmp) { m_bmpDisabled = bmp; } + void SetNormalBitmap(const wxBitmapBundle& bmp) { m_bmpNormal = bmp; } + void SetDisabledBitmap(const wxBitmapBundle& bmp) { m_bmpDisabled = bmp; } virtual void SetLabel(const wxString& label) { m_label = label; } @@ -251,8 +254,8 @@ protected: bool m_enabled; // normal and disabled bitmaps for the tool, both can be invalid - wxBitmap m_bmpNormal; - wxBitmap m_bmpDisabled; + wxBitmapBundle m_bmpNormal; + wxBitmapBundle m_bmpDisabled; // the button label wxString m_label; @@ -290,8 +293,8 @@ public: // is created and used as the disabled image. wxToolBarToolBase *AddTool(int toolid, const wxString& label, - const wxBitmap& bitmap, - const wxBitmap& bmpDisabled, + const wxBitmapBundle& bitmap, + const wxBitmapBundle& bmpDisabled, wxItemKind kind = wxITEM_NORMAL, const wxString& shortHelp = wxEmptyString, const wxString& longHelp = wxEmptyString, @@ -304,7 +307,7 @@ public: // the most common AddTool() version wxToolBarToolBase *AddTool(int toolid, const wxString& label, - const wxBitmap& bitmap, + const wxBitmapBundle& bitmap, const wxString& shortHelp = wxEmptyString, wxItemKind kind = wxITEM_NORMAL) { @@ -314,8 +317,8 @@ public: // add a check tool, i.e. a tool which can be toggled wxToolBarToolBase *AddCheckTool(int toolid, const wxString& label, - const wxBitmap& bitmap, - const wxBitmap& bmpDisabled = wxNullBitmap, + const wxBitmapBundle& bitmap, + const wxBitmapBundle& bmpDisabled = wxNullBitmap, const wxString& shortHelp = wxEmptyString, const wxString& longHelp = wxEmptyString, wxObject *clientData = NULL) @@ -328,8 +331,8 @@ public: // other toggled radio tools in the same group when it happens wxToolBarToolBase *AddRadioTool(int toolid, const wxString& label, - const wxBitmap& bitmap, - const wxBitmap& bmpDisabled = wxNullBitmap, + const wxBitmapBundle& bitmap, + const wxBitmapBundle& bmpDisabled = wxNullBitmap, const wxString& shortHelp = wxEmptyString, const wxString& longHelp = wxEmptyString, wxObject *clientData = NULL) @@ -346,8 +349,8 @@ public: size_t pos, int toolid, const wxString& label, - const wxBitmap& bitmap, - const wxBitmap& bmpDisabled = wxNullBitmap, + const wxBitmapBundle& bitmap, + const wxBitmapBundle& bmpDisabled = wxNullBitmap, wxItemKind kind = wxITEM_NORMAL, const wxString& shortHelp = wxEmptyString, const wxString& longHelp = wxEmptyString, @@ -427,9 +430,9 @@ public: virtual wxString GetToolLongHelp(int toolid) const; virtual void SetToolNormalBitmap(int WXUNUSED(id), - const wxBitmap& WXUNUSED(bitmap)) {} + const wxBitmapBundle& WXUNUSED(bitmap)) {} virtual void SetToolDisabledBitmap(int WXUNUSED(id), - const wxBitmap& WXUNUSED(bitmap)) {} + const wxBitmapBundle& WXUNUSED(bitmap)) {} // margins/packing/separation @@ -576,8 +579,8 @@ public: // ------------------------- virtual wxToolBarToolBase *CreateTool(int toolid, const wxString& label, - const wxBitmap& bmpNormal, - const wxBitmap& bmpDisabled = wxNullBitmap, + const wxBitmapBundle& bmpNormal, + const wxBitmapBundle& bmpDisabled = wxNullBitmap, wxItemKind kind = wxITEM_NORMAL, wxObject *clientData = NULL, const wxString& shortHelp = wxEmptyString, @@ -625,8 +628,8 @@ protected: ( int toolid, const wxString& label, - const wxBitmap& bitmap, - const wxBitmap& bmpDisabled, + const wxBitmapBundle& bitmap, + const wxBitmapBundle& bmpDisabled, wxItemKind kind, const wxString& shortHelp = wxEmptyString, const wxString& longHelp = wxEmptyString, diff --git a/include/wx/univ/toolbar.h b/include/wx/univ/toolbar.h index 22ab99dd1c..3d8bcd7238 100644 --- a/include/wx/univ/toolbar.h +++ b/include/wx/univ/toolbar.h @@ -91,8 +91,8 @@ protected: virtual wxToolBarToolBase *CreateTool(int id, const wxString& label, - const wxBitmap& bmpNormal, - const wxBitmap& bmpDisabled, + const wxBitmapBundle& bmpNormal, + const wxBitmapBundle& bmpDisabled, wxItemKind kind, wxObject *clientData, const wxString& shortHelp, diff --git a/include/wx/wx.h b/include/wx/wx.h index 9f6a42cb13..f672167d60 100644 --- a/include/wx/wx.h +++ b/include/wx/wx.h @@ -44,6 +44,7 @@ #include "wx/gdiobj.h" #include "wx/region.h" #include "wx/bitmap.h" +#include "wx/bmpbndl.h" #include "wx/image.h" #include "wx/colour.h" #include "wx/font.h" diff --git a/interface/wx/artprov.h b/interface/wx/artprov.h index 260f61d218..95df55859f 100644 --- a/interface/wx/artprov.h +++ b/interface/wx/artprov.h @@ -110,13 +110,21 @@ const char* wxART_EDIT; class MyProvider : public wxArtProvider { protected: + // Override this method to return a bundle containing the required + // bitmap in all available sizes. + wxBitmapBundle CreateBitmapBundle(const wxArtID& id, + const wxArtClient& client, + const wxSize& size) override; + + // If all bitmaps are available in a single size only, it may be + // simpler to override just this one. wxBitmap CreateBitmap(const wxArtID& id, const wxArtClient& client, - const wxSize& size); + const wxSize& size) override; // optionally override this one as well wxIconBundle CreateIconBundle(const wxArtID& id, - const wxArtClient& client); + const wxArtClient& client) override; { ... } }; ... @@ -128,8 +136,8 @@ const char* wxART_EDIT; and supplying icon bundles that contain different bitmap sizes. There's another way of taking advantage of this class: you can use it in your - code and use platform native icons as provided by wxArtProvider::GetBitmap or - wxArtProvider::GetIcon. + code and use platform native icons as provided by wxArtProvider::GetBitmapBundle + or wxArtProvider::GetIcon. @section artprovider_identify Identifying art resources @@ -272,6 +280,9 @@ public: /** Query registered providers for bitmap with given ID. + Note that applications using wxWidgets 3.1.6 or later should prefer + calling GetBitmapBundle(). + @param id wxArtID unique identifier of the bitmap. @param client @@ -286,6 +297,28 @@ public: const wxArtClient& client = wxART_OTHER, const wxSize& size = wxDefaultSize); + /** + Query registered providers for a bundle of bitmaps with given ID. + + @since 3.1.6 + + @param id + wxArtID unique identifier of the bitmap. + @param client + wxArtClient identifier of the client (i.e. who is asking for the bitmap). + @param size + Default size for the returned bundle. + + @return If any of the registered providers recognizes the ID in its + CreateBitmapBundle(), this bundle is returned. Otherwise, if any of + providers returns a valid bitmap from CreateBitmap(), the bundle + containing only this bitmap is returned. Otherwise, an empty bundle + is returned. + */ + static wxBitmapBundle GetBitmapBundle(const wxArtID& id, + const wxArtClient& client = wxART_OTHER, + const wxSize& size = wxDefaultSize); + /** Same as wxArtProvider::GetBitmap, but return a wxIcon object (or ::wxNullIcon on failure). @@ -404,8 +437,13 @@ public: protected: /** - Derived art provider classes must override this method to create requested art - resource. Note that returned bitmaps are cached by wxArtProvider and it is + Derived art provider classes may override this method to create requested art + resource. + + For bitmaps available in more than one size, CreateBitmapBundle() + should be overridden instead. + + Note that returned bitmaps are cached by wxArtProvider and it is therefore not necessary to optimize CreateBitmap() for speed (e.g. you may create wxBitmap objects from XPMs here). @@ -429,6 +467,29 @@ protected: const wxArtClient& client, const wxSize& size); + /** + Override this method to create the requested art resources available in + more than one size. + + Unlike CreateBitmap(), this method can be overridden to return the same + bitmap in several (or all, if wxBitmapBundle::FromSVG() is used) sizes + at once, which will allow selecting the size best suited for the + current display resolution automatically. + + @param id + wxArtID unique identifier of the bitmap. + @param client + wxArtClient identifier of the client (i.e. who is asking for the bitmap). + This only serves as a hint. + @param size + Default size of the bitmaps returned by the bundle. + + @since 3.1.6 + */ + virtual wxBitmapBundle CreateBitmapBundle(const wxArtID& id, + const wxArtClient& client, + const wxSize& size); + /** This method is similar to CreateBitmap() but can be used when a bitmap (or an icon) exists in several sizes. diff --git a/interface/wx/bmpbndl.h b/interface/wx/bmpbndl.h new file mode 100644 index 0000000000..9cc2194e1a --- /dev/null +++ b/interface/wx/bmpbndl.h @@ -0,0 +1,341 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: wx/bmpbndl.h +// Purpose: Interface of wxBitmapBundle. +// Author: Vadim Zeitlin +// Created: 2021-09-24 +// Copyright: (c) 2021 Vadim Zeitlin +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +/** + Contains representations of the same bitmap in different resolutions. + + This class generalizes wxBitmap for applications supporting multiple DPIs + and allows to operate with multiple versions of the same bitmap, in the + sizes appropriate to the currently used display resolution, as a single + unit. Notably, an entire wxBitmapBundle can be passed to functions such as + wxToolBar::AddTool() to allow toolbar to select the best available bitmap + to be shown. + + Objects of this class are typically created by the application and then + passed to wxWidgets functions, but not used by the application itself. + Currently bitmap bundles can be created from: + + - A vector of bitmaps, of any provenance. + - A single wxBitmap or wxImage for backwards compatibility. + + More functions for creating bitmap bundles will be added in the future. + + Objects of wxBitmapBundle class have value-like semantics, i.e. they can be + copied around freely (and cheaply) and don't need to be allocated on the + heap. However they usually are created using static factory functions + (known as "pseudo-constructors") such as FromBitmaps() instead of using the + real constructors. + + Example of using this class to initialize a toolbar in a frame constructor: + @code + MyFrame::MyFrame() + : wxFrame(nullptr, wxID_ANY, "My frame") + { + ... + wxToolBar* toolBar = CreateToolBar(); + + wxVector bitmaps; + bitmaps.push_back(wxBITMAP_PNG(open_32x32)); + bitmaps.push_back(wxBITMAP_PNG(open_48x48)); + bitmaps.push_back(wxBITMAP_PNG(open_64x64)); + + toolBar->AddTool(wxID_OPEN, wxBitmapBundle::FromBitmaps(bitmaps)); + } + @endcode + + The code shown above will use 32 pixel bitmap in normal DPI, 64 pixel + bitmap in "high DPI", i.e. pixel-doubling or 200% resolution, and 48 pixel + bitmap in 150% resolution. For all the other resolutions, the best matching + bitmap will be created dynamically from the best available match, e.g. for + 175% resolution, 64 pixel bitmap will be rescaled to 56 pixels. + + Of course, this code relies on actually having the resources with the + corresponding names (i.e. @c open_NxN) in MSW .rc file or Mac application + bundle and @c open_NxN_png arrays being defined in the program code, e.g. + by including a file generated with @c bin2c (see wxBITMAP_PNG_FROM_DATA()), + on the other platforms. + + For the platforms with resources support, you can also create the bundle + from the bitmaps defined in the resources, which has the advantage of not + having to explicitly list all the bitmaps, e.g. the code above becomes + @code + #ifdef wxHAS_IMAGE_RESOURCES + toolBar->AddTool(wxID_OPEN, wxBitmapBundle::FromResources("open")); + #else + ... same code as shown above ... + #endif + @endcode + and will load all resources called @c open, @c open_2x, @c open_1_5x etc + (at least the first one of them must be available). See also + wxBITMAP_BUNDLE_2() macro which can avoid the need to check for + wxHAS_IMAGE_RESOURCES explicitly in the code in a common case of having + only 2 embedded resources (for standard and high DPI). + + Also note that the existing code using wxBitmap is compatible with the + functions taking wxBitmapBundle in wxWidgets 3.1.6 and later because + bitmaps are implicitly convertible to the objects of this class, so just + passing wxBitmap to the functions taking wxBitmapBundle continues to work + and if high resolution versions of bitmap are not (yet) available for the + other toolbar tools, single bitmaps can continue to be used instead. + + @library{wxcore} + @category{gdi} + + @since 3.1.6 +*/ +class wxBitmapBundle +{ +public: + /** + Default constructor constructs an empty bundle. + + An empty bundle can't be used for anything, but can be assigned + something else later. + */ + wxBitmapBundle(); + + /** + Conversion constructor from a single bitmap. + + This constructor does the same thing as FromBitmap() and only exists + for interoperability with the existing code using wxBitmap. + */ + wxBitmapBundle(const wxBitmap& bitmap); + + /** + Conversion constructor from a single image. + + Similarly to the constructor from wxBitmap, this constructor only + exists for interoperability with the existing code using wxImage and + can be replaced with more readable FromImage() in the new code. + */ + wxBitmapBundle(const wxImage& image); + + /** + Copy constructor creates a copy of another bundle. + */ + wxBitmapBundle(const wxBitmapBundle& other); + + /** + Assignment operator makes this bundle a copy of another bundle. + */ + wxBitmapBundle& operator=(const wxBitmapBundle& other); + + + /** + Create a bundle from the given collection of bitmaps. + + If the @a bitmaps vector is empty, an invalid, empty bundle is + returned, otherwise initialize the bundle with all the bitmaps in this + vector which must be themselves valid. + */ + static wxBitmapBundle FromBitmaps(const wxVector& bitmaps); + + /// @overload + static wxBitmapBundle FromBitmaps(const wxBitmap& bitmap1, + const wxBitmap& bitmap2); + + /** + Create a bundle from a single bitmap. + + This is only useful for compatibility with the existing code using + wxBitmap. + + If @a bitmap is invalid, empty bundle is returned. + */ + static wxBitmapBundle FromBitmap(const wxBitmap& bitmap); + + /** + Create a bundle from a single image. + + This is only useful for compatibility with the existing code using + wxImage. + + If @a image is invalid, empty bundle is returned. + */ + static wxBitmapBundle FromImage(const wxImage& image); + + /** + Create a bundle from a custom bitmap bundle implementation. + + This function can be used to create bundles implementing custom logic + for creating the bitmaps, e.g. creating them on the fly rather than + using predefined bitmaps. + + See wxBitmapBundleImpl. + + @param impl A valid, i.e. non-null, pointer. This function takes + ownership of it, so the caller must @e not call DecRef() on it. + */ + static wxBitmapBundle FromImpl(wxBitmapBundleImpl* impl); + + /** + Create a bundle from the bitmaps in the application resources. + + This function can only be used on the platforms supporting storing + bitmaps in resources, and currently only works under MSW and simply + returns an empty bundle on the other platforms. + + Under MSW, for this function to create a valid bundle, you must have @c + RCDATA resource with the given @a name in your application resource + file (with the extension @c .rc) containing PNG file, and any other + resources using @a name as prefix and suffix with the scale, e.g. "_2x" + or "_1_5x" (for 150% DPI) will be also loaded as part of the bundle. + */ + static wxBitmapBundle FromResources(const wxString& name); + + /** + Create a bundle from the SVG image. + + Please note that the current implementation uses NanoSVG library + (https://github.com/memononen/nanosvg) for parsing and rasterizing SVG + images which imposes the following limitations: + + - Text elements are not supported at all. + - SVG 1.1 filters are not supported. + + These limitations will be relaxed in the future wxWidgets versions. + + Please also note that this method is only available in the ports + providing raw bitmap access via wxPixelData. This is the case for all + tier-1 ports, but not all of them, check if @c wxHAS_SVG is defined + before using this method if for maximum portability. + + @param data This data may, or not, have the XML document preamble, i.e. + it can start either with @c "AddTool(wxID_OPEN, wxBitmapBundle::FromImpl(new MyCustomBitmapBundleImpl()); + @endcode + + Full (but still very simple) example of using it can be found in the + toolbar sample code. + + @library{wxcore} + @category{gdi} + + @since 3.1.6 +*/ +class wxBitmapBundleImpl : public wxRefCounter +{ +public: + /** + Return the size of the bitmaps represented by this bundle in the default + DPI. + + Must always return a valid size. + */ + virtual wxSize GetDefaultSize() const = 0; + + /** + Retrieve the bitmap of exactly the given size. + + Note that this function is non-const because it may generate the bitmap + on demand and cache it. + */ + virtual wxBitmap GetBitmap(const wxSize size) = 0; +}; + +/** + Creates a wxBitmapBundle from resources on the platforms supporting them or + from two embedded bitmaps otherwise. + + This macro use wxBitmapBundle::FromResources() with the provide @a name, + which must be an @e identifier and not a string, i.e. used without quotes, + on the platforms where it works and wxBitmapBundle::FromBitmaps() with @c + name_png and @c name_2x_png arrays containing PNG data elsewhere. + + Using it allows to avoid using preprocessor checks in the common case when + just two bitmaps (for standard and high DPI) are embedded in the + application code. Note that all bitmaps defined in the resources, even if + there are more than 2 of them. + + Example of use: + @code + toolBar->AddTool(wxID_OPEN, wxBITMAP_BUNDLE_2(open)); + @endcode + + @header{wx/bmpbndl.h} + + @since 3.1.6 + */ +#define wxBITMAP_BUNDLE_2(name) diff --git a/interface/wx/toolbar.h b/interface/wx/toolbar.h index 3cdb064c73..35474cf509 100644 --- a/interface/wx/toolbar.h +++ b/interface/wx/toolbar.h @@ -83,8 +83,8 @@ public: wxToolBarToolBase(wxToolBarBase *tbar = NULL, int toolid = wxID_SEPARATOR, const wxString& label = wxEmptyString, - const wxBitmap& bmpNormal = wxNullBitmap, - const wxBitmap& bmpDisabled = wxNullBitmap, + const wxBitmapBundle& bmpNormal = wxNullBitmap, + const wxBitmapBundle& bmpDisabled = wxNullBitmap, wxItemKind kind = wxITEM_NORMAL, wxObject *clientData = NULL, const wxString& shortHelpString = wxEmptyString, @@ -112,10 +112,10 @@ public: bool IsToggled() const; bool CanBeToggled() const; - const wxBitmap& GetNormalBitmap() const; - const wxBitmap& GetDisabledBitmap() const; + wxBitmap GetNormalBitmap() const; + wxBitmap GetDisabledBitmap() const; - const wxBitmap& GetBitmap() const; + wxBitmap GetBitmap() const; const wxString& GetLabel() const; const wxString& GetShortHelp() const; @@ -129,8 +129,8 @@ public: bool SetShortHelp(const wxString& help); bool SetLongHelp(const wxString& help); void Toggle(); - void SetNormalBitmap(const wxBitmap& bmp); - void SetDisabledBitmap(const wxBitmap& bmp); + void SetNormalBitmap(const wxBitmapBundle& bmp); + void SetDisabledBitmap(const wxBitmapBundle& bmp); void SetLabel(const wxString& label); void SetClientData(wxObject *clientData); @@ -318,8 +318,8 @@ public: @see AddTool() */ wxToolBarToolBase* AddCheckTool(int toolId, const wxString& label, - const wxBitmap& bitmap1, - const wxBitmap& bmpDisabled = wxNullBitmap, + const wxBitmapBundle& bitmap1, + const wxBitmapBundle& bmpDisabled = wxNullBitmap, const wxString& shortHelp = wxEmptyString, const wxString& longHelp = wxEmptyString, wxObject* clientData = NULL); @@ -354,8 +354,8 @@ public: @see AddTool() */ wxToolBarToolBase* AddRadioTool(int toolId, const wxString& label, - const wxBitmap& bitmap1, - const wxBitmap& bmpDisabled = wxNullBitmap, + const wxBitmapBundle& bitmap1, + const wxBitmapBundle& bmpDisabled = wxNullBitmap, const wxString& shortHelp = wxEmptyString, const wxString& longHelp = wxEmptyString, wxObject* clientData = NULL); @@ -436,7 +436,7 @@ public: InsertTool(), DeleteTool(), Realize(), SetDropdownMenu() */ wxToolBarToolBase* AddTool(int toolId, const wxString& label, - const wxBitmap& bitmap, + const wxBitmapBundle& bitmap, const wxString& shortHelp = wxEmptyString, wxItemKind kind = wxITEM_NORMAL); @@ -478,8 +478,8 @@ public: InsertTool(), DeleteTool(), Realize(), SetDropdownMenu() */ wxToolBarToolBase* AddTool(int toolId, const wxString& label, - const wxBitmap& bitmap, - const wxBitmap& bmpDisabled, + const wxBitmapBundle& bitmap, + const wxBitmapBundle& bmpDisabled, wxItemKind kind = wxITEM_NORMAL, const wxString& shortHelp = wxEmptyString, const wxString& longHelp = wxEmptyString, @@ -727,8 +727,8 @@ public: wxToolBarToolBase* InsertTool( size_t pos, int toolId, const wxString& label, - const wxBitmap& bitmap, - const wxBitmap& bmpDisabled = wxNullBitmap, + const wxBitmapBundle& bitmap, + const wxBitmapBundle& bmpDisabled = wxNullBitmap, wxItemKind kind = wxITEM_NORMAL, const wxString& shortHelp = wxEmptyString, const wxString& longHelp = wxEmptyString, @@ -860,6 +860,11 @@ public: Sets the default size of each tool bitmap. The default bitmap size is 16 by 15 pixels. + Note that @a size does @e not need to be multiplied by the + DPI-dependent factor even under MSW, where it would normally be + necessary, as the toolbar adjusts this size to the current DPI + automatically. + @param size The size of the bitmaps in the toolbar. @@ -895,7 +900,7 @@ public: have no effect on those platforms. */ - virtual void SetToolDisabledBitmap(int id, const wxBitmap& bitmap); + virtual void SetToolDisabledBitmap(int id, const wxBitmapBundle& bitmap); /** Sets the long help for the given tool. @@ -921,7 +926,7 @@ public: @param bitmap Bitmap to use for normals tools. */ - virtual void SetToolNormalBitmap(int id, const wxBitmap& bitmap); + virtual void SetToolNormalBitmap(int id, const wxBitmapBundle& bitmap); /** Sets the value used for spacing tools. The default value is 1. @@ -982,8 +987,8 @@ public: */ virtual wxToolBarToolBase *CreateTool(int toolId, const wxString& label, - const wxBitmap& bmpNormal, - const wxBitmap& bmpDisabled = wxNullBitmap, + const wxBitmapBundle& bmpNormal, + const wxBitmapBundle& bmpDisabled = wxNullBitmap, wxItemKind kind = wxITEM_NORMAL, wxObject *clientData = NULL, const wxString& shortHelp = wxEmptyString, diff --git a/samples/toolbar/toolbar.cpp b/samples/toolbar/toolbar.cpp index f636352703..30e7cd529d 100644 --- a/samples/toolbar/toolbar.cpp +++ b/samples/toolbar/toolbar.cpp @@ -25,6 +25,7 @@ #endif #include "wx/toolbar.h" +#include "wx/bmpbndl.h" #include "wx/log.h" #include "wx/image.h" #include "wx/filedlg.h" @@ -72,6 +73,18 @@ #include "bitmaps/help_2x_png.c" #endif // !wxHAS_IMAGE_RESOURCES +// Real SVGs would typically be loaded from files, but to keep things as simple +// as possible here, we embed this one directly in the program text. +static const char svg_data[] = +"" +"" +"" +"" +"" +"" +"" +; + enum Positions { TOOLBAR_LEFT, @@ -95,12 +108,7 @@ public: class MyFrame: public wxFrame { public: - MyFrame(wxFrame *parent, - wxWindowID id = wxID_ANY, - const wxString& title = "wxToolBar Sample", - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = wxDEFAULT_FRAME_STYLE|wxCLIP_CHILDREN); + MyFrame(); virtual ~MyFrame(); void PopulateToolbar(wxToolBarBase* toolBar); @@ -110,7 +118,6 @@ public: void OnAbout(wxCommandEvent& event); void OnSize(wxSizeEvent& event); - void OnDPIChanged(wxDPIChangedEvent& event); void OnToggleToolbar(wxCommandEvent& event); void OnToggleAnotherToolbar(wxCommandEvent& event); @@ -236,15 +243,14 @@ enum // event tables // ---------------------------------------------------------------------------- -// Notice that wxID_HELP will be processed for the 'About' menu and the toolbar +// Notice that wxID_ABOUT will be processed for the 'About' menu and the toolbar // help button. wxBEGIN_EVENT_TABLE(MyFrame, wxFrame) EVT_SIZE(MyFrame::OnSize) - EVT_DPI_CHANGED(MyFrame::OnDPIChanged) EVT_MENU(wxID_EXIT, MyFrame::OnQuit) - EVT_MENU(wxID_HELP, MyFrame::OnAbout) + EVT_MENU(wxID_ABOUT, MyFrame::OnAbout) EVT_MENU(IDM_TOOLBAR_TOGGLE_TOOLBAR, MyFrame::OnToggleToolbar) EVT_MENU(IDM_TOOLBAR_TOGGLE_ANOTHER_TOOLBAR, MyFrame::OnToggleAnotherToolbar) @@ -313,9 +319,7 @@ bool MyApp::OnInit() wxImage::AddHandler(new wxPNGHandler); // Create the main frame window - MyFrame* frame = new MyFrame((wxFrame *) NULL, wxID_ANY, - "wxToolBar Sample", - wxPoint(100, 100), wxDefaultSize); + MyFrame* frame = new MyFrame(); frame->Show(true); @@ -386,48 +390,46 @@ void MyFrame::PopulateToolbar(wxToolBarBase* toolBar) Tool_paste, Tool_print, Tool_help, + Tool_about, Tool_Max }; - wxBitmap toolBarBitmaps[Tool_Max]; + wxBitmapBundle toolBarBitmaps[Tool_Max]; - if ( GetDPIScaleFactor() >= 1.5 ) - { - toolBarBitmaps[Tool_new ] = wxBITMAP_PNG(new_2x ); - toolBarBitmaps[Tool_open ] = wxBITMAP_PNG(open_2x ); - toolBarBitmaps[Tool_save ] = wxBITMAP_PNG(save_2x ); - toolBarBitmaps[Tool_copy ] = wxBITMAP_PNG(copy_2x ); - toolBarBitmaps[Tool_cut ] = wxBITMAP_PNG(cut_2x ); - toolBarBitmaps[Tool_paste] = wxBITMAP_PNG(paste_2x); - toolBarBitmaps[Tool_print] = wxBITMAP_PNG(print_2x); - toolBarBitmaps[Tool_help ] = wxBITMAP_PNG(help_2x ); - } - else - { - toolBarBitmaps[Tool_new ] = wxBITMAP_PNG(new ); - toolBarBitmaps[Tool_open ] = wxBITMAP_PNG(open ); - toolBarBitmaps[Tool_save ] = wxBITMAP_PNG(save ); - toolBarBitmaps[Tool_copy ] = wxBITMAP_PNG(copy ); - toolBarBitmaps[Tool_cut ] = wxBITMAP_PNG(cut ); - toolBarBitmaps[Tool_paste] = wxBITMAP_PNG(paste); - toolBarBitmaps[Tool_print] = wxBITMAP_PNG(print); - toolBarBitmaps[Tool_help ] = wxBITMAP_PNG(help ); - } + // Note that to use wxBITMAP_BUNDLE_2() macro it is necessary to + // + // 1. Have resources (either RT_RCDATA under MSW or files in the app + // bundle resources subdirectory under Mac) with this name. + // + // 2. Have name_png and name_2x_png arrays defined under the other + // platforms (as is done in this sample by including the corresponding + // *_png.c files above). + toolBarBitmaps[Tool_new ] = wxBITMAP_BUNDLE_2(new ); + toolBarBitmaps[Tool_open ] = wxBITMAP_BUNDLE_2(open ); + toolBarBitmaps[Tool_save ] = wxBITMAP_BUNDLE_2(save ); + toolBarBitmaps[Tool_copy ] = wxBITMAP_BUNDLE_2(copy ); + toolBarBitmaps[Tool_cut ] = wxBITMAP_BUNDLE_2(cut ); + toolBarBitmaps[Tool_paste] = wxBITMAP_BUNDLE_2(paste); + toolBarBitmaps[Tool_print] = wxBITMAP_BUNDLE_2(print); + toolBarBitmaps[Tool_help ] = wxBITMAP_BUNDLE_2(help ); - int w = toolBarBitmaps[Tool_new].GetWidth(), - h = toolBarBitmaps[Tool_new].GetHeight(); + // Size of the bitmaps we use by default. + // + // Note that scaling it up by 2 is not something we would do in real + // application code, it is only done in the sample for testing of bigger + // bitmap sizes. + const wxSize sizeBitmap = toolBarBitmaps[Tool_new].GetDefaultSize() * + (m_smallToolbar ? 1 : 2); - if ( !m_smallToolbar ) - { - w *= 2; - h *= 2; +#ifdef wxHAS_SVG + // Use vector SVG image for this button for demonstration purposes. + toolBarBitmaps[Tool_about] = wxBitmapBundle::FromSVG(svg_data, sizeBitmap); +#endif // wxHAS_SVG - for ( size_t n = Tool_new; n < WXSIZEOF(toolBarBitmaps); n++ ) - { - toolBarBitmaps[n] = - wxBitmap(toolBarBitmaps[n].ConvertToImage().Scale(w, h)); - } - } + // Note that there is no need for FromDIP() here, wxMSW will adjust the + // size on its own and under the other platforms there is no need for + // scaling the coordinates anyhow. + toolBar->SetToolBitmapSize(sizeBitmap); toolBar->AddTool(wxID_NEW, "New", toolBarBitmaps[Tool_new], wxNullBitmap, wxITEM_DROPDOWN, @@ -468,15 +470,15 @@ void MyFrame::PopulateToolbar(wxToolBarBase* toolBar) if ( m_useCustomDisabled ) { - wxBitmap bmpDisabled(w, h); + wxBitmap bmpDisabled(sizeBitmap); { wxMemoryDC dc; dc.SelectObject(bmpDisabled); - dc.DrawBitmap(toolBarBitmaps[Tool_print], 0, 0); + dc.DrawBitmap(toolBarBitmaps[Tool_print].GetBitmap(sizeBitmap), 0, 0); wxPen pen(*wxRED, 5); dc.SetPen(pen); - dc.DrawLine(0, 0, w, h); + dc.DrawLine(0, 0, sizeBitmap.x, sizeBitmap.y); } toolBar->AddTool(wxID_PRINT, "Print", toolBarBitmaps[Tool_print], @@ -495,17 +497,65 @@ void MyFrame::PopulateToolbar(wxToolBarBase* toolBar) toolBar->AddStretchableSpace(); toolBar->AddTool(wxID_HELP, "Help", toolBarBitmaps[Tool_help], "Help button", wxITEM_CHECK); + toolBar->AddTool(wxID_ABOUT, "About", toolBarBitmaps[Tool_about], "About"); + if ( !m_pathBmp.empty() ) { - // create a tool with a custom bitmap for testing - wxImage img(m_pathBmp); - if ( img.IsOk() ) + wxImage image(m_pathBmp); + if ( image.IsOk() ) { - if ( img.GetWidth() > w && img.GetHeight() > h ) - img = img.GetSubImage(wxRect(0, 0, w, h)); + // create a custom bitmap bundle for testing + class MyCustomBitmapBundleImpl : public wxBitmapBundleImpl + { + public: + MyCustomBitmapBundleImpl(const wxImage& image, + const wxSize& sizeDef) + : m_image(image), + m_sizeDef(sizeDef) + { + } + + wxSize GetDefaultSize() const wxOVERRIDE + { + return m_sizeDef; + } + + wxBitmap GetBitmap(const wxSize size) wxOVERRIDE + { + // In this simple implementation we don't bother caching + // anything. + wxImage image = m_image; + if ( image.GetSize() != size ) + image.Rescale(size.x, size.y, wxIMAGE_QUALITY_HIGH); + + // This is required under MSW in order to be able to draw + // over the bitmap using wxDC. For full alpha support, + // wxGraphicsContext should be used. + if ( image.HasAlpha() ) + image.ClearAlpha(); + + wxBitmap bitmap(image); + + // This is the custom part: we show the size of the bitmap + // being used in the bitmap itself. + wxMemoryDC dc(bitmap); + dc.SetTextForeground(*wxRED); + dc.SetFont(wxFontInfo(wxSize(size.x/4, size.y/2)).Bold()); + dc.DrawText(wxString::Format("%d", size.y), size.x/4, size.y/4); + + return bitmap; + } + + private: + const wxImage m_image; + const wxSize m_sizeDef; + }; + + wxBitmapBundleImpl* const + impl = new MyCustomBitmapBundleImpl(image, sizeBitmap); toolBar->AddSeparator(); - toolBar->AddTool(wxID_ANY, "Custom", img); + toolBar->AddTool(wxID_ANY, "Custom", wxBitmapBundle::FromImpl(impl)); } } @@ -522,13 +572,8 @@ void MyFrame::PopulateToolbar(wxToolBarBase* toolBar) // ---------------------------------------------------------------------------- // Define my frame constructor -MyFrame::MyFrame(wxFrame* parent, - wxWindowID id, - const wxString& title, - const wxPoint& pos, - const wxSize& size, - long style) - : wxFrame(parent, id, title, pos, size, style) +MyFrame::MyFrame() + : wxFrame(NULL, wxID_ANY, "wxToolBar Sample") { m_tbar = NULL; @@ -622,7 +667,7 @@ MyFrame::MyFrame(wxFrame* parent, fileMenu->Append(wxID_EXIT, "E&xit\tAlt-X", "Quit toolbar sample" ); wxMenu *helpMenu = new wxMenu; - helpMenu->Append(wxID_HELP, "&About", "About toolbar sample"); + helpMenu->Append(wxID_ABOUT, "&About", "About toolbar sample"); wxMenuBar* menuBar = new wxMenuBar( wxMB_DOCKABLE ); @@ -706,16 +751,6 @@ void MyFrame::OnSize(wxSizeEvent& event) } } -void MyFrame::OnDPIChanged(wxDPIChangedEvent& event) -{ - event.Skip(); - - // We check the DPI scaling factor when the toolbar is created, so just - // recreate it whenever DPI changes. We could also just update the tools - // bitmaps, but this is simpler and doesn't have any significant drawbacks. - RecreateToolbar(); -} - void MyFrame::OnToggleToolbar(wxCommandEvent& WXUNUSED(event)) { wxToolBar *tbar = GetToolBar(); diff --git a/src/common/artprov.cpp b/src/common/artprov.cpp index 07d662dacc..66327070fb 100644 --- a/src/common/artprov.cpp +++ b/src/common/artprov.cpp @@ -39,6 +39,7 @@ WX_DEFINE_LIST(wxArtProvidersList) // ---------------------------------------------------------------------------- WX_DECLARE_EXPORTED_STRING_HASH_MAP(wxBitmap, wxArtProviderBitmapsHash); +WX_DECLARE_EXPORTED_STRING_HASH_MAP(wxBitmapBundle, wxArtProviderBitmapBundlesHash); WX_DECLARE_EXPORTED_STRING_HASH_MAP(wxIconBundle, wxArtProviderIconBundlesHash); class WXDLLEXPORT wxArtProviderCache @@ -48,6 +49,10 @@ public: void PutBitmap(const wxString& full_id, const wxBitmap& bmp) { m_bitmapsHash[full_id] = bmp; } + bool GetBitmapBundle(const wxString& full_id, wxBitmapBundle* bmpbndl); + void PutBitmapBundle(const wxString& full_id, const wxBitmapBundle& bmpbndl) + { m_bitmapsBundlesHash[full_id] = bmpbndl; } + bool GetIconBundle(const wxString& full_id, wxIconBundle* bmp); void PutIconBundle(const wxString& full_id, const wxIconBundle& iconbundle) { m_iconBundlesHash[full_id] = iconbundle; } @@ -62,8 +67,9 @@ public: const wxArtClient& client); private: - wxArtProviderBitmapsHash m_bitmapsHash; // cache of wxBitmaps - wxArtProviderIconBundlesHash m_iconBundlesHash; // cache of wxIconBundles + wxArtProviderBitmapsHash m_bitmapsHash; // cache of wxBitmaps + wxArtProviderBitmapBundlesHash m_bitmapsBundlesHash; // cache of wxBitmaps + wxArtProviderIconBundlesHash m_iconBundlesHash; // cache of wxIconBundles }; bool wxArtProviderCache::GetBitmap(const wxString& full_id, wxBitmap* bmp) @@ -80,6 +86,21 @@ bool wxArtProviderCache::GetBitmap(const wxString& full_id, wxBitmap* bmp) } } +bool wxArtProviderCache::GetBitmapBundle(const wxString& full_id, wxBitmapBundle* bmpbndl) +{ + wxArtProviderBitmapBundlesHash::iterator entry = m_bitmapsBundlesHash.find(full_id); + if ( entry == m_bitmapsBundlesHash.end() ) + { + return false; + } + else + { + *bmpbndl = entry->second; + return true; + } +} + + bool wxArtProviderCache::GetIconBundle(const wxString& full_id, wxIconBundle* bmp) { wxArtProviderIconBundlesHash::iterator entry = m_iconBundlesHash.find(full_id); @@ -274,6 +295,37 @@ void wxArtProvider::RescaleBitmap(wxBitmap& bmp, const wxSize& sizeNeeded) return bmp; } +/*static*/ +wxBitmapBundle wxArtProvider::GetBitmapBundle(const wxArtID& id, + const wxArtClient& client, + const wxSize& size) +{ + // safety-check against writing client,id,size instead of id,client,size: + wxASSERT_MSG( client.Last() == wxT('C'), wxT("invalid 'client' parameter") ); + + wxCHECK_MSG( sm_providers, wxNullBitmap, wxT("no wxArtProvider exists") ); + + wxString hashId = wxArtProviderCache::ConstructHashID(id, client); + + wxBitmapBundle bitmapbundle; // (DoGetIconBundle(id, client)); + + if ( !sm_cache->GetBitmapBundle(hashId, &bitmapbundle) ) + { + for (wxArtProvidersList::compatibility_iterator node = sm_providers->GetFirst(); + node; node = node->GetNext()) + { + bitmapbundle = node->GetData()->CreateBitmapBundle(id, client, size); + if ( bitmapbundle.IsOk() ) + break; + } + + sm_cache->PutBitmapBundle(hashId, bitmapbundle); + } + + return bitmapbundle; +} + + /*static*/ wxIconBundle wxArtProvider::GetIconBundle(const wxArtID& id, const wxArtClient& client) { diff --git a/src/common/bmpbndl.cpp b/src/common/bmpbndl.cpp new file mode 100644 index 0000000000..f290617ee3 --- /dev/null +++ b/src/common/bmpbndl.cpp @@ -0,0 +1,329 @@ +/////////////////////////////////////////////////////////////////////////////// +// Name: src/common/bmpbndl.cpp +// Purpose: Common methods of wxBitmapBundle class. +// Author: Vadim Zeitlin +// Created: 2021-09-22 +// Copyright: (c) 2021 Vadim Zeitlin +// Licence: wxWindows licence +/////////////////////////////////////////////////////////////////////////////// + +// ============================================================================ +// declarations +// ============================================================================ + +// ---------------------------------------------------------------------------- +// headers +// ---------------------------------------------------------------------------- + +// for compilers that support precompilation, includes "wx.h". +#include "wx/wxprec.h" + +#ifndef WX_PRECOMP +#endif // WX_PRECOMP + +#include "wx/bmpbndl.h" + +#include "wx/private/bmpbndl.h" + +#include + +#ifdef __WXOSX__ +#include "wx/osx/private.h" +#endif + +// ---------------------------------------------------------------------------- +// private helpers +// ---------------------------------------------------------------------------- + +namespace +{ + +// Simplest possible bundle implementation storing a collection of bitmaps +class wxBitmapBundleImplSet : public wxBitmapBundleImpl +{ +public: + // The vector must not be empty, caller is supposed to have checked for it. + explicit wxBitmapBundleImplSet(const wxVector& bitmaps) + { + Init(&bitmaps[0], bitmaps.size()); + } + + // Convenience ctor from a single bitmap. + explicit wxBitmapBundleImplSet(const wxBitmap& bitmap) + { + Init(&bitmap, 1); + } + + ~wxBitmapBundleImplSet() + { +#ifdef __WXOSX__ + if (m_nsImage) + wxMacCocoaRelease(m_nsImage); +#endif + } + + virtual wxSize GetDefaultSize() const wxOVERRIDE; + virtual wxBitmap GetBitmap(const wxSize size) wxOVERRIDE; + +#ifdef __WXOSX__ + virtual WXImage OSXGetImage() const wxOVERRIDE; + +private: + mutable WXImage m_nsImage = NULL; +#endif + +private: + // Struct containing bitmap itself as well as a flag indicating whether we + // generated it by rescaling the existing bitmap or not. + struct Entry + { + // Create a new entry from the original bitmap. + explicit Entry(const wxBitmap& bitmap_) + : bitmap(bitmap_) + { + generated = false; + } + + // Create a new entry of the given size by resizing the bitmap of an + // existing one. + Entry(const Entry& entry, const wxSize& size) + : bitmap(entry.bitmap) + { + wxASSERT_MSG( !entry.generated, wxS("should use original bitmap") ); + + generated = true; + + wxBitmap::Rescale(bitmap, size); + } + + wxBitmap bitmap; + bool generated; + }; + + // Comparator comparing entries by the bitmap size. + struct BitmapSizeComparator + { + bool operator()(const Entry& entry1, const Entry& entry2) const + { + // We could compare the bitmaps areas too, but they're supposed to + // all use different sizes anyhow, so keep things simple. + return entry1.bitmap.GetHeight() < entry2.bitmap.GetHeight(); + } + }; + + typedef wxVector Entries; + + // All bitmaps sorted by size. + // + // Note that this vector is never empty. + Entries m_entries; + + + // Common implementation of all ctors. + void Init(const wxBitmap* bitmaps, size_t n); + + wxDECLARE_NO_COPY_CLASS(wxBitmapBundleImplSet); +}; + +} // anonymous namespace + +// ============================================================================ +// wxBitmapBundleImplSet implementation +// ============================================================================ + +void wxBitmapBundleImplSet::Init(const wxBitmap* bitmaps, size_t n) +{ + m_entries.reserve(n); + for ( size_t i = 0; i < n; ++i ) + { + const wxBitmap& bitmap = bitmaps[i]; + + wxASSERT_MSG( bitmap.IsOk(), wxS("all bundle bitmaps must be valid") ); + + m_entries.push_back(Entry(bitmap)); + } + + std::sort(m_entries.begin(), m_entries.end(), BitmapSizeComparator()); + + // Should we check that all bitmaps really have unique sizes here? For now, + // don't bother with this, but we might want to do it later if it really + // turns out to be a problem in practice. +} + +wxSize wxBitmapBundleImplSet::GetDefaultSize() const +{ + // Default size is the size of the smallest bitmap in the bundle. + return m_entries[0].bitmap.GetSize(); +} + +wxBitmap wxBitmapBundleImplSet::GetBitmap(const wxSize size) +{ + // We use linear search instead if binary one because it's simpler and the + // vector size is small enough (< 10) for it not to matter in practice. + const size_t n = m_entries.size(); + size_t lastSmaller = 0; + for ( size_t i = 0; i < n; ++i ) + { + const Entry& entry = m_entries[i]; + + const wxSize sizeThis = entry.bitmap.GetSize(); + if ( sizeThis.y == size.y ) + { + // Exact match, just use it. + return entry.bitmap; + } + + if ( sizeThis.y < size.y ) + { + // Don't rescale this one, we prefer to downscale rather than + // upscale as it results in better-looking bitmaps. + lastSmaller = i; + continue; + } + + if ( sizeThis.y > size.y && !entry.generated ) + { + // We know that we don't have any exact match and we've found the + // next bigger bitmap, so rescale it to the desired size. + const Entry entryNew(entry, size); + + m_entries.insert(m_entries.begin() + lastSmaller + 1, entryNew); + + return entryNew.bitmap; + } + } + + // We only get here if the requested size is larger than the size of all + // the bitmaps we have, in which case we have no choice but to upscale one + // of the bitmaps, so find the largest available non-generated bitmap. + for ( size_t i = n; n > 0; --i ) + { + const Entry& entry = m_entries[i - 1]; + if ( !entry.generated ) + { + const Entry entryNew(entry, size); + + m_entries.push_back(entryNew); + + return entryNew.bitmap; + } + } + + // We should have at least one non-generated bitmap. + wxFAIL_MSG( wxS("unreachable") ); + + return wxBitmap(); +} + +#ifdef __WXOSX__ +WXImage wxBitmapBundleImplSet::OSXGetImage() const +{ + if ( m_nsImage == NULL ) + { +#if wxOSX_USE_COCOA + m_nsImage = wxOSXImageFromBitmap(m_entries[0].bitmap); + const size_t n = m_entries.size(); + for ( size_t i = 1; i < n; ++i ) + { + const Entry& entry = m_entries[i]; + wxOSXAddBitmapToImage(m_nsImage, entry.bitmap); + } +#else + // TODO determine best bitmap for device scale factor, and use that + // with wxOSXImageFromBitmap as on iOS there is only one bitmap in a UIImage +#endif + if ( m_nsImage ) + wxMacCocoaRetain(m_nsImage); + } + return m_nsImage; +} +#endif + +// ============================================================================ +// wxBitmapBundle implementation +// ============================================================================ + +wxBitmapBundle::wxBitmapBundle() +{ +} + +wxBitmapBundle::wxBitmapBundle(wxBitmapBundleImpl* impl) + : m_impl(impl) +{ +} + +wxBitmapBundle::wxBitmapBundle(const wxBitmap& bitmap) + : m_impl(bitmap.IsOk() ? new wxBitmapBundleImplSet(bitmap) : NULL) +{ +} + +wxBitmapBundle::wxBitmapBundle(const wxImage& image) + : m_impl(image.IsOk() ? new wxBitmapBundleImplSet(wxBitmap(image)) : NULL) +{ +} + +wxBitmapBundle::wxBitmapBundle(const wxBitmapBundle& other) + : m_impl(other.m_impl) +{ +} + +wxBitmapBundle& wxBitmapBundle::operator=(const wxBitmapBundle& other) +{ + // No need to check for self-assignment because m_impl already does. + m_impl = other.m_impl; + return *this; +} + +wxBitmapBundle::~wxBitmapBundle() +{ +} + +/* static */ +wxBitmapBundle wxBitmapBundle::FromBitmaps(const wxVector& bitmaps) +{ + if ( bitmaps.empty() ) + return wxBitmapBundle(); + + return wxBitmapBundle(new wxBitmapBundleImplSet(bitmaps)); +} + +/* static */ +wxBitmapBundle wxBitmapBundle::FromImpl(wxBitmapBundleImpl* impl) +{ + return wxBitmapBundle(impl); +} + + +// MSW has its own, actually working, version, in MSW-specific code. +#if !defined( __WXMSW__ ) && !defined( __WXOSX__ ) + +/* static */ +wxBitmapBundle wxBitmapBundle::FromResources(const wxString& WXUNUSED(name)) +{ + wxFAIL_MSG + ( + "Loading bitmaps from resources not available on this platform, " + "don't use this function and call wxBitmapBundle::FromBitmaps() " + "instead." + ); + + return wxBitmapBundle(); +} + +#endif // !__WXMSW__ && !__WXOSX__ + +wxSize wxBitmapBundle::GetDefaultSize() const +{ + if ( !m_impl ) + return wxDefaultSize; + + return m_impl->GetDefaultSize(); +} + +wxBitmap wxBitmapBundle::GetBitmap(const wxSize size) const +{ + if ( !m_impl ) + return wxBitmap(); + + return m_impl->GetBitmap(size == wxDefaultSize ? GetDefaultSize() : size); +} diff --git a/src/common/tbarbase.cpp b/src/common/tbarbase.cpp index 5f08d11480..251600f652 100644 --- a/src/common/tbarbase.cpp +++ b/src/common/tbarbase.cpp @@ -156,8 +156,8 @@ void wxToolBarBase::FixupStyle() wxToolBarToolBase *wxToolBarBase::DoAddTool(int toolid, const wxString& label, - const wxBitmap& bitmap, - const wxBitmap& bmpDisabled, + const wxBitmapBundle& bitmap, + const wxBitmapBundle& bmpDisabled, wxItemKind kind, const wxString& shortHelp, const wxString& longHelp, @@ -173,8 +173,8 @@ wxToolBarToolBase *wxToolBarBase::DoAddTool(int toolid, wxToolBarToolBase *wxToolBarBase::InsertTool(size_t pos, int toolid, const wxString& label, - const wxBitmap& bitmap, - const wxBitmap& bmpDisabled, + const wxBitmapBundle& bitmap, + const wxBitmapBundle& bmpDisabled, wxItemKind kind, const wxString& shortHelp, const wxString& longHelp, diff --git a/src/generic/bmpsvg.cpp b/src/generic/bmpsvg.cpp new file mode 100644 index 0000000000..9bf45ebeb4 --- /dev/null +++ b/src/generic/bmpsvg.cpp @@ -0,0 +1,184 @@ +/////////////////////////////////////////////////////////////////////////////// +// Name: src/generic/bmpsvg.cpp +// Purpose: Generic wxBitmapBundle::FromSVG() implementation +// Author: Vadim Zeitlin, Gunter Königsmann +// Created: 2021-09-28 +// Copyright: (c) 2019 Gunter Königsmann +// (c) 2021 Vadim Zeitlin +// Licence: wxWindows licence +/////////////////////////////////////////////////////////////////////////////// + +// ============================================================================ +// declarations +// ============================================================================ + +// ---------------------------------------------------------------------------- +// headers +// ---------------------------------------------------------------------------- + +// for compilers that support precompilation, includes "wx.h". +#include "wx/wxprec.h" + +#include "wx/bmpbndl.h" + +#ifdef wxHAS_SVG + +#ifndef WX_PRECOMP + #include "wx/utils.h" // Only for wxMin() +#endif // WX_PRECOMP + +#include "wx/rawbmp.h" + +#include "wx/private/bmpbndl.h" + +// Disable some warnings inside NanoSVG code that we're not interested in. +#ifdef __VISUALC__ + #pragma warning(push) + #pragma warning(disable:4456) + #pragma warning(disable:4702) + + // Also make nanosvg.h compile with older MSVC versions which didn't have + // strtoll(). + #if _MSC_VER < 1800 + #define strtoll _strtoi64 + #endif +#endif + +#define NANOSVG_IMPLEMENTATION +#define NANOSVGRAST_IMPLEMENTATION +#include "../../3rdparty/nanosvg/src/nanosvg.h" +#include "../../3rdparty/nanosvg/src/nanosvgrast.h" + +#ifdef __VISUALC__ + #pragma warning(pop) +#endif + +// ---------------------------------------------------------------------------- +// private helpers +// ---------------------------------------------------------------------------- + +namespace +{ + +class wxBitmapBundleImplSVG : public wxBitmapBundleImpl +{ +public: + // Ctor must be passed a valid NSVGimage and takes ownership of it. + wxBitmapBundleImplSVG(NSVGimage* svgImage, const wxSize& sizeDef) + : m_svgImage(svgImage), + m_svgRasterizer(nsvgCreateRasterizer()), + m_sizeDef(sizeDef) + { + } + + ~wxBitmapBundleImplSVG() + { + nsvgDeleteRasterizer(m_svgRasterizer); + nsvgDelete(m_svgImage); + } + + virtual wxSize GetDefaultSize() const wxOVERRIDE; + virtual wxBitmap GetBitmap(const wxSize size) wxOVERRIDE; + +private: + wxBitmap DoRasterize(const wxSize size); + + NSVGimage* const m_svgImage; + NSVGrasterizer* const m_svgRasterizer; + + const wxSize m_sizeDef; + + // Cache the last used bitmap (may be invalid if not used yet). + // + // Note that we cache only the last bitmap and not all the bitmaps ever + // requested from GetBitmap() for the different sizes because there would + // be no way to clear such cache and its growth could be unbounded, + // resulting in too many bitmap objects being used in an application using + // SVG for all of its icons. + wxBitmap m_cachedBitmap; + + wxDECLARE_NO_COPY_CLASS(wxBitmapBundleImplSVG); +}; + +} // anonymous namespace + +// ============================================================================ +// wxBitmapBundleImplSVG implementation +// ============================================================================ + +wxSize wxBitmapBundleImplSVG::GetDefaultSize() const +{ + return m_sizeDef; +} + +wxBitmap wxBitmapBundleImplSVG::GetBitmap(const wxSize size) +{ + if ( !m_cachedBitmap.IsOk() || m_cachedBitmap.GetSize() != size ) + { + m_cachedBitmap = DoRasterize(size); + } + + return m_cachedBitmap; +} + +wxBitmap wxBitmapBundleImplSVG::DoRasterize(const wxSize size) +{ + wxVector buffer(size.x*size.y*4); + nsvgRasterize + ( + m_svgRasterizer, + m_svgImage, + 0.0, 0.0, // no offset + wxMin + ( + size.x/m_svgImage->width, + size.y/m_svgImage->height + ), // scale + &buffer[0], + size.x, size.y, + size.x*4 // stride -- we have no gaps between lines + ); + + wxBitmap bitmap(size, 32); + wxAlphaPixelData bmpdata(bitmap); + wxAlphaPixelData::Iterator dst(bmpdata); + + const unsigned char* src = &buffer[0]; + for ( int y = 0; y < size.y; ++y ) + { + dst.MoveTo(bmpdata, 0, y); + for ( int x = 0; x < size.x; ++x ) + { + const unsigned char a = src[3]; + dst.Red() = src[0] * a / 255; + dst.Green() = src[1] * a / 255; + dst.Blue() = src[2] * a / 255; + dst.Alpha() = a; + + ++dst; + src += 4; + } + } + + return bitmap; +} + +/* static */ +wxBitmapBundle wxBitmapBundle::FromSVG(char* data, const wxSize sizeDef) +{ + NSVGimage* const svgImage = nsvgParse(data, "px", 96); + if ( !svgImage ) + return wxBitmapBundle(); + + return wxBitmapBundle(new wxBitmapBundleImplSVG(svgImage, sizeDef)); +} + +/* static */ +wxBitmapBundle wxBitmapBundle::FromSVG(const char* data, const wxSize sizeDef) +{ + wxCharBuffer copy(data); + + return FromSVG(copy.data(), sizeDef); +} + +#endif // wxHAS_SVG diff --git a/src/generic/buttonbar.cpp b/src/generic/buttonbar.cpp index b6b50a2edd..c904e738c3 100644 --- a/src/generic/buttonbar.cpp +++ b/src/generic/buttonbar.cpp @@ -46,8 +46,8 @@ public: wxButtonToolBarTool(wxButtonToolBar *tbar, int id, const wxString& label, - const wxBitmap& bmpNormal, - const wxBitmap& bmpDisabled, + const wxBitmapBundle& bmpNormal, + const wxBitmapBundle& bmpDisabled, wxItemKind kind, wxObject *clientData, const wxString& shortHelp, @@ -261,8 +261,8 @@ void wxButtonToolBar::DoSetToggle(wxToolBarToolBase *WXUNUSED(tool), bool WXUNUS wxToolBarToolBase *wxButtonToolBar::CreateTool(int id, const wxString& label, - const wxBitmap& bmpNormal, - const wxBitmap& bmpDisabled, + const wxBitmapBundle& bmpNormal, + const wxBitmapBundle& bmpDisabled, wxItemKind kind, wxObject *clientData, const wxString& shortHelp, diff --git a/src/gtk/toolbar.cpp b/src/gtk/toolbar.cpp index 155b2afbac..9429a5fb33 100644 --- a/src/gtk/toolbar.cpp +++ b/src/gtk/toolbar.cpp @@ -35,8 +35,8 @@ public: wxToolBarTool(wxToolBar *tbar, int id, const wxString& label, - const wxBitmap& bitmap1, - const wxBitmap& bitmap2, + const wxBitmapBundle& bitmap1, + const wxBitmapBundle& bitmap2, wxItemKind kind, wxObject *clientData, const wxString& shortHelpString, @@ -373,8 +373,8 @@ void wxToolBarTool::SetLabel(const wxString& label) wxToolBarToolBase *wxToolBar::CreateTool(int id, const wxString& text, - const wxBitmap& bitmap1, - const wxBitmap& bitmap2, + const wxBitmapBundle& bitmap1, + const wxBitmapBundle& bitmap2, wxItemKind kind, wxObject *clientData, const wxString& shortHelpString, @@ -795,7 +795,7 @@ void wxToolBar::SetToolShortHelp( int id, const wxString& helpString ) } } -void wxToolBar::SetToolNormalBitmap( int id, const wxBitmap& bitmap ) +void wxToolBar::SetToolNormalBitmap( int id, const wxBitmapBundle& bitmap ) { wxToolBarTool* tool = static_cast(FindById(id)); if ( tool ) @@ -807,7 +807,7 @@ void wxToolBar::SetToolNormalBitmap( int id, const wxBitmap& bitmap ) } } -void wxToolBar::SetToolDisabledBitmap( int id, const wxBitmap& bitmap ) +void wxToolBar::SetToolDisabledBitmap( int id, const wxBitmapBundle& bitmap ) { wxToolBarTool* tool = static_cast(FindById(id)); if ( tool ) diff --git a/src/gtk1/toolbar.cpp b/src/gtk1/toolbar.cpp index 5032fa3fc7..bfd6713671 100644 --- a/src/gtk1/toolbar.cpp +++ b/src/gtk1/toolbar.cpp @@ -75,8 +75,8 @@ public: wxToolBarTool(wxToolBar *tbar, int id, const wxString& label, - const wxBitmap& bitmap1, - const wxBitmap& bitmap2, + const wxBitmapBundle& bitmap1, + const wxBitmapBundle& bitmap2, wxItemKind kind, wxObject *clientData, const wxString& shortHelpString, @@ -234,8 +234,8 @@ void wxToolBarTool::Init() wxToolBarToolBase *wxToolBar::CreateTool(int id, const wxString& text, - const wxBitmap& bitmap1, - const wxBitmap& bitmap2, + const wxBitmapBundle& bitmap1, + const wxBitmapBundle& bitmap2, wxItemKind kind, wxObject *clientData, const wxString& shortHelpString, diff --git a/src/motif/toolbar.cpp b/src/motif/toolbar.cpp index 9877f2b197..874dca1e12 100644 --- a/src/motif/toolbar.cpp +++ b/src/motif/toolbar.cpp @@ -80,8 +80,8 @@ public: wxToolBarTool(wxToolBar *tbar, int id, const wxString& label, - const wxBitmap& bmpNormal, - const wxBitmap& bmpToggled, + const wxBitmapBundle& bmpNormal, + const wxBitmapBundle& bmpToggled, wxItemKind kind, wxObject *clientData, const wxString& shortHelp, @@ -142,8 +142,8 @@ wxString wxToolBarTimer::helpString; wxToolBarToolBase *wxToolBar::CreateTool(int id, const wxString& label, - const wxBitmap& bmpNormal, - const wxBitmap& bmpToggled, + const wxBitmapBundle& bmpNormal, + const wxBitmapBundle& bmpToggled, wxItemKind kind, wxObject *clientData, const wxString& shortHelp, diff --git a/src/msw/bmpbndl.cpp b/src/msw/bmpbndl.cpp new file mode 100644 index 0000000000..1bba6e3668 --- /dev/null +++ b/src/msw/bmpbndl.cpp @@ -0,0 +1,307 @@ +/////////////////////////////////////////////////////////////////////////////// +// Name: src/msw/bmpbndl.cpp +// Purpose: MSW-specific part of wxBitmapBundle class. +// Author: Vadim Zeitlin +// Created: 2021-09-22 +// Copyright: (c) 2021 Vadim Zeitlin +// Licence: wxWindows licence +/////////////////////////////////////////////////////////////////////////////// + +// ============================================================================ +// declarations +// ============================================================================ + +// ---------------------------------------------------------------------------- +// headers +// ---------------------------------------------------------------------------- + +// for compilers that support precompilation, includes "wx.h". +#include "wx/wxprec.h" + +#ifndef WX_PRECOMP + #include "wx/log.h" + + #include "wx/msw/wrapwin.h" +#endif // WX_PRECOMP + +#include "wx/bmpbndl.h" + +#include "wx/private/bmpbndl.h" + +#include + +// ---------------------------------------------------------------------------- +// private helpers +// ---------------------------------------------------------------------------- + +namespace +{ + +// Helper function, which will probably need to be factored out as it's likely +// to be useful elsewhere, returning the scale determined by the given suffix, +// i.e. it returns 2 for the suffix of "_2x" or 1.5 for "_1_5x". +// +// Returns 1 if the suffix is empty or 0 if it doesn't look like a valid scale +// suffix at all. +double GetScaleFromSuffix(const wxString& suffix) +{ + if ( suffix.empty() ) + return 1.0; + + if ( *suffix.begin() != '_' ) + return 0; + + if ( *suffix.rbegin() != 'x' ) + return 0; + + wxString factor = suffix.substr(1, suffix.length() - 2); + if ( factor.empty() ) + return 0; + + factor.Replace(wxS("_"), wxS(".")); + + double d; + if ( !factor.ToCDouble(&d) ) + return 0; + + return d; +} + +// Just a bitmap name and the corresponding scale for some resource. +struct ResourceInfo +{ + ResourceInfo(const wxString& name_, double scale_) + : name(name_), scale(scale_) + { + } + + wxString name; + double scale; +}; + +// Predicate for std::sort() comparing resource infos using their scale. +struct ScaleComparator +{ + bool operator()(const ResourceInfo& info1, const ResourceInfo& info2) const + { + return info1.scale < info2.scale; + } +}; + +typedef wxVector ResourceInfos; + +// Used to pass information to EnumRCBitmaps() callback. +struct RCEnumCallbackData +{ + explicit RCEnumCallbackData(const wxString& name_) + : name(name_.Lower()) + { + } + + // The base name of all resources, passed to the callback. + wxString name; + + // All the existing bitmaps starting with this name and using a valid scale + // suffix, filled by the callback. + ResourceInfos resourceInfos; +}; + +BOOL CALLBACK EnumRCBitmaps(HMODULE WXUNUSED(hModule), + LPCTSTR WXUNUSED(lpszType), + LPTSTR lpszName, + LONG_PTR lParam) +{ + wxString name(lpszName); + name.MakeLower(); // resource names are case insensitive + + RCEnumCallbackData *data = reinterpret_cast(lParam); + + wxString suffix; + if ( name.StartsWith(data->name, &suffix) ) + { + const double scale = GetScaleFromSuffix(suffix); + if ( scale ) + data->resourceInfos.push_back(ResourceInfo(name, scale)); + } + + return TRUE; // continue enumeration +} + +// Bundle implementation using PNG bitmaps from Windows resources. +class wxBitmapBundleImplRC : public wxBitmapBundleImpl +{ +public: + // Ctor takes the vector containing all the existing resources starting + // with the given name and the valid bitmap corresponding to the base name + // resource itself. + wxBitmapBundleImplRC(const ResourceInfos& resourceInfos, + const wxBitmap& bitmap); + + virtual wxSize GetDefaultSize() const wxOVERRIDE; + virtual wxBitmap GetBitmap(const wxSize size) wxOVERRIDE; + +private: + // Load the bitmap from the given resource and add it m_bitmaps, after + // rescaling it to the given size if necessary, i.e. if the needed size is + // different from the size of this bitmap itself. + // + // The expected size is used to confirm that the resource really has the + // size we expect it to have. + // + // Return the just loaded bitmap. + wxBitmap + AddBitmap(const ResourceInfo& info, + const wxSize& sizeExpected, + const wxSize& sizeNeeded); + + + // All the available resources. + const ResourceInfos m_resourceInfos; + + // All already loaded bitmaps sorted by their size. + // + // This vector is never empty and its first element is the bitmap using the + // default size. + wxVector m_bitmaps; + + wxDECLARE_NO_COPY_CLASS(wxBitmapBundleImplRC); +}; + +} // anonymous namespace + +// ============================================================================ +// wxBitmapBundleImplRC implementation +// ============================================================================ + +wxBitmapBundleImplRC::wxBitmapBundleImplRC(const ResourceInfos& resourceInfos, + const wxBitmap& bitmap) + : m_resourceInfos(resourceInfos) +{ + m_bitmaps.push_back(bitmap); +} + +wxSize wxBitmapBundleImplRC::GetDefaultSize() const +{ + return m_bitmaps[0].GetSize(); +} + +wxBitmap +wxBitmapBundleImplRC::AddBitmap(const ResourceInfo& info, + const wxSize& sizeExpected, + const wxSize& sizeNeeded) +{ + // First load the bitmap, it shouldn't fail, but we can't do much if it + // does fail -- we're just going to return an invalid bitmap in this case. + wxBitmap bitmap(info.name, wxBITMAP_TYPE_PNG_RESOURCE); + + // We rely on suffixes really corresponding to the bitmap sizes and bad + // things will happen if they don't. + wxASSERT_MSG + ( + bitmap.GetSize() == sizeExpected, + wxString::Format(wxS("Bitmap \"%s\" should have size %d*%d."), + sizeExpected.x, sizeExpected.y) + ); + + if ( sizeNeeded != sizeExpected ) + wxBitmap::Rescale(bitmap, sizeNeeded); + + + // Now cache the bitmap for future use by inserting it into our sorted + // vector of bitmaps. We don't bother with the binary search here because + // the vector is typically very small (< 10 elements). + const wxSize sizeThis = bitmap.GetSize(); + for ( size_t i = 0; ; ++i ) + { + if ( i == m_bitmaps.size() ) + { + // This is the biggest bitmap we have, put it at the end. + m_bitmaps.push_back(bitmap); + break; + } + + if ( m_bitmaps[i].GetSize().y > sizeThis.y ) + { + m_bitmaps.insert(m_bitmaps.begin() + i, bitmap); + break; + } + } + + return bitmap; +} + +wxBitmap wxBitmapBundleImplRC::GetBitmap(const wxSize size) +{ + // First check if we already have the bitmap of this size: we're only + // interested in the exact match here. + for ( size_t i = 0; i < m_bitmaps.size(); ++i ) + { + const wxBitmap& bitmap = m_bitmaps[i]; + + if ( bitmap.GetSize() == size ) + return bitmap; + } + + // If we don't have one, create it using one of the available resources. + // Here we try to find the exact match (ideal) or the next larger size + // (downscaling results in better appearance than upscaling, generally + // speaking). + const wxSize sizeDef = GetDefaultSize(); + for ( size_t i = 0; i < m_resourceInfos.size(); ++i ) + { + const ResourceInfo& info = m_resourceInfos[i]; + + const wxSize sizeThis = sizeDef*info.scale; + + // Use this bitmap if it's the first one bigger than the requested size + // or if it's the last item as in this case we're not going to find any + // bitmap bigger than the given one anyhow and we don't have any choice + // but to upscale the largest one we have. + if ( sizeThis.y >= size.y || i + 1 == m_resourceInfos.size() ) + return AddBitmap(info, sizeThis, size); + } + + wxFAIL_MSG( wxS("unreachable") ); + + return wxBitmap(); +} + +// ============================================================================ +// wxBitmapBundle::FromResources() implementation +// ============================================================================ + +/* static */ +wxBitmapBundle wxBitmapBundle::FromResources(const wxString& name) +{ + // First of all, find all resources starting with this name. + RCEnumCallbackData data(name); + + if ( !::EnumResourceNames(NULL, // this HMODULE + RT_RCDATA, + EnumRCBitmaps, + reinterpret_cast(&data)) ) + { + const DWORD err = ::GetLastError(); + if ( err != NO_ERROR && err != ERROR_RESOURCE_TYPE_NOT_FOUND ) + { + wxLogSysError(wxS("Couldn't enumerate RCDATA resources")); + } + } + + ResourceInfos& resourceInfos = data.resourceInfos; + + if ( resourceInfos.empty() ) + return wxBitmapBundle(); + + // We need to load the base bitmap to get the default size anyhow, so do it + // now and also check that it works. + wxBitmap bitmap(name, wxBITMAP_TYPE_PNG_RESOURCE); + if ( !bitmap.IsOk() ) + return wxBitmapBundle(); + + // Sort the resources in the order of increasing sizes to simplify the code + // of wxBitmapBundleImplRC::GetBitmap(). + std::sort(resourceInfos.begin(), resourceInfos.end(), ScaleComparator()); + + return wxBitmapBundle(new wxBitmapBundleImplRC(resourceInfos, bitmap)); +} diff --git a/src/msw/toolbar.cpp b/src/msw/toolbar.cpp index 07ccd29108..fe7b8f49d2 100644 --- a/src/msw/toolbar.cpp +++ b/src/msw/toolbar.cpp @@ -150,8 +150,8 @@ public: wxToolBarTool(wxToolBar *tbar, int id, const wxString& label, - const wxBitmap& bmpNormal, - const wxBitmap& bmpDisabled, + const wxBitmapBundle& bmpNormal, + const wxBitmapBundle& bmpDisabled, wxItemKind kind, wxObject *clientData, const wxString& shortHelp, @@ -344,8 +344,8 @@ static bool MSWShouldBeChecked(const wxToolBarToolBase *tool) wxToolBarToolBase *wxToolBar::CreateTool(int id, const wxString& label, - const wxBitmap& bmpNormal, - const wxBitmap& bmpDisabled, + const wxBitmapBundle& bmpNormal, + const wxBitmapBundle& bmpDisabled, wxItemKind kind, wxObject *clientData, const wxString& shortHelp, @@ -781,14 +781,14 @@ void wxToolBar::CreateDisabledImageList() node = m_tools.GetFirst(); node; node = node->GetNext() ) { wxToolBarToolBase *tool = node->GetData(); - wxBitmap bmpDisabled = tool->GetDisabledBitmap(); + wxBitmap bmpDisabled = tool->GetDisabledBitmap(wxSize(m_defaultWidth, + m_defaultHeight)); if ( bmpDisabled.IsOk() ) { - const wxSize sizeBitmap = bmpDisabled.GetSize(); m_disabledImgList = new wxImageList ( - sizeBitmap.x, - sizeBitmap.y, + m_defaultWidth, + m_defaultHeight, // Don't use mask if we have alpha // (wxImageList will fall back to // mask if alpha not supported) @@ -858,11 +858,15 @@ bool wxToolBar::Realize() wxMemoryDC dcAllButtons; wxBitmap bitmap(totalBitmapWidth, totalBitmapHeight); + const wxSize sizeBitmap(m_defaultWidth, m_defaultHeight); + for ( node = m_tools.GetFirst(); node; node = node->GetNext() ) { wxToolBarToolBase *tool = node->GetData(); - if ( tool->IsButton() && - tool->GetNormalBitmap().IsOk() && tool->GetNormalBitmap().HasAlpha() ) + wxBitmap toolBitmap; + if ( tool->IsButton() ) + toolBitmap = tool->GetNormalBitmap(sizeBitmap); + if ( toolBitmap.IsOk() && toolBitmap.HasAlpha() ) { // By default bitmaps don't have alpha in wxMSW, but if we // use a bitmap tool with alpha, we should use alpha for @@ -925,16 +929,10 @@ bool wxToolBar::Realize() wxToolBarToolBase *tool = node->GetData(); if ( tool->IsButton() ) { - wxBitmap bmp = tool->GetNormalBitmap(); - - const int w = bmp.GetWidth(); - const int h = bmp.GetHeight(); + wxBitmap bmp = tool->GetNormalBitmap(sizeBitmap); if ( bmp.IsOk() ) { - int xOffset = wxMax(0, (m_defaultWidth - w)/2); - int yOffset = wxMax(0, (m_defaultHeight - h)/2); - #if wxUSE_IMAGE // If a mix of icons with alpha and without is used, // convert them all to use alpha. @@ -947,7 +945,7 @@ bool wxToolBar::Realize() #endif // notice the last parameter: do use mask - dcAllButtons.DrawBitmap(bmp, x + xOffset, yOffset, true); + dcAllButtons.DrawBitmap(bmp, x, 0, true); // Handle of the bitmap could have changed inside // DrawBitmap() call if it had to convert it from DDB to @@ -963,7 +961,8 @@ bool wxToolBar::Realize() // also deal with disabled bitmap if we want to use them if ( m_disabledImgList ) { - wxBitmap bmpDisabled = tool->GetDisabledBitmap(); + wxBitmap bmpDisabled = tool->GetDisabledBitmap(sizeBitmap); + #if wxUSE_IMAGE && wxUSE_WXDIB if ( !bmpDisabled.IsOk() ) { @@ -977,9 +976,9 @@ bool wxToolBar::Realize() { // we need to have light grey background colour for // MapBitmap() to work correctly - for ( int y = 0; y < h; y++ ) + for ( int y = 0; y < m_defaultHeight; y++ ) { - for ( int xx = 0; xx < w; xx++ ) + for ( int xx = 0; xx < m_defaultWidth; xx++ ) { if ( imgGreyed.IsTransparent(xx, y) ) imgGreyed.SetRGB(xx, y, @@ -995,7 +994,10 @@ bool wxToolBar::Realize() #endif // wxUSE_IMAGE if ( remapValue == Remap_Buttons ) - MapBitmap(bmpDisabled.GetHBITMAP(), w, h); + { + MapBitmap(bmpDisabled.GetHBITMAP(), + m_defaultWidth, m_defaultHeight); + } m_disabledImgList->Add(bmpDisabled); } @@ -1842,7 +1844,7 @@ void wxToolBar::DoSetToggle(wxToolBarToolBase *WXUNUSED(tool), bool WXUNUSED(tog wxFAIL_MSG( wxT("not implemented") ); } -void wxToolBar::SetToolNormalBitmap( int id, const wxBitmap& bitmap ) +void wxToolBar::SetToolNormalBitmap( int id, const wxBitmapBundle& bitmap ) { wxToolBarTool* tool = static_cast(FindById(id)); if ( tool ) @@ -1854,7 +1856,7 @@ void wxToolBar::SetToolNormalBitmap( int id, const wxBitmap& bitmap ) } } -void wxToolBar::SetToolDisabledBitmap( int id, const wxBitmap& bitmap ) +void wxToolBar::SetToolDisabledBitmap( int id, const wxBitmapBundle& bitmap ) { wxToolBarTool* tool = static_cast(FindById(id)); if ( tool ) @@ -1947,6 +1949,10 @@ void wxToolBar::RealizeHelper() void wxToolBar::OnDPIChanged(wxDPIChangedEvent& event) { + // Ensure that when Realize() is called, the bitmaps size corresponding to + // the new resolution will be used. + SetToolBitmapSize(event.Scale(wxSize(m_defaultWidth, m_defaultHeight))); + // Manually scale the size of the controls. Even though the font has been // updated, the internal size of the controls does not. wxToolBarToolsList::compatibility_iterator node; diff --git a/src/osx/artmac.cpp b/src/osx/artmac.cpp index fda7bd5658..81faccb758 100644 --- a/src/osx/artmac.cpp +++ b/src/osx/artmac.cpp @@ -35,11 +35,11 @@ protected: const wxArtClient& client) wxOVERRIDE; #endif #if wxOSX_USE_COCOA_OR_IPHONE - virtual wxBitmap CreateBitmap(const wxArtID& id, + virtual wxBitmapBundle CreateBitmapBundle(const wxArtID& id, const wxArtClient& client, const wxSize& size) wxOVERRIDE { - return wxOSXCreateSystemBitmap(id, client, size); + return wxOSXCreateSystemBitmapBundle(id, client, size); } #endif }; diff --git a/src/osx/carbon/utilscocoa.mm b/src/osx/carbon/utilscocoa.mm index 7e27bb21ac..4dbf4848e8 100644 --- a/src/osx/carbon/utilscocoa.mm +++ b/src/osx/carbon/utilscocoa.mm @@ -27,6 +27,7 @@ #endif #include "wx/fontutil.h" +#include "wx/private/bmpbndl.h" #ifdef __WXMAC__ @@ -165,14 +166,14 @@ WXWindow wxOSXGetKeyWindow() #if wxOSX_USE_IPHONE -wxBitmap wxOSXCreateSystemBitmap(const wxString& name, const wxString &client, const wxSize& size) +wxBitmapBundle wxOSXCreateSystemBitmapBundle(const wxString& name, const wxString &client, const wxSize& size) { #if 1 // unfortunately this only accesses images in the app bundle, not the system wide globals wxCFStringRef cfname(name); - return wxBitmap( [[UIImage imageNamed:cfname.AsNSString()] CGImage] ); + return wxOSXMakeBundleFromImage( [UIImage imageNamed:cfname.AsNSString()] ); #else - return wxBitmap(); + return wxNullBitmap; #endif } @@ -197,14 +198,12 @@ WXImage wxOSXGetSystemImage(const wxString& name) return nsimage; } -wxBitmap wxOSXCreateSystemBitmap(const wxString& name, const wxString &WXUNUSED(client), const wxSize& WXUNUSED(sizeHint)) +wxBitmapBundle wxOSXCreateSystemBitmapBundle(const wxString& name, const wxString &WXUNUSED(client), const wxSize& WXUNUSED(sizeHint)) { NSImage* nsimage = wxOSXGetSystemImage(name); if ( nsimage ) { - // if ( sizeHint != wxDefaultSize ) - // [nsimage setSize:NSMakeSize(sizeHint.GetHeight(), sizeHint.GetWidth())]; - return wxBitmap( nsimage ); + return wxOSXMakeBundleFromImage( nsimage ); } return wxNullBitmap; } diff --git a/src/osx/cocoa/preferences.mm b/src/osx/cocoa/preferences.mm index 4d26a958ab..e58274a18c 100644 --- a/src/osx/cocoa/preferences.mm +++ b/src/osx/cocoa/preferences.mm @@ -32,6 +32,7 @@ #include "wx/weakref.h" #include "wx/windowid.h" #include "wx/osx/private.h" +#include "wx/private/bmpbndl.h" #include "wx/osx/private/available.h" #import @@ -39,15 +40,16 @@ wxBitmap wxStockPreferencesPage::GetLargeIcon() const { + wxBitmapBundle bundle; #if __MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_16 if ( WX_IS_MACOS_AVAILABLE(11, 0) ) { switch ( m_kind ) { case Kind_General: - return wxBitmap([NSImage imageWithSystemSymbolName:@"gearshape" accessibilityDescription:nil]); + bundle = wxOSXMakeBundleFromImage([NSImage imageWithSystemSymbolName:@"gearshape" accessibilityDescription:nil]); case Kind_Advanced: - return wxBitmap([NSImage imageWithSystemSymbolName:@"gearshape.2" accessibilityDescription:nil]); + bundle = wxOSXMakeBundleFromImage([NSImage imageWithSystemSymbolName:@"gearshape.2" accessibilityDescription:nil]); } } #endif @@ -55,12 +57,12 @@ wxBitmap wxStockPreferencesPage::GetLargeIcon() const switch ( m_kind ) { case Kind_General: - return wxBitmap([NSImage imageNamed:NSImageNamePreferencesGeneral]); + bundle = wxOSXMakeBundleFromImage([NSImage imageNamed:NSImageNamePreferencesGeneral]); case Kind_Advanced: - return wxBitmap([NSImage imageNamed:NSImageNameAdvanced]); + bundle = wxOSXMakeBundleFromImage([NSImage imageNamed:NSImageNameAdvanced]); } - return wxBitmap(); // silence compiler warning + return bundle.IsOk() ? bundle.GetBitmap(bundle.GetDefaultSize()) : wxNullBitmap; } @@ -98,7 +100,7 @@ public: "can't add more preferences pages after showing the window" ); const wxString title = page->GetName(); - wxBitmap bmp(page->GetLargeIcon()); + wxBitmapBundle bmp(page->GetLargeIcon()); wxASSERT_MSG( bmp.IsOk(), "OS X requires valid bitmap for preference page" ); int toolId = wxIdManager::ReserveId(); diff --git a/src/osx/cocoa/toolbar.mm b/src/osx/cocoa/toolbar.mm index 54e89a15d3..2e3b84da21 100644 --- a/src/osx/cocoa/toolbar.mm +++ b/src/osx/cocoa/toolbar.mm @@ -20,6 +20,7 @@ #include "wx/app.h" #include "wx/osx/private.h" #include "wx/osx/private/available.h" +#include "wx/private/bmpbndl.h" #include "wx/geometry.h" #include "wx/sysopt.h" @@ -77,8 +78,8 @@ public: wxToolBar *tbar, int id, const wxString& label, - const wxBitmap& bmpNormal, - const wxBitmap& bmpDisabled, + const wxBitmapBundle& bmpNormal, + const wxBitmapBundle& bmpDisabled, wxItemKind kind, wxObject *clientData, const wxString& shortHelp, @@ -591,14 +592,14 @@ void wxToolBarTool::SetPosition( const wxPoint& position ) void wxToolBarTool::UpdateImages() { - [(NSButton*) m_controlHandle setImage:m_bmpNormal.GetNSImage()]; + [(NSButton*) m_controlHandle setImage:wxOSXGetImageFromBundle(m_bmpNormal)]; if ( CanBeToggled() ) { - int w = m_bmpNormal.GetScaledWidth(); - int h = m_bmpNormal.GetScaledHeight(); + // TODO CS this should use the best current representation, or optionally iterate through all + wxSize sz = m_bmpNormal.GetDefaultSize(); m_alternateBitmap = wxBitmap(); - m_alternateBitmap.CreateScaled(w, h, -1, m_bmpNormal.GetScaleFactor()); + m_alternateBitmap.Create(sz.x, sz.y, -1); // TODO CS m_alternateBitmap.CreateScaled(sz.x, sz.y, -1, m_bmpNormal.GetScaleFactor()); m_alternateBitmap.UseAlpha(); wxMemoryDC dc; @@ -610,8 +611,8 @@ void wxToolBarTool::UpdateImages() dc.Clear(); dc.SetPen(grey); dc.SetBrush(grey); - dc.DrawRoundedRectangle( 0, 0, w, h, 3 ); - dc.DrawBitmap( m_bmpNormal, 0, 0, true ); + dc.DrawRoundedRectangle( 0, 0, sz.x, sz.y, 3 ); + dc.DrawBitmap( m_bmpNormal.GetBitmap(sz), 0, 0, true ); dc.SelectObject( wxNullBitmap ); [(NSButton*) m_controlHandle setAlternateImage:m_alternateBitmap.GetNSImage()]; @@ -633,7 +634,7 @@ void wxToolBarTool::UpdateToggleImage( bool toggle ) if ( CanBeToggled() && toggle ) [m_toolbarItem setImage:m_alternateBitmap.GetNSImage()]; else - [m_toolbarItem setImage:m_bmpNormal.GetNSImage()]; + [m_toolbarItem setImage:wxOSXGetImageFromBundle(m_bmpNormal)]; } #endif @@ -645,8 +646,8 @@ wxToolBarTool::wxToolBarTool( wxToolBar *tbar, int id, const wxString& label, - const wxBitmap& bmpNormal, - const wxBitmap& bmpDisabled, + const wxBitmapBundle& bmpNormal, + const wxBitmapBundle& bmpDisabled, wxItemKind kind, wxObject *clientData, const wxString& shortHelp, @@ -665,8 +666,8 @@ wxToolBarTool::wxToolBarTool( wxToolBarToolBase *wxToolBar::CreateTool( int id, const wxString& label, - const wxBitmap& bmpNormal, - const wxBitmap& bmpDisabled, + const wxBitmapBundle& bmpNormal, + const wxBitmapBundle& bmpDisabled, wxItemKind kind, wxObject *clientData, const wxString& shortHelp, @@ -1380,7 +1381,7 @@ void wxToolBar::MacSuperChangedPosition() */ } -void wxToolBar::SetToolNormalBitmap( int id, const wxBitmap& bitmap ) +void wxToolBar::SetToolNormalBitmap( int id, const wxBitmapBundle& bitmap ) { wxToolBarTool* tool = static_cast(FindById(id)); if ( tool ) @@ -1394,7 +1395,7 @@ void wxToolBar::SetToolNormalBitmap( int id, const wxBitmap& bitmap ) } } -void wxToolBar::SetToolDisabledBitmap( int id, const wxBitmap& bitmap ) +void wxToolBar::SetToolDisabledBitmap( int id, const wxBitmapBundle& bitmap ) { wxToolBarTool* tool = static_cast(FindById(id)); if ( tool ) diff --git a/src/osx/core/bmpbndl.mm b/src/osx/core/bmpbndl.mm new file mode 100644 index 0000000000..582d171b82 --- /dev/null +++ b/src/osx/core/bmpbndl.mm @@ -0,0 +1,180 @@ +/////////////////////////////////////////////////////////////////////////////// +// Name: src/osx/core/bmpbndl.mm +// Purpose: OSX-specific part of wxBitmapBundle class. +// Author: Vadim Zeitlin and Stefan Csomor +// Created: 2021-09-22 +// Copyright: (c) 2021 Vadim Zeitlin +// Licence: wxWindows licence +/////////////////////////////////////////////////////////////////////////////// + +// ============================================================================ +// declarations +// ============================================================================ + +// ---------------------------------------------------------------------------- +// headers +// ---------------------------------------------------------------------------- + +// for compilers that support precompilation, includes "wx.h". +#include "wx/wxprec.h" + +#ifndef WX_PRECOMP +#endif // WX_PRECOMP + +#include "wx/bmpbndl.h" + +#include "wx/private/bmpbndl.h" + +#include "wx/osx/private.h" + +#include + +// ---------------------------------------------------------------------------- +// private helpers +// ---------------------------------------------------------------------------- + +namespace +{ +// Bundle implementation using PNG bitmaps from Windows resources. +class wxOSXImageBundleImpl : public wxBitmapBundleImpl +{ +public: + // Ctor takes the vector containing all the existing resources starting + // with the given name and the valid bitmap corresponding to the base name + // resource itself. + wxOSXImageBundleImpl(WXImage image); + ~wxOSXImageBundleImpl(); + + virtual wxSize GetDefaultSize() const wxOVERRIDE; + virtual wxBitmap GetBitmap(const wxSize size) wxOVERRIDE; + + virtual WXImage OSXGetImage() const wxOVERRIDE; + +private: + WXImage m_nsImage; +}; + +} // anonymouse namespace + +// ============================================================================ +// wxOSXImageBundleImpl implementation +// ============================================================================ + +wxOSXImageBundleImpl::wxOSXImageBundleImpl(WXImage image) +{ + m_nsImage = (WXImage) wxMacCocoaRetain(image); +} + +wxOSXImageBundleImpl::~wxOSXImageBundleImpl() +{ + wxMacCocoaRelease(m_nsImage); +} + +wxSize wxOSXImageBundleImpl::GetDefaultSize() const +{ + CGSize sz = wxOSXGetImageSize(m_nsImage); + return wxSize(sz.width, sz.height); +} + +wxBitmap wxOSXImageBundleImpl::GetBitmap(const wxSize size) +{ + return wxBitmap(); +} + +WXImage wxOSXImageBundleImpl::OSXGetImage() const +{ + return m_nsImage; +} + +wxBitmapBundle wxOSXMakeBundleFromImage( WXImage img) +{ + return wxBitmapBundle::FromImpl( new wxOSXImageBundleImpl(img) ); +} + +// ============================================================================ +// wxOSXImageBundleImpl implementation +// ============================================================================ + +WXImage wxOSXImageFromBitmap( const wxBitmap& bmp) +{ + WXImage image; +#if wxOSX_USE_COCOA + double scale = bmp.GetScaleFactor(); + NSSize sz = NSMakeSize( bmp.GetWidth()*scale, bmp.GetHeight()*scale); + image = [[NSImage alloc] initWithSize:sz]; + wxOSXAddBitmapToImage(image, bmp); +#else + wxCFRef cgimage = bmp.CreateCGImage(); + image = [[UIImage alloc] initWithCGImage:cgimage scale:bmp.GetScaleFactor() orientation:UIImageOrientationUp]; +#endif + [image autorelease]; + return image; +} + +#if wxOSX_USE_COCOA +void wxOSXAddBitmapToImage( WXImage image, const wxBitmap& bmp) +{ + wxCFRef cgimage = bmp.CreateCGImage(); + NSImageRep* nsrep = [[NSBitmapImageRep alloc] initWithCGImage:cgimage]; + [image addRepresentation:nsrep]; + [nsrep release]; +} +#endif + +wxBitmapBundle wxBitmapBundle::FromResources(const wxString& name) +{ + wxVector resources; + + wxString ext = "png"; // TODO adapt as soon as we get res param + wxCFStringRef restype(ext); + + for ( int dpiFactor = 1 ; dpiFactor <= 2 ; ++dpiFactor) + { + wxString filename; + if ( dpiFactor == 1 ) + filename = name; + else + filename = wxString::Format("%s@%dx", name, dpiFactor); + + wxCFStringRef resname(filename); + wxCFRef imageURL(CFBundleCopyResourceURL(CFBundleGetMainBundle(), resname, restype, NULL)); + if ( !imageURL.get() && dpiFactor != 1 ) + { + // try alternate naming scheme + filename = wxString::Format("%s_%dx", name, dpiFactor); + resname = wxCFStringRef(filename); + imageURL = CFBundleCopyResourceURL(CFBundleGetMainBundle(), resname, restype, NULL); + } + if ( imageURL.get() ) + { + // Create the data provider object + wxCFRef provider(CGDataProviderCreateWithURL (imageURL) ); + CGImageRef image = NULL; + + if ( ext == "jpeg" ) + image = CGImageCreateWithJPEGDataProvider (provider, NULL, true, + kCGRenderingIntentDefault); + else if ( ext == "png" ) + image = CGImageCreateWithPNGDataProvider (provider, NULL, true, + kCGRenderingIntentDefault); + if ( image != NULL ) + { + wxBitmap bmp(image, dpiFactor); + CGImageRelease(image); + resources.push_back(bmp); + } + } + } + + return wxBitmapBundle::FromBitmaps(resources); +} + +WXImage wxOSXGetImageFromBundle(const wxBitmapBundle& bundle) +{ + WXImage image = bundle.GetImpl()->OSXGetImage(); + + if (image == 0) + image = bundle.GetBitmap(bundle.GetDefaultSize()).OSXGetImage(); + + return image; +} diff --git a/src/osx/iphone/toolbar.mm b/src/osx/iphone/toolbar.mm index 0c22197ebf..ce8f83e6e5 100644 --- a/src/osx/iphone/toolbar.mm +++ b/src/osx/iphone/toolbar.mm @@ -19,10 +19,13 @@ #endif #include "wx/app.h" -#include "wx/osx/private.h" #include "wx/geometry.h" #include "wx/sysopt.h" +#include "wx/private/bmpbndl.h" + +#include "wx/osx/private.h" + #pragma mark - #pragma mark Tool Implementation @@ -58,8 +61,8 @@ public: wxToolBar *tbar, int id, const wxString& label, - const wxBitmap& bmpNormal, - const wxBitmap& bmpDisabled, + const wxBitmapBundle& bmpNormal, + const wxBitmapBundle& bmpDisabled, wxItemKind kind, wxObject *clientData, const wxString& shortHelp, @@ -104,8 +107,8 @@ wxToolBarTool::wxToolBarTool( wxToolBar *tbar, int id, const wxString& label, - const wxBitmap& bmpNormal, - const wxBitmap& bmpDisabled, + const wxBitmapBundle& bmpNormal, + const wxBitmapBundle& bmpDisabled, wxItemKind kind, wxObject *clientData, const wxString& shortHelp, @@ -127,7 +130,7 @@ wxToolBarToolBase( } else if ( bmpNormal.IsOk() ) { - bui = [bui initWithImage:bmpNormal.GetUIImage() style:UIBarButtonItemStylePlain target:toolbar + bui = [bui initWithImage:wxOSXGetImageFromBundle(bmpNormal) style:UIBarButtonItemStylePlain target:toolbar action:@selector(clickedAction:)]; } else @@ -180,8 +183,8 @@ wxToolBarTool::~wxToolBarTool() wxToolBarToolBase *wxToolBar::CreateTool( int id, const wxString& label, - const wxBitmap& bmpNormal, - const wxBitmap& bmpDisabled, + const wxBitmapBundle& bmpNormal, + const wxBitmapBundle& bmpDisabled, wxItemKind kind, wxObject *clientData, const wxString& shortHelp, @@ -296,7 +299,7 @@ void wxToolBar::SetRows(int nRows) m_maxRows = nRows; } -void wxToolBar::SetToolNormalBitmap( int id, const wxBitmap& bitmap ) +void wxToolBar::SetToolNormalBitmap( int id, const wxBitmapBundle& bitmap ) { wxToolBarTool* tool = static_cast(FindById(id)); if ( tool ) @@ -307,7 +310,7 @@ void wxToolBar::SetToolNormalBitmap( int id, const wxBitmap& bitmap ) } } -void wxToolBar::SetToolDisabledBitmap( int id, const wxBitmap& bitmap ) +void wxToolBar::SetToolDisabledBitmap( int id, const wxBitmapBundle& bitmap ) { wxToolBarTool* tool = static_cast(FindById(id)); if ( tool ) diff --git a/src/qt/toolbar.cpp b/src/qt/toolbar.cpp index 61a765e1c0..953713bddf 100644 --- a/src/qt/toolbar.cpp +++ b/src/qt/toolbar.cpp @@ -28,8 +28,8 @@ class wxQtToolButton; class wxToolBarTool : public wxToolBarToolBase { public: - wxToolBarTool(wxToolBar *tbar, int id, const wxString& label, const wxBitmap& bitmap1, - const wxBitmap& bitmap2, wxItemKind kind, wxObject *clientData, + wxToolBarTool(wxToolBar *tbar, int id, const wxString& label, const wxBitmapBundle& bitmap1, + const wxBitmapBundle& bitmap2, wxItemKind kind, wxObject *clientData, const wxString& shortHelpString, const wxString& longHelpString) : wxToolBarToolBase(tbar, id, label, bitmap1, bitmap2, kind, clientData, shortHelpString, longHelpString) @@ -194,7 +194,7 @@ void wxToolBar::SetToolShortHelp( int id, const wxString& helpString ) } } -void wxToolBar::SetToolNormalBitmap( int id, const wxBitmap& bitmap ) +void wxToolBar::SetToolNormalBitmap( int id, const wxBitmapBundle& bitmap ) { wxToolBarTool* tool = static_cast(FindById(id)); if ( tool ) @@ -206,7 +206,7 @@ void wxToolBar::SetToolNormalBitmap( int id, const wxBitmap& bitmap ) } } -void wxToolBar::SetToolDisabledBitmap( int id, const wxBitmap& bitmap ) +void wxToolBar::SetToolDisabledBitmap( int id, const wxBitmapBundle& bitmap ) { wxToolBarTool* tool = static_cast(FindById(id)); if ( tool ) @@ -364,8 +364,8 @@ void wxToolBar::DoSetToggle(wxToolBarToolBase * WXUNUSED(tool), wxFAIL_MSG( wxT("not implemented") ); } -wxToolBarToolBase *wxToolBar::CreateTool(int id, const wxString& label, const wxBitmap& bmpNormal, - const wxBitmap& bmpDisabled, wxItemKind kind, wxObject *clientData, +wxToolBarToolBase *wxToolBar::CreateTool(int id, const wxString& label, const wxBitmapBundle& bmpNormal, + const wxBitmapBundle& bmpDisabled, wxItemKind kind, wxObject *clientData, const wxString& shortHelp, const wxString& longHelp) { return new wxToolBarTool(this, id, label, bmpNormal, bmpDisabled, kind, diff --git a/src/univ/toolbar.cpp b/src/univ/toolbar.cpp index e37c4c20d1..fce33ce6fc 100644 --- a/src/univ/toolbar.cpp +++ b/src/univ/toolbar.cpp @@ -78,8 +78,8 @@ public: wxToolBarTool(wxToolBar *tbar, int id, const wxString& label, - const wxBitmap& bmpNormal, - const wxBitmap& bmpDisabled, + const wxBitmapBundle& bmpNormal, + const wxBitmapBundle& bmpDisabled, wxItemKind kind, wxObject *clientData, const wxString& shortHelp, @@ -313,8 +313,8 @@ void wxToolBar::DoSetToggle(wxToolBarToolBase *tool, bool WXUNUSED(toggle)) wxToolBarToolBase *wxToolBar::CreateTool(int id, const wxString& label, - const wxBitmap& bmpNormal, - const wxBitmap& bmpDisabled, + const wxBitmapBundle& bmpNormal, + const wxBitmapBundle& bmpDisabled, wxItemKind kind, wxObject *clientData, const wxString& shortHelp, diff --git a/tests/Makefile.in b/tests/Makefile.in index 41e448c2b8..afefe8f5f7 100644 --- a/tests/Makefile.in +++ b/tests/Makefile.in @@ -183,6 +183,7 @@ TEST_GUI_OBJECTS = \ test_gui_point.o \ test_gui_region.o \ test_gui_bitmap.o \ + test_gui_bmpbundle.o \ test_gui_colour.o \ test_gui_ellipsization.o \ test_gui_measuring.o \ @@ -904,6 +905,9 @@ test_gui_region.o: $(srcdir)/geometry/region.cpp $(TEST_GUI_ODEP) test_gui_bitmap.o: $(srcdir)/graphics/bitmap.cpp $(TEST_GUI_ODEP) $(CXXC) -c -o $@ $(TEST_GUI_CXXFLAGS) $(srcdir)/graphics/bitmap.cpp +test_gui_bmpbundle.o: $(srcdir)/graphics/bmpbundle.cpp $(TEST_GUI_ODEP) + $(CXXC) -c -o $@ $(TEST_GUI_CXXFLAGS) $(srcdir)/graphics/bmpbundle.cpp + test_gui_colour.o: $(srcdir)/graphics/colour.cpp $(TEST_GUI_ODEP) $(CXXC) -c -o $@ $(TEST_GUI_CXXFLAGS) $(srcdir)/graphics/colour.cpp diff --git a/tests/graphics/bmpbundle.cpp b/tests/graphics/bmpbundle.cpp new file mode 100644 index 0000000000..aaddfc546a --- /dev/null +++ b/tests/graphics/bmpbundle.cpp @@ -0,0 +1,79 @@ +/////////////////////////////////////////////////////////////////////////////// +// Name: tests/graphics/bmpbundle.cpp +// Purpose: wxBitmapBundle unit test +// Author: Vadim Zeitlin +// Created: 2021-09-27 +// Copyright: (c) 2021 Vadim Zeitlin +/////////////////////////////////////////////////////////////////////////////// + +// ---------------------------------------------------------------------------- +// headers +// ---------------------------------------------------------------------------- + +#include "testprec.h" + +#include "wx/bmpbndl.h" + +#include "asserthelper.h" + +// ---------------------------------------------------------------------------- +// tests +// ---------------------------------------------------------------------------- + +TEST_CASE("BitmapBundle::Create", "[bmpbundle]") +{ + wxBitmapBundle b; + CHECK( !b.IsOk() ); + CHECK( b.GetDefaultSize() == wxDefaultSize ); + + b = wxBitmap(16, 16); + CHECK( b.IsOk() ); + CHECK( b.GetDefaultSize() == wxSize(16, 16) ); +} + +TEST_CASE("BitmapBundle::FromBitmaps", "[bmpbundle]") +{ + wxVector bitmaps; + bitmaps.push_back(wxBitmap(16, 16)); + bitmaps.push_back(wxBitmap(24, 24)); + + wxBitmapBundle b = wxBitmapBundle::FromBitmaps(bitmaps); + REQUIRE( b.IsOk() ); + CHECK( b.GetDefaultSize() == wxSize(16, 16) ); + + CHECK( b.GetBitmap(wxDefaultSize ).GetSize() == wxSize(16, 16) ); + CHECK( b.GetBitmap(wxSize(16, 16)).GetSize() == wxSize(16, 16) ); + CHECK( b.GetBitmap(wxSize(20, 20)).GetSize() == wxSize(20, 20) ); + CHECK( b.GetBitmap(wxSize(24, 24)).GetSize() == wxSize(24, 24) ); +} + +#ifdef wxHAS_SVG + +TEST_CASE("BitmapBundle::FromSVG", "[bmpbundle][svg]") +{ + static const char svg_data[] = +"" +"" +"" +"" +"" +"" +"" + ; + + wxBitmapBundle b = wxBitmapBundle::FromSVG(svg_data, wxSize(20, 20)); + REQUIRE( b.IsOk() ); + CHECK( b.GetDefaultSize() == wxSize(20, 20) ); + + CHECK( b.GetBitmap(wxSize(32, 32)).GetSize() == wxSize(32, 32) ); + + // Check that not using XML header works too. + const char* svg_tag_start = strstr(svg_data, " + diff --git a/tests/test_gui.vcxproj.filters b/tests/test_gui.vcxproj.filters index 4528b32f47..25a943ac30 100644 --- a/tests/test_gui.vcxproj.filters +++ b/tests/test_gui.vcxproj.filters @@ -23,6 +23,9 @@ Source Files + + Source Files + Source Files @@ -320,4 +323,4 @@ Resource Files - \ No newline at end of file + diff --git a/tests/test_vc8_test_gui.vcproj b/tests/test_vc8_test_gui.vcproj index db9e9d3d4c..150f9f8879 100644 --- a/tests/test_vc8_test_gui.vcproj +++ b/tests/test_vc8_test_gui.vcproj @@ -858,6 +858,10 @@ RelativePath=".\controls\bitmaptogglebuttontest.cpp" > + + diff --git a/tests/test_vc9_test_gui.vcproj b/tests/test_vc9_test_gui.vcproj index 867da681f6..64c7eced6f 100644 --- a/tests/test_vc9_test_gui.vcproj +++ b/tests/test_vc9_test_gui.vcproj @@ -830,6 +830,10 @@ RelativePath=".\controls\bitmaptogglebuttontest.cpp" > + +