wxBitmapBundle for wxMenuItem on Mac
This commit is contained in:
@@ -66,6 +66,12 @@ public:
|
|||||||
// containing this position.
|
// containing this position.
|
||||||
bool OSXGetRadioGroupRange(int pos, int *start, int *end) const;
|
bool OSXGetRadioGroupRange(int pos, int *start, int *end) const;
|
||||||
|
|
||||||
|
#if wxUSE_MENUBAR
|
||||||
|
virtual void Attach(wxMenuBarBase *menubar) wxOVERRIDE;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void SetupBitmaps();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// hide special menu items like exit, preferences etc
|
// hide special menu items like exit, preferences etc
|
||||||
// that are expected in the app menu
|
// that are expected in the app menu
|
||||||
@@ -163,6 +169,9 @@ public:
|
|||||||
static void MacSetCommonMenuBar(wxMenuBar* menubar) { s_macCommonMenuBar=menubar; }
|
static void MacSetCommonMenuBar(wxMenuBar* menubar) { s_macCommonMenuBar=menubar; }
|
||||||
static wxMenuBar* MacGetCommonMenuBar() { return s_macCommonMenuBar; }
|
static wxMenuBar* MacGetCommonMenuBar() { return s_macCommonMenuBar; }
|
||||||
|
|
||||||
|
virtual void Attach(wxFrame *frame) wxOVERRIDE;
|
||||||
|
void SetupBitmaps();
|
||||||
|
|
||||||
|
|
||||||
static WXHMENU MacGetWindowMenuHMenu() { return s_macWindowMenuHandle ; }
|
static WXHMENU MacGetWindowMenuHMenu() { return s_macWindowMenuHandle ; }
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
#include "wx/defs.h"
|
#include "wx/defs.h"
|
||||||
#include "wx/bitmap.h"
|
#include "wx/bmpbndl.h"
|
||||||
#include "wx/vector.h"
|
#include "wx/vector.h"
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@@ -49,8 +49,8 @@ public:
|
|||||||
void RemoveHiddenItems();
|
void RemoveHiddenItems();
|
||||||
#endif // wxUSE_ACCEL
|
#endif // wxUSE_ACCEL
|
||||||
|
|
||||||
virtual void SetBitmap(const wxBitmap& bitmap) ;
|
virtual void SetBitmap(const wxBitmapBundle& bitmap) ;
|
||||||
virtual const wxBitmap& GetBitmap() const { return m_bitmap; }
|
virtual wxBitmap GetBitmap() const;
|
||||||
|
|
||||||
|
|
||||||
// Implementation only from now on.
|
// Implementation only from now on.
|
||||||
@@ -64,7 +64,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
void UncheckRadio() ;
|
void UncheckRadio() ;
|
||||||
|
|
||||||
wxBitmap m_bitmap; // Bitmap for menuitem, if any
|
wxBitmapBundle m_bitmap; // Bitmap for menuitem, if any
|
||||||
|
|
||||||
wxMenuItemImpl* m_peer;
|
wxMenuItemImpl* m_peer;
|
||||||
|
|
||||||
|
|||||||
@@ -155,7 +155,17 @@ bool wxMenu::DoInsertOrAppend(wxMenuItem *item, size_t pos)
|
|||||||
#if wxUSE_MENUBAR
|
#if wxUSE_MENUBAR
|
||||||
// if we're already attached to the menubar, we must update it
|
// if we're already attached to the menubar, we must update it
|
||||||
if ( IsAttached() && GetMenuBar()->IsAttached() )
|
if ( IsAttached() && GetMenuBar()->IsAttached() )
|
||||||
|
{
|
||||||
|
if ( item->IsSubMenu() )
|
||||||
|
{
|
||||||
|
item->GetSubMenu()->SetupBitmaps();
|
||||||
|
}
|
||||||
|
if ( !item->IsSeparator() )
|
||||||
|
{
|
||||||
|
item->UpdateItemBitmap();
|
||||||
|
}
|
||||||
GetMenuBar()->Refresh();
|
GetMenuBar()->Refresh();
|
||||||
|
}
|
||||||
#endif // wxUSE_MENUBAR
|
#endif // wxUSE_MENUBAR
|
||||||
|
|
||||||
if ( check )
|
if ( check )
|
||||||
@@ -399,6 +409,36 @@ void wxMenu::HandleMenuClosed()
|
|||||||
DoHandleMenuOpenedOrClosed(wxEVT_MENU_CLOSE);
|
DoHandleMenuOpenedOrClosed(wxEVT_MENU_CLOSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if wxUSE_MENUBAR
|
||||||
|
void wxMenu::Attach(wxMenuBarBase *menubar)
|
||||||
|
{
|
||||||
|
wxMenuBase::Attach(menubar);
|
||||||
|
|
||||||
|
if (menubar->IsAttached())
|
||||||
|
{
|
||||||
|
SetupBitmaps();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void wxMenu::SetupBitmaps()
|
||||||
|
{
|
||||||
|
for ( wxMenuItemList::compatibility_iterator node = m_items.GetFirst();
|
||||||
|
node;
|
||||||
|
node = node->GetNext() )
|
||||||
|
{
|
||||||
|
wxMenuItem *item = node->GetData();
|
||||||
|
if ( item->IsSubMenu() )
|
||||||
|
{
|
||||||
|
item->GetSubMenu()->SetupBitmaps();
|
||||||
|
}
|
||||||
|
if ( !item->IsSeparator() )
|
||||||
|
{
|
||||||
|
item->UpdateItemBitmap();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#if wxUSE_MENUBAR
|
#if wxUSE_MENUBAR
|
||||||
|
|
||||||
// Menu Bar
|
// Menu Bar
|
||||||
@@ -625,6 +665,21 @@ wxString wxMenuBar::GetMenuLabel(size_t pos) const
|
|||||||
return GetMenu(pos)->GetTitle();
|
return GetMenu(pos)->GetTitle();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void wxMenuBar::SetupBitmaps()
|
||||||
|
{
|
||||||
|
for ( wxMenuList::const_iterator it = m_menus.begin(); it != m_menus.end(); ++it )
|
||||||
|
{
|
||||||
|
(*it)->SetupBitmaps();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxMenuBar::Attach(wxFrame *frame)
|
||||||
|
{
|
||||||
|
wxMenuBarBase::Attach(frame);
|
||||||
|
|
||||||
|
SetupBitmaps();
|
||||||
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
// wxMenuBar construction
|
// wxMenuBar construction
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -70,10 +70,26 @@ wxMenuItem::~wxMenuItem()
|
|||||||
// change item state
|
// change item state
|
||||||
// -----------------
|
// -----------------
|
||||||
|
|
||||||
void wxMenuItem::SetBitmap(const wxBitmap& bitmap)
|
void wxMenuItem::SetBitmap(const wxBitmapBundle& bitmap)
|
||||||
{
|
{
|
||||||
m_bitmap = bitmap;
|
m_bitmap = bitmap;
|
||||||
UpdateItemBitmap();
|
}
|
||||||
|
|
||||||
|
wxBitmap wxMenuItem::GetBitmap() const
|
||||||
|
{
|
||||||
|
wxBitmap bmp;
|
||||||
|
if ( m_bitmap.IsOk() )
|
||||||
|
{
|
||||||
|
if (m_parentMenu && m_parentMenu->GetWindow())
|
||||||
|
{
|
||||||
|
bmp = m_bitmap.GetBitmapFor(m_parentMenu->GetWindow());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
bmp = m_bitmap.GetBitmap(wxDefaultSize);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return bmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxMenuItem::Enable(bool bDoEnable)
|
void wxMenuItem::Enable(bool bDoEnable)
|
||||||
@@ -167,7 +183,7 @@ void wxMenuItem::UpdateItemBitmap()
|
|||||||
|
|
||||||
if ( m_bitmap.IsOk() )
|
if ( m_bitmap.IsOk() )
|
||||||
{
|
{
|
||||||
GetPeer()->SetBitmap( m_bitmap );
|
GetPeer()->SetBitmap(GetBitmap());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -871,6 +871,8 @@ bool wxWindowMac::SetCursor(const wxCursor& cursor)
|
|||||||
bool wxWindowMac::DoPopupMenu(wxMenu *menu, int x, int y)
|
bool wxWindowMac::DoPopupMenu(wxMenu *menu, int x, int y)
|
||||||
{
|
{
|
||||||
#ifndef __WXUNIVERSAL__
|
#ifndef __WXUNIVERSAL__
|
||||||
|
menu->SetupBitmaps();
|
||||||
|
|
||||||
if ( x == wxDefaultCoord && y == wxDefaultCoord )
|
if ( x == wxDefaultCoord && y == wxDefaultCoord )
|
||||||
{
|
{
|
||||||
wxPoint mouse = wxGetMousePosition();
|
wxPoint mouse = wxGetMousePosition();
|
||||||
|
|||||||
Reference in New Issue
Block a user