2003-03-21 14:51:47 -05:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: wx/cocoa/menuitem.h
|
|
|
|
// Purpose: wxMenuItem class
|
|
|
|
// Author: David Elliott
|
|
|
|
// Modified by:
|
|
|
|
// Created: 2002/12/13
|
2009-01-11 06:58:34 -05:00
|
|
|
// RCS-ID: $Id$
|
2003-03-21 14:51:47 -05:00
|
|
|
// Copyright: (c) 2002 David Elliott
|
2004-05-23 16:53:33 -04:00
|
|
|
// Licence: wxWindows licence
|
2003-03-21 14:51:47 -05:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#ifndef _WX_COCOA_MENUITEM_H_
|
|
|
|
#define _WX_COCOA_MENUITEM_H_
|
|
|
|
|
|
|
|
#include "wx/hashmap.h"
|
|
|
|
#include "wx/bitmap.h"
|
|
|
|
|
2004-10-14 21:39:35 -04:00
|
|
|
#include "wx/cocoa/ObjcRef.h"
|
|
|
|
|
2003-03-21 14:51:47 -05:00
|
|
|
// ========================================================================
|
|
|
|
// wxMenuItem
|
|
|
|
// ========================================================================
|
|
|
|
|
|
|
|
#define wxMenuItemCocoa wxMenuItem
|
|
|
|
class wxMenuItemCocoa;
|
|
|
|
WX_DECLARE_HASH_MAP(WX_NSMenuItem,wxMenuItem*,wxPointerHash,wxPointerEqual,wxMenuItemCocoaHash);
|
|
|
|
|
2008-03-26 11:06:00 -04:00
|
|
|
class WXDLLIMPEXP_CORE wxMenuItemCocoa : public wxMenuItemBase
|
2003-03-21 14:51:47 -05:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
// ------------------------------------------------------------------------
|
|
|
|
// initialization
|
|
|
|
// ------------------------------------------------------------------------
|
2009-01-19 08:55:27 -05:00
|
|
|
wxMenuItemCocoa(wxMenu *parentMenu = NULL,
|
2003-03-21 14:51:47 -05:00
|
|
|
int id = wxID_SEPARATOR,
|
|
|
|
const wxString& name = wxEmptyString,
|
|
|
|
const wxString& help = wxEmptyString,
|
|
|
|
wxItemKind kind = wxITEM_NORMAL,
|
2009-01-19 08:55:27 -05:00
|
|
|
wxMenu *subMenu = NULL);
|
2003-03-21 14:51:47 -05:00
|
|
|
virtual ~wxMenuItemCocoa();
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------
|
|
|
|
// Cocoa specifics
|
|
|
|
// ------------------------------------------------------------------------
|
|
|
|
public:
|
|
|
|
inline WX_NSMenuItem GetNSMenuItem() { return m_cocoaNSMenuItem; }
|
|
|
|
static inline wxMenuItem* GetFromCocoa(WX_NSMenuItem cocoaNSMenuItem)
|
|
|
|
{
|
|
|
|
wxMenuItemCocoaHash::iterator iter=sm_cocoaHash.find(cocoaNSMenuItem);
|
|
|
|
if(iter!=sm_cocoaHash.end())
|
|
|
|
return iter->second;
|
|
|
|
return NULL;
|
|
|
|
}
|
2004-10-14 21:39:35 -04:00
|
|
|
void CocoaItemSelected();
|
|
|
|
bool Cocoa_validateMenuItem();
|
2003-03-21 14:51:47 -05:00
|
|
|
protected:
|
2004-10-20 15:18:46 -04:00
|
|
|
void CocoaSetKeyEquivalent();
|
2003-03-21 14:51:47 -05:00
|
|
|
WX_NSMenuItem m_cocoaNSMenuItem;
|
|
|
|
static wxMenuItemCocoaHash sm_cocoaHash;
|
2004-10-14 21:39:35 -04:00
|
|
|
static wxObjcAutoRefFromAlloc<struct objc_object *> sm_cocoaTarget;
|
2003-03-21 14:51:47 -05:00
|
|
|
// ------------------------------------------------------------------------
|
|
|
|
// Implementation
|
|
|
|
// ------------------------------------------------------------------------
|
|
|
|
public:
|
|
|
|
// override base class virtuals to update the item appearance on screen
|
2007-08-11 13:54:59 -04:00
|
|
|
virtual void SetItemLabel(const wxString& text);
|
2003-03-21 14:51:47 -05:00
|
|
|
virtual void SetCheckable(bool checkable);
|
|
|
|
|
|
|
|
virtual void Enable(bool enable = TRUE);
|
|
|
|
virtual void Check(bool check = TRUE);
|
|
|
|
|
|
|
|
// we add some extra functions which are also available under MSW from
|
|
|
|
// wxOwnerDrawn class - they will be moved to wxMenuItemBase later
|
|
|
|
// hopefully
|
|
|
|
void SetBitmaps(const wxBitmap& bmpChecked,
|
|
|
|
const wxBitmap& bmpUnchecked = wxNullBitmap);
|
|
|
|
void SetBitmap(const wxBitmap& bmp) { SetBitmaps(bmp); }
|
|
|
|
const wxBitmap& GetBitmap(bool checked = TRUE) const
|
|
|
|
{ return checked ? m_bmpChecked : m_bmpUnchecked; }
|
|
|
|
|
|
|
|
protected:
|
|
|
|
// notify the menu about the change in this item
|
|
|
|
inline void NotifyMenu();
|
|
|
|
|
|
|
|
// set the accel index and string from text
|
|
|
|
void UpdateAccelInfo();
|
|
|
|
|
|
|
|
// the bitmaps (may be invalid, then they're not used)
|
|
|
|
wxBitmap m_bmpChecked,
|
|
|
|
m_bmpUnchecked;
|
|
|
|
|
|
|
|
// the accel string (i.e. "Ctrl-Q" or "Alt-F1")
|
|
|
|
wxString m_strAccel;
|
|
|
|
|
|
|
|
private:
|
|
|
|
DECLARE_DYNAMIC_CLASS(wxMenuItem)
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // _WX_COCOA_MENUITEM_H_
|
|
|
|
|