]>
git.saurik.com Git - wxWidgets.git/blob - src/mac/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
& strName
, const wxString
& strHelp
,
43 m_bCheckable(bCheckable
),
47 wxASSERT( pParentMenu
!= NULL
);
49 m_pParentMenu
= pParentMenu
;
50 m_pSubMenu
= pSubMenu
;
54 if ( m_strName
== "E&xit" ||m_strName
== "Exit" )
56 m_strName
= "Quit\tCtrl+Q" ;
60 wxMenuItem::~wxMenuItem()
67 // delete the sub menu
68 void wxMenuItem::DeleteSubMenu()
70 wxASSERT( m_pSubMenu
!= NULL
);
79 void wxMenuItem::Enable(bool bDoEnable
)
81 if ( m_bEnabled
!= bDoEnable
) {
82 if ( m_pSubMenu
== NULL
)
85 if ( m_pParentMenu
->m_macMenuHandle
)
87 int index
= m_pParentMenu
->MacGetIndexFromItem( this ) ;
91 UMAEnableMenuItem( m_pParentMenu
->m_macMenuHandle
, index
) ;
93 UMADisableMenuItem( m_pParentMenu
->m_macMenuHandle
, index
) ;
100 if ( m_pParentMenu
->m_macMenuHandle
)
102 int index
= m_pParentMenu
->MacGetIndexFromItem( this ) ;
106 UMAEnableMenuItem( m_pParentMenu
->m_macMenuHandle
, index
) ;
108 UMADisableMenuItem( m_pParentMenu
->m_macMenuHandle
, index
) ;
113 m_bEnabled
= bDoEnable
;
117 void wxMenuItem::Check(bool bDoCheck
)
119 wxCHECK_RET( IsCheckable(), "only checkable items may be checked" );
121 if ( m_bChecked
!= bDoCheck
)
123 m_bChecked
= bDoCheck
;
124 if ( m_pParentMenu
->m_macMenuHandle
)
126 int index
= m_pParentMenu
->MacGetIndexFromItem( this ) ;
130 ::SetItemMark( m_pParentMenu
->m_macMenuHandle
, index
, 0x12 ) ; // checkmark
132 ::SetItemMark( m_pParentMenu
->m_macMenuHandle
, index
, 0 ) ; // no mark