]> git.saurik.com Git - wxWidgets.git/blob - include/wx/cocoa/menuitem.h
Remove wxRTTI macro for wxComboBox from Motif port.
[wxWidgets.git] / include / wx / cocoa / menuitem.h
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: wx/cocoa/menuitem.h
3 // Purpose: wxMenuItem class
4 // Author: David Elliott
5 // Modified by:
6 // Created: 2002/12/13
7 // RCS-ID: $Id$
8 // Copyright: (c) 2002 David Elliott
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_COCOA_MENUITEM_H_
13 #define _WX_COCOA_MENUITEM_H_
14
15 #include "wx/hashmap.h"
16 #include "wx/bitmap.h"
17
18 #include "wx/cocoa/ObjcRef.h"
19
20 // ========================================================================
21 // wxMenuItem
22 // ========================================================================
23
24 #define wxMenuItemCocoa wxMenuItem
25 class wxMenuItemCocoa;
26 WX_DECLARE_HASH_MAP(WX_NSMenuItem,wxMenuItem*,wxPointerHash,wxPointerEqual,wxMenuItemCocoaHash);
27
28 class WXDLLIMPEXP_CORE wxMenuItemCocoa : public wxMenuItemBase
29 {
30 public:
31 // ------------------------------------------------------------------------
32 // initialization
33 // ------------------------------------------------------------------------
34 wxMenuItemCocoa(wxMenu *parentMenu = NULL,
35 int id = wxID_SEPARATOR,
36 const wxString& name = wxEmptyString,
37 const wxString& help = wxEmptyString,
38 wxItemKind kind = wxITEM_NORMAL,
39 wxMenu *subMenu = NULL);
40 virtual ~wxMenuItemCocoa();
41
42 // ------------------------------------------------------------------------
43 // Cocoa specifics
44 // ------------------------------------------------------------------------
45 public:
46 inline WX_NSMenuItem GetNSMenuItem() { return m_cocoaNSMenuItem; }
47 static inline wxMenuItem* GetFromCocoa(WX_NSMenuItem cocoaNSMenuItem)
48 {
49 wxMenuItemCocoaHash::iterator iter=sm_cocoaHash.find(cocoaNSMenuItem);
50 if(iter!=sm_cocoaHash.end())
51 return iter->second;
52 return NULL;
53 }
54 void CocoaItemSelected();
55 bool Cocoa_validateMenuItem();
56 protected:
57 void CocoaSetKeyEquivalent();
58 WX_NSMenuItem m_cocoaNSMenuItem;
59 static wxMenuItemCocoaHash sm_cocoaHash;
60 static wxObjcAutoRefFromAlloc<struct objc_object *> sm_cocoaTarget;
61 // ------------------------------------------------------------------------
62 // Implementation
63 // ------------------------------------------------------------------------
64 public:
65 // override base class virtuals to update the item appearance on screen
66 virtual void SetItemLabel(const wxString& text);
67 virtual void SetCheckable(bool checkable);
68
69 virtual void Enable(bool enable = TRUE);
70 virtual void Check(bool check = TRUE);
71
72 // we add some extra functions which are also available under MSW from
73 // wxOwnerDrawn class - they will be moved to wxMenuItemBase later
74 // hopefully
75 void SetBitmaps(const wxBitmap& bmpChecked,
76 const wxBitmap& bmpUnchecked = wxNullBitmap);
77 void SetBitmap(const wxBitmap& bmp) { SetBitmaps(bmp); }
78 const wxBitmap& GetBitmap(bool checked = TRUE) const
79 { return checked ? m_bmpChecked : m_bmpUnchecked; }
80
81 protected:
82 // notify the menu about the change in this item
83 inline void NotifyMenu();
84
85 // set the accel index and string from text
86 void UpdateAccelInfo();
87
88 // the bitmaps (may be invalid, then they're not used)
89 wxBitmap m_bmpChecked,
90 m_bmpUnchecked;
91
92 // the accel string (i.e. "Ctrl-Q" or "Alt-F1")
93 wxString m_strAccel;
94
95 private:
96 DECLARE_DYNAMIC_CLASS(wxMenuItem)
97 };
98
99 #endif // _WX_COCOA_MENUITEM_H_
100