X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/17131ffd751235d115e1ee3f1b38a88b5858d13e..7929902d65215d481c59733a5d05b81e373b8237:/src/palmos/menu.cpp diff --git a/src/palmos/menu.cpp b/src/palmos/menu.cpp index de25c0492b..2725ce1448 100644 --- a/src/palmos/menu.cpp +++ b/src/palmos/menu.cpp @@ -17,10 +17,6 @@ // 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" @@ -30,9 +26,10 @@ #if wxUSE_MENUS +#include "wx/menu.h" + #ifndef WX_PRECOMP #include "wx/frame.h" - #include "wx/menu.h" #include "wx/utils.h" #include "wx/intl.h" #include "wx/log.h" @@ -42,6 +39,15 @@ #include "wx/ownerdrw.h" #endif +#ifdef __WXPALMOS6__ +#include +#else // __WXPALMOS5__ +#include // MenuRscType +#endif + +#include +#include + // ---------------------------------------------------------------------------- // global variables // ---------------------------------------------------------------------------- @@ -63,9 +69,9 @@ static const int idMenuTitle = -3; // implementation // ============================================================================ -#include +#include "wx/listimpl.cpp" -WX_DEFINE_LIST( wxMenuInfoList ) ; +WX_DEFINE_LIST( wxMenuInfoList ) #if wxUSE_EXTENDED_RTTI @@ -151,7 +157,7 @@ const wxMenuInfoList& wxMenuBar::GetMenuInfos() const for( size_t i = 0 ; i < GetMenuCount() ; ++i ) { wxMenuInfo* info = new wxMenuInfo() ; - info->Create( const_cast(this)->GetMenu(i) , GetLabelTop(i) ) ; + info->Create( const_cast(this)->GetMenu(i) , GetMenuLabel(i) ) ; list->Append( info ) ; } return m_menuInfos ; @@ -332,7 +338,7 @@ wxMenuBar::wxMenuBar( long WXUNUSED(style) ) { } -wxMenuBar::wxMenuBar(int count, wxMenu *menus[], const wxString titles[]) +wxMenuBar::wxMenuBar(size_t count, wxMenu *menus[], const wxString titles[], long WXUNUSED(style)) { } @@ -371,11 +377,11 @@ void wxMenuBar::EnableTop(size_t pos, bool enable) // Palm OS does not have support for grayed or disabled items } -void wxMenuBar::SetLabelTop(size_t pos, const wxString& label) +void wxMenuBar::SetMenuLabel(size_t pos, const wxString& label) { wxCHECK_RET( pos < GetMenuCount(), wxT("invalid menu index") ); - m_titles[pos]=wxStripMenuCodes(label); + m_titles[pos] = label; if ( !IsAttached() ) { @@ -386,12 +392,12 @@ void wxMenuBar::SetLabelTop(size_t pos, const wxString& label) Refresh(); } -wxString wxMenuBar::GetLabelTop(size_t pos) const +wxString wxMenuBar::GetMenuLabel(size_t pos) const { wxCHECK_MSG( pos < GetMenuCount(), wxEmptyString, - wxT("invalid menu index in wxMenuBar::GetLabelTop") ); + wxT("invalid menu index in wxMenuBar::GetMenuLabel") ); - return wxMenuItem::GetLabelFromText(m_titles[pos]); + return m_titles[pos]; } // --------------------------------------------------------------------------- @@ -404,7 +410,7 @@ wxMenu *wxMenuBar::Replace(size_t pos, wxMenu *menu, const wxString& title) if ( !menuOld ) return NULL; - m_titles[pos]=wxStripMenuCodes(title); + m_titles[pos] = title; if ( IsAttached() ) { @@ -420,7 +426,7 @@ bool wxMenuBar::Insert(size_t pos, wxMenu *menu, const wxString& title) if ( !wxMenuBarBase::Insert(pos, menu, title) ) return false; - m_titles.Insert(wxStripMenuCodes(title), pos); + m_titles.Insert(title, pos); if ( IsAttached() ) { @@ -436,7 +442,7 @@ bool wxMenuBar::Append(wxMenu *menu, const wxString& title) if ( !wxMenuBarBase::Append(menu, title) ) return false; - m_titles.Add(wxStripMenuCodes(title)); + m_titles.Add(title); if(IsAttached()) { @@ -536,12 +542,13 @@ void wxMenuBar::LoadMenu() { int i=0; int j=0; - +#ifdef __WXPALMOS6__ // Handle to the currently running application database DmOpenRef AppDB; // Get app database reference - needed for some Palm OS Menu API calls. SysGetModuleDatabase(SysGetRefNum(), NULL, &AppDB); +#endif // __WXPALMOS6__ // Get the number of menus int NumMenus=GetMenuCount(); @@ -553,24 +560,24 @@ void wxMenuBar::LoadMenu() // Load the menu template and set up the menu pointers if(NumMenus==1) { - PalmOSMenuBar=DmGetResource(AppDB,'MBAR',1000); - PalmOSMenuBarPtr=(char *)MemHandleLock(PalmOSMenuBar); + PalmOSMenuBar = POS_DmGetResource (AppDB, MenuRscType, 1000); + PalmOSMenuBarPtr = (char *)MemHandleLock (PalmOSMenuBar); - PalmOSMenuBarPtr+=74; + PalmOSMenuBarPtr += 74; } else if(NumMenus==2) { - PalmOSMenuBar=DmGetResource(AppDB,'MBAR',2000); - PalmOSMenuBarPtr=(char *)MemHandleLock(PalmOSMenuBar); + PalmOSMenuBar = POS_DmGetResource (AppDB, MenuRscType, 2000); + PalmOSMenuBarPtr = (char *)MemHandleLock (PalmOSMenuBar); - PalmOSMenuBarPtr+=116; + PalmOSMenuBarPtr += 116; } else if(NumMenus==3) { - PalmOSMenuBar=DmGetResource(AppDB,'MBAR',3000); - PalmOSMenuBarPtr=(char *)MemHandleLock(PalmOSMenuBar); + PalmOSMenuBar = POS_DmGetResource (AppDB, MenuRscType, 3000); + PalmOSMenuBarPtr = (char *)MemHandleLock (PalmOSMenuBar); - PalmOSMenuBarPtr+=158; + PalmOSMenuBarPtr += 158; } else { @@ -578,10 +585,10 @@ void wxMenuBar::LoadMenu() // more than we can handle. NumMenus=4; - PalmOSMenuBar=DmGetResource(AppDB,'MBAR',4000); - PalmOSMenuBarPtr=(char *)MemHandleLock(PalmOSMenuBar); + PalmOSMenuBar = POS_DmGetResource (AppDB, MenuRscType, 4000); + PalmOSMenuBarPtr = (char *)MemHandleLock (PalmOSMenuBar); - PalmOSMenuBarPtr+=200; + PalmOSMenuBarPtr += 200; } // Set the proper names for the drop-down triggers. @@ -594,11 +601,11 @@ void wxMenuBar::LoadMenu() wxString MenuTitle=m_titles.Item(i); // Make sure we don't copy more than 8 bytes for the label - int LengthToCopy=MenuTitle.length(); - if(LengthToCopy>8) - LengthToCopy=8; + int LengthToCopy = MenuTitle.length(); + if(LengthToCopy > 8) + LengthToCopy = 8; - MemMove(PalmOSMenuBarPtr,MenuTitle,LengthToCopy); + MemMove(PalmOSMenuBarPtr,(char*)(&MenuTitle),LengthToCopy); PalmOSMenuBarPtr+=11; } @@ -608,7 +615,7 @@ void wxMenuBar::LoadMenu() // We must make the menu active before we can add items to the drop-down // triggers. - FrmSetMenu(FrmGetActiveForm(),AppDB,NumMenus*1000); + POS_FrmSetMenu (FrmGetActiveForm(), AppDB, NumMenus * 1000); /* Add the menu items to the drop-down triggers. This must be done after * setting the triggers, because setting the names of drop-down triggers @@ -636,9 +643,9 @@ void wxMenuBar::LoadMenu() else { if(j==0) - MenuAddItem(9000+i,((i*1000)+1000)+j,0x00,ItemLabel); + MenuAddItem(9000+i,((i*1000)+1000)+j,0x00,(char *)(&ItemLabel)); else - MenuAddItem(((i*1000)+1000)+j-1,((i*1000)+1000)+j,0x00,ItemLabel); + MenuAddItem(((i*1000)+1000)+j-1,((i*1000)+1000)+j,0x00,(char *)(&ItemLabel)); } }