]> git.saurik.com Git - wxWidgets.git/blame_incremental - include/wx/os2/menu.h
don't draw borders for bitmap buttons with wxBORDER_NONE style
[wxWidgets.git] / include / wx / os2 / menu.h
... / ...
CommitLineData
1/////////////////////////////////////////////////////////////////////////////
2// Name: menu.h
3// Purpose: wxMenu, wxMenuBar classes
4// Author: David Webster
5// Modified by:
6// Created: 10/10/99
7// RCS-ID: $Id$
8// Copyright: (c) David Webster
9// Licence: wxWindows licence
10/////////////////////////////////////////////////////////////////////////////
11
12#ifndef _WX_MENU_H_
13#define _WX_MENU_H_
14
15#if wxUSE_ACCEL
16 #include "wx/accel.h"
17 #include "wx/list.h" // for "template" list classes
18 #include "wx/dynarray.h"
19
20 WX_DEFINE_EXPORTED_ARRAY_PTR(wxAcceleratorEntry *, wxAcceleratorArray);
21#endif // wxUSE_ACCEL
22
23class WXDLLIMPEXP_FWD_CORE wxFrame;
24
25void wxSetShortCutKey(wxChar* zText);
26
27// ----------------------------------------------------------------------------
28// Menu
29// ----------------------------------------------------------------------------
30
31class WXDLLIMPEXP_CORE wxMenu : public wxMenuBase
32{
33public:
34 //
35 // Ctors & dtor
36 //
37 wxMenu( const wxString& rTitle
38 ,long lStyle = 0
39 )
40 : wxMenuBase( rTitle
41 ,lStyle
42 )
43 {
44 Init();
45 }
46
47 wxMenu(long lStyle = 0)
48 : wxMenuBase(lStyle)
49 {
50 Init();
51 }
52
53 virtual ~wxMenu();
54
55 //
56 // Implement base class virtuals
57 //
58 virtual wxMenuItem* DoAppend(wxMenuItem* pItem);
59 virtual wxMenuItem* DoInsert( size_t nPos
60 ,wxMenuItem* pItem
61 );
62 virtual wxMenuItem* DoRemove(wxMenuItem* pItem);
63 virtual void Break(void);
64 virtual void SetTitle(const wxString& rTitle);
65
66 //
67 // Implementation only from now on
68 // -------------------------------
69 //
70 virtual void Attach(wxMenuBarBase* pMenubar);
71
72 bool OS2Command( WXUINT uParam
73 ,WXWORD wId
74 );
75
76 //
77 // Semi-private accessors
78 //
79
80 //
81 // Get the window which contains this menu
82 //
83 wxWindow* GetWindow(void) const;
84
85 //
86 // Get the menu handle
87 //
88 WXHMENU GetHMenu() const { return m_hMenu; }
89
90#if wxUSE_ACCEL
91 //
92 // Called by wxMenuBar to build its accel table from the accels of all menus
93 //
94 bool HasAccels(void) const { return m_vAccels.IsEmpty(); }
95 size_t GetAccelCount(void) const { return m_vAccels.GetCount(); }
96 size_t CopyAccels(wxAcceleratorEntry* pAccels) const;
97
98 //
99 // Called by wxMenuItem when its accels changes
100 //
101 void UpdateAccel(wxMenuItem* pItem);
102
103 //
104 // Helper used by wxMenu itself (returns the index in m_accels)
105 //
106 int FindAccel(int nId) const;
107#endif // wxUSE_ACCEL
108 //
109 // OS/2 specific Find
110 //
111 wxMenuItem* FindItem(int id, ULONG hItem, wxMenu **menu = NULL) const;
112 //virtual function hiding suppression
113 int FindItem(const wxString& rsString) const
114 { return wxMenuBase::FindItem(rsString); }
115 wxMenuItem* FindItem(int id, wxMenu **menu = NULL) const
116 { return wxMenuBase::FindItem(id, menu); }
117
118 //
119 // All OS/2PM Menu's have one of these
120 //
121 MENUITEM m_vMenuData;
122
123private:
124 //
125 // Common part of all ctors
126 //
127 void Init();
128
129 //
130 // Common part of Append/Insert (behaves as Append is pos == (size_t)-1)
131 //
132 bool DoInsertOrAppend( wxMenuItem* pItem
133 ,size_t nPos = (size_t)-1
134 );
135
136 //
137 // Terminate the current radio group, if any
138 //
139 void EndRadioGroup(void);
140
141 //
142 // If true, insert a breal before appending the next item
143 //
144 bool m_bDoBreak;
145
146 //
147 // The menu handle of this menu
148 //
149 WXHMENU m_hMenu;
150
151 //
152 // The helper variable for creating unique IDs.
153 //
154 static USHORT m_nextMenuId;
155
156 //
157 // The position of the first item in the current radio group or -1
158 //
159 int m_nStartRadioGroup;
160
161#if wxUSE_ACCEL
162 //
163 // The accelerators for our menu items
164 //
165 wxAcceleratorArray m_vAccels;
166#endif // wxUSE_ACCEL
167
168 DECLARE_DYNAMIC_CLASS(wxMenu)
169}; // end of wxMenu
170
171// ----------------------------------------------------------------------------
172// Menu Bar (a la Windows)
173// ----------------------------------------------------------------------------
174
175class WXDLLIMPEXP_CORE wxMenuBar : public wxMenuBarBase
176{
177public:
178 //
179 // Ctors & dtor
180 //
181
182 //
183 // Default constructor
184 //
185 wxMenuBar();
186
187 //
188 // Unused under OS2
189 wxMenuBar(long lStyle);
190
191 //
192 // Menubar takes ownership of the menus arrays but copies the titles
193 //
194 wxMenuBar( int n
195 ,wxMenu* vMenus[]
196 ,const wxString sTitles[]
197 ,long lStyle = 0
198 );
199 virtual ~wxMenuBar();
200
201 //
202 // Menubar construction
203 //
204 virtual bool Append( wxMenu* pMenu
205 ,const wxString& rTitle
206 );
207 virtual bool Insert( size_t nPos
208 ,wxMenu* pMenu
209 ,const wxString& rTitle
210 );
211 virtual wxMenu* Replace( size_t nPos
212 ,wxMenu* pMenu
213 ,const wxString& rTitle
214 );
215 virtual wxMenu* Remove(size_t nPos);
216 virtual int FindMenuItem( const wxString& rMenuString
217 ,const wxString& rItemString
218 ) const;
219 virtual wxMenuItem* FindItem( int nId
220 ,wxMenu** ppMenu = NULL
221 ) const;
222 virtual wxMenuItem* FindItem( int nId
223 ,ULONG hItem
224 ,wxMenu** ppMenu = NULL
225 ) const;
226 virtual void EnableTop( size_t nPos
227 ,bool bFlag
228 );
229 virtual void SetMenuLabel( size_t nPos
230 ,const wxString& rLabel
231 );
232 virtual wxString GetMenuLabel(size_t nPos) const;
233
234 //
235 // Implementation from now on
236 //
237 WXHMENU Create(void);
238 virtual void Detach(void);
239 virtual void Attach(wxFrame* pFrame);
240
241#if wxUSE_ACCEL
242 //
243 // Get the accel table for all the menus
244 //
245 const wxAcceleratorTable& GetAccelTable(void) const { return m_vAccelTable; }
246
247 //
248 // Update the accel table (must be called after adding/deleting a menu)
249 //
250 void RebuildAccelTable(void);
251#endif // wxUSE_ACCEL
252
253 //
254 // Get the menu handle
255 WXHMENU GetHMenu(void) const { return m_hMenu; }
256
257 //
258 // If the menubar is modified, the display is not updated automatically,
259 // call this function to update it (m_menuBarFrame should be !NULL)
260 //
261 void Refresh(void);
262
263protected:
264 //
265 // Common part of all ctors
266 //
267 void Init(void);
268
269 wxArrayString m_titles;
270
271 WXHMENU m_hMenu;
272
273#if wxUSE_ACCEL
274 //
275 // The accelerator table for all accelerators in all our menus
276 //
277 wxAcceleratorTable m_vAccelTable;
278#endif // wxUSE_ACCEL
279
280private:
281 //
282 // Virtual function hiding suppression
283 //
284 void Refresh( bool bErase
285 ,const wxRect* pRect
286 )
287 { wxWindow::Refresh(bErase, pRect); }
288
289 DECLARE_DYNAMIC_CLASS(wxMenuBar)
290};
291
292#endif // _WX_MENU_H_