2001-06-26 16:59:19 -04:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: wx/univ/menuitem.h
|
|
|
|
// Purpose: wxMenuItem class for wxUniversal
|
|
|
|
// Author: Vadim Zeitlin
|
|
|
|
// Modified by:
|
|
|
|
// Created: 05.05.01
|
|
|
|
// RCS-ID: $Id$
|
2001-07-02 15:42:27 -04:00
|
|
|
// Copyright: (c) 2001 SciTech Software, Inc. (www.scitechsoft.com)
|
2004-05-23 16:53:33 -04:00
|
|
|
// Licence: wxWindows licence
|
2001-06-26 16:59:19 -04:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#ifndef _WX_UNIV_MENUITEM_H_
|
|
|
|
#define _WX_UNIV_MENUITEM_H_
|
|
|
|
|
2003-08-09 08:38:21 -04:00
|
|
|
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
|
2001-07-04 14:07:15 -04:00
|
|
|
#pragma interface "univmenuitem.h"
|
2001-06-26 16:59:19 -04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// wxMenuItem implements wxMenuItemBase
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
class WXDLLEXPORT wxMenuItem : public wxMenuItemBase
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
// ctor & dtor
|
|
|
|
wxMenuItem(wxMenu *parentMenu = (wxMenu *)NULL,
|
|
|
|
int id = wxID_SEPARATOR,
|
|
|
|
const wxString& name = wxEmptyString,
|
|
|
|
const wxString& help = wxEmptyString,
|
2002-03-22 14:18:51 -05:00
|
|
|
wxItemKind kind = wxITEM_NORMAL,
|
2001-06-26 16:59:19 -04:00
|
|
|
wxMenu *subMenu = (wxMenu *)NULL);
|
|
|
|
virtual ~wxMenuItem();
|
|
|
|
|
|
|
|
// override base class virtuals to update the item appearance on screen
|
|
|
|
virtual void SetText(const wxString& text);
|
|
|
|
virtual void SetCheckable(bool checkable);
|
|
|
|
|
2004-08-10 09:08:43 -04:00
|
|
|
virtual void Enable(bool enable = true);
|
|
|
|
virtual void Check(bool check = true);
|
2001-06-26 16:59:19 -04:00
|
|
|
|
|
|
|
// 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); }
|
2004-08-10 09:08:43 -04:00
|
|
|
const wxBitmap& GetBitmap(bool checked = true) const
|
2001-06-26 16:59:19 -04:00
|
|
|
{ return checked ? m_bmpChecked : m_bmpUnchecked; }
|
|
|
|
|
2004-02-08 07:38:31 -05:00
|
|
|
void SetDisabledBitmap( const wxBitmap& bmpDisabled )
|
|
|
|
{ m_bmpDisabled = bmpDisabled; }
|
|
|
|
const wxBitmap& GetDisabledBitmap() const
|
|
|
|
{ return m_bmpDisabled; }
|
|
|
|
|
2003-02-02 09:50:05 -05:00
|
|
|
// mark item as belonging to the given radio group
|
|
|
|
void SetAsRadioGroupStart();
|
|
|
|
void SetRadioGroupStart(int start);
|
|
|
|
void SetRadioGroupEnd(int end);
|
|
|
|
|
2001-06-26 16:59:19 -04:00
|
|
|
// wxUniv-specific methods for implementation only starting from here
|
|
|
|
|
|
|
|
// get the accel index of our label or -1 if none
|
|
|
|
int GetAccelIndex() const { return m_indexAccel; }
|
|
|
|
|
|
|
|
// get the accel string (displayed to the right of the label)
|
|
|
|
const wxString& GetAccelString() const { return m_strAccel; }
|
|
|
|
|
|
|
|
// set/get the y coord and the height of this item: note that it must be
|
|
|
|
// set first and retrieved later, the item doesn't calculate it itself
|
|
|
|
void SetGeometry(wxCoord y, wxCoord height)
|
|
|
|
{
|
|
|
|
m_posY = y;
|
|
|
|
m_height = height;
|
|
|
|
}
|
|
|
|
|
|
|
|
wxCoord GetPosition() const
|
|
|
|
{
|
2004-08-10 09:08:43 -04:00
|
|
|
wxASSERT_MSG( m_posY != wxDefaultCoord, _T("must call SetHeight first!") );
|
2001-06-26 16:59:19 -04:00
|
|
|
|
|
|
|
return m_posY;
|
|
|
|
}
|
|
|
|
|
|
|
|
wxCoord GetHeight() const
|
|
|
|
{
|
2004-08-10 09:08:43 -04:00
|
|
|
wxASSERT_MSG( m_height != wxDefaultCoord, _T("must call SetHeight first!") );
|
2001-06-26 16:59:19 -04:00
|
|
|
|
|
|
|
return m_height;
|
|
|
|
}
|
|
|
|
|
|
|
|
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,
|
2004-02-08 07:38:31 -05:00
|
|
|
m_bmpUnchecked,
|
|
|
|
m_bmpDisabled;
|
2001-06-26 16:59:19 -04:00
|
|
|
|
2003-02-02 09:50:05 -05:00
|
|
|
// the positions of the first and last items of the radio group this item
|
|
|
|
// belongs to or -1: start is the radio group start and is valid for all
|
2004-08-10 09:08:43 -04:00
|
|
|
// but first radio group items (m_isRadioGroupStart == false), end is valid
|
2003-02-02 09:50:05 -05:00
|
|
|
// only for the first one
|
|
|
|
union
|
|
|
|
{
|
|
|
|
int start;
|
|
|
|
int end;
|
|
|
|
} m_radioGroup;
|
|
|
|
|
|
|
|
// does this item start a radio group?
|
|
|
|
bool m_isRadioGroupStart;
|
|
|
|
|
2001-06-26 16:59:19 -04:00
|
|
|
// the position of the accelerator in our label, -1 if none
|
|
|
|
int m_indexAccel;
|
|
|
|
|
|
|
|
// the accel string (i.e. "Ctrl-Q" or "Alt-F1")
|
|
|
|
wxString m_strAccel;
|
|
|
|
|
|
|
|
// the position and height of the displayed item
|
|
|
|
wxCoord m_posY,
|
|
|
|
m_height;
|
|
|
|
|
|
|
|
private:
|
|
|
|
DECLARE_DYNAMIC_CLASS(wxMenuItem)
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // _WX_UNIV_MENUITEM_H_
|
|
|
|
|