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