Update menu bitmaps when invoking window is set in wxOSX
Changing invoking window always needs to update the bitmaps because the scale factor may need to be changed if this window is on a different display, using different scaling, so do it automatically whenever SetInvokingWindow() is called instead of having to remember to call SetupBitmaps() manually everywhere SetInvokingWindow() is. This required making the base class function virtual, but allows to get rid of SetupBitmaps() call in wxWindow::DoPopupMenu(), as it can now rely on this being already done by wxWindowBase::PopupMenu().
This commit is contained in:
parent
53938a85d3
commit
616e7c8842
4 changed files with 11 additions and 3 deletions
|
|
@ -261,7 +261,7 @@ public:
|
|||
//
|
||||
// NB: avoid calling SetInvokingWindow() directly if possible, use
|
||||
// wxMenuInvokingWindowSetter class below instead
|
||||
void SetInvokingWindow(wxWindow *win);
|
||||
virtual void SetInvokingWindow(wxWindow *win);
|
||||
wxWindow *GetInvokingWindow() const { return m_invokingWindow; }
|
||||
|
||||
// the window associated with this menu: this is the invoking window for
|
||||
|
|
|
|||
|
|
@ -36,6 +36,8 @@ public:
|
|||
|
||||
virtual void SetTitle(const wxString& title) wxOVERRIDE;
|
||||
|
||||
virtual void SetInvokingWindow(wxWindow* win) wxOVERRIDE;
|
||||
|
||||
bool ProcessCommand(wxCommandEvent& event);
|
||||
|
||||
// get the menu handle
|
||||
|
|
|
|||
|
|
@ -421,6 +421,14 @@ void wxMenu::Attach(wxMenuBarBase *menubar)
|
|||
}
|
||||
#endif
|
||||
|
||||
void wxMenu::SetInvokingWindow(wxWindow* win)
|
||||
{
|
||||
wxMenuBase::SetInvokingWindow(win);
|
||||
|
||||
if ( win )
|
||||
SetupBitmaps();
|
||||
}
|
||||
|
||||
void wxMenu::SetupBitmaps()
|
||||
{
|
||||
for ( wxMenuItemList::compatibility_iterator node = m_items.GetFirst();
|
||||
|
|
|
|||
|
|
@ -871,8 +871,6 @@ bool wxWindowMac::SetCursor(const wxCursor& cursor)
|
|||
bool wxWindowMac::DoPopupMenu(wxMenu *menu, int x, int y)
|
||||
{
|
||||
#ifndef __WXUNIVERSAL__
|
||||
menu->SetupBitmaps();
|
||||
|
||||
if ( x == wxDefaultCoord && y == wxDefaultCoord )
|
||||
{
|
||||
wxPoint mouse = wxGetMousePosition();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue