1998-09-18 17:36:20 -04:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
2011-03-19 20:14:35 -04:00
|
|
|
// Name: wx/msw/menuitem.h
|
1998-09-18 17:36:20 -04:00
|
|
|
// Purpose: wxMenuItem class
|
|
|
|
// Author: Vadim Zeitlin
|
1999-03-24 14:05:19 -05:00
|
|
|
// Modified by:
|
1998-09-18 17:36:20 -04:00
|
|
|
// Created: 11.11.97
|
|
|
|
// RCS-ID: $Id$
|
|
|
|
// Copyright: (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
|
2004-05-23 16:53:33 -04:00
|
|
|
// Licence: wxWindows licence
|
1998-09-18 17:36:20 -04:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#ifndef _MENUITEM_H
|
|
|
|
#define _MENUITEM_H
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// headers
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
1998-09-25 09:28:52 -04:00
|
|
|
#if wxUSE_OWNER_DRAWN
|
2010-01-23 08:21:12 -05:00
|
|
|
#include "wx/ownerdrw.h"
|
|
|
|
#include "wx/bitmap.h"
|
2010-01-26 04:01:13 -05:00
|
|
|
|
|
|
|
struct tagRECT;
|
1998-09-18 17:36:20 -04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// wxMenuItem: an item in the menu, optionally implements owner-drawn behaviour
|
|
|
|
// ----------------------------------------------------------------------------
|
1999-10-25 11:51:37 -04:00
|
|
|
|
2008-03-26 11:06:00 -04:00
|
|
|
class WXDLLIMPEXP_CORE wxMenuItem : public wxMenuItemBase
|
1998-09-25 09:28:52 -04:00
|
|
|
#if wxUSE_OWNER_DRAWN
|
1999-10-25 11:51:37 -04:00
|
|
|
, public wxOwnerDrawn
|
1998-09-18 17:36:20 -04:00
|
|
|
#endif
|
|
|
|
{
|
|
|
|
public:
|
1999-10-25 11:51:37 -04:00
|
|
|
// ctor & dtor
|
2009-01-19 08:55:27 -05:00
|
|
|
wxMenuItem(wxMenu *parentMenu = NULL,
|
1999-10-25 11:51:37 -04:00
|
|
|
int id = wxID_SEPARATOR,
|
|
|
|
const wxString& name = wxEmptyString,
|
|
|
|
const wxString& help = wxEmptyString,
|
2002-03-22 14:18:51 -05:00
|
|
|
wxItemKind kind = wxITEM_NORMAL,
|
2009-01-19 08:55:27 -05:00
|
|
|
wxMenu *subMenu = NULL);
|
1999-10-25 11:51:37 -04:00
|
|
|
virtual ~wxMenuItem();
|
|
|
|
|
|
|
|
// override base class virtuals
|
2007-08-11 13:54:59 -04:00
|
|
|
virtual void SetItemLabel(const wxString& strName);
|
1999-10-25 11:51:37 -04:00
|
|
|
|
2004-08-30 06:18:55 -04:00
|
|
|
virtual void Enable(bool bDoEnable = true);
|
|
|
|
virtual void Check(bool bDoCheck = true);
|
1999-10-26 15:35:25 -04:00
|
|
|
virtual bool IsChecked() const;
|
1999-10-25 11:51:37 -04:00
|
|
|
|
|
|
|
// unfortunately needed to resolve ambiguity between
|
|
|
|
// wxMenuItemBase::IsCheckable() and wxOwnerDrawn::IsCheckable()
|
|
|
|
bool IsCheckable() const { return wxMenuItemBase::IsCheckable(); }
|
|
|
|
|
|
|
|
// the id for a popup menu is really its menu handle (as required by
|
|
|
|
// ::AppendMenu() API), so this function will return either the id or the
|
2007-11-17 15:38:07 -05:00
|
|
|
// menu handle depending on what we are
|
|
|
|
//
|
|
|
|
// notice that it also returns the id as an unsigned int, as required by
|
|
|
|
// Win32 API
|
2008-02-27 21:22:52 -05:00
|
|
|
WXWPARAM GetMSWId() const;
|
1999-10-25 11:51:37 -04:00
|
|
|
|
2002-03-20 21:35:08 -05:00
|
|
|
// mark item as belonging to the given radio group
|
2002-03-23 20:24:16 -05:00
|
|
|
void SetAsRadioGroupStart();
|
|
|
|
void SetRadioGroupStart(int start);
|
|
|
|
void SetRadioGroupEnd(int end);
|
2002-03-20 21:35:08 -05:00
|
|
|
|
2008-05-29 00:26:29 -04:00
|
|
|
#if WXWIN_COMPATIBILITY_2_8
|
2002-03-22 20:23:11 -05:00
|
|
|
// compatibility only, don't use in new code
|
2008-05-29 00:26:29 -04:00
|
|
|
wxDEPRECATED(
|
2002-03-22 20:23:11 -05:00
|
|
|
wxMenuItem(wxMenu *parentMenu,
|
|
|
|
int id,
|
|
|
|
const wxString& text,
|
|
|
|
const wxString& help,
|
|
|
|
bool isCheckable,
|
2008-05-29 00:26:29 -04:00
|
|
|
wxMenu *subMenu = NULL)
|
|
|
|
);
|
|
|
|
#endif
|
2002-03-22 20:23:11 -05:00
|
|
|
|
2010-01-23 08:21:12 -05:00
|
|
|
#if wxUSE_OWNER_DRAWN
|
|
|
|
|
|
|
|
void SetBitmaps(const wxBitmap& bmpChecked,
|
|
|
|
const wxBitmap& bmpUnchecked = wxNullBitmap)
|
|
|
|
{
|
|
|
|
m_bmpChecked = bmpChecked;
|
|
|
|
m_bmpUnchecked = bmpUnchecked;
|
|
|
|
SetOwnerDrawn(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetBitmap(const wxBitmap& bmp, bool bChecked = true)
|
|
|
|
{
|
|
|
|
if ( bChecked )
|
|
|
|
m_bmpChecked = bmp;
|
|
|
|
else
|
|
|
|
m_bmpUnchecked = bmp;
|
|
|
|
SetOwnerDrawn(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetDisabledBitmap(const wxBitmap& bmpDisabled)
|
|
|
|
{
|
|
|
|
m_bmpDisabled = bmpDisabled;
|
|
|
|
SetOwnerDrawn(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
const wxBitmap& GetBitmap(bool bChecked = true) const
|
|
|
|
{ return (bChecked ? m_bmpChecked : m_bmpUnchecked); }
|
|
|
|
|
|
|
|
const wxBitmap& GetDisabledBitmap() const
|
|
|
|
{ return m_bmpDisabled; }
|
|
|
|
|
2010-01-23 08:21:46 -05:00
|
|
|
int MeasureAccelWidth() const;
|
2010-01-23 08:21:12 -05:00
|
|
|
|
|
|
|
// override wxOwnerDrawn base class virtuals
|
|
|
|
virtual wxString GetName() const;
|
|
|
|
virtual bool OnMeasureItem(size_t *pwidth, size_t *pheight);
|
|
|
|
virtual bool OnDrawItem(wxDC& dc, const wxRect& rc, wxODAction act, wxODStatus stat);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual void GetFontToUse(wxFont& font) const;
|
2010-01-23 08:21:36 -05:00
|
|
|
virtual void GetColourToUse(wxODStatus stat, wxColour& colText, wxColour& colBack) const;
|
2010-01-23 08:21:12 -05:00
|
|
|
|
2010-01-23 08:21:52 -05:00
|
|
|
private:
|
|
|
|
// helper function for draw std menu check mark
|
2010-01-26 04:01:13 -05:00
|
|
|
void DrawStdCheckMark(WXHDC hdc, const tagRECT* rc, wxODStatus stat);
|
2010-01-23 08:21:52 -05:00
|
|
|
|
2010-01-23 08:21:12 -05:00
|
|
|
#endif // wxUSE_OWNER_DRAWN
|
|
|
|
|
1998-09-18 17:36:20 -04:00
|
|
|
private:
|
2002-03-22 20:23:11 -05:00
|
|
|
// common part of all ctors
|
|
|
|
void Init();
|
|
|
|
|
2002-03-20 21:35:08 -05:00
|
|
|
// the positions of the first and last items of the radio group this item
|
2002-03-23 20:24:16 -05:00
|
|
|
// belongs to or -1: start is the radio group start and is valid for all
|
2004-08-30 06:18:55 -04:00
|
|
|
// but first radio group items (m_isRadioGroupStart == false), end is valid
|
2002-03-23 20:24:16 -05:00
|
|
|
// only for the first one
|
|
|
|
union
|
|
|
|
{
|
|
|
|
int start;
|
|
|
|
int end;
|
|
|
|
} m_radioGroup;
|
|
|
|
|
|
|
|
// does this item start a radio group?
|
|
|
|
bool m_isRadioGroupStart;
|
2002-03-20 21:35:08 -05:00
|
|
|
|
2010-01-23 08:21:12 -05:00
|
|
|
#if wxUSE_OWNER_DRAWN
|
|
|
|
// item bitmaps
|
|
|
|
wxBitmap m_bmpChecked, // bitmap to put near the item
|
|
|
|
m_bmpUnchecked, // (checked is used also for 'uncheckable' items)
|
|
|
|
m_bmpDisabled;
|
|
|
|
#endif // wxUSE_OWNER_DRAWN
|
|
|
|
|
2003-07-21 20:24:07 -04:00
|
|
|
DECLARE_DYNAMIC_CLASS_NO_COPY(wxMenuItem)
|
1998-09-18 17:36:20 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif //_MENUITEM_H
|