X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/9add93670bb4a38e4007b8422b34b29b6194eecb..d4052bcb78b0ba58ec357b47faa15c92465def20:/src/os2/menu.cpp diff --git a/src/os2/menu.cpp b/src/os2/menu.cpp index 1174131571..ca8af4aa8e 100644 --- a/src/os2/menu.cpp +++ b/src/os2/menu.cpp @@ -47,7 +47,7 @@ extern wxMenu* wxCurrentPopupMenu; // // The (popup) menu title has this special id // -static const int idMenuTitle = -2; +static const int idMenuTitle = -3; // // The unique ID for Menus @@ -61,47 +61,6 @@ USHORT wxMenu::m_nextMenuId = 0; 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 // ============================================================================ @@ -243,7 +202,7 @@ void wxMenu::UpdateAccel( // size_t n = FindAccel(pItem->GetId()); - if (n == wxNOT_FOUND) + if (n == (size_t)wxNOT_FOUND) { // // No old, add new if any @@ -267,7 +226,7 @@ void wxMenu::UpdateAccel( if (IsAttached()) { - m_menuBar->RebuildAccelTable(); + GetMenuBar()->RebuildAccelTable(); } } } // wxMenu::UpdateAccel @@ -288,7 +247,6 @@ bool wxMenu::DoInsertOrAppend( ERRORID vError; wxString sError; - char zMsg[128]; #if wxUSE_ACCEL UpdateAccel(pItem); @@ -304,16 +262,10 @@ bool wxMenu::DoInsertOrAppend( 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")); @@ -328,7 +280,7 @@ bool wxMenu::DoInsertOrAppend( rItem.id = pItem->GetId(); } - BYTE* pData; + BYTE* pData=NULL; #if wxUSE_OWNER_DRAWN if (pItem->IsOwnerDrawn()) @@ -346,11 +298,24 @@ bool wxMenu::DoInsertOrAppend( } else #endif + if (pItem->IsSeparator()) { - // - // Menu is just a normal string (passed in data parameter) - // - rItem.afStyle |= MIS_TEXT; + rItem.afStyle = MIS_SEPARATOR; + } + else + { + 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(); } @@ -373,7 +338,6 @@ bool wxMenu::DoInsertOrAppend( #if wxUSE_OWNER_DRAWN if (pItem->IsOwnerDrawn()) { - BOOL rc; MENUITEM vMenuItem; ::WinSendMsg( GetHmenu() @@ -385,7 +349,7 @@ bool wxMenu::DoInsertOrAppend( ); } #endif - if (rc == MIT_MEMERROR || rc == MIT_ERROR) + if (rc == (APIRET)MIT_MEMERROR || rc == (APIRET)MIT_ERROR) { vError = ::WinGetLastError(vHabmain); sError = wxPMErrorToStr(vError); @@ -398,9 +362,9 @@ bool wxMenu::DoInsertOrAppend( // // 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; } @@ -541,12 +505,12 @@ 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(); } // @@ -643,7 +607,7 @@ bool wxMenu::OS2Command( SendEvent( vId ,(int)::WinSendMsg( GetHmenu() ,MM_QUERYITEMATTR - ,(MPARAM)vId + ,MPFROMSHORT(vId) ,(MPARAM)MIA_CHECKED ) ); @@ -659,8 +623,8 @@ wxWindow* wxMenu::GetWindow() const { 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 @@ -772,7 +736,6 @@ void wxMenuBar::Refresh() WXHMENU wxMenuBar::Create() { - MENUITEM vItem; HWND hFrame; if (m_hMenu != 0 ) @@ -841,7 +804,7 @@ WXHMENU wxMenuBar::Create() 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); @@ -942,7 +905,7 @@ wxMenu* wxMenuBar::Replace( ) { SHORT nId; - wxString sTitle = TextToLabel(rTitle); + wxString sTitle = wxPMTextToLabel(rTitle); wxMenu* pMenuOld = wxMenuBarBase::Replace( nPos ,pMenu ,sTitle @@ -983,7 +946,7 @@ bool wxMenuBar::Insert( , const wxString& rTitle ) { - wxString sTitle = TextToLabel(rTitle); + wxString sTitle = wxPMTextToLabel(rTitle); if (!wxMenuBarBase::Insert( nPos ,pMenu @@ -1024,7 +987,7 @@ bool wxMenuBar::Append( 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;