1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/motif/menu.h
3 // Purpose: wxMenu, wxMenuBar classes
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_MOTIF_MENU_H_
13 #define _WX_MOTIF_MENU_H_
15 #include "wx/colour.h"
17 #include "wx/arrstr.h"
19 class WXDLLIMPEXP_CORE wxFrame
;
21 // ----------------------------------------------------------------------------
23 // ----------------------------------------------------------------------------
25 class WXDLLIMPEXP_CORE wxMenu
: public wxMenuBase
29 wxMenu(const wxString
& title
, long style
= 0)
30 : wxMenuBase(title
, style
) { Init(); }
32 wxMenu(long style
= 0) : wxMenuBase(style
) { Init(); }
36 // implement base class virtuals
37 virtual wxMenuItem
* DoAppend(wxMenuItem
*item
);
38 virtual wxMenuItem
* DoInsert(size_t pos
, wxMenuItem
*item
);
39 virtual wxMenuItem
* DoRemove(wxMenuItem
*item
);
43 virtual void SetTitle(const wxString
& title
);
45 bool ProcessCommand(wxCommandEvent
& event
);
48 WXWidget
GetButtonWidget() const { return m_buttonWidget
; }
49 void SetButtonWidget(WXWidget buttonWidget
) { m_buttonWidget
= buttonWidget
; }
51 WXWidget
GetMainWidget() const { return m_menuWidget
; }
53 int GetId() const { return m_menuId
; }
54 void SetId(int id
) { m_menuId
= id
; }
56 void SetMenuBar(wxMenuBar
* menuBar
) { m_menuBar
= menuBar
; }
57 wxMenuBar
* GetMenuBar() const { return m_menuBar
; }
59 void CreatePopup(WXWidget logicalParent
, int x
, int y
);
61 void ShowPopup(int x
, int y
);
64 WXWidget
CreateMenu(wxMenuBar
*menuBar
, WXWidget parent
, wxMenu
*topMenu
,
65 size_t index
, const wxString
& title
= wxEmptyString
,
66 bool isPulldown
= false);
68 // For popups, need to destroy, then recreate menu for a different (or
69 // possibly same) window, since the parent may change.
70 void DestroyMenu(bool full
);
71 WXWidget
FindMenuItem(int id
, wxMenuItem
**it
= NULL
) const;
73 const wxColour
& GetBackgroundColour() const { return m_backgroundColour
; }
74 const wxColour
& GetForegroundColour() const { return m_foregroundColour
; }
75 const wxFont
& GetFont() const { return m_font
; }
77 void SetBackgroundColour(const wxColour
& colour
);
78 void SetForegroundColour(const wxColour
& colour
);
79 void SetFont(const wxFont
& colour
);
80 void ChangeFont(bool keepOriginalSize
= false);
82 WXWidget
GetHandle() const { return m_menuWidget
; }
84 bool IsTearOff() const { return (m_style
& wxMENU_TEAROFF
) != 0; }
86 void DestroyWidgetAndDetach();
88 // Motif-specific data
90 WXWidget m_menuWidget
;
91 WXWidget m_popupShell
; // For holding the popup shell widget
92 WXWidget m_buttonWidget
; // The actual string, so we can grey it etc.
94 wxMenu
* m_topLevelMenu
;
95 bool m_ownedByMenuBar
;
96 wxColour m_foregroundColour
;
97 wxColour m_backgroundColour
;
101 // common code for both constructors:
104 DECLARE_DYNAMIC_CLASS(wxMenu
)
107 // ----------------------------------------------------------------------------
109 // ----------------------------------------------------------------------------
111 class WXDLLIMPEXP_CORE wxMenuBar
: public wxMenuBarBase
114 wxMenuBar() { Init(); }
115 wxMenuBar(long WXUNUSED(style
)) { Init(); }
116 wxMenuBar(size_t n
, wxMenu
*menus
[], const wxString titles
[], long style
= 0);
117 wxMenuBar(size_t n
, wxMenu
*menus
[], const wxArrayString
& titles
, long style
= 0);
118 virtual ~wxMenuBar();
120 // implement base class (pure) virtuals
121 // ------------------------------------
123 virtual bool Append( wxMenu
*menu
, const wxString
&title
);
124 virtual bool Insert(size_t pos
, wxMenu
*menu
, const wxString
& title
);
125 virtual wxMenu
*Replace(size_t pos
, wxMenu
*menu
, const wxString
& title
);
126 virtual wxMenu
*Remove(size_t pos
);
128 virtual int FindMenuItem(const wxString
& menuString
,
129 const wxString
& itemString
) const;
130 virtual wxMenuItem
* FindItem( int id
, wxMenu
**menu
= NULL
) const;
132 virtual void EnableTop( size_t pos
, bool flag
);
133 virtual void SetLabelTop( size_t pos
, const wxString
& label
);
134 virtual wxString
GetLabelTop( size_t pos
) const;
136 // implementation only from now on
137 // -------------------------------
139 wxFrame
* GetMenuBarFrame() const { return m_menuBarFrame
; }
140 void SetMenuBarFrame(wxFrame
* frame
) { m_menuBarFrame
= frame
; }
141 WXWidget
GetMainWidget() const { return m_mainWidget
; }
142 void SetMainWidget(WXWidget widget
) { m_mainWidget
= widget
; }
145 bool CreateMenuBar(wxFrame
* frame
);
147 // Destroy menubar, but keep data structures intact so we can recreate it.
148 bool DestroyMenuBar();
150 const wxColour
& GetBackgroundColour() const { return m_backgroundColour
; }
151 const wxColour
& GetForegroundColour() const { return m_foregroundColour
; }
152 const wxFont
& GetFont() const { return m_font
; }
154 virtual bool SetBackgroundColour(const wxColour
& colour
);
155 virtual bool SetForegroundColour(const wxColour
& colour
);
156 virtual bool SetFont(const wxFont
& colour
);
157 void ChangeFont(bool keepOriginalSize
= false);
160 // common part of all ctors
163 wxArrayString m_titles
;
164 wxFrame
*m_menuBarFrame
;
166 WXWidget m_mainWidget
;
168 wxColour m_foregroundColour
;
169 wxColour m_backgroundColour
;
172 DECLARE_DYNAMIC_CLASS(wxMenuBar
)
175 #endif // _WX_MOTIF_MENU_H_