]> git.saurik.com Git - wxWidgets.git/blame - include/wx/cocoa/menuitem.h
Baked files with Bakefile 0.1.2 (Mac OS 10.3 Python 2.3)
[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
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// ========================================================================
19// wxMenuItem
20// ========================================================================
21
22#define wxMenuItemCocoa wxMenuItem
23class wxMenuItemCocoa;
24WX_DECLARE_HASH_MAP(WX_NSMenuItem,wxMenuItem*,wxPointerHash,wxPointerEqual,wxMenuItemCocoaHash);
25
26class WXDLLEXPORT wxMenuItemCocoa : public wxMenuItemBase
27{
28public:
29// ------------------------------------------------------------------------
30// initialization
31// ------------------------------------------------------------------------
32 wxMenuItemCocoa(wxMenu *parentMenu = (wxMenu *)NULL,
33 int id = wxID_SEPARATOR,
34 const wxString& name = wxEmptyString,
35 const wxString& help = wxEmptyString,
36 wxItemKind kind = wxITEM_NORMAL,
37 wxMenu *subMenu = (wxMenu *)NULL);
38 virtual ~wxMenuItemCocoa();
39
40// ------------------------------------------------------------------------
41// Cocoa specifics
42// ------------------------------------------------------------------------
43public:
44 inline WX_NSMenuItem GetNSMenuItem() { return m_cocoaNSMenuItem; }
45 static inline wxMenuItem* GetFromCocoa(WX_NSMenuItem cocoaNSMenuItem)
46 {
47 wxMenuItemCocoaHash::iterator iter=sm_cocoaHash.find(cocoaNSMenuItem);
48 if(iter!=sm_cocoaHash.end())
49 return iter->second;
50 return NULL;
51 }
52protected:
53 WX_NSMenuItem m_cocoaNSMenuItem;
54 static wxMenuItemCocoaHash sm_cocoaHash;
2fc2d511 55 static struct objc_object *sm_cocoaTarget;
fb896a32
DE
56// ------------------------------------------------------------------------
57// Implementation
58// ------------------------------------------------------------------------
59public:
60 // override base class virtuals to update the item appearance on screen
61 virtual void SetText(const wxString& text);
62 virtual void SetCheckable(bool checkable);
63
64 virtual void Enable(bool enable = TRUE);
65 virtual void Check(bool check = TRUE);
66
67 // we add some extra functions which are also available under MSW from
68 // wxOwnerDrawn class - they will be moved to wxMenuItemBase later
69 // hopefully
70 void SetBitmaps(const wxBitmap& bmpChecked,
71 const wxBitmap& bmpUnchecked = wxNullBitmap);
72 void SetBitmap(const wxBitmap& bmp) { SetBitmaps(bmp); }
73 const wxBitmap& GetBitmap(bool checked = TRUE) const
74 { return checked ? m_bmpChecked : m_bmpUnchecked; }
75
76protected:
77 // notify the menu about the change in this item
78 inline void NotifyMenu();
79
80 // set the accel index and string from text
81 void UpdateAccelInfo();
82
83 // the bitmaps (may be invalid, then they're not used)
84 wxBitmap m_bmpChecked,
85 m_bmpUnchecked;
86
87 // the accel string (i.e. "Ctrl-Q" or "Alt-F1")
88 wxString m_strAccel;
89
90private:
91 DECLARE_DYNAMIC_CLASS(wxMenuItem)
92};
93
94#endif // _WX_COCOA_MENUITEM_H_
95