]> git.saurik.com Git - wxWidgets.git/blame - include/wx/os2/menu.h
avoid unimplemented wx stubs being used
[wxWidgets.git] / include / wx / os2 / menu.h
CommitLineData
0e320a79
DW
1/////////////////////////////////////////////////////////////////////////////
2// Name: menu.h
3// Purpose: wxMenu, wxMenuBar classes
75f11ad7 4// Author: David Webster
0e320a79 5// Modified by:
75f11ad7 6// Created: 10/10/99
0e320a79 7// RCS-ID: $Id$
75f11ad7 8// Copyright: (c) David Webster
65571936 9// Licence: wxWindows licence
0e320a79
DW
10/////////////////////////////////////////////////////////////////////////////
11
12#ifndef _WX_MENU_H_
13#define _WX_MENU_H_
14
75f11ad7 15#if wxUSE_ACCEL
598d8cac
DW
16 #include "wx/accel.h"
17 #include "wx/list.h" // for "template" list classes
18 #include "wx/dynarray.h"
e92f266c 19
598d8cac 20 WX_DEFINE_EXPORTED_ARRAY(wxAcceleratorEntry *, wxAcceleratorArray);
75f11ad7 21#endif // wxUSE_ACCEL
0e320a79 22
75f11ad7 23class WXDLLEXPORT wxFrame;
0e320a79 24
8c5907ce
DW
25void wxSetShortCutKey(wxChar* zText);
26
0e320a79
DW
27// ----------------------------------------------------------------------------
28// Menu
29// ----------------------------------------------------------------------------
0e320a79 30
e92f266c
DW
31class WXDLLEXPORT wxMenu : public wxMenuBase
32{
0e320a79 33public:
61243a51
DW
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 }
75f11ad7 46
61243a51
DW
47 wxMenu(long lStyle = 0)
48 : wxMenuBase(lStyle)
49 {
50 Init();
51 }
75f11ad7
DW
52
53 virtual ~wxMenu();
54
61243a51
DW
55 //
56 // Implement base class virtuals
57 //
9add9367
RD
58 virtual wxMenuItem* DoAppend(wxMenuItem* pItem);
59 virtual wxMenuItem* DoInsert( size_t nPos
61243a51
DW
60 ,wxMenuItem* pItem
61 );
62 virtual wxMenuItem* DoRemove(wxMenuItem* pItem);
63 virtual void Break(void);
64 virtual void SetTitle(const wxString& rTitle);
65
61243a51
DW
66 //
67 // Implementation only from now on
68 // -------------------------------
69 //
598d8cac
DW
70 virtual void Attach(wxMenuBarBase* pMenubar);
71
61243a51
DW
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 //
e92f266c 88 WXHMENU GetHMenu() const { return m_hMenu; }
75f11ad7 89
75f11ad7 90#if wxUSE_ACCEL
61243a51
DW
91 //
92 // Called by wxMenuBar to build its accel table from the accels of all menus
93 //
598d8cac
DW
94 bool HasAccels(void) const { return m_vAccels.IsEmpty(); }
95 size_t GetAccelCount(void) const { return m_vAccels.GetCount(); }
61243a51
DW
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;
e92f266c 107#endif // wxUSE_ACCEL
45bedfdd
DW
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); }
75f11ad7 117
61243a51
DW
118 //
119 // All OS/2PM Menu's have one of these
120 //
121 MENUITEM m_vMenuData;
122
75f11ad7 123private:
61243a51
DW
124 //
125 // Common part of all ctors
126 //
e92f266c
DW
127 void Init();
128
61243a51
DW
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
ab4fece8
DW
136 //
137 // Terminate the current radio group, if any
138 //
139 void EndRadioGroup(void);
140
61243a51
DW
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;
75f11ad7 150
f6bcfd97
BP
151 //
152 // The helper variable for creating unique IDs.
153 //
598d8cac 154 static USHORT m_nextMenuId;
f6bcfd97 155
ab4fece8
DW
156 //
157 // The position of the first item in the current radio group or -1
158 //
159 int m_nStartRadioGroup;
160
75f11ad7 161#if wxUSE_ACCEL
61243a51
DW
162 //
163 // The accelerators for our menu items
164 //
598d8cac 165 wxAcceleratorArray m_vAccels;
75f11ad7 166#endif // wxUSE_ACCEL
e92f266c
DW
167
168 DECLARE_DYNAMIC_CLASS(wxMenu)
61243a51 169}; // end of wxMenu
0e320a79
DW
170
171// ----------------------------------------------------------------------------
172// Menu Bar (a la Windows)
173// ----------------------------------------------------------------------------
75f11ad7 174
e92f266c 175class WXDLLEXPORT wxMenuBar : public wxMenuBarBase
0e320a79 176{
75f11ad7 177public:
61243a51
DW
178 //
179 // Ctors & dtor
180 //
e92f266c 181
61243a51
DW
182 //
183 // Default constructor
184 //
185 wxMenuBar();
75f11ad7 186
61243a51
DW
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 );
198 virtual ~wxMenuBar();
75f11ad7 199
61243a51
DW
200 //
201 // Menubar construction
202 //
203 virtual bool Append( wxMenu* pMenu
204 ,const wxString& rTitle
205 );
206 virtual bool Insert( size_t nPos
207 ,wxMenu* pMenu
208 ,const wxString& rTitle
209 );
210 virtual wxMenu* Replace( size_t nPos
211 ,wxMenu* pMenu
212 ,const wxString& rTitle
213 );
214 virtual wxMenu* Remove(size_t nPos);
215 virtual int FindMenuItem( const wxString& rMenuString
216 ,const wxString& rItemString
217 ) const;
218 virtual wxMenuItem* FindItem( int nId
219 ,wxMenu** ppMenu = NULL
220 ) const;
45bedfdd
DW
221 virtual wxMenuItem* FindItem( int nId
222 ,ULONG hItem
223 ,wxMenu** ppMenu = NULL
224 ) const;
61243a51
DW
225 virtual void EnableTop( size_t nPos
226 ,bool bFlag
227 );
228 virtual void SetLabelTop( size_t nPos
229 ,const wxString& rLabel
230 );
231 virtual wxString GetLabelTop(size_t nPos) const;
232
61243a51
DW
233 //
234 // Implementation from now on
235 //
236 WXHMENU Create(void);
210a651b
DW
237 virtual void Detach(void);
238 virtual void Attach(wxFrame* pFrame);
61243a51
DW
239
240#if wxUSE_ACCEL
241 //
242 // Get the accel table for all the menus
243 //
244 const wxAcceleratorTable& GetAccelTable(void) const { return m_vAccelTable; }
245
246 //
247 // Update the accel table (must be called after adding/deletign a menu)
248 //
249 void RebuildAccelTable(void);
75f11ad7
DW
250#endif // wxUSE_ACCEL
251
61243a51
DW
252 //
253 // Get the menu handle
254 WXHMENU GetHMenu(void) const { return m_hMenu; }
75f11ad7 255
61243a51
DW
256 //
257 // If the menubar is modified, the display is not updated automatically,
75f11ad7 258 // call this function to update it (m_menuBarFrame should be !NULL)
61243a51
DW
259 //
260 void Refresh(void);
75f11ad7
DW
261
262protected:
61243a51
DW
263 //
264 // Common part of all ctors
265 //
266 void Init(void);
75f11ad7 267
e92f266c
DW
268 wxArrayString m_titles;
269
0fe536e3 270 WXHMENU m_hMenu;
75f11ad7
DW
271
272#if wxUSE_ACCEL
61243a51
DW
273 //
274 // The accelerator table for all accelerators in all our menus
275 //
276 wxAcceleratorTable m_vAccelTable;
75f11ad7 277#endif // wxUSE_ACCEL
e92f266c
DW
278
279private:
61243a51
DW
280 //
281 // Virtual function hiding suppression
282 //
283 void Refresh( bool bErase
284 ,const wxRect* pRect
285 )
286 { wxWindow::Refresh(bErase, pRect); }
287
e92f266c 288 DECLARE_DYNAMIC_CLASS(wxMenuBar)
0e320a79
DW
289};
290
291#endif // _WX_MENU_H_