From c95b3937fef3e2c63768f1b3b1dc2c898f23d91d Mon Sep 17 00:00:00 2001 From: B Stack Date: Wed, 22 Jul 2020 11:37:03 -0400 Subject: add upstream 11.0 --- wx+/context_menu.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'wx+/context_menu.h') diff --git a/wx+/context_menu.h b/wx+/context_menu.h index 08a313bf..7096da33 100644 --- a/wx+/context_menu.h +++ b/wx+/context_menu.h @@ -29,10 +29,10 @@ class ContextMenu : private wxEvtHandler public: ContextMenu() {} - void addItem(const wxString& label, const std::function& command, const wxBitmap* bmp = nullptr, bool enabled = true) + void addItem(const wxString& label, const std::function& command, const wxImage& img = wxNullImage, bool enabled = true) { wxMenuItem* newItem = new wxMenuItem(menu_.get(), wxID_ANY, label); //menu owns item! - if (bmp) newItem->SetBitmap(*bmp); //do not set AFTER appending item! wxWidgets screws up for yet another crappy reason + if (img.IsOk()) newItem->SetBitmap(img); //do not set AFTER appending item! wxWidgets screws up for yet another crappy reason menu_->Append(newItem); if (!enabled) newItem->Enable(false); //do not enable BEFORE appending item! wxWidgets screws up for yet another crappy reason commandList_[newItem->GetId()] = command; //defer event connection, this may be a submenu only! @@ -56,7 +56,7 @@ public: void addSeparator() { menu_->AppendSeparator(); } - void addSubmenu(const wxString& label, ContextMenu& submenu, const wxBitmap* bmp = nullptr, bool enabled = true) //invalidates submenu! + void addSubmenu(const wxString& label, ContextMenu& submenu, const wxImage& img = wxNullImage, bool enabled = true) //invalidates submenu! { //transfer submenu commands: commandList_.insert(submenu.commandList_.begin(), submenu.commandList_.end()); @@ -65,7 +65,7 @@ public: submenu.menu_->SetNextHandler(menu_.get()); //on wxGTK submenu events are not propagated to their parent menu by default! wxMenuItem* newItem = new wxMenuItem(menu_.get(), wxID_ANY, label, L"", wxITEM_NORMAL, submenu.menu_.release()); //menu owns item, item owns submenu! - if (bmp) newItem->SetBitmap(*bmp); //do not set AFTER appending item! wxWidgets screws up for yet another crappy reason + if (img.IsOk()) newItem->SetBitmap(img); //do not set AFTER appending item! wxWidgets screws up for yet another crappy reason menu_->Append(newItem); if (!enabled) newItem->Enable(false); } -- cgit