X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/2cb5d2d2b70566c40be5578fe3db29cb3c3a34ad..f239a20092359e3c914adb79bd39f3f5d2b2e06f:/src/osx/carbon/menu.cpp diff --git a/src/osx/carbon/menu.cpp b/src/osx/carbon/menu.cpp index 5db7b7bc50..5a9f62156f 100644 --- a/src/osx/carbon/menu.cpp +++ b/src/osx/carbon/menu.cpp @@ -37,10 +37,10 @@ // under carbon there's no such thing as a MenuItemRef, everything is done // on the 'parent' menu via index APIs (first line having index 1 !) -// so to make things still work, we store the wxMenuItemImpl instance as a +// so to make things still work, we store the wxMenuItemImpl instance as a // RefCon at the respective menu line -class wxMenuItemCarbonImpl : public wxMenuItemImpl +class wxMenuItemCarbonImpl : public wxMenuItemImpl { public : wxMenuItemCarbonImpl( wxMenuItem* peer ) : wxMenuItemImpl(peer) @@ -48,15 +48,15 @@ public : // the parent menu ref is only set, once the item has been attached m_parentMenuRef = NULL; } - + ~wxMenuItemCarbonImpl(); - + void SetBitmap( const wxBitmap& bitmap ) { MenuItemIndex i = FindMenuItemIndex() ; if ( i > 0 ) { - if ( bitmap.Ok() ) + if ( bitmap.IsOk() ) { #if wxUSE_BMPBUTTON ControlButtonContentInfo info ; @@ -74,21 +74,21 @@ public : #endif } } - } - - void Enable( bool enable ) + } + + void Enable( bool enable ) { MenuItemIndex i = FindMenuItemIndex() ; if ( i > 0 ) { - + if ( GetWXPeer()->GetId() == wxApp::s_macPreferencesMenuItemId) { if ( enable ) EnableMenuCommand( NULL , kHICommandPreferences ) ; else DisableMenuCommand( NULL , kHICommandPreferences ) ; - } + } else if ( GetWXPeer()->GetId() == wxApp::s_macExitMenuItemId) { if ( enable ) @@ -96,20 +96,20 @@ public : else DisableMenuCommand( NULL , kHICommandQuit ) ; } - + if ( enable ) EnableMenuItem(m_parentMenuRef , i); else DisableMenuItem(m_parentMenuRef , i); - + if ( GetWXPeer()->IsSubMenu() ) { UMAEnableMenuItem( GetWXPeer()->GetSubMenu()->GetHMenu() , 0 , enable ) ; } } - } - - void Check( bool check ) + } + + void Check( bool check ) { MenuItemIndex i = FindMenuItemIndex() ; if ( i > 0 ) @@ -119,9 +119,9 @@ public : else ::SetItemMark( m_parentMenuRef, i, 0 ) ; // no mark } - } + } - void Hide( bool hide ) + void Hide( bool hide ) { MenuItemIndex i = FindMenuItemIndex() ; if ( i > 0 ) @@ -131,9 +131,9 @@ public : else ChangeMenuItemAttributes( m_parentMenuRef, i, 0 , kMenuItemAttrHidden ); } - } - - void SetLabel( const wxString& text, wxAcceleratorEntry *entry ) + } + + void SetLabel( const wxString& text, wxAcceleratorEntry *entry ) { MenuItemIndex i = FindMenuItemIndex() ; if ( i > 0 ) @@ -142,16 +142,16 @@ public : UMASetMenuItemShortcut( m_parentMenuRef, i , entry ) ; } } - + void * GetHMenuItem() { return NULL; } - + // Carbon Only - - void AttachToParent( MenuRef parentMenuRef, MenuItemIndex index ) + + void AttachToParent( MenuRef parentMenuRef, MenuItemIndex index ) { m_parentMenuRef = parentMenuRef; if ( m_parentMenuRef && index > 0 ) - SetMenuItemRefCon( m_parentMenuRef, index, (URefCon) this ); + SetMenuItemRefCon( m_parentMenuRef, index, (URefCon) m_peer ); } MenuItemIndex FindMenuItemIndex() @@ -163,7 +163,7 @@ public : { URefCon storedRef = 0; GetMenuItemRefCon(m_parentMenuRef, i, &storedRef ); - if ( storedRef == (URefCon) this ) + if ( storedRef == (URefCon) m_peer ) { hit = i; break; @@ -180,7 +180,7 @@ protected : // wxMenuImpl // -class wxMenuCarbonImpl : public wxMenuImpl +class wxMenuCarbonImpl : public wxMenuImpl { public : wxMenuCarbonImpl( wxMenu* peer , MenuRef menu) : wxMenuImpl(peer), m_osxMenu(menu) @@ -188,8 +188,8 @@ public : } virtual ~wxMenuCarbonImpl(); - - virtual void InsertOrAppend(wxMenuItem *pItem, size_t pos) + + virtual void InsertOrAppend(wxMenuItem *pItem, size_t pos) { // MacOS counts menu items from 1 and inserts after, therefore having the // same effect as wx 0 based and inserting before, we must correct pos @@ -198,14 +198,14 @@ public : MenuItemIndex index = pos; if ( pos == (size_t) -1 ) index = CountMenuItems(m_osxMenu); - + if ( pItem->IsSeparator() ) { InsertMenuItemTextWithCFString( m_osxMenu, CFSTR(""), index, kMenuItemAttrSeparator, 0); // now switch to the Carbon 1 based counting index += 1 ; } - else + else { InsertMenuItemTextWithCFString( m_osxMenu, CFSTR("placeholder"), index, 0, 0 ); @@ -223,7 +223,7 @@ public : SetMenuItemCommandID( m_osxMenu, index , wxIdToMacCommand(pItem->GetId()) ) ; } } - + wxMenuItemCarbonImpl* impl = (wxMenuItemCarbonImpl*) pItem->GetPeer(); impl->AttachToParent( m_osxMenu, index ); // only now can all settings be updated correctly @@ -231,8 +231,8 @@ public : pItem->UpdateItemStatus(); pItem->UpdateItemBitmap(); } - - virtual void Remove( wxMenuItem *pItem ) + + virtual void Remove( wxMenuItem *pItem ) { wxMenuItemCarbonImpl* impl = (wxMenuItemCarbonImpl*) pItem->GetPeer(); if ( impl ) @@ -245,7 +245,7 @@ public : } } } - + virtual void MakeRoot() { SetRootMenu( m_osxMenu ); @@ -354,7 +354,7 @@ wxMenuItemCarbonImpl::~wxMenuItemCarbonImpl() } -wxMenuItemImpl* wxMenuItemImpl::Create( wxMenuItem* peer, +wxMenuItemImpl* wxMenuItemImpl::Create( wxMenuItem* peer, wxMenu * WXUNUSED(pParentMenu), int WXUNUSED(id), const wxString& WXUNUSED(text),