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