/////////////////////////////////////////////////////////////////////////////
-// Name: menu.cpp
+// Name: src/msw/menu.cpp
// Purpose: wxMenu, wxMenuBar, wxMenuItem
// Author: Julian Smart
// Modified by: Vadim Zeitlin
// headers
// ---------------------------------------------------------------------------
-#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
- #pragma implementation "menu.h"
-#endif
-
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
// ----------------------------------------------------------------------------
// make the given menu item default
-static void SetDefaultMenuItem(HMENU hmenu, UINT id)
+static void SetDefaultMenuItem(HMENU WXUNUSED_IN_WINCE(hmenu),
+ UINT WXUNUSED_IN_WINCE(id))
{
#ifndef __WXWINCE__
MENUITEMINFO mii;
{
wxLogLastError(wxT("SetMenuItemInfo"));
}
-#else
- wxUnusedVar(hmenu);
- wxUnusedVar(id);
#endif
}
// implementation
// ============================================================================
-#include <wx/listimpl.cpp>
+#include "wx/listimpl.cpp"
-WX_DEFINE_LIST( wxMenuInfoList ) ;
+WX_DEFINE_LIST( wxMenuInfoList )
#if wxUSE_EXTENDED_RTTI
}
else if ( !item->IsSeparator() )
{
+ // recurse upwards: we should only modify m_accels of the top level
+ // menus, not of the submenus as wxMenuBar doesn't look at them
+ // (alternative and arguable cleaner solution would be to recurse
+ // downwards in GetAccelCount() and CopyAccels())
+ if ( GetParent() )
+ {
+ GetParent()->UpdateAccel(item);
+ return;
+ }
+
// find the (new) accel for this item
wxAcceleratorEntry *accel = wxGetAccelFromString(item->GetText());
if ( accel )
pos = GetMenuItemCount() - 1;
}
+ // adjust position to account for the title, if any
+ if ( !m_title.empty() )
+ pos += 2; // for the title itself and its separator
+
BOOL ok = false;
// check if we have something more than a simple text item
// now run-time one: MIIM_BITMAP only works under WinME/2000+
if ( wxGetWinVersion() >= wxWinVersion_98 )
{
- mii.fMask = MIIM_ID | MIIM_STRING | MIIM_DATA | MIIM_BITMAP;
- mii.wID = id;
+ mii.fMask = MIIM_STRING | MIIM_DATA | MIIM_BITMAP;
mii.cch = itemText.length();
mii.dwTypeData = wx_const_cast(wxChar *, itemText.c_str());
+ if (flags & MF_POPUP)
+ {
+ mii.fMask |= MIIM_SUBMENU;
+ mii.hSubMenu = (HMENU)pItem->GetSubMenu()->GetHMenu();
+ }
+ else
+ {
+ mii.fMask |= MIIM_ID;
+ mii.wID = id;
+ }
+
// we can't pass HBITMAP directly as hbmpItem for 2 reasons:
// 1. we can't draw it with transparency then (this is not
// very important now but would be with themed menu bg)
info.cbSize = sizeof(info);
info.fMask = MIIM_TYPE;
info.fType = MFT_STRING;
- info.cch = m_title.Length();
+ info.cch = m_title.length();
info.dwTypeData = (LPTSTR) m_title.c_str();
if ( !SetMenuItemInfo(hMenu, 0, TRUE, & info) )
{
info.cbSize = sizeof(info);
info.fMask = MIIM_TYPE;
info.fType = MFT_STRING;
- info.cch = label.Length();
+ info.cch = label.length();
info.dwTypeData = (LPTSTR) label.c_str();
if ( !SetMenuItemInfo(GetHmenu(), id, TRUE, & info) )
{