Add wxUSE_OWNER_DRAW checks to wxMSW wxMenu code.

Allow compiling with wxUSE_OWNER_DRAW==0. This fixes another problem in
Windows CE build where owner drawn menus are not supported.

Closes #13851.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@70316 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2012-01-11 13:42:02 +00:00
parent 29686ebc00
commit 51c2f7ea41

View File

@@ -407,7 +407,9 @@ void wxMenu::UpdateAccel(wxMenuItem *item)
GetMenuBar()->RebuildAccelTable(); GetMenuBar()->RebuildAccelTable();
} }
#if wxUSE_OWNER_DRAW
ResetMaxAccelWidth(); ResetMaxAccelWidth();
#endif
} }
//else: it is a separator, they can't have accels, nothing to do //else: it is a separator, they can't have accels, nothing to do
} }
@@ -436,6 +438,7 @@ HBITMAP GetHBitmapForMenu(wxMenuItem *pItem, bool checked = true)
#if wxUSE_IMAGE #if wxUSE_IMAGE
if ( wxGetWinVersion() >= wxWinVersion_Vista ) if ( wxGetWinVersion() >= wxWinVersion_Vista )
{ {
#if wxUSE_OWNER_DRAW
wxBitmap bmp = pItem->GetBitmap(checked); wxBitmap bmp = pItem->GetBitmap(checked);
if ( bmp.IsOk() ) if ( bmp.IsOk() )
{ {
@@ -449,6 +452,7 @@ HBITMAP GetHBitmapForMenu(wxMenuItem *pItem, bool checked = true)
return GetHbitmapOf(pItem->GetBitmap(checked)); return GetHbitmapOf(pItem->GetBitmap(checked));
} }
#endif // wxUSE_OWNER_DRAW
//else: bitmap is not set //else: bitmap is not set
return NULL; return NULL;
@@ -790,7 +794,9 @@ wxMenuItem *wxMenu::DoRemove(wxMenuItem *item)
m_accels.RemoveAt(n); m_accels.RemoveAt(n);
#if wxUSE_OWNER_DRAW
ResetMaxAccelWidth(); ResetMaxAccelWidth();
#endif
} }
//else: this item doesn't have an accel, nothing to do //else: this item doesn't have an accel, nothing to do
#endif // wxUSE_ACCEL #endif // wxUSE_ACCEL
@@ -974,6 +980,7 @@ bool wxMenu::MSWCommand(WXUINT WXUNUSED(param), WXWORD id_)
} }
// get the menu with given handle (recursively) // get the menu with given handle (recursively)
#if wxUSE_OWNER_DRAW
wxMenu* wxMenu::MSWGetMenu(WXHMENU hMenu) wxMenu* wxMenu::MSWGetMenu(WXHMENU hMenu)
{ {
// check self // check self
@@ -996,6 +1003,7 @@ wxMenu* wxMenu::MSWGetMenu(WXHMENU hMenu)
// unknown hMenu // unknown hMenu
return NULL; return NULL;
} }
#endif // wxUSE_OWNER_DRAW
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
// Menu Bar // Menu Bar
@@ -1585,6 +1593,7 @@ wxMenu* wxMenuBar::MSWGetMenu(WXHMENU hMenu)
wxCHECK_MSG( GetHMenu() != hMenu, NULL, wxCHECK_MSG( GetHMenu() != hMenu, NULL,
wxT("wxMenuBar::MSWGetMenu(): menu handle is wxMenuBar, not wxMenu") ); wxT("wxMenuBar::MSWGetMenu(): menu handle is wxMenuBar, not wxMenu") );
#if wxUSE_OWNER_DRAW
// query all menus // query all menus
for ( size_t n = 0 ; n < GetMenuCount(); ++n ) for ( size_t n = 0 ; n < GetMenuCount(); ++n )
{ {
@@ -1592,6 +1601,7 @@ wxMenu* wxMenuBar::MSWGetMenu(WXHMENU hMenu)
if ( menu ) if ( menu )
return menu; return menu;
} }
#endif
// unknown hMenu // unknown hMenu
return NULL; return NULL;