From bbdbee3e57bc7278bbde20653c93e5c20fc8c34a Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 18 Dec 2021 00:01:37 +0000 Subject: [PATCH] Use wxArtProvider::GetBitmapBundle() in the AUI sample This sweeps under the carpet the regression which resulted in bitmaps returned from wxArtProvider::GetBitmap() not looking the same since starting to use wxBitmapBundle in AUI, but OTOH it just doesn't seem possible to both preserve the compatibility and allow actually using appropriate, not scaled, bitmaps in different resolutions. The new code is as simple as the old version, follows the official advice to use GetBitmapBundle() rather than GetBitmap(), and looks good in high DPI, which should compensate for the behaviour change. --- samples/aui/auidemo.cpp | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/samples/aui/auidemo.cpp b/samples/aui/auidemo.cpp index 51fb69fe91..1e415b311b 100644 --- a/samples/aui/auidemo.cpp +++ b/samples/aui/auidemo.cpp @@ -781,12 +781,12 @@ MyFrame::MyFrame(wxWindow* parent, // create some toolbars wxAuiToolBar* tb1 = new wxAuiToolBar(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxAUI_TB_DEFAULT_STYLE | wxAUI_TB_OVERFLOW); - tb1->AddTool(ID_SampleItem+1, "Test", wxArtProvider::GetBitmap(wxART_ERROR)); + tb1->AddTool(ID_SampleItem+1, "Test", wxArtProvider::GetBitmapBundle(wxART_ERROR)); tb1->AddSeparator(); - tb1->AddTool(ID_SampleItem+2, "Test", wxArtProvider::GetBitmap(wxART_QUESTION)); - tb1->AddTool(ID_SampleItem+3, "Test", wxArtProvider::GetBitmap(wxART_INFORMATION)); - tb1->AddTool(ID_SampleItem+4, "Test", wxArtProvider::GetBitmap(wxART_WARNING)); - tb1->AddTool(ID_SampleItem+5, "Test", wxArtProvider::GetBitmap(wxART_MISSING_IMAGE)); + tb1->AddTool(ID_SampleItem+2, "Test", wxArtProvider::GetBitmapBundle(wxART_QUESTION)); + tb1->AddTool(ID_SampleItem+3, "Test", wxArtProvider::GetBitmapBundle(wxART_INFORMATION)); + tb1->AddTool(ID_SampleItem+4, "Test", wxArtProvider::GetBitmapBundle(wxART_WARNING)); + tb1->AddTool(ID_SampleItem+5, "Test", wxArtProvider::GetBitmapBundle(wxART_MISSING_IMAGE)); tb1->SetCustomOverflowItems(prepend_items, append_items); tb1->Realize(); @@ -794,7 +794,7 @@ MyFrame::MyFrame(wxWindow* parent, wxAuiToolBar* tb2 = new wxAuiToolBar(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxAUI_TB_DEFAULT_STYLE | wxAUI_TB_OVERFLOW | wxAUI_TB_HORIZONTAL); - wxBitmap tb2_bmp1 = wxArtProvider::GetBitmap(wxART_QUESTION, wxART_OTHER, FromDIP(wxSize(16,16))); + wxBitmapBundle tb2_bmp1 = wxArtProvider::GetBitmapBundle(wxART_QUESTION, wxART_OTHER, wxSize(16,16)); tb2->AddTool(ID_SampleItem+6, "Disabled", tb2_bmp1); tb2->AddTool(ID_SampleItem+7, "Test", tb2_bmp1); tb2->AddTool(ID_SampleItem+8, "Test", tb2_bmp1); @@ -814,7 +814,7 @@ MyFrame::MyFrame(wxWindow* parent, wxAuiToolBar* tb3 = new wxAuiToolBar(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxAUI_TB_DEFAULT_STYLE | wxAUI_TB_OVERFLOW); - wxBitmap tb3_bmp1 = wxArtProvider::GetBitmap(wxART_FOLDER, wxART_OTHER, FromDIP(wxSize(16,16))); + wxBitmapBundle tb3_bmp1 = wxArtProvider::GetBitmapBundle(wxART_FOLDER, wxART_OTHER, wxSize(16,16)); tb3->AddTool(ID_SampleItem+16, "Check 1", tb3_bmp1, "Check 1", wxITEM_CHECK); tb3->AddTool(ID_SampleItem+17, "Check 2", tb3_bmp1, "Check 2", wxITEM_CHECK); tb3->AddTool(ID_SampleItem+18, "Check 3", tb3_bmp1, "Check 3", wxITEM_CHECK); @@ -836,7 +836,7 @@ MyFrame::MyFrame(wxWindow* parent, wxAUI_TB_OVERFLOW | wxAUI_TB_TEXT | wxAUI_TB_HORZ_TEXT); - wxBitmap tb4_bmp1 = wxArtProvider::GetBitmap(wxART_NORMAL_FILE, wxART_OTHER, FromDIP(wxSize(16,16))); + wxBitmapBundle tb4_bmp1 = wxArtProvider::GetBitmapBundle(wxART_NORMAL_FILE, wxART_OTHER, wxSize(16,16)); tb4->AddTool(ID_DropDownToolbarItem, "Item 1", tb4_bmp1); tb4->AddTool(ID_SampleItem+23, "Item 2", tb4_bmp1); tb4->SetToolSticky(ID_SampleItem+23, true); @@ -859,12 +859,12 @@ MyFrame::MyFrame(wxWindow* parent, wxAuiToolBar* tb5 = new wxAuiToolBar(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxAUI_TB_DEFAULT_STYLE | wxAUI_TB_OVERFLOW | wxAUI_TB_VERTICAL); - tb5->AddTool(ID_SampleItem+30, "Test", wxArtProvider::GetBitmap(wxART_ERROR)); + tb5->AddTool(ID_SampleItem+30, "Test", wxArtProvider::GetBitmapBundle(wxART_ERROR)); tb5->AddSeparator(); - tb5->AddTool(ID_SampleItem+31, "Test", wxArtProvider::GetBitmap(wxART_QUESTION)); - tb5->AddTool(ID_SampleItem+32, "Test", wxArtProvider::GetBitmap(wxART_INFORMATION)); - tb5->AddTool(ID_SampleItem+33, "Test", wxArtProvider::GetBitmap(wxART_WARNING)); - tb5->AddTool(ID_SampleItem+34, "Test", wxArtProvider::GetBitmap(wxART_MISSING_IMAGE)); + tb5->AddTool(ID_SampleItem+31, "Test", wxArtProvider::GetBitmapBundle(wxART_QUESTION)); + tb5->AddTool(ID_SampleItem+32, "Test", wxArtProvider::GetBitmapBundle(wxART_INFORMATION)); + tb5->AddTool(ID_SampleItem+33, "Test", wxArtProvider::GetBitmapBundle(wxART_WARNING)); + tb5->AddTool(ID_SampleItem+34, "Test", wxArtProvider::GetBitmapBundle(wxART_MISSING_IMAGE)); tb5->SetCustomOverflowItems(prepend_items, append_items); tb5->Realize(); @@ -923,9 +923,9 @@ MyFrame::MyFrame(wxWindow* parent, m_mgr.AddPane(wnd10, wxAuiPaneInfo(). Name("test10").Caption("Text Pane with Hide Prompt"). Bottom().Layer(1).Position(1). - Icon(wxArtProvider::GetBitmap(wxART_WARNING, - wxART_OTHER, - wxSize(iconSize, iconSize)))); + Icon(wxArtProvider::GetBitmapBundle(wxART_WARNING, + wxART_OTHER, + wxSize(iconSize, iconSize)))); m_mgr.AddPane(CreateSizeReportCtrl(), wxAuiPaneInfo(). Name("test11").Caption("Fixed Pane"). @@ -1484,6 +1484,7 @@ void MyFrame::OnDropDownToolbarItem(wxAuiToolBarEvent& evt) // create the popup menu wxMenu menuPopup; + // TODO: Use GetBitmapBundle() when wxMenuItem is updated to use it too. wxBitmap bmp = wxArtProvider::GetBitmap(wxART_QUESTION, wxART_OTHER, FromDIP(wxSize(16,16))); wxMenuItem* m1 = new wxMenuItem(&menuPopup, 10001, _("Drop Down Item 1")); @@ -1650,7 +1651,7 @@ wxAuiNotebook* MyFrame::CreateNotebook() m_notebook_style); ctrl->Freeze(); - wxBitmap page_bmp = wxArtProvider::GetBitmap(wxART_NORMAL_FILE, wxART_OTHER, FromDIP(wxSize(16,16))); + wxBitmapBundle page_bmp = wxArtProvider::GetBitmapBundle(wxART_NORMAL_FILE, wxART_OTHER, wxSize(16,16)); ctrl->AddPage(CreateHTMLCtrl(ctrl), "Welcome to wxAUI" , false, page_bmp); ctrl->SetPageToolTip(0, "Welcome to wxAUI (this is a page tooltip)");