From 685e3af613761f0a788de018a2a71f5f54d5a22d Mon Sep 17 00:00:00 2001 From: Alexander Koshelev Date: Mon, 7 Feb 2022 12:44:02 +0300 Subject: [PATCH] Use wxBitmapBundle in combo sample Replace PNG files with SVG ones. Closes #22103. --- build/cmake/samples/CMakeLists.txt | 2 +- samples/combo/Makefile.in | 2 +- samples/combo/combo.bkl | 7 ++--- samples/combo/combo.cpp | 42 +++++------------------------ samples/combo/dropbuth.png | Bin 371 -> 0 bytes samples/combo/dropbuth.svg | 7 +++++ samples/combo/dropbutn.png | Bin 237 -> 0 bytes samples/combo/dropbutn.svg | 4 +++ samples/combo/dropbutp.png | Bin 366 -> 0 bytes samples/combo/dropbutp.svg | 7 +++++ samples/combo/makefile.gcc | 2 +- samples/combo/makefile.vc | 2 +- samples/combo/three-dots.svg | 4 +++ 13 files changed, 37 insertions(+), 42 deletions(-) delete mode 100644 samples/combo/dropbuth.png create mode 100644 samples/combo/dropbuth.svg delete mode 100644 samples/combo/dropbutn.png create mode 100644 samples/combo/dropbutn.svg delete mode 100644 samples/combo/dropbutp.png create mode 100644 samples/combo/dropbutp.svg create mode 100644 samples/combo/three-dots.svg diff --git a/build/cmake/samples/CMakeLists.txt b/build/cmake/samples/CMakeLists.txt index cf650069d1..82357c1604 100644 --- a/build/cmake/samples/CMakeLists.txt +++ b/build/cmake/samples/CMakeLists.txt @@ -16,7 +16,7 @@ wx_add_sample(calendar DEPENDS wxUSE_CALENDARCTRL) wx_add_sample(caret DEPENDS wxUSE_CARET) wx_add_sample(clipboard DEPENDS wxUSE_CLIPBOARD) wx_add_sample(collpane DEPENDS wxUSE_COLLPANE) -wx_add_sample(combo DATA dropbuth.png dropbutn.png dropbutp.png DEPENDS wxUSE_COMBOCTRL) +wx_add_sample(combo DATA dropbuth.svg dropbutn.svg dropbutp.svg three-dots.svg DEPENDS wxUSE_COMBOCTRL) wx_add_sample(config conftest.cpp DEPENDS wxUSE_CONFIG) wx_add_sample(console CONSOLE IMPORTANT) wx_add_sample(dataview IMPORTANT dataview.cpp mymodels.cpp mymodels.h DEPENDS wxUSE_DATAVIEWCTRL) diff --git a/samples/combo/Makefile.in b/samples/combo/Makefile.in index dfeda5666a..0286a6297e 100644 --- a/samples/combo/Makefile.in +++ b/samples/combo/Makefile.in @@ -184,7 +184,7 @@ combo$(EXEEXT): $(COMBO_OBJECTS) $(__combo___win32rc) data: @mkdir -p . - @for f in dropbuth.png dropbutn.png dropbutp.png; do \ + @for f in dropbuth.svg dropbutn.svg dropbutp.svg three-dots.svg; do \ if test ! -f ./$$f -a ! -d ./$$f ; \ then x=yep ; \ else x=`find $(srcdir)/$$f -newer ./$$f -print` ; \ diff --git a/samples/combo/combo.bkl b/samples/combo/combo.bkl index 8b5869d52d..f8bb569e47 100644 --- a/samples/combo/combo.bkl +++ b/samples/combo/combo.bkl @@ -12,9 +12,10 @@ - dropbuth.png - dropbutn.png - dropbutp.png + dropbuth.svg + dropbutn.svg + dropbutp.svg + three-dots.svg diff --git a/samples/combo/combo.cpp b/samples/combo/combo.cpp index cddbc62ce4..5e0c4479f6 100644 --- a/samples/combo/combo.cpp +++ b/samples/combo/combo.cpp @@ -538,32 +538,7 @@ public: style | wxCC_STD_BUTTON, validator,name); - // - // Prepare custom button bitmap (just '...' text) - wxMemoryDC dc; - wxBitmap bmp(12,16); - dc.SelectObject(bmp); - - // Draw transparent background - wxColour magic(255,0,255); - wxBrush magicBrush(magic); - dc.SetBrush( magicBrush ); - dc.SetPen( *wxTRANSPARENT_PEN ); - dc.DrawRectangle(0,0,bmp.GetWidth(),bmp.GetHeight()); - - // Draw text - wxString str = "..."; - int w,h; - dc.GetTextExtent(str, &w, &h, 0, 0); - dc.DrawText(str, (bmp.GetWidth()-w)/2, (bmp.GetHeight()-h)/2); - - dc.SelectObject( wxNullBitmap ); - - // Finalize transparency with a mask - wxMask *mask = new wxMask( bmp, magic ); - bmp.SetMask( mask ); - - SetButtonBitmaps(bmp,true); + SetButtonBitmaps(wxBitmapBundle::FromSVGFile("three-dots.svg", wxSize(16, 16)), true); } virtual void OnButtonClick() wxOVERRIDE @@ -852,17 +827,14 @@ MyFrame::MyFrame(const wxString& title) ); // Load images from disk - wxImage imgNormal("dropbutn.png"); - wxImage imgPressed("dropbutp.png"); - wxImage imgHover("dropbuth.png"); + wxBitmapBundle bmpNormal = wxBitmapBundle::FromSVGFile("dropbutn.svg", wxSize(16, 16)); + wxBitmapBundle bmpPressed = wxBitmapBundle::FromSVGFile("dropbutp.svg", wxSize(16, 16)); + wxBitmapBundle bmpHover = wxBitmapBundle::FromSVGFile("dropbuth.svg", wxSize(16, 16)); - if ( imgNormal.IsOk() && imgPressed.IsOk() && imgHover.IsOk() ) + if ( bmpNormal.IsOk() && bmpPressed.IsOk() && bmpHover.IsOk() ) { - wxBitmap bmpNormal(imgNormal); - wxBitmap bmpPressed(imgPressed); - wxBitmap bmpHover(imgHover); - odc->SetButtonBitmaps(bmpNormal,false,bmpPressed,bmpHover); - odc2->SetButtonBitmaps(bmpNormal,true,bmpPressed,bmpHover); + odc->SetButtonBitmaps(bmpNormal, false, bmpPressed, bmpHover); + odc2->SetButtonBitmaps(bmpNormal, true, bmpPressed, bmpHover); } else wxLogError("Dropbutton images not found"); diff --git a/samples/combo/dropbuth.png b/samples/combo/dropbuth.png deleted file mode 100644 index 089eda926db75e8d6998564440a6553693ca0708..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 371 zcmeAS@N?(olHy`uVBq!ia0vp^d_c_4!3HF+i2N%7Qfx`y?k)`L7*;bpzbhVp2`Iu@ z;1OBOz@VoL!i*J5?aP3I>?NMQuI$%X#Q8Ki*?&$m1PaNPxJHyX=jZ08=9Mrw7o{ea zq^2m8XO?6rgk+>DxO@5ryiZZh11h}k>Eaktack}*M=xhXfwui8pIl86tKHiiE@0bi z9b3(IaB&4!|1yP$Q{5J`Q)2c+tvY*oTcZQV{ps~>Jacv|DSY0(VWaCE`?Z>>HI6Lv zY~q$BL)v*VqCidhS|zZMiuWC`uyik*-wG}Z5Q#JX+O zJl63a_U_zmx7goleoHFXmKk@g{yg1lFynKgpIN$rdbFx^O0ittx$WoPv;E19J@HI> zN8Y(}Z?FDgzdvVAsNU@ + +Layer 1 + + + + diff --git a/samples/combo/dropbutn.png b/samples/combo/dropbutn.png deleted file mode 100644 index 9dceceab13eea551159ad71f8b2eca00b70108d4..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 237 zcmeAS@N?(olHy`uVBq!ia0vp^d_c_4!3HF+i2N%7Qfx`y?k)`fL2$v|<&%LToCO|{ z#S9F3${@^GvDCf{D9B#o>FdgVjYXVK&ES3t(>I`yY>8_`iF1B#Zfaf$gL6@8Vo7R> zLV0FMhC)b2s)DZ{rEqA-E2Y4q=>g3RSpZ* zin0bi?k?A0&x}0q{r%O@dIrJ03H#UVShey)O>=oNZ?pUn5w6L?EDVuPc-AcN+4E%E aI!-1{DdC9nrTsv|89ZJ6T-G@yGywpzi%c&7 diff --git a/samples/combo/dropbutn.svg b/samples/combo/dropbutn.svg new file mode 100644 index 0000000000..e7365d6163 --- /dev/null +++ b/samples/combo/dropbutn.svg @@ -0,0 +1,4 @@ + + + + diff --git a/samples/combo/dropbutp.png b/samples/combo/dropbutp.png deleted file mode 100644 index 82e905e081c5f9a0cd848b63ce925166ae113574..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 366 zcmeAS@N?(olHy`uVBq!ia0vp^d_c_4!3HF+i2N%7Qfx`y?k)`L7*;bpzbhVp2`Iu@ z;1OBOz@VoL!i*J5?aP3I>?NMQuI$%X#Q8M1KfE~>0~C@iag8W(&d<$F%`0JWE=o-- zNlj5G&n(GM2+2rQaQE~Lc%P!02UK{;)5S5Q;?~?rzI;sv0zQ?vbdo$PRjXEapOA`O=%b>0bu;hp4BxP9 z(S!#(T_&x`u6z9K#mNl~e-$$-Zr4RE-L7?$<*R4uo3|Bv86O(^@v2^LtOfdx!PC{x JWt~$(69C7UkSPEF diff --git a/samples/combo/dropbutp.svg b/samples/combo/dropbutp.svg new file mode 100644 index 0000000000..1804ddfc7f --- /dev/null +++ b/samples/combo/dropbutp.svg @@ -0,0 +1,7 @@ + + +Layer 1 + + + + diff --git a/samples/combo/makefile.gcc b/samples/combo/makefile.gcc index 06456ff995..36fffae7b8 100644 --- a/samples/combo/makefile.gcc +++ b/samples/combo/makefile.gcc @@ -222,7 +222,7 @@ $(OBJS)\combo.exe: $(COMBO_OBJECTS) $(OBJS)\combo_sample_rc.o data: if not exist $(OBJS) mkdir $(OBJS) - for %%f in (dropbuth.png dropbutn.png dropbutp.png) do if not exist $(OBJS)\%%f copy .\%%f $(OBJS) + for %%f in (dropbuth.svg dropbutn.svg dropbutp.svg three-dots.svg) do if not exist $(OBJS)\%%f copy .\%%f $(OBJS) $(OBJS)\combo_sample_rc.o: ./../../samples/sample.rc $(WINDRES) -i$< -o$@ --define __WXMSW__ $(__WXUNIV_DEFINE_p_1) $(__DEBUG_DEFINE_p_1) $(__NDEBUG_DEFINE_p_1) $(__EXCEPTIONS_DEFINE_p_1) $(__RTTI_DEFINE_p_1) $(__THREAD_DEFINE_p_1) $(__UNICODE_DEFINE_p_1) --include-dir $(SETUPHDIR) --include-dir ./../../include $(__CAIRO_INCLUDEDIR_p) --include-dir . $(__DLLFLAG_p_1) --define wxUSE_DPI_AWARE_MANIFEST=$(USE_DPI_AWARE_MANIFEST) --include-dir ./../../samples --define NOPCH diff --git a/samples/combo/makefile.vc b/samples/combo/makefile.vc index f17d5dd505..3bdaa06fe6 100644 --- a/samples/combo/makefile.vc +++ b/samples/combo/makefile.vc @@ -431,7 +431,7 @@ $(OBJS)\combo.exe: $(COMBO_OBJECTS) $(OBJS)\combo_sample.res data: if not exist $(OBJS) mkdir $(OBJS) - for %f in (dropbuth.png dropbutn.png dropbutp.png) do if not exist $(OBJS)\%f copy .\%f $(OBJS) + for %f in (dropbuth.svg dropbutn.svg dropbutp.svg three-dots.svg) do if not exist $(OBJS)\%f copy .\%f $(OBJS) $(OBJS)\combo_sample.res: .\..\..\samples\sample.rc rc /fo$@ /d WIN32 $(____DEBUGRUNTIME_3_p_1) /d _CRT_SECURE_NO_DEPRECATE=1 /d _CRT_NON_CONFORMING_SWPRINTFS=1 /d _SCL_SECURE_NO_WARNINGS=1 $(__NO_VC_CRTDBG_p_1) $(__TARGET_CPU_COMPFLAG_p_1) /d __WXMSW__ $(__WXUNIV_DEFINE_p_1) $(__DEBUG_DEFINE_p_1) $(__NDEBUG_DEFINE_p_1) $(__EXCEPTIONS_DEFINE_p_1) $(__RTTI_DEFINE_p_1) $(__THREAD_DEFINE_p_1) $(__UNICODE_DEFINE_p_1) /i $(SETUPHDIR) /i .\..\..\include $(____CAIRO_INCLUDEDIR_FILENAMES_1_p) /i . $(__DLLFLAG_p_1) /d _WINDOWS /i .\..\..\samples /d NOPCH .\..\..\samples\sample.rc diff --git a/samples/combo/three-dots.svg b/samples/combo/three-dots.svg new file mode 100644 index 0000000000..1e0e5bb40e --- /dev/null +++ b/samples/combo/three-dots.svg @@ -0,0 +1,4 @@ + + + +