]> git.saurik.com Git - wxWidgets.git/blame - include/wx/motif/menu.h
Committing in .
[wxWidgets.git] / include / wx / motif / menu.h
CommitLineData
9b6dbb09
JS
1/////////////////////////////////////////////////////////////////////////////
2// Name: menu.h
3// Purpose: wxMenu, wxMenuBar classes
4// Author: Julian Smart
5// Modified by:
6// Created: 17/09/98
7// RCS-ID: $Id$
8// Copyright: (c) Julian Smart
ee31c392 9// Licence: wxWindows licence
9b6dbb09
JS
10/////////////////////////////////////////////////////////////////////////////
11
9874b4ee
VZ
12#ifndef _WX_MOTIF_MENU_H_
13#define _WX_MOTIF_MENU_H_
9b6dbb09
JS
14
15#ifdef __GNUG__
9874b4ee 16 #pragma interface "menu.h"
9b6dbb09
JS
17#endif
18
9874b4ee 19#include "wx/colour.h"
94b49b93 20#include "wx/font.h"
9b6dbb09 21
9874b4ee 22class wxFrame;
9b6dbb09
JS
23
24// ----------------------------------------------------------------------------
25// Menu
26// ----------------------------------------------------------------------------
9874b4ee 27
c71830c3 28class wxMenu : public wxMenuBase
9b6dbb09 29{
9b6dbb09 30public:
c71830c3
VZ
31 // ctors & dtor
32 wxMenu(const wxString& title, long style = 0)
33 : wxMenuBase(title, style) { Init(); }
34
35 wxMenu(long style = 0) : wxMenuBase(style) { Init(); }
36
37 virtual ~wxMenu();
38
39 // implement base class virtuals
40 virtual bool DoAppend(wxMenuItem *item);
41 virtual bool DoInsert(size_t pos, wxMenuItem *item);
42 virtual wxMenuItem *DoRemove(wxMenuItem *item);
43
44 virtual void Break();
45
46 virtual void SetTitle(const wxString& title);
47
48 bool ProcessCommand(wxCommandEvent& event);
49
c71830c3
VZ
50 wxMenu(const wxString& title, const wxFunction func)
51 : wxMenuBase(title)
ee31c392 52 {
c71830c3 53 Callback(func);
ee31c392 54 }
9b6dbb09 55
c71830c3
VZ
56 //// Motif-specific
57 WXWidget GetButtonWidget() const { return m_buttonWidget; }
58 void SetButtonWidget(WXWidget buttonWidget) { m_buttonWidget = buttonWidget; }
9b6dbb09 59
c71830c3 60 WXWidget GetMainWidget() const { return m_menuWidget; }
9b6dbb09 61
c71830c3
VZ
62 int GetId() const { return m_menuId; }
63 void SetId(int id) { m_menuId = id; }
631f1bfe 64
c71830c3
VZ
65 void SetMenuBar(wxMenuBar* menuBar) { m_menuBar = menuBar; }
66 wxMenuBar* GetMenuBar() const { return m_menuBar; }
50414e24 67
c71830c3
VZ
68 void CreatePopup(WXWidget logicalParent, int x, int y);
69 void DestroyPopup();
70 void ShowPopup(int x, int y);
71 void HidePopup();
50414e24 72
c71830c3
VZ
73 WXWidget CreateMenu(wxMenuBar *menuBar, WXWidget parent, wxMenu *topMenu,
74 const wxString& title = wxEmptyString,
75 bool isPulldown = FALSE);
50414e24 76
c71830c3
VZ
77 // For popups, need to destroy, then recreate menu for a different (or
78 // possibly same) window, since the parent may change.
79 void DestroyMenu(bool full);
80 WXWidget FindMenuItem(int id, wxMenuItem **it = NULL) const;
50414e24 81
c71830c3
VZ
82 const wxColour& GetBackgroundColour() const { return m_backgroundColour; }
83 const wxColour& GetForegroundColour() const { return m_foregroundColour; }
84 const wxFont& GetFont() const { return m_font; }
94b49b93 85
c71830c3
VZ
86 void SetBackgroundColour(const wxColour& colour);
87 void SetForegroundColour(const wxColour& colour);
88 void SetFont(const wxFont& colour);
89 void ChangeFont(bool keepOriginalSize = FALSE);
94b49b93 90
c71830c3 91 WXWidget GetHandle() const { return m_menuWidget; }
ee31c392 92
c71830c3 93 bool IsTearOff() const { return (m_style & wxMENU_TEAROFF) != 0; }
9b6dbb09 94
c71830c3
VZ
95public:
96 // Motif-specific data
97 int m_numColumns;
98 WXWidget m_menuWidget;
99 WXWidget m_popupShell; // For holding the popup shell widget
100 WXWidget m_buttonWidget; // The actual string, so we can grey it etc.
101 int m_menuId;
102 wxMenu* m_topLevelMenu ;
103 bool m_ownedByMenuBar;
104 wxColour m_foregroundColour;
105 wxColour m_backgroundColour;
106 wxFont m_font;
ee31c392
VZ
107
108private:
109 // common code for both constructors:
c71830c3
VZ
110 void Init();
111
112 DECLARE_DYNAMIC_CLASS(wxMenu)
9b6dbb09
JS
113};
114
115// ----------------------------------------------------------------------------
9874b4ee 116// Menu Bar
9b6dbb09 117// ----------------------------------------------------------------------------
ee31c392 118
9874b4ee 119class wxMenuBar : public wxMenuBarBase
9b6dbb09 120{
ee31c392 121public:
9874b4ee
VZ
122 wxMenuBar() { Init(); }
123 wxMenuBar(long WXUNUSED(style)) { Init(); }
ee31c392 124 wxMenuBar(int n, wxMenu *menus[], const wxString titles[]);
9874b4ee
VZ
125 virtual ~wxMenuBar();
126
127 // implement base class (pure) virtuals
128 // ------------------------------------
129
130 virtual bool Append( wxMenu *menu, const wxString &title );
131 virtual bool Insert(size_t pos, wxMenu *menu, const wxString& title);
132 virtual wxMenu *Replace(size_t pos, wxMenu *menu, const wxString& title);
133 virtual wxMenu *Remove(size_t pos);
134
135 virtual int FindMenuItem(const wxString& menuString,
136 const wxString& itemString) const;
137 virtual wxMenuItem* FindItem( int id, wxMenu **menu = NULL ) const;
138
139 virtual void EnableTop( size_t pos, bool flag );
140 virtual void SetLabelTop( size_t pos, const wxString& label );
141 virtual wxString GetLabelTop( size_t pos ) const;
142
143 // implementation only from now on
144 // -------------------------------
145
ee31c392
VZ
146 wxFrame* GetMenuBarFrame() const { return m_menuBarFrame; }
147 void SetMenuBarFrame(wxFrame* frame) { m_menuBarFrame = frame; }
148 WXWidget GetMainWidget() const { return m_mainWidget; }
149 void SetMainWidget(WXWidget widget) { m_mainWidget = widget; }
150
151 // Create menubar
152 bool CreateMenuBar(wxFrame* frame);
153
154 // Destroy menubar, but keep data structures intact so we can recreate it.
155 bool DestroyMenuBar();
156
157 const wxColour& GetBackgroundColour() const { return m_backgroundColour; }
158 const wxColour& GetForegroundColour() const { return m_foregroundColour; }
159 const wxFont& GetFont() const { return m_font; }
160
9874b4ee
VZ
161 virtual bool SetBackgroundColour(const wxColour& colour);
162 virtual bool SetForegroundColour(const wxColour& colour);
163 virtual bool SetFont(const wxFont& colour);
ee31c392 164 void ChangeFont(bool keepOriginalSize = FALSE);
50414e24 165
ee31c392 166public:
9874b4ee
VZ
167 // common part of all ctors
168 void Init();
169
170 wxArrayString m_titles;
171 wxFrame *m_menuBarFrame;
172
173 WXWidget m_mainWidget;
174
175 wxColour m_foregroundColour;
176 wxColour m_backgroundColour;
177 wxFont m_font;
178
179 DECLARE_DYNAMIC_CLASS(wxMenuBar)
9b6dbb09
JS
180};
181
9874b4ee 182#endif // _WX_MOTIF_MENU_H_