]> git.saurik.com Git - wxWidgets.git/blame - include/wx/os2/menu.h
Applied patch [ 619705 ] Fixes wxApp::GetComCtl32Version
[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
DW
8// Copyright: (c) David Webster
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 //
58 virtual bool DoAppend(wxMenuItem* pItem);
59 virtual bool 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#if wxUSE_MENU_CALLBACK
67 wxMenu( const wxString& rTitle
68 ,const wxFunction fnFunc
69 )
70 : wxMenuBase(rTitle)
e92f266c 71 {
61243a51
DW
72 Init();
73 Callback(fnFunc);
e92f266c 74 }
61243a51 75#endif // wxUSE_MENU_CALLBACK
e92f266c 76
61243a51
DW
77 //
78 // Implementation only from now on
79 // -------------------------------
80 //
598d8cac
DW
81 virtual void Attach(wxMenuBarBase* pMenubar);
82
61243a51
DW
83 bool OS2Command( WXUINT uParam
84 ,WXWORD wId
85 );
86
87 //
88 // Semi-private accessors
89 //
90
91 //
92 // Get the window which contains this menu
93 //
94 wxWindow* GetWindow(void) const;
95
96 //
97 // Get the menu handle
98 //
e92f266c 99 WXHMENU GetHMenu() const { return m_hMenu; }
75f11ad7 100
75f11ad7 101#if wxUSE_ACCEL
61243a51
DW
102 //
103 // Called by wxMenuBar to build its accel table from the accels of all menus
104 //
598d8cac
DW
105 bool HasAccels(void) const { return m_vAccels.IsEmpty(); }
106 size_t GetAccelCount(void) const { return m_vAccels.GetCount(); }
61243a51
DW
107 size_t CopyAccels(wxAcceleratorEntry* pAccels) const;
108
109 //
110 // Called by wxMenuItem when its accels changes
111 //
112 void UpdateAccel(wxMenuItem* pItem);
113
114 //
115 // Helper used by wxMenu itself (returns the index in m_accels)
116 //
117 int FindAccel(int nId) const;
e92f266c 118#endif // wxUSE_ACCEL
45bedfdd
DW
119 //
120 // OS/2 specific Find
121 //
122 wxMenuItem* FindItem(int id, ULONG hItem, wxMenu **menu = NULL) const;
123 //virtual function hiding suppression
124 int FindItem(const wxString& rsString) const
125 { return wxMenuBase::FindItem(rsString); }
126 wxMenuItem* FindItem(int id, wxMenu **menu = NULL) const
127 { return wxMenuBase::FindItem(id, menu); }
75f11ad7 128
61243a51
DW
129 //
130 // All OS/2PM Menu's have one of these
131 //
132 MENUITEM m_vMenuData;
133
75f11ad7 134private:
61243a51
DW
135 //
136 // Common part of all ctors
137 //
e92f266c
DW
138 void Init();
139
61243a51
DW
140 //
141 // Common part of Append/Insert (behaves as Append is pos == (size_t)-1)
142 //
143 bool DoInsertOrAppend( wxMenuItem* pItem
144 ,size_t nPos = (size_t)-1
145 );
146
ab4fece8
DW
147 //
148 // Terminate the current radio group, if any
149 //
150 void EndRadioGroup(void);
151
61243a51
DW
152 //
153 // If TRUE, insert a breal before appending the next item
154 //
155 bool m_bDoBreak;
156
157 //
158 // The menu handle of this menu
159 //
160 WXHMENU m_hMenu;
75f11ad7 161
f6bcfd97
BP
162 //
163 // The helper variable for creating unique IDs.
164 //
598d8cac 165 static USHORT m_nextMenuId;
f6bcfd97 166
ab4fece8
DW
167 //
168 // The position of the first item in the current radio group or -1
169 //
170 int m_nStartRadioGroup;
171
75f11ad7 172#if wxUSE_ACCEL
61243a51
DW
173 //
174 // The accelerators for our menu items
175 //
598d8cac 176 wxAcceleratorArray m_vAccels;
75f11ad7 177#endif // wxUSE_ACCEL
e92f266c
DW
178
179 DECLARE_DYNAMIC_CLASS(wxMenu)
61243a51 180}; // end of wxMenu
0e320a79
DW
181
182// ----------------------------------------------------------------------------
183// Menu Bar (a la Windows)
184// ----------------------------------------------------------------------------
75f11ad7 185
e92f266c 186class WXDLLEXPORT wxMenuBar : public wxMenuBarBase
0e320a79 187{
75f11ad7 188public:
61243a51
DW
189 //
190 // Ctors & dtor
191 //
e92f266c 192
61243a51
DW
193 //
194 // Default constructor
195 //
196 wxMenuBar();
75f11ad7 197
61243a51
DW
198 //
199 // Unused under OS2
200 wxMenuBar(long lStyle);
201
202 //
203 // Menubar takes ownership of the menus arrays but copies the titles
204 //
205 wxMenuBar( int n
206 ,wxMenu* vMenus[]
207 ,const wxString sTitles[]
208 );
209 virtual ~wxMenuBar();
75f11ad7 210
61243a51
DW
211 //
212 // Menubar construction
213 //
214 virtual bool Append( wxMenu* pMenu
215 ,const wxString& rTitle
216 );
217 virtual bool Insert( size_t nPos
218 ,wxMenu* pMenu
219 ,const wxString& rTitle
220 );
221 virtual wxMenu* Replace( size_t nPos
222 ,wxMenu* pMenu
223 ,const wxString& rTitle
224 );
225 virtual wxMenu* Remove(size_t nPos);
226 virtual int FindMenuItem( const wxString& rMenuString
227 ,const wxString& rItemString
228 ) const;
229 virtual wxMenuItem* FindItem( int nId
230 ,wxMenu** ppMenu = NULL
231 ) const;
45bedfdd
DW
232 virtual wxMenuItem* FindItem( int nId
233 ,ULONG hItem
234 ,wxMenu** ppMenu = NULL
235 ) const;
61243a51
DW
236 virtual void EnableTop( size_t nPos
237 ,bool bFlag
238 );
239 virtual void SetLabelTop( size_t nPos
240 ,const wxString& rLabel
241 );
242 virtual wxString GetLabelTop(size_t nPos) const;
243
244 //
245 // Compatibility: these functions are deprecated
246 //
e92f266c 247#if WXWIN_COMPATIBILITY
61243a51
DW
248 void SetEventHandler(wxEvtHandler* pHandler) { m_pEventHandler = pHandler; }
249 wxEvtHandler* GetEventHandler(void) { return m_pEventHandler; }
250 bool Enabled(int nId) const { return IsEnabled(nId); }
251 bool Checked(int nId) const { return IsChecked(nId); }
75f11ad7
DW
252#endif // WXWIN_COMPATIBILITY
253
61243a51
DW
254 //
255 // Implementation from now on
256 //
257 WXHMENU Create(void);
210a651b
DW
258 virtual void Detach(void);
259 virtual void Attach(wxFrame* pFrame);
61243a51
DW
260
261#if wxUSE_ACCEL
262 //
263 // Get the accel table for all the menus
264 //
265 const wxAcceleratorTable& GetAccelTable(void) const { return m_vAccelTable; }
266
267 //
268 // Update the accel table (must be called after adding/deletign a menu)
269 //
270 void RebuildAccelTable(void);
75f11ad7
DW
271#endif // wxUSE_ACCEL
272
61243a51
DW
273 //
274 // Get the menu handle
275 WXHMENU GetHMenu(void) const { return m_hMenu; }
75f11ad7 276
61243a51
DW
277 //
278 // If the menubar is modified, the display is not updated automatically,
75f11ad7 279 // call this function to update it (m_menuBarFrame should be !NULL)
61243a51
DW
280 //
281 void Refresh(void);
75f11ad7
DW
282
283protected:
61243a51
DW
284 //
285 // Common part of all ctors
286 //
287 void Init(void);
75f11ad7 288
e92f266c 289#if WXWIN_COMPATIBILITY
61243a51 290 wxEvtHandler* m_pEventHandler;
e92f266c
DW
291#endif // WXWIN_COMPATIBILITY
292
293 wxArrayString m_titles;
294
0fe536e3 295 WXHMENU m_hMenu;
75f11ad7
DW
296
297#if wxUSE_ACCEL
61243a51
DW
298 //
299 // The accelerator table for all accelerators in all our menus
300 //
301 wxAcceleratorTable m_vAccelTable;
75f11ad7 302#endif // wxUSE_ACCEL
e92f266c
DW
303
304private:
61243a51
DW
305 //
306 // Virtual function hiding suppression
307 //
308 void Refresh( bool bErase
309 ,const wxRect* pRect
310 )
311 { wxWindow::Refresh(bErase, pRect); }
312
e92f266c 313 DECLARE_DYNAMIC_CLASS(wxMenuBar)
0e320a79
DW
314};
315
316#endif // _WX_MENU_H_