| 1 | /////////////////////////////////////////////////////////////////////////////// |
| 2 | // Name: menuitem.cpp |
| 3 | // Purpose: wxMenuItem implementation |
| 4 | // Author: AUTHOR |
| 5 | // Modified by: |
| 6 | // Created: ??/??/98 |
| 7 | // RCS-ID: $Id$ |
| 8 | // Copyright: (c) AUTHOR |
| 9 | // Licence: wxWindows licence |
| 10 | /////////////////////////////////////////////////////////////////////////////// |
| 11 | |
| 12 | // ============================================================================ |
| 13 | // headers & declarations |
| 14 | // ============================================================================ |
| 15 | |
| 16 | #include "wx/menu.h" |
| 17 | #include "wx/menuitem.h" |
| 18 | |
| 19 | // ============================================================================ |
| 20 | // implementation |
| 21 | // ============================================================================ |
| 22 | |
| 23 | // ---------------------------------------------------------------------------- |
| 24 | // dynamic classes implementation |
| 25 | // ---------------------------------------------------------------------------- |
| 26 | |
| 27 | #if !USE_SHARED_LIBRARY |
| 28 | IMPLEMENT_DYNAMIC_CLASS(wxMenuItem, wxObject) |
| 29 | #endif //USE_SHARED_LIBRARY |
| 30 | |
| 31 | // ---------------------------------------------------------------------------- |
| 32 | // wxMenuItem |
| 33 | // ---------------------------------------------------------------------------- |
| 34 | |
| 35 | // ctor & dtor |
| 36 | // ----------- |
| 37 | |
| 38 | wxMenuItem::wxMenuItem(wxMenu *pParentMenu, int id, |
| 39 | const wxString& strName, const wxString& strHelp, |
| 40 | bool bCheckable, |
| 41 | wxMenu *pSubMenu) : |
| 42 | m_bCheckable(bCheckable), |
| 43 | m_strName(strName), |
| 44 | m_strHelp(strHelp) |
| 45 | { |
| 46 | wxASSERT( pParentMenu != NULL ); |
| 47 | |
| 48 | m_pParentMenu = pParentMenu; |
| 49 | m_pSubMenu = pSubMenu; |
| 50 | m_idItem = id; |
| 51 | m_bEnabled = TRUE; |
| 52 | } |
| 53 | |
| 54 | wxMenuItem::~wxMenuItem() |
| 55 | { |
| 56 | } |
| 57 | |
| 58 | // misc |
| 59 | // ---- |
| 60 | |
| 61 | // delete the sub menu |
| 62 | void wxMenuItem::DeleteSubMenu() |
| 63 | { |
| 64 | wxASSERT( m_pSubMenu != NULL ); |
| 65 | |
| 66 | delete m_pSubMenu; |
| 67 | m_pSubMenu = NULL; |
| 68 | } |
| 69 | |
| 70 | // change item state |
| 71 | // ----------------- |
| 72 | |
| 73 | void wxMenuItem::Enable(bool bDoEnable) |
| 74 | { |
| 75 | if ( m_bEnabled != bDoEnable ) { |
| 76 | if ( m_pSubMenu == NULL ) { // normal menu item |
| 77 | // TODO |
| 78 | } |
| 79 | else // submenu |
| 80 | { |
| 81 | // TODO |
| 82 | } |
| 83 | |
| 84 | m_bEnabled = bDoEnable; |
| 85 | } |
| 86 | } |
| 87 | |
| 88 | void wxMenuItem::Check(bool bDoCheck) |
| 89 | { |
| 90 | wxCHECK_RET( IsCheckable(), "only checkable items may be checked" ); |
| 91 | |
| 92 | if ( m_bChecked != bDoCheck ) { |
| 93 | // TODO |
| 94 | m_bChecked = bDoCheck; |
| 95 | } |
| 96 | } |