X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/4055ed8281971e3d35bf04177193c27043d42ed1..fc2d42090058bb7ebb9545b857a9a435ecbdd876:/src/palmos/menu.cpp diff --git a/src/palmos/menu.cpp b/src/palmos/menu.cpp index a1d5f3be61..7274757921 100644 --- a/src/palmos/menu.cpp +++ b/src/palmos/menu.cpp @@ -1,10 +1,10 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: menu.cpp +// Name: src/palmos/menu.cpp // Purpose: wxMenu, wxMenuBar, wxMenuItem -// Author: William Osborne +// Author: William Osborne - minimal working wxPalmOS port // Modified by: // Created: 10/12/04 -// RCS-ID: $Id: +// RCS-ID: $Id$ // Copyright: (c) William Osborne // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -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,9 +39,8 @@ #include "wx/ownerdrw.h" #endif -// other standard headers -#include - +#include +#include #include // ---------------------------------------------------------------------------- @@ -68,9 +64,9 @@ static const int idMenuTitle = -3; // implementation // ============================================================================ -#include +#include "wx/listimpl.cpp" -WX_DEFINE_LIST( wxMenuInfoList ) ; +WX_DEFINE_LIST( wxMenuInfoList ) #if wxUSE_EXTENDED_RTTI @@ -337,7 +333,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)) { } @@ -654,6 +650,89 @@ void wxMenuBar::LoadMenu() void wxMenuBar::Attach(wxFrame *frame) { + // before attaching preprocess menus to not include wxID_EXIT item + // as PalmOS guidelines suggest + + wxMenuItem *item; + wxMenu *menu; + int i; + + while( item = FindItem(wxID_EXIT) ) + { + menu = item->GetMenu(); + if( !menu ) break; // something broken ? + + size_t count = menu->GetMenuItemCount(); + if( count == 0 ) break; // something broken ? + + // if EXIT is last item in menu + if( menu->FindItemByPosition( count - 1 ) == item ) + { + menu->Destroy( item ); + + // was more than one item? + // was previous separator ? + if( count > 2 ) + { + item = menu->FindItemByPosition( count - 2 ); + if(item && item->IsSeparator()) + menu->Destroy( item ); + } + } + + // if EXIT is first item in menu + else if( menu->FindItemByPosition( 0 ) == item ) + { + menu->Destroy( item ); + + // was more than one item? + // was previous separator ? + if( count > 2 ) + { + item = menu->FindItemByPosition( 0 ); + if(item && item->IsSeparator()) + menu->Destroy( item ); + } + } + + // if EXIT is in the middle but before and after are selectors + else + { + i = 1; // 0 case already done + while ( (i < count) && (menu->FindItemByPosition( 0 ) != item) ) + { + i++; + } + + if (i >= count) break; + if (menu->FindItemByPosition( i ) != item) break; + menu->Destroy( item ); + item = menu->FindItemByPosition( i ); + if ( item && + item->IsSeparator() && + menu->FindItemByPosition( i-1 )->IsSeparator() ) + { + // noe need for two neighbouring separators + menu->Destroy( item ); + } + } + } + + // check if we received any empty menu! + i = 0; + while(i < GetMenuCount()) + { + menu = GetMenu(i); + + if( menu && (menu->GetMenuItemCount()==0) ) + { + menu = Remove( i ); + delete menu; + } + else + i++; + } + wxMenuBarBase::Attach(frame); LoadMenu();