// Created: 10/10/99
// RCS-ID: $Id$
// Copyright: (c) David Webster
-// Licence: wxWidgets licence
+// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
//
// The (popup) menu title has this special id
//
-static const int idMenuTitle = -2;
+static const int idMenuTitle = -3;
//
// The unique ID for Menus
if (pItem->IsSubMenu())
{
wxMenu* pSubmenu = pItem->GetSubMenu();
- wxMenuItemList::Node* pNode = pSubmenu->GetMenuItems().GetFirst();
+ wxMenuItemList::compatibility_iterator node = pSubmenu->GetMenuItems().GetFirst();
- while (pNode)
+ while (node)
{
- UpdateAccel(pNode->GetData());
- pNode = pNode->GetNext();
+ UpdateAccel(node->GetData());
+ node = node->GetNext();
}
}
else if (!pItem->IsSeparator())
rItem.id = pItem->GetId();
}
- BYTE* pData;
+ BYTE* pData=NULL;
#if wxUSE_OWNER_DRAWN
if (pItem->IsOwnerDrawn())
}
else
{
- //
- // Menu is just a normal string (passed in data parameter)
- //
- rItem.afStyle |= MIS_TEXT;
+ if (pItem->GetId() == idMenuTitle)
+ {
+ // Item is an unselectable title to be passed via pData
+ rItem.afStyle = MIS_STATIC;
+ }
+ else
+ {
+ //
+ // Menu is just a normal string (passed in data parameter)
+ //
+ rItem.afStyle |= MIS_TEXT;
+ }
pData = (char*)pItem->GetText().c_str();
}
//
pItem->SetRadioGroupStart(m_nStartRadioGroup);
- wxMenuItemList::Node* pNode = GetMenuItems().Item(m_nStartRadioGroup);
+ wxMenuItemList::compatibility_iterator node = GetMenuItems().Item(m_nStartRadioGroup);
- if (pNode)
+ if (node)
{
- pNode->GetData()->SetRadioGroupEnd(nCount);
+ node->GetData()->SetRadioGroupEnd(nCount);
}
else
{
// We need to find the items position in the child list
//
size_t nPos;
- wxMenuItemList::Node* pNode = GetMenuItems().GetFirst();
+ wxMenuItemList::compatibility_iterator node = GetMenuItems().GetFirst();
- for (nPos = 0; pNode; nPos++)
+ for (nPos = 0; node; nPos++)
{
- if (pNode->GetData() == pItem)
+ if (node->GetData() == pItem)
break;
- pNode = pNode->GetNext();
+ node = node->GetNext();
}
//
// DoRemove() (unlike Remove) can only be called for existing item!
//
- wxCHECK_MSG(pNode, NULL, wxT("bug in wxMenu::Remove logic"));
+ wxCHECK_MSG(node, NULL, wxT("bug in wxMenu::Remove logic"));
#if wxUSE_ACCEL
//
wxMenuItem* pItem = NULL;
- for ( wxMenuItemList::Node *node = m_items.GetFirst();
+ for ( wxMenuItemList::compatibility_iterator node = m_items.GetFirst();
node && !pItem;
node = node->GetNext() )
{
int nCount
, wxMenu* vMenus[]
, const wxString sTitles[]
+, long WXUNUSED(lStyle)
)
{
Init();
}
else
{
- size_t nCount = GetMenuCount();
-
- for (size_t i = 0; i < nCount; i++)
+ size_t nCount = GetMenuCount(), i;
+ wxMenuList::iterator it;
+ for (i = 0, it = m_menus.begin(); i < nCount; i++, it++)
{
APIRET rc;
ERRORID vError;
//
// Set the parent and owner of the submenues to be the menubar, not the desktop
//
- hSubMenu = m_menus[i]->m_vMenuData.hwndSubMenu;
- if (!::WinSetParent(m_menus[i]->m_vMenuData.hwndSubMenu, m_hMenu, FALSE))
+ hSubMenu = (*it)->m_vMenuData.hwndSubMenu;
+ if (!::WinSetParent((*it)->m_vMenuData.hwndSubMenu, m_hMenu, FALSE))
{
vError = ::WinGetLastError(vHabmain);
sError = wxPMErrorToStr(vError);
return NULLHANDLE;
}
- if (!::WinSetOwner(m_menus[i]->m_vMenuData.hwndSubMenu, m_hMenu))
+ if (!::WinSetOwner((*it)->m_vMenuData.hwndSubMenu, m_hMenu))
{
vError = ::WinGetLastError(vHabmain);
sError = wxPMErrorToStr(vError);
return NULLHANDLE;
}
- m_menus[i]->m_vMenuData.iPosition = i;
+ (*it)->m_vMenuData.iPosition = i;
- rc = (APIRET)::WinSendMsg(m_hMenu, MM_INSERTITEM, (MPARAM)&m_menus[i]->m_vMenuData, (MPARAM)m_titles[i].c_str());
+ rc = (APIRET)::WinSendMsg(m_hMenu, MM_INSERTITEM, (MPARAM)&(*it)->m_vMenuData, (MPARAM)m_titles[i].c_str());
if (rc == (APIRET)MIT_MEMERROR || rc == (APIRET)MIT_ERROR)
{
vError = ::WinGetLastError(vHabmain);
#endif // wxUSE_ACCEL
Refresh();
}
- m_titles.Remove(nPos);
+ m_titles.RemoveAt(nPos);
return pMenu;
} // end of wxMenuBar::Remove
size_t nAccelCount = 0;
size_t i;
size_t nCount = GetMenuCount();
-
- for (i = 0; i < nCount; i++)
+ wxMenuList::iterator it;
+ for (i = 0, it = m_menus.begin(); i < nCount; i++, it++)
{
- nAccelCount += m_menus[i]->GetAccelCount();
+ nAccelCount += (*it)->GetAccelCount();
}
if (nAccelCount)
wxAcceleratorEntry* pAccelEntries = new wxAcceleratorEntry[nAccelCount];
nAccelCount = 0;
- for (i = 0; i < nCount; i++)
+ for (i = 0, it = m_menus.begin(); i < nCount; i++, it++)
{
- nAccelCount += m_menus[i]->CopyAccels(&pAccelEntries[nAccelCount]);
+ nAccelCount += (*it)->CopyAccels(&pAccelEntries[nAccelCount]);
}
m_vAccelTable = wxAcceleratorTable( nAccelCount
,pAccelEntries
) const
{
wxString sMenuLabel = wxStripMenuCodes(rMenuString);
- size_t nCount = GetMenuCount();
-
- for (size_t i = 0; i < nCount; i++)
+ size_t nCount = GetMenuCount(), i;
+ wxMenuList::const_iterator it;
+ for (i = 0, it = m_menus.begin(); i < nCount; i++, it++)
{
wxString sTitle = wxStripMenuCodes(m_titles[i]);
if (rMenuString == sTitle)
- return m_menus[i]->FindItem(rItemString);
+ return (*it)->FindItem(rItemString);
}
return wxNOT_FOUND;
} // end of wxMenuBar::FindMenuItem
*ppItemMenu = NULL;
wxMenuItem* pItem = NULL;
- size_t nCount = GetMenuCount();
-
- for (size_t i = 0; !pItem && (i < nCount); i++)
+ size_t nCount = GetMenuCount(), i;
+ wxMenuList::const_iterator it;
+ for (i = 0, it = m_menus.begin(); !pItem && (i < nCount); i++, it++)
{
- pItem = m_menus[i]->FindItem( nId
- ,ppItemMenu
- );
+ pItem = (*it)->FindItem( nId
+ ,ppItemMenu
+ );
}
return pItem;
} // end of wxMenuBar::FindItem
*ppItemMenu = NULL;
wxMenuItem* pItem = NULL;
- size_t nCount = GetMenuCount();
-
- for (size_t i = 0; !pItem && (i < nCount); i++)
+ size_t nCount = GetMenuCount(), i;
+ wxMenuList::const_iterator it;
+ for (i = 0, it = m_menus.begin(); !pItem && (i < nCount); i++, it++)
{
- pItem = m_menus[i]->FindItem( nId
- ,hItem
- ,ppItemMenu
- );
+ pItem = (*it)->FindItem( nId
+ ,hItem
+ ,ppItemMenu
+ );
}
return pItem;
} // end of wxMenuBar::FindItem