//
// The unique ID for Menus
//
-#ifdef __VISAGECPP__
USHORT wxMenu::m_nextMenuId = 0;
-#else
-static USHORT wxMenu::m_nextMenuId = 0;
-#endif
// ----------------------------------------------------------------------------
// macros
IMPLEMENT_DYNAMIC_CLASS(wxMenu, wxEvtHandler)
IMPLEMENT_DYNAMIC_CLASS(wxMenuBar, wxEvtHandler)
-// ----------------------------------------------------------------------------
-// static function for translating menu labels
-// ----------------------------------------------------------------------------
-
-static wxString TextToLabel(
- const wxString& rsTitle
-)
-{
- wxString sTitle = "";
- const wxChar* zPc;
-
- if (rsTitle.IsEmpty())
- return sTitle;
- for (zPc = rsTitle.c_str(); *zPc != wxT('\0'); zPc++ )
- {
- if (*zPc == wxT('&') )
- {
- if (*(zPc + 1) == wxT('&'))
- {
- zPc++;
- sTitle << wxT('&');
- }
- else
- sTitle << wxT('~');
- }
- else
- {
- if ( *zPc == wxT('~') )
- {
- //
- // Tildes must be doubled to prevent them from being
- // interpreted as accelerator character prefix by PM ???
- //
- sTitle << *zPc;
- }
- sTitle << *zPc;
- }
- }
- return sTitle;
-} // end of TextToLabel
-
// ============================================================================
// implementation
// ============================================================================
//
size_t n = FindAccel(pItem->GetId());
- if (n == wxNOT_FOUND)
+ if (n == (size_t)wxNOT_FOUND)
{
//
// No old, add new if any
if (IsAttached())
{
- m_menuBar->RebuildAccelTable();
+ GetMenuBar()->RebuildAccelTable();
}
}
} // wxMenu::UpdateAccel
ERRORID vError;
wxString sError;
- char zMsg[128];
#if wxUSE_ACCEL
UpdateAccel(pItem);
m_bDoBreak = FALSE;
}
- if (pItem->IsSeparator())
- {
- rItem.afStyle |= MIS_SEPARATOR;
- }
-
//
// Id is the numeric id for normal menu items and HMENU for submenus as
// required by ::MM_INSERTITEM message API
//
-
if (pSubmenu != NULL)
{
wxASSERT_MSG(pSubmenu->GetHMenu(), wxT("invalid submenu"));
}
else
#endif
+ if (pItem->IsSeparator())
+ {
+ rItem.afStyle = MIS_SEPARATOR;
+ }
+ else
{
//
// Menu is just a normal string (passed in data parameter)
#if wxUSE_OWNER_DRAWN
if (pItem->IsOwnerDrawn())
{
- BOOL rc;
MENUITEM vMenuItem;
::WinSendMsg( GetHmenu()
);
}
#endif
- if (rc == MIT_MEMERROR || rc == MIT_ERROR)
+ if (rc == (APIRET)MIT_MEMERROR || rc == (APIRET)MIT_ERROR)
{
vError = ::WinGetLastError(vHabmain);
sError = wxPMErrorToStr(vError);
//
// If we're already attached to the menubar, we must update it
//
- if (IsAttached() && m_menuBar->IsAttached())
+ if (IsAttached() && GetMenuBar()->IsAttached())
{
- m_menuBar->Refresh();
+ GetMenuBar()->Refresh();
}
return TRUE;
}
m_nStartRadioGroup = -1;
} // end of wxMenu::EndRadioGroup
-bool wxMenu::DoAppend(
+wxMenuItem* wxMenu::DoAppend(
wxMenuItem* pItem
)
{
- wxCHECK_MSG( pItem, FALSE, _T("NULL item in wxMenu::DoAppend") );
+ wxCHECK_MSG( pItem, NULL, _T("NULL item in wxMenu::DoAppend") );
bool bCheck = FALSE;
if (!wxMenuBase::DoAppend(pItem) || !DoInsertOrAppend(pItem))
{
- return FALSE;
+ return NULL;
}
if (bCheck)
{
//
pItem->Check(TRUE);
}
- return TRUE;
+ return pItem;
} // end of wxMenu::DoAppend
-bool wxMenu::DoInsert(
+wxMenuItem* wxMenu::DoInsert(
size_t nPos
, wxMenuItem* pItem
)
{
- return ( wxMenuBase::DoInsert( nPos
- ,pItem) &&
+ if ( wxMenuBase::DoInsert( nPos
+ ,pItem) &&
DoInsertOrAppend( pItem
,nPos
- )
- );
+ ))
+ return pItem;
+ else
+ return NULL;
} // end of wxMenu::DoInsert
wxMenuItem* wxMenu::DoRemove(
,MPFROM2SHORT(pItem->GetId(), TRUE)
,(MPARAM)0
);
- if (IsAttached() && m_menuBar->IsAttached())
+ if (IsAttached() && GetMenuBar()->IsAttached())
{
//
// Otherwise, the chane won't be visible
//
- m_menuBar->Refresh();
+ GetMenuBar()->Refresh();
}
//
SendEvent( vId
,(int)::WinSendMsg( GetHmenu()
,MM_QUERYITEMATTR
- ,(MPARAM)vId
+ ,MPFROMSHORT(vId)
,(MPARAM)MIA_CHECKED
)
);
{
if (m_invokingWindow != NULL)
return m_invokingWindow;
- else if ( m_menuBar != NULL)
- return m_menuBar->GetFrame();
+ else if ( GetMenuBar() != NULL)
+ return GetMenuBar()->GetFrame();
return NULL;
} // end of wxMenu::GetWindow
WXHMENU wxMenuBar::Create()
{
- MENUITEM vItem;
HWND hFrame;
if (m_hMenu != 0 )
m_menus[i]->m_vMenuData.iPosition = i;
rc = (APIRET)::WinSendMsg(m_hMenu, MM_INSERTITEM, (MPARAM)&m_menus[i]->m_vMenuData, (MPARAM)m_titles[i].c_str());
- if (rc == MIT_MEMERROR || rc == MIT_ERROR)
+ if (rc == (APIRET)MIT_MEMERROR || rc == (APIRET)MIT_ERROR)
{
vError = ::WinGetLastError(vHabmain);
sError = wxPMErrorToStr(vError);
)
{
SHORT nId;
- wxString sTitle = TextToLabel(rTitle);
+ wxString sTitle = wxPMTextToLabel(rTitle);
wxMenu* pMenuOld = wxMenuBarBase::Replace( nPos
,pMenu
,sTitle
, const wxString& rTitle
)
{
- wxString sTitle = TextToLabel(rTitle);
+ wxString sTitle = wxPMTextToLabel(rTitle);
if (!wxMenuBarBase::Insert( nPos
,pMenu
wxCHECK_MSG(hSubmenu, FALSE, wxT("can't append invalid menu to menubar"));
- wxString sTitle = TextToLabel(rsTitle);
+ wxString sTitle = wxPMTextToLabel(rsTitle);
if (!wxMenuBarBase::Append(pMenu, sTitle))
return FALSE;