]> git.saurik.com Git - wxWidgets.git/blame - include/wx/os2/menu.h
add wx-prefixed and semicolon-requiring versions of DECLARE_NO_{COPY,ASSIGN}_CLASS...
[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
7e1e6965 20 WX_DEFINE_EXPORTED_ARRAY_PTR(wxAcceleratorEntry *, wxAcceleratorArray);
75f11ad7 21#endif // wxUSE_ACCEL
0e320a79 22
b5dbe15d 23class WXDLLIMPEXP_FWD_CORE wxFrame;
0e320a79 24
8c5907ce
DW
25void wxSetShortCutKey(wxChar* zText);
26
0e320a79
DW
27// ----------------------------------------------------------------------------
28// Menu
29// ----------------------------------------------------------------------------
0e320a79 30
53a2db12 31class WXDLLIMPEXP_CORE wxMenu : public wxMenuBase
e92f266c 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 141 //
7e1e6965 142 // If true, insert a breal before appending the next item
61243a51 143 //
7e1e6965 144 bool m_bDoBreak;
61243a51
DW
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
53a2db12 175class WXDLLIMPEXP_CORE 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[]
294ea16d 197 ,long lStyle = 0
61243a51
DW
198 );
199 virtual ~wxMenuBar();
75f11ad7 200
61243a51
DW
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;
45bedfdd
DW
222 virtual wxMenuItem* FindItem( int nId
223 ,ULONG hItem
224 ,wxMenu** ppMenu = NULL
225 ) const;
61243a51
DW
226 virtual void EnableTop( size_t nPos
227 ,bool bFlag
228 );
52af3158 229 virtual void SetMenuLabel( size_t nPos
61243a51
DW
230 ,const wxString& rLabel
231 );
52af3158 232 virtual wxString GetMenuLabel(size_t nPos) const;
61243a51 233
61243a51
DW
234 //
235 // Implementation from now on
236 //
237 WXHMENU Create(void);
210a651b
DW
238 virtual void Detach(void);
239 virtual void Attach(wxFrame* pFrame);
61243a51
DW
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 //
3103e8a9 248 // Update the accel table (must be called after adding/deleting a menu)
61243a51
DW
249 //
250 void RebuildAccelTable(void);
75f11ad7
DW
251#endif // wxUSE_ACCEL
252
61243a51
DW
253 //
254 // Get the menu handle
255 WXHMENU GetHMenu(void) const { return m_hMenu; }
75f11ad7 256
61243a51
DW
257 //
258 // If the menubar is modified, the display is not updated automatically,
75f11ad7 259 // call this function to update it (m_menuBarFrame should be !NULL)
61243a51
DW
260 //
261 void Refresh(void);
75f11ad7
DW
262
263protected:
61243a51
DW
264 //
265 // Common part of all ctors
266 //
267 void Init(void);
75f11ad7 268
e92f266c
DW
269 wxArrayString m_titles;
270
0fe536e3 271 WXHMENU m_hMenu;
75f11ad7
DW
272
273#if wxUSE_ACCEL
61243a51
DW
274 //
275 // The accelerator table for all accelerators in all our menus
276 //
277 wxAcceleratorTable m_vAccelTable;
75f11ad7 278#endif // wxUSE_ACCEL
e92f266c
DW
279
280private:
61243a51
DW
281 //
282 // Virtual function hiding suppression
283 //
284 void Refresh( bool bErase
285 ,const wxRect* pRect
286 )
287 { wxWindow::Refresh(bErase, pRect); }
288
e92f266c 289 DECLARE_DYNAMIC_CLASS(wxMenuBar)
0e320a79
DW
290};
291
292#endif // _WX_MENU_H_