1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: wx/cocoa/menuitem.h
3 // Purpose: wxMenuItem class
4 // Author: David Elliott
8 // Copyright: (c) 2002 David Elliott
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_COCOA_MENUITEM_H_
13 #define _WX_COCOA_MENUITEM_H_
15 #include "wx/hashmap.h"
16 #include "wx/bitmap.h"
18 #include "wx/cocoa/ObjcRef.h"
20 // ========================================================================
22 // ========================================================================
24 #define wxMenuItemCocoa wxMenuItem
25 class wxMenuItemCocoa
;
26 WX_DECLARE_HASH_MAP(WX_NSMenuItem
,wxMenuItem
*,wxPointerHash
,wxPointerEqual
,wxMenuItemCocoaHash
);
28 class WXDLLEXPORT wxMenuItemCocoa
: public wxMenuItemBase
31 // ------------------------------------------------------------------------
33 // ------------------------------------------------------------------------
34 wxMenuItemCocoa(wxMenu
*parentMenu
= (wxMenu
*)NULL
,
35 int id
= wxID_SEPARATOR
,
36 const wxString
& name
= wxEmptyString
,
37 const wxString
& help
= wxEmptyString
,
38 wxItemKind kind
= wxITEM_NORMAL
,
39 wxMenu
*subMenu
= (wxMenu
*)NULL
);
40 virtual ~wxMenuItemCocoa();
42 // ------------------------------------------------------------------------
44 // ------------------------------------------------------------------------
46 inline WX_NSMenuItem
GetNSMenuItem() { return m_cocoaNSMenuItem
; }
47 static inline wxMenuItem
* GetFromCocoa(WX_NSMenuItem cocoaNSMenuItem
)
49 wxMenuItemCocoaHash::iterator iter
=sm_cocoaHash
.find(cocoaNSMenuItem
);
50 if(iter
!=sm_cocoaHash
.end())
54 void CocoaItemSelected();
55 bool Cocoa_validateMenuItem();
57 WX_NSMenuItem m_cocoaNSMenuItem
;
58 static wxMenuItemCocoaHash sm_cocoaHash
;
59 static wxObjcAutoRefFromAlloc
<struct objc_object
*> sm_cocoaTarget
;
60 // ------------------------------------------------------------------------
62 // ------------------------------------------------------------------------
64 // override base class virtuals to update the item appearance on screen
65 virtual void SetText(const wxString
& text
);
66 virtual void SetCheckable(bool checkable
);
68 virtual void Enable(bool enable
= TRUE
);
69 virtual void Check(bool check
= TRUE
);
71 // we add some extra functions which are also available under MSW from
72 // wxOwnerDrawn class - they will be moved to wxMenuItemBase later
74 void SetBitmaps(const wxBitmap
& bmpChecked
,
75 const wxBitmap
& bmpUnchecked
= wxNullBitmap
);
76 void SetBitmap(const wxBitmap
& bmp
) { SetBitmaps(bmp
); }
77 const wxBitmap
& GetBitmap(bool checked
= TRUE
) const
78 { return checked
? m_bmpChecked
: m_bmpUnchecked
; }
81 // notify the menu about the change in this item
82 inline void NotifyMenu();
84 // set the accel index and string from text
85 void UpdateAccelInfo();
87 // the bitmaps (may be invalid, then they're not used)
88 wxBitmap m_bmpChecked
,
91 // the accel string (i.e. "Ctrl-Q" or "Alt-F1")
95 DECLARE_DYNAMIC_CLASS(wxMenuItem
)
98 #endif // _WX_COCOA_MENUITEM_H_