1999-07-29 01:11:30 -04:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
2011-03-19 20:14:35 -04:00
|
|
|
// Name: wx/os2/menu.h
|
1999-07-29 01:11:30 -04:00
|
|
|
// Purpose: wxMenu, wxMenuBar classes
|
1999-10-10 22:49:06 -04:00
|
|
|
// Author: David Webster
|
1999-07-29 01:11:30 -04:00
|
|
|
// Modified by:
|
1999-10-10 22:49:06 -04:00
|
|
|
// Created: 10/10/99
|
1999-07-29 01:11:30 -04:00
|
|
|
// RCS-ID: $Id$
|
1999-10-10 22:49:06 -04:00
|
|
|
// Copyright: (c) David Webster
|
2004-05-23 16:53:33 -04:00
|
|
|
// Licence: wxWindows licence
|
1999-07-29 01:11:30 -04:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#ifndef _WX_MENU_H_
|
|
|
|
#define _WX_MENU_H_
|
|
|
|
|
1999-10-10 22:49:06 -04:00
|
|
|
#if wxUSE_ACCEL
|
2002-04-14 23:31:42 -04:00
|
|
|
#include "wx/accel.h"
|
|
|
|
#include "wx/list.h" // for "template" list classes
|
|
|
|
#include "wx/dynarray.h"
|
1999-11-01 23:38:14 -05:00
|
|
|
|
2005-07-21 13:18:43 -04:00
|
|
|
WX_DEFINE_EXPORTED_ARRAY_PTR(wxAcceleratorEntry *, wxAcceleratorArray);
|
1999-10-10 22:49:06 -04:00
|
|
|
#endif // wxUSE_ACCEL
|
1999-07-29 01:11:30 -04:00
|
|
|
|
2007-07-09 06:09:52 -04:00
|
|
|
class WXDLLIMPEXP_FWD_CORE wxFrame;
|
1999-07-29 01:11:30 -04:00
|
|
|
|
2000-03-19 19:20:29 -05:00
|
|
|
void wxSetShortCutKey(wxChar* zText);
|
|
|
|
|
1999-07-29 01:11:30 -04:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// Menu
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
2008-03-26 11:06:00 -04:00
|
|
|
class WXDLLIMPEXP_CORE wxMenu : public wxMenuBase
|
1999-11-01 23:38:14 -05:00
|
|
|
{
|
1999-07-29 01:11:30 -04:00
|
|
|
public:
|
2000-02-27 23:40:52 -05:00
|
|
|
//
|
|
|
|
// Ctors & dtor
|
|
|
|
//
|
|
|
|
wxMenu( const wxString& rTitle
|
|
|
|
,long lStyle = 0
|
|
|
|
)
|
|
|
|
: wxMenuBase( rTitle
|
|
|
|
,lStyle
|
|
|
|
)
|
|
|
|
{
|
|
|
|
Init();
|
|
|
|
}
|
1999-10-10 22:49:06 -04:00
|
|
|
|
2000-02-27 23:40:52 -05:00
|
|
|
wxMenu(long lStyle = 0)
|
|
|
|
: wxMenuBase(lStyle)
|
|
|
|
{
|
|
|
|
Init();
|
|
|
|
}
|
1999-10-10 22:49:06 -04:00
|
|
|
|
|
|
|
virtual ~wxMenu();
|
|
|
|
|
2000-02-27 23:40:52 -05:00
|
|
|
//
|
|
|
|
// Implement base class virtuals
|
|
|
|
//
|
2004-01-23 13:46:05 -05:00
|
|
|
virtual wxMenuItem* DoAppend(wxMenuItem* pItem);
|
|
|
|
virtual wxMenuItem* DoInsert( size_t nPos
|
2000-02-27 23:40:52 -05:00
|
|
|
,wxMenuItem* pItem
|
|
|
|
);
|
|
|
|
virtual wxMenuItem* DoRemove(wxMenuItem* pItem);
|
|
|
|
virtual void Break(void);
|
|
|
|
virtual void SetTitle(const wxString& rTitle);
|
|
|
|
|
|
|
|
//
|
|
|
|
// Implementation only from now on
|
|
|
|
// -------------------------------
|
|
|
|
//
|
2002-04-14 23:31:42 -04:00
|
|
|
virtual void Attach(wxMenuBarBase* pMenubar);
|
|
|
|
|
2000-02-27 23:40:52 -05:00
|
|
|
bool OS2Command( WXUINT uParam
|
|
|
|
,WXWORD wId
|
|
|
|
);
|
|
|
|
|
|
|
|
//
|
|
|
|
// Semi-private accessors
|
|
|
|
//
|
|
|
|
|
|
|
|
//
|
|
|
|
// Get the window which contains this menu
|
|
|
|
//
|
|
|
|
wxWindow* GetWindow(void) const;
|
|
|
|
|
|
|
|
//
|
|
|
|
// Get the menu handle
|
|
|
|
//
|
1999-11-01 23:38:14 -05:00
|
|
|
WXHMENU GetHMenu() const { return m_hMenu; }
|
1999-10-10 22:49:06 -04:00
|
|
|
|
|
|
|
#if wxUSE_ACCEL
|
2000-02-27 23:40:52 -05:00
|
|
|
//
|
|
|
|
// Called by wxMenuBar to build its accel table from the accels of all menus
|
|
|
|
//
|
2002-04-14 23:31:42 -04:00
|
|
|
bool HasAccels(void) const { return m_vAccels.IsEmpty(); }
|
|
|
|
size_t GetAccelCount(void) const { return m_vAccels.GetCount(); }
|
2000-02-27 23:40:52 -05:00
|
|
|
size_t CopyAccels(wxAcceleratorEntry* pAccels) const;
|
|
|
|
|
|
|
|
//
|
|
|
|
// Called by wxMenuItem when its accels changes
|
|
|
|
//
|
|
|
|
void UpdateAccel(wxMenuItem* pItem);
|
|
|
|
|
|
|
|
//
|
|
|
|
// Helper used by wxMenu itself (returns the index in m_accels)
|
|
|
|
//
|
|
|
|
int FindAccel(int nId) const;
|
1999-11-01 23:38:14 -05:00
|
|
|
#endif // wxUSE_ACCEL
|
2001-03-20 00:46:07 -05:00
|
|
|
//
|
|
|
|
// OS/2 specific Find
|
|
|
|
//
|
|
|
|
wxMenuItem* FindItem(int id, ULONG hItem, wxMenu **menu = NULL) const;
|
|
|
|
//virtual function hiding suppression
|
|
|
|
int FindItem(const wxString& rsString) const
|
|
|
|
{ return wxMenuBase::FindItem(rsString); }
|
|
|
|
wxMenuItem* FindItem(int id, wxMenu **menu = NULL) const
|
|
|
|
{ return wxMenuBase::FindItem(id, menu); }
|
1999-10-10 22:49:06 -04:00
|
|
|
|
2000-02-27 23:40:52 -05:00
|
|
|
//
|
|
|
|
// All OS/2PM Menu's have one of these
|
|
|
|
//
|
|
|
|
MENUITEM m_vMenuData;
|
|
|
|
|
1999-10-10 22:49:06 -04:00
|
|
|
private:
|
2000-02-27 23:40:52 -05:00
|
|
|
//
|
|
|
|
// Common part of all ctors
|
|
|
|
//
|
1999-11-01 23:38:14 -05:00
|
|
|
void Init();
|
|
|
|
|
2000-02-27 23:40:52 -05:00
|
|
|
//
|
|
|
|
// Common part of Append/Insert (behaves as Append is pos == (size_t)-1)
|
|
|
|
//
|
|
|
|
bool DoInsertOrAppend( wxMenuItem* pItem
|
|
|
|
,size_t nPos = (size_t)-1
|
|
|
|
);
|
|
|
|
|
2002-03-25 13:06:12 -05:00
|
|
|
//
|
|
|
|
// Terminate the current radio group, if any
|
|
|
|
//
|
|
|
|
void EndRadioGroup(void);
|
|
|
|
|
2000-02-27 23:40:52 -05:00
|
|
|
//
|
2005-07-21 13:18:43 -04:00
|
|
|
// If true, insert a breal before appending the next item
|
2000-02-27 23:40:52 -05:00
|
|
|
//
|
2005-07-21 13:18:43 -04:00
|
|
|
bool m_bDoBreak;
|
2000-02-27 23:40:52 -05:00
|
|
|
|
|
|
|
//
|
|
|
|
// The menu handle of this menu
|
|
|
|
//
|
|
|
|
WXHMENU m_hMenu;
|
1999-10-10 22:49:06 -04:00
|
|
|
|
2000-07-15 15:51:35 -04:00
|
|
|
//
|
|
|
|
// The helper variable for creating unique IDs.
|
|
|
|
//
|
2002-04-14 23:31:42 -04:00
|
|
|
static USHORT m_nextMenuId;
|
2000-07-15 15:51:35 -04:00
|
|
|
|
2002-03-25 13:06:12 -05:00
|
|
|
//
|
|
|
|
// The position of the first item in the current radio group or -1
|
|
|
|
//
|
|
|
|
int m_nStartRadioGroup;
|
|
|
|
|
1999-10-10 22:49:06 -04:00
|
|
|
#if wxUSE_ACCEL
|
2000-02-27 23:40:52 -05:00
|
|
|
//
|
|
|
|
// The accelerators for our menu items
|
|
|
|
//
|
2002-04-14 23:31:42 -04:00
|
|
|
wxAcceleratorArray m_vAccels;
|
1999-10-10 22:49:06 -04:00
|
|
|
#endif // wxUSE_ACCEL
|
1999-11-01 23:38:14 -05:00
|
|
|
|
|
|
|
DECLARE_DYNAMIC_CLASS(wxMenu)
|
2000-02-27 23:40:52 -05:00
|
|
|
}; // end of wxMenu
|
1999-07-29 01:11:30 -04:00
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// Menu Bar (a la Windows)
|
|
|
|
// ----------------------------------------------------------------------------
|
1999-10-10 22:49:06 -04:00
|
|
|
|
2008-03-26 11:06:00 -04:00
|
|
|
class WXDLLIMPEXP_CORE wxMenuBar : public wxMenuBarBase
|
1999-07-29 01:11:30 -04:00
|
|
|
{
|
1999-10-10 22:49:06 -04:00
|
|
|
public:
|
2000-02-27 23:40:52 -05:00
|
|
|
//
|
|
|
|
// Ctors & dtor
|
|
|
|
//
|
1999-11-01 23:38:14 -05:00
|
|
|
|
2000-02-27 23:40:52 -05:00
|
|
|
//
|
|
|
|
// Default constructor
|
|
|
|
//
|
|
|
|
wxMenuBar();
|
1999-10-10 22:49:06 -04:00
|
|
|
|
2000-02-27 23:40:52 -05:00
|
|
|
//
|
|
|
|
// Unused under OS2
|
|
|
|
wxMenuBar(long lStyle);
|
|
|
|
|
|
|
|
//
|
|
|
|
// Menubar takes ownership of the menus arrays but copies the titles
|
|
|
|
//
|
|
|
|
wxMenuBar( int n
|
|
|
|
,wxMenu* vMenus[]
|
|
|
|
,const wxString sTitles[]
|
2005-03-17 18:45:24 -05:00
|
|
|
,long lStyle = 0
|
2000-02-27 23:40:52 -05:00
|
|
|
);
|
|
|
|
virtual ~wxMenuBar();
|
1999-10-10 22:49:06 -04:00
|
|
|
|
2000-02-27 23:40:52 -05:00
|
|
|
//
|
|
|
|
// Menubar construction
|
|
|
|
//
|
|
|
|
virtual bool Append( wxMenu* pMenu
|
|
|
|
,const wxString& rTitle
|
|
|
|
);
|
|
|
|
virtual bool Insert( size_t nPos
|
|
|
|
,wxMenu* pMenu
|
|
|
|
,const wxString& rTitle
|
|
|
|
);
|
|
|
|
virtual wxMenu* Replace( size_t nPos
|
|
|
|
,wxMenu* pMenu
|
|
|
|
,const wxString& rTitle
|
|
|
|
);
|
|
|
|
virtual wxMenu* Remove(size_t nPos);
|
|
|
|
virtual int FindMenuItem( const wxString& rMenuString
|
|
|
|
,const wxString& rItemString
|
|
|
|
) const;
|
|
|
|
virtual wxMenuItem* FindItem( int nId
|
|
|
|
,wxMenu** ppMenu = NULL
|
|
|
|
) const;
|
2001-03-20 00:46:07 -05:00
|
|
|
virtual wxMenuItem* FindItem( int nId
|
|
|
|
,ULONG hItem
|
|
|
|
,wxMenu** ppMenu = NULL
|
|
|
|
) const;
|
2000-02-27 23:40:52 -05:00
|
|
|
virtual void EnableTop( size_t nPos
|
|
|
|
,bool bFlag
|
|
|
|
);
|
2007-08-11 13:54:59 -04:00
|
|
|
virtual void SetMenuLabel( size_t nPos
|
2000-02-27 23:40:52 -05:00
|
|
|
,const wxString& rLabel
|
|
|
|
);
|
2007-08-11 13:54:59 -04:00
|
|
|
virtual wxString GetMenuLabel(size_t nPos) const;
|
2000-02-27 23:40:52 -05:00
|
|
|
|
|
|
|
//
|
|
|
|
// Implementation from now on
|
|
|
|
//
|
|
|
|
WXHMENU Create(void);
|
2001-07-06 17:45:11 -04:00
|
|
|
virtual void Detach(void);
|
|
|
|
virtual void Attach(wxFrame* pFrame);
|
2000-02-27 23:40:52 -05:00
|
|
|
|
|
|
|
#if wxUSE_ACCEL
|
|
|
|
//
|
|
|
|
// Get the accel table for all the menus
|
|
|
|
//
|
|
|
|
const wxAcceleratorTable& GetAccelTable(void) const { return m_vAccelTable; }
|
|
|
|
|
|
|
|
//
|
2005-05-31 05:20:43 -04:00
|
|
|
// Update the accel table (must be called after adding/deleting a menu)
|
2000-02-27 23:40:52 -05:00
|
|
|
//
|
|
|
|
void RebuildAccelTable(void);
|
1999-10-10 22:49:06 -04:00
|
|
|
#endif // wxUSE_ACCEL
|
|
|
|
|
2000-02-27 23:40:52 -05:00
|
|
|
//
|
|
|
|
// Get the menu handle
|
|
|
|
WXHMENU GetHMenu(void) const { return m_hMenu; }
|
1999-10-10 22:49:06 -04:00
|
|
|
|
2000-02-27 23:40:52 -05:00
|
|
|
//
|
|
|
|
// If the menubar is modified, the display is not updated automatically,
|
1999-10-10 22:49:06 -04:00
|
|
|
// call this function to update it (m_menuBarFrame should be !NULL)
|
2000-02-27 23:40:52 -05:00
|
|
|
//
|
|
|
|
void Refresh(void);
|
1999-10-10 22:49:06 -04:00
|
|
|
|
|
|
|
protected:
|
2000-02-27 23:40:52 -05:00
|
|
|
//
|
|
|
|
// Common part of all ctors
|
|
|
|
//
|
|
|
|
void Init(void);
|
1999-10-10 22:49:06 -04:00
|
|
|
|
1999-11-01 23:38:14 -05:00
|
|
|
wxArrayString m_titles;
|
|
|
|
|
2000-02-18 18:35:39 -05:00
|
|
|
WXHMENU m_hMenu;
|
1999-10-10 22:49:06 -04:00
|
|
|
|
|
|
|
#if wxUSE_ACCEL
|
2000-02-27 23:40:52 -05:00
|
|
|
//
|
|
|
|
// The accelerator table for all accelerators in all our menus
|
|
|
|
//
|
|
|
|
wxAcceleratorTable m_vAccelTable;
|
1999-10-10 22:49:06 -04:00
|
|
|
#endif // wxUSE_ACCEL
|
1999-11-01 23:38:14 -05:00
|
|
|
|
|
|
|
private:
|
2000-02-27 23:40:52 -05:00
|
|
|
//
|
|
|
|
// Virtual function hiding suppression
|
|
|
|
//
|
|
|
|
void Refresh( bool bErase
|
|
|
|
,const wxRect* pRect
|
|
|
|
)
|
|
|
|
{ wxWindow::Refresh(bErase, pRect); }
|
|
|
|
|
1999-11-01 23:38:14 -05:00
|
|
|
DECLARE_DYNAMIC_CLASS(wxMenuBar)
|
1999-07-29 01:11:30 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // _WX_MENU_H_
|