1998-09-18 06:19:10 -04:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
2006-07-25 10:31:55 -04:00
|
|
|
// Name: wx/motif/menu.h
|
1998-09-18 06:19:10 -04:00
|
|
|
// Purpose: wxMenu, wxMenuBar classes
|
|
|
|
// Author: Julian Smart
|
|
|
|
// Modified by:
|
|
|
|
// Created: 17/09/98
|
|
|
|
// RCS-ID: $Id$
|
|
|
|
// Copyright: (c) Julian Smart
|
2004-05-23 16:53:33 -04:00
|
|
|
// Licence: wxWindows licence
|
1998-09-18 06:19:10 -04:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
1999-10-27 09:19:07 -04:00
|
|
|
#ifndef _WX_MOTIF_MENU_H_
|
|
|
|
#define _WX_MOTIF_MENU_H_
|
1998-09-18 06:19:10 -04:00
|
|
|
|
1999-10-27 09:19:07 -04:00
|
|
|
#include "wx/colour.h"
|
1998-12-18 09:40:38 -05:00
|
|
|
#include "wx/font.h"
|
2003-07-20 15:27:14 -04:00
|
|
|
#include "wx/arrstr.h"
|
1998-09-18 06:19:10 -04:00
|
|
|
|
2007-07-09 06:09:52 -04:00
|
|
|
class WXDLLIMPEXP_FWD_CORE wxFrame;
|
1998-09-18 06:19:10 -04:00
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// Menu
|
|
|
|
// ----------------------------------------------------------------------------
|
1999-10-27 09:19:07 -04:00
|
|
|
|
2005-08-02 20:53:09 -04:00
|
|
|
class WXDLLIMPEXP_CORE wxMenu : public wxMenuBase
|
1998-09-18 06:19:10 -04:00
|
|
|
{
|
|
|
|
public:
|
1999-11-02 12:23:29 -05:00
|
|
|
// ctors & dtor
|
|
|
|
wxMenu(const wxString& title, long style = 0)
|
|
|
|
: wxMenuBase(title, style) { Init(); }
|
2006-07-25 10:31:55 -04:00
|
|
|
|
1999-11-02 12:23:29 -05:00
|
|
|
wxMenu(long style = 0) : wxMenuBase(style) { Init(); }
|
2006-07-25 10:31:55 -04:00
|
|
|
|
1999-11-02 12:23:29 -05:00
|
|
|
virtual ~wxMenu();
|
2006-07-25 10:31:55 -04:00
|
|
|
|
1999-11-02 12:23:29 -05:00
|
|
|
// implement base class virtuals
|
2004-01-23 13:46:05 -05:00
|
|
|
virtual wxMenuItem* DoAppend(wxMenuItem *item);
|
|
|
|
virtual wxMenuItem* DoInsert(size_t pos, wxMenuItem *item);
|
|
|
|
virtual wxMenuItem* DoRemove(wxMenuItem *item);
|
2006-07-25 10:31:55 -04:00
|
|
|
|
1999-11-02 12:23:29 -05:00
|
|
|
virtual void Break();
|
2006-07-25 10:31:55 -04:00
|
|
|
|
1999-11-02 12:23:29 -05:00
|
|
|
virtual void SetTitle(const wxString& title);
|
2006-07-25 10:31:55 -04:00
|
|
|
|
1999-11-02 12:23:29 -05:00
|
|
|
bool ProcessCommand(wxCommandEvent& event);
|
2006-07-25 10:31:55 -04:00
|
|
|
|
1999-11-02 12:23:29 -05:00
|
|
|
//// Motif-specific
|
|
|
|
WXWidget GetButtonWidget() const { return m_buttonWidget; }
|
|
|
|
void SetButtonWidget(WXWidget buttonWidget) { m_buttonWidget = buttonWidget; }
|
2006-07-25 10:31:55 -04:00
|
|
|
|
1999-11-02 12:23:29 -05:00
|
|
|
WXWidget GetMainWidget() const { return m_menuWidget; }
|
2006-07-25 10:31:55 -04:00
|
|
|
|
1999-11-02 12:23:29 -05:00
|
|
|
int GetId() const { return m_menuId; }
|
|
|
|
void SetId(int id) { m_menuId = id; }
|
2006-07-25 10:31:55 -04:00
|
|
|
|
1999-11-02 12:23:29 -05:00
|
|
|
void SetMenuBar(wxMenuBar* menuBar) { m_menuBar = menuBar; }
|
|
|
|
wxMenuBar* GetMenuBar() const { return m_menuBar; }
|
2006-07-25 10:31:55 -04:00
|
|
|
|
1999-11-02 12:23:29 -05:00
|
|
|
void CreatePopup(WXWidget logicalParent, int x, int y);
|
|
|
|
void DestroyPopup();
|
|
|
|
void ShowPopup(int x, int y);
|
|
|
|
void HidePopup();
|
2006-07-25 10:31:55 -04:00
|
|
|
|
1999-11-02 12:23:29 -05:00
|
|
|
WXWidget CreateMenu(wxMenuBar *menuBar, WXWidget parent, wxMenu *topMenu,
|
2005-09-30 05:15:52 -04:00
|
|
|
size_t index, const wxString& title = wxEmptyString,
|
2005-02-06 12:38:33 -05:00
|
|
|
bool isPulldown = false);
|
2006-07-25 10:31:55 -04:00
|
|
|
|
1999-11-02 12:23:29 -05:00
|
|
|
// For popups, need to destroy, then recreate menu for a different (or
|
|
|
|
// possibly same) window, since the parent may change.
|
|
|
|
void DestroyMenu(bool full);
|
|
|
|
WXWidget FindMenuItem(int id, wxMenuItem **it = NULL) const;
|
2006-07-25 10:31:55 -04:00
|
|
|
|
1999-11-02 12:23:29 -05:00
|
|
|
const wxColour& GetBackgroundColour() const { return m_backgroundColour; }
|
|
|
|
const wxColour& GetForegroundColour() const { return m_foregroundColour; }
|
|
|
|
const wxFont& GetFont() const { return m_font; }
|
2006-07-25 10:31:55 -04:00
|
|
|
|
1999-11-02 12:23:29 -05:00
|
|
|
void SetBackgroundColour(const wxColour& colour);
|
|
|
|
void SetForegroundColour(const wxColour& colour);
|
|
|
|
void SetFont(const wxFont& colour);
|
2005-02-06 12:38:33 -05:00
|
|
|
void ChangeFont(bool keepOriginalSize = false);
|
2006-07-25 10:31:55 -04:00
|
|
|
|
1999-11-02 12:23:29 -05:00
|
|
|
WXWidget GetHandle() const { return m_menuWidget; }
|
2006-07-25 10:31:55 -04:00
|
|
|
|
1999-11-02 12:23:29 -05:00
|
|
|
bool IsTearOff() const { return (m_style & wxMENU_TEAROFF) != 0; }
|
2003-02-02 10:48:50 -05:00
|
|
|
|
|
|
|
void DestroyWidgetAndDetach();
|
1999-11-02 12:23:29 -05:00
|
|
|
public:
|
|
|
|
// Motif-specific data
|
|
|
|
int m_numColumns;
|
|
|
|
WXWidget m_menuWidget;
|
|
|
|
WXWidget m_popupShell; // For holding the popup shell widget
|
|
|
|
WXWidget m_buttonWidget; // The actual string, so we can grey it etc.
|
|
|
|
int m_menuId;
|
|
|
|
wxMenu* m_topLevelMenu ;
|
|
|
|
bool m_ownedByMenuBar;
|
|
|
|
wxColour m_foregroundColour;
|
|
|
|
wxColour m_backgroundColour;
|
|
|
|
wxFont m_font;
|
2006-07-25 10:31:55 -04:00
|
|
|
|
1999-07-21 12:10:18 -04:00
|
|
|
private:
|
|
|
|
// common code for both constructors:
|
1999-11-02 12:23:29 -05:00
|
|
|
void Init();
|
2006-07-25 10:31:55 -04:00
|
|
|
|
1999-11-02 12:23:29 -05:00
|
|
|
DECLARE_DYNAMIC_CLASS(wxMenu)
|
1998-09-18 06:19:10 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
1999-10-27 09:19:07 -04:00
|
|
|
// Menu Bar
|
1998-09-18 06:19:10 -04:00
|
|
|
// ----------------------------------------------------------------------------
|
1999-07-21 12:10:18 -04:00
|
|
|
|
2005-08-02 20:53:09 -04:00
|
|
|
class WXDLLIMPEXP_CORE wxMenuBar : public wxMenuBarBase
|
1998-09-18 06:19:10 -04:00
|
|
|
{
|
1999-07-21 12:10:18 -04:00
|
|
|
public:
|
1999-10-27 09:19:07 -04:00
|
|
|
wxMenuBar() { Init(); }
|
|
|
|
wxMenuBar(long WXUNUSED(style)) { Init(); }
|
2005-03-17 18:45:24 -05:00
|
|
|
wxMenuBar(size_t n, wxMenu *menus[], const wxString titles[], long style = 0);
|
|
|
|
wxMenuBar(size_t n, wxMenu *menus[], const wxArrayString& titles, long style = 0);
|
1999-10-27 09:19:07 -04:00
|
|
|
virtual ~wxMenuBar();
|
2006-07-25 10:31:55 -04:00
|
|
|
|
1999-10-27 09:19:07 -04:00
|
|
|
// implement base class (pure) virtuals
|
|
|
|
// ------------------------------------
|
2006-07-25 10:31:55 -04:00
|
|
|
|
1999-10-27 09:19:07 -04:00
|
|
|
virtual bool Append( wxMenu *menu, const wxString &title );
|
|
|
|
virtual bool Insert(size_t pos, wxMenu *menu, const wxString& title);
|
|
|
|
virtual wxMenu *Replace(size_t pos, wxMenu *menu, const wxString& title);
|
|
|
|
virtual wxMenu *Remove(size_t pos);
|
2006-07-25 10:31:55 -04:00
|
|
|
|
1999-10-27 09:19:07 -04:00
|
|
|
virtual int FindMenuItem(const wxString& menuString,
|
2002-02-05 11:34:33 -05:00
|
|
|
const wxString& itemString) const;
|
1999-10-27 09:19:07 -04:00
|
|
|
virtual wxMenuItem* FindItem( int id, wxMenu **menu = NULL ) const;
|
2006-07-25 10:31:55 -04:00
|
|
|
|
1999-10-27 09:19:07 -04:00
|
|
|
virtual void EnableTop( size_t pos, bool flag );
|
2007-08-11 13:54:59 -04:00
|
|
|
virtual void SetMenuLabel( size_t pos, const wxString& label );
|
|
|
|
virtual wxString GetMenuLabel( size_t pos ) const;
|
2006-07-25 10:31:55 -04:00
|
|
|
|
1999-10-27 09:19:07 -04:00
|
|
|
// implementation only from now on
|
|
|
|
// -------------------------------
|
2006-07-25 10:31:55 -04:00
|
|
|
|
1999-07-21 12:10:18 -04:00
|
|
|
wxFrame* GetMenuBarFrame() const { return m_menuBarFrame; }
|
|
|
|
void SetMenuBarFrame(wxFrame* frame) { m_menuBarFrame = frame; }
|
|
|
|
WXWidget GetMainWidget() const { return m_mainWidget; }
|
|
|
|
void SetMainWidget(WXWidget widget) { m_mainWidget = widget; }
|
2006-07-25 10:31:55 -04:00
|
|
|
|
1999-07-21 12:10:18 -04:00
|
|
|
// Create menubar
|
|
|
|
bool CreateMenuBar(wxFrame* frame);
|
2006-07-25 10:31:55 -04:00
|
|
|
|
1999-07-21 12:10:18 -04:00
|
|
|
// Destroy menubar, but keep data structures intact so we can recreate it.
|
|
|
|
bool DestroyMenuBar();
|
2006-07-25 10:31:55 -04:00
|
|
|
|
1999-07-21 12:10:18 -04:00
|
|
|
const wxColour& GetBackgroundColour() const { return m_backgroundColour; }
|
|
|
|
const wxColour& GetForegroundColour() const { return m_foregroundColour; }
|
|
|
|
const wxFont& GetFont() const { return m_font; }
|
2006-07-25 10:31:55 -04:00
|
|
|
|
1999-10-27 09:19:07 -04:00
|
|
|
virtual bool SetBackgroundColour(const wxColour& colour);
|
|
|
|
virtual bool SetForegroundColour(const wxColour& colour);
|
|
|
|
virtual bool SetFont(const wxFont& colour);
|
2005-02-06 12:38:33 -05:00
|
|
|
void ChangeFont(bool keepOriginalSize = false);
|
2006-07-25 10:31:55 -04:00
|
|
|
|
1999-07-21 12:10:18 -04:00
|
|
|
public:
|
1999-10-27 09:19:07 -04:00
|
|
|
// common part of all ctors
|
|
|
|
void Init();
|
2006-07-25 10:31:55 -04:00
|
|
|
|
1999-10-27 09:19:07 -04:00
|
|
|
wxArrayString m_titles;
|
|
|
|
wxFrame *m_menuBarFrame;
|
2006-07-25 10:31:55 -04:00
|
|
|
|
1999-10-27 09:19:07 -04:00
|
|
|
WXWidget m_mainWidget;
|
2006-07-25 10:31:55 -04:00
|
|
|
|
1999-10-27 09:19:07 -04:00
|
|
|
wxColour m_foregroundColour;
|
|
|
|
wxColour m_backgroundColour;
|
|
|
|
wxFont m_font;
|
2006-07-25 10:31:55 -04:00
|
|
|
|
1999-10-27 09:19:07 -04:00
|
|
|
DECLARE_DYNAMIC_CLASS(wxMenuBar)
|
1998-09-18 06:19:10 -04:00
|
|
|
};
|
|
|
|
|
1999-10-27 09:19:07 -04:00
|
|
|
#endif // _WX_MOTIF_MENU_H_
|