diff --git a/Makefile.in b/Makefile.in index 73bc043727..e580468523 100644 --- a/Makefile.in +++ b/Makefile.in @@ -4049,6 +4049,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 \ @@ -4709,7 +4710,8 @@ 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_bmpbndl.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) \ @@ -4971,7 +4973,8 @@ 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_bmpbndl.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 \ @@ -6705,7 +6708,8 @@ 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_bmpbndl.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) \ @@ -6967,7 +6971,8 @@ 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_bmpbndl.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 \ @@ -8854,7 +8859,8 @@ 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_bmpbndl.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) \ @@ -9116,7 +9122,8 @@ 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_bmpbndl.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 \ @@ -10579,7 +10586,8 @@ 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_bmpbndl.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) \ @@ -10841,7 +10849,8 @@ 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_bmpbndl.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 \ @@ -21014,6 +21023,9 @@ 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_bmpbndl.o: $(srcdir)/src/common/bmpbndl.cpp $(MONODLL_ODEP) +@COND_USE_GUI_1@ $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/common/bmpbndl.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 @@ -26303,6 +26315,9 @@ 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_bmpbndl.o: $(srcdir)/src/common/bmpbndl.cpp $(MONOLIB_ODEP) +@COND_USE_GUI_1@ $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/common/bmpbndl.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 @@ -31697,6 +31712,9 @@ 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_bmpbndl.o: $(srcdir)/src/common/bmpbndl.cpp $(COREDLL_ODEP) +@COND_USE_GUI_1@ $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $(srcdir)/src/common/bmpbndl.cpp + corelib_event.o: $(srcdir)/src/common/event.cpp $(CORELIB_ODEP) $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $(srcdir)/src/common/event.cpp @@ -35951,6 +35969,9 @@ 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_bmpbndl.o: $(srcdir)/src/common/bmpbndl.cpp $(CORELIB_ODEP) +@COND_USE_GUI_1@ $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $(srcdir)/src/common/bmpbndl.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 20f690cf12..a4d673f43a 100644 --- a/build/bakefiles/files.bkl +++ b/build/bakefiles/files.bkl @@ -1015,6 +1015,7 @@ 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 wx/affinematrix2dbase.h @@ -1306,6 +1307,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 diff --git a/build/cmake/files.cmake b/build/cmake/files.cmake index 8e5bee9963..b0ff257df4 100644 --- a/build/cmake/files.cmake +++ b/build/cmake/files.cmake @@ -918,6 +918,7 @@ set(GUI_CMN_SRC src/generic/creddlgg.cpp src/generic/rowheightcache.cpp src/generic/animateg.cpp + src/common/bmpbndl.cpp ) set(GUI_CMN_HDR @@ -1209,6 +1210,7 @@ set(GUI_CMN_HDR wx/creddlg.h wx/generic/creddlgg.h wx/generic/animate.h + wx/bmpbndl.h ) set(UNIX_SRC diff --git a/build/files b/build/files index 66277ee757..e8584a4cd6 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 @@ -950,6 +951,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 diff --git a/build/msw/makefile.gcc b/build/msw/makefile.gcc index fcb8ae9aa3..438b69dd16 100644 --- a/build/msw/makefile.gcc +++ b/build/msw/makefile.gcc @@ -2201,7 +2201,8 @@ ____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_bmpbndl.o endif endif ifeq ($(USE_GUI),1) @@ -2531,7 +2532,8 @@ ____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_bmpbndl.o endif endif ifeq ($(USE_STC),1) @@ -3043,7 +3045,8 @@ ____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_bmpbndl.o endif endif ifeq ($(USE_GUI),1) @@ -3373,7 +3376,8 @@ ____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_bmpbndl.o endif endif ifeq ($(USE_STC),1) @@ -3768,7 +3772,8 @@ ____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_bmpbndl.o endif endif ifeq ($(USE_GUI),1) @@ -4098,7 +4103,8 @@ ____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_bmpbndl.o endif endif ifeq ($(MONOLITHIC),0) @@ -4451,7 +4457,8 @@ ____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_bmpbndl.o endif endif ifeq ($(USE_GUI),1) @@ -4781,7 +4788,8 @@ ____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_bmpbndl.o endif endif ifeq ($(SHARED),1) @@ -9456,6 +9464,11 @@ $(OBJS)\monodll_rowheightcache.o: ../../src/generic/rowheightcache.cpp $(CXX) -c -o $@ $(MONODLL_CXXFLAGS) $(CPPDEPS) $< endif +ifeq ($(USE_GUI),1) +$(OBJS)\monodll_bmpbndl.o: ../../src/common/bmpbndl.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 @@ -12030,6 +12043,11 @@ $(OBJS)\monolib_rowheightcache.o: ../../src/generic/rowheightcache.cpp $(CXX) -c -o $@ $(MONOLIB_CXXFLAGS) $(CPPDEPS) $< endif +ifeq ($(USE_GUI),1) +$(OBJS)\monolib_bmpbndl.o: ../../src/common/bmpbndl.cpp + $(CXX) -c -o $@ $(MONOLIB_CXXFLAGS) $(CPPDEPS) $< +endif + $(OBJS)\basedll_dummy.o: ../../src/common/dummy.cpp $(CXX) -c -o $@ $(BASEDLL_CXXFLAGS) $(CPPDEPS) $< @@ -14577,6 +14595,11 @@ $(OBJS)\coredll_rowheightcache.o: ../../src/generic/rowheightcache.cpp $(CXX) -c -o $@ $(COREDLL_CXXFLAGS) $(CPPDEPS) $< endif +ifeq ($(USE_GUI),1) +$(OBJS)\coredll_bmpbndl.o: ../../src/common/bmpbndl.cpp + $(CXX) -c -o $@ $(COREDLL_CXXFLAGS) $(CPPDEPS) $< +endif + $(OBJS)\corelib_dummy.o: ../../src/common/dummy.cpp $(CXX) -c -o $@ $(CORELIB_CXXFLAGS) $(CPPDEPS) $< @@ -16317,6 +16340,11 @@ $(OBJS)\corelib_rowheightcache.o: ../../src/generic/rowheightcache.cpp $(CXX) -c -o $@ $(CORELIB_CXXFLAGS) $(CPPDEPS) $< endif +ifeq ($(USE_GUI),1) +$(OBJS)\corelib_bmpbndl.o: ../../src/common/bmpbndl.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 e8fd66a266..8eafa88214 100644 --- a/build/msw/makefile.vc +++ b/build/msw/makefile.vc @@ -2531,7 +2531,8 @@ ____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_bmpbndl.obj !endif !if "$(USE_GUI)" == "1" && "$(WXUNIV)" == "1" ____CORE_SRC_FILENAMES_OBJECTS = \ @@ -2859,7 +2860,8 @@ ____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_bmpbndl.obj !endif !if "$(USE_STC)" == "1" ____MONOLIB_STC_SRC_FILENAMES_OBJECTS = \ @@ -3373,7 +3375,8 @@ ____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_bmpbndl.obj !endif !if "$(USE_GUI)" == "1" && "$(WXUNIV)" == "1" ____CORE_SRC_FILENAMES_1_OBJECTS = \ @@ -3701,7 +3704,8 @@ ____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_bmpbndl.obj !endif !if "$(USE_STC)" == "1" ____MONOLIB_STC_SRC_FILENAMES_1_OBJECTS = \ @@ -4148,7 +4152,8 @@ ____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_bmpbndl.obj !endif !if "$(USE_GUI)" == "1" && "$(WXUNIV)" == "1" ____CORE_SRC_FILENAMES_2_OBJECTS = \ @@ -4476,7 +4481,8 @@ ____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_bmpbndl.obj !endif !if "$(MONOLITHIC)" == "0" && "$(SHARED)" == "0" && "$(USE_GUI)" == "1" __corelib___depname = \ @@ -4829,7 +4835,8 @@ ____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_bmpbndl.obj !endif !if "$(USE_GUI)" == "1" && "$(WXUNIV)" == "1" ____CORE_SRC_FILENAMES_3_OBJECTS = \ @@ -5157,7 +5164,8 @@ ____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_bmpbndl.obj !endif !if "$(SHARED)" == "1" ____wxcore_namedll_DEP = $(__coredll___depname) @@ -9887,6 +9895,11 @@ $(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_bmpbndl.obj: ..\..\src\common\bmpbndl.cpp + $(CXX) /c /nologo /TP /Fo$@ $(MONODLL_CXXFLAGS) ..\..\src\common\bmpbndl.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 @@ -12461,6 +12474,11 @@ $(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_bmpbndl.obj: ..\..\src\common\bmpbndl.cpp + $(CXX) /c /nologo /TP /Fo$@ $(MONOLIB_CXXFLAGS) ..\..\src\common\bmpbndl.cpp +!endif + $(OBJS)\basedll_dummy.obj: ..\..\src\common\dummy.cpp $(CXX) /c /nologo /TP /Fo$@ $(BASEDLL_CXXFLAGS) /Ycwx/wxprec.h ..\..\src\common\dummy.cpp @@ -15008,6 +15026,11 @@ $(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_bmpbndl.obj: ..\..\src\common\bmpbndl.cpp + $(CXX) /c /nologo /TP /Fo$@ $(COREDLL_CXXFLAGS) ..\..\src\common\bmpbndl.cpp +!endif + $(OBJS)\corelib_dummy.obj: ..\..\src\common\dummy.cpp $(CXX) /c /nologo /TP /Fo$@ $(CORELIB_CXXFLAGS) /Ycwx/wxprec.h ..\..\src\common\dummy.cpp @@ -16748,6 +16771,11 @@ $(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_bmpbndl.obj: ..\..\src\common\bmpbndl.cpp + $(CXX) /c /nologo /TP /Fo$@ $(CORELIB_CXXFLAGS) ..\..\src\common\bmpbndl.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..6ccddecfb6 100644 --- a/build/msw/wx_core.vcxproj +++ b/build/msw/wx_core.vcxproj @@ -459,6 +459,7 @@ + @@ -1087,6 +1088,7 @@ true true + diff --git a/build/msw/wx_core.vcxproj.filters b/build/msw/wx_core.vcxproj.filters index 53d84d94a5..f743597569 100644 --- a/build/msw/wx_core.vcxproj.filters +++ b/build/msw/wx_core.vcxproj.filters @@ -1068,6 +1068,9 @@ Common Sources + + Common Sources + @@ -2299,6 +2302,9 @@ Common Headers + + Common Headers + diff --git a/build/msw/wx_vc8_core.vcproj b/build/msw/wx_vc8_core.vcproj index 9e1cc432f5..c835118cb6 100644 --- a/build/msw/wx_vc8_core.vcproj +++ b/build/msw/wx_vc8_core.vcproj @@ -785,6 +785,10 @@ RelativePath="..\..\src\common\bmpbase.cpp" > + + @@ -3316,6 +3320,10 @@ RelativePath="..\..\include\wx\bitmap.h" > + + diff --git a/build/msw/wx_vc9_core.vcproj b/build/msw/wx_vc9_core.vcproj index 0fce999ed3..730f268991 100644 --- a/build/msw/wx_vc9_core.vcproj +++ b/build/msw/wx_vc9_core.vcproj @@ -781,6 +781,10 @@ RelativePath="..\..\src\common\bmpbase.cpp" > + + @@ -3312,6 +3316,10 @@ RelativePath="..\..\include\wx\bitmap.h" > + + diff --git a/include/wx/bmpbndl.h b/include/wx/bmpbndl.h new file mode 100644 index 0000000000..db041ad375 --- /dev/null +++ b/include/wx/bmpbndl.h @@ -0,0 +1,120 @@ +/////////////////////////////////////////////////////////////////////////////// +// 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; + +// ---------------------------------------------------------------------------- +// 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); + + + // 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; + +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; +}; + +// 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)); +} + +#endif // _WX_BMPBNDL_H_ 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/private/bmpbndl.h b/include/wx/private/bmpbndl.h new file mode 100644 index 0000000000..fd17d82041 --- /dev/null +++ b/include/wx/private/bmpbndl.h @@ -0,0 +1,37 @@ +/////////////////////////////////////////////////////////////////////////////// +// 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/object.h" + +// ---------------------------------------------------------------------------- +// 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. +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; +}; + +#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/bmpbndl.h b/interface/wx/bmpbndl.h new file mode 100644 index 0000000000..3b95a74c7a --- /dev/null +++ b/interface/wx/bmpbndl.h @@ -0,0 +1,179 @@ +///////////////////////////////////////////////////////////////////////////// +// 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. + + 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); + + /** + Check if bitmap bundle is non-empty. + + Return @true if the bundle contains any bitmaps or @false if it is + empty. + */ + bool IsOk() const; + + /** + Get the size of the bitmap represented by this bundle in default + resolution or, equivalently, at 100% scaling. + + When creating the bundle from a number of bitmaps, this will be just + the size of the smallest bitmap in it. + + Note that this function is mostly used by wxWidgets itself and not the + application. + */ + wxSize GetDefaultSize() const; + + /** + Get bitmap of the specified size, creating a new bitmap from the closest + available size by rescaling it if necessary. + + This function is mostly used by wxWidgets itself and not the + application. As all bitmaps created by it dynamically are currently + cached, avoid calling it for many different sizes if you do use it, as + this will create many bitmaps that will never be deleted and will + consume resources until the application termination. + */ + wxBitmap GetBitmap(const wxSize size) const; +}; diff --git a/interface/wx/toolbar.h b/interface/wx/toolbar.h index 3cdb064c73..6961be25bd 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, @@ -895,7 +895,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 +921,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 +982,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..300cc1b4ca 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" @@ -50,9 +51,8 @@ #include "../sample.xpm" #endif // !wxHAS_IMAGES_IN_RESOURCES -// If PNG files are not available in resources, we need to embed them in the -// program itself. We could also load them during run-time. -#ifndef wxHAS_IMAGE_RESOURCES +// Temporarily embed bitmaps in the program itself on all platforms. +#if 1 // ndef wxHAS_IMAGE_RESOURCES #include "bitmaps/new_png.c" #include "bitmaps/open_png.c" #include "bitmaps/save_png.c" @@ -389,46 +389,36 @@ void MyFrame::PopulateToolbar(wxToolBarBase* toolBar) 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 ); - } + // This macro relies on having name_png and name_2x_png arrays defined, + // (this is done in this sample by including the corresponding *_png.c files + // above). + #define BUNDLE_2(name) \ + wxBitmapBundle::FromBitmaps(wxBITMAP_PNG_FROM_DATA(name), \ + wxBITMAP_PNG_FROM_DATA(name##_2x)) - int w = toolBarBitmaps[Tool_new].GetWidth(), - h = toolBarBitmaps[Tool_new].GetHeight(); + toolBarBitmaps[Tool_new ] = BUNDLE_2(new ); + toolBarBitmaps[Tool_open ] = BUNDLE_2(open ); + toolBarBitmaps[Tool_save ] = BUNDLE_2(save ); + toolBarBitmaps[Tool_copy ] = BUNDLE_2(copy ); + toolBarBitmaps[Tool_cut ] = BUNDLE_2(cut ); + toolBarBitmaps[Tool_paste] = BUNDLE_2(paste); + toolBarBitmaps[Tool_print] = BUNDLE_2(print); + toolBarBitmaps[Tool_help ] = BUNDLE_2(help ); + + // Size of the bitmaps we use by default. + int w = 32, + h = 32; if ( !m_smallToolbar ) { w *= 2; h *= 2; - - for ( size_t n = Tool_new; n < WXSIZEOF(toolBarBitmaps); n++ ) - { - toolBarBitmaps[n] = - wxBitmap(toolBarBitmaps[n].ConvertToImage().Scale(w, h)); - } } + toolBar->SetToolBitmapSize(wxSize(w, h)); + toolBar->AddTool(wxID_NEW, "New", toolBarBitmaps[Tool_new], wxNullBitmap, wxITEM_DROPDOWN, "New file", "This is help for new file tool"); @@ -472,7 +462,7 @@ void MyFrame::PopulateToolbar(wxToolBarBase* toolBar) { wxMemoryDC dc; dc.SelectObject(bmpDisabled); - dc.DrawBitmap(toolBarBitmaps[Tool_print], 0, 0); + dc.DrawBitmap(toolBarBitmaps[Tool_print].GetBitmap(wxSize(w, h)), 0, 0); wxPen pen(*wxRED, 5); dc.SetPen(pen); diff --git a/src/common/bmpbndl.cpp b/src/common/bmpbndl.cpp new file mode 100644 index 0000000000..c594747f8d --- /dev/null +++ b/src/common/bmpbndl.cpp @@ -0,0 +1,261 @@ +/////////////////////////////////////////////////////////////////////////////// +// 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 + +// ---------------------------------------------------------------------------- +// 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); + } + + virtual wxSize GetDefaultSize() const wxOVERRIDE; + virtual wxBitmap GetBitmap(const wxSize size) wxOVERRIDE; + +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(); +} + +// ============================================================================ +// 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)); +} + +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/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/toolbar.cpp b/src/msw/toolbar.cpp index 07ccd29108..36d5840058 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 ) 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,