]>
git.saurik.com Git - wxWidgets.git/blob - src/mac/carbon/menuitem.cpp
1 ///////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxMenuItem implementation
8 // Copyright: (c) AUTHOR
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
12 // ============================================================================
13 // headers & declarations
14 // ============================================================================
17 #include "wx/menuitem.h"
19 #include <wx/mac/uma.h>
20 // ============================================================================
22 // ============================================================================
24 // ----------------------------------------------------------------------------
25 // dynamic classes implementation
26 // ----------------------------------------------------------------------------
28 #if !USE_SHARED_LIBRARY
29 IMPLEMENT_DYNAMIC_CLASS(wxMenuItem
, wxObject
)
30 #endif //USE_SHARED_LIBRARY
32 // ----------------------------------------------------------------------------
34 // ----------------------------------------------------------------------------
39 wxMenuItem::wxMenuItem(wxMenu
*pParentMenu
, int id
,
40 const wxString
& text
, const wxString
& strHelp
,
44 wxASSERT( pParentMenu
!= NULL
);
46 m_parentMenu
= pParentMenu
;
52 m_isCheckable
= bCheckable
;
56 if ( m_text
== "E&xit" ||m_text
== "Exit" )
58 m_text
= "Quit\tCtrl+Q" ;
62 wxMenuItem::~wxMenuItem()
71 // delete the sub menu
72 void wxMenuItem::DeleteSubMenu()
74 wxASSERT( m_subMenu != NULL );
85 void wxMenuItem::Enable(bool bDoEnable
)
87 if ( m_isEnabled
!= bDoEnable
) {
88 if ( m_subMenu
== NULL
)
91 if ( m_parentMenu
->GetHMenu() )
93 int index
= m_parentMenu
->MacGetIndexFromItem( this ) ;
97 UMAEnableMenuItem( m_parentMenu
->GetHMenu() , index
) ;
99 UMADisableMenuItem( m_parentMenu
->GetHMenu() , index
) ;
106 if ( m_parentMenu
->GetHMenu() )
108 int index
= m_parentMenu
->MacGetIndexFromItem( this ) ;
112 UMAEnableMenuItem( m_parentMenu
->GetHMenu() , index
) ;
114 UMADisableMenuItem( m_parentMenu
->GetHMenu() , index
) ;
119 m_isEnabled
= bDoEnable
;
123 void wxMenuItem::Check(bool bDoCheck
)
125 wxCHECK_RET( IsCheckable(), "only checkable items may be checked" );
127 if ( m_isChecked
!= bDoCheck
)
129 m_isChecked
= bDoCheck
;
130 if ( m_parentMenu
->GetHMenu() )
132 int index
= m_parentMenu
->MacGetIndexFromItem( this ) ;
136 ::SetItemMark( m_parentMenu
->GetHMenu() , index
, 0x12 ) ; // checkmark
138 ::SetItemMark( m_parentMenu
->GetHMenu() , index
, 0 ) ; // no mark