]> git.saurik.com Git - wxWidgets.git/blame - include/wx/mac/carbon/menu.h
more extra semicolons removed (patch 1303724)
[wxWidgets.git] / include / wx / mac / carbon / menu.h
CommitLineData
8cf73271
SC
1/////////////////////////////////////////////////////////////////////////////
2// Name: menu.h
3// Purpose: wxMenu, wxMenuBar classes
4// Author: Stefan Csomor
5// Modified by:
6// Created: 1998-01-01
7// RCS-ID: $Id$
8// Copyright: (c) Stefan Csomor
65571936 9// Licence: wxWindows licence
8cf73271
SC
10/////////////////////////////////////////////////////////////////////////////
11
12#ifndef _WX_MENU_H_
13#define _WX_MENU_H_
14
8cf73271
SC
15class WXDLLEXPORT wxFrame;
16
17#include "wx/arrstr.h"
18
19// ----------------------------------------------------------------------------
20// Menu
21// ----------------------------------------------------------------------------
22
23class WXDLLEXPORT wxMenu : public wxMenuBase
24{
25public:
26 // ctors & dtor
27 wxMenu(const wxString& title, long style = 0)
28 : wxMenuBase(title, style) { Init(); }
29
30 wxMenu(long style = 0) : wxMenuBase(style) { Init(); }
31
32 virtual ~wxMenu();
33
34 // implement base class virtuals
35 virtual wxMenuItem* DoAppend(wxMenuItem *item);
36 virtual wxMenuItem* DoInsert(size_t pos, wxMenuItem *item);
37 virtual wxMenuItem* DoRemove(wxMenuItem *item);
38 virtual void Attach(wxMenuBarBase *menubar) ;
39
40 virtual void Break();
41
42 virtual void SetTitle(const wxString& title);
43
44 // MSW-specific
45 bool ProcessCommand(wxCommandEvent& event);
46
47 // implementation only from now on
48 // -------------------------------
49
50 int MacGetIndexFromId( int id ) ;
51 int MacGetIndexFromItem( wxMenuItem *pItem ) ;
52 void MacEnableMenu( bool bDoEnable ) ;
53 // MacOS needs to know about submenus somewhere within this menu
54 // before it can be displayed , also hide special menu items like preferences
55 // that are handled by the OS
56 void MacBeforeDisplay( bool isSubMenu ) ;
57 // undo all changes from the MacBeforeDisplay call
58 void MacAfterDisplay( bool isSubMenu ) ;
59
60 // semi-private accessors
61 // get the window which contains this menu
62 wxWindow *GetWindow() const;
63 // get the menu handle
64 WXHMENU GetHMenu() const { return m_hMenu; }
65
66 short MacGetMenuId() { return m_macMenuId ; }
67
68private:
69 // common part of all ctors
70 void Init();
71
72 // common part of Append/Insert (behaves as Append is pos == (size_t)-1)
73 bool DoInsertOrAppend(wxMenuItem *item, size_t pos = (size_t)-1);
74
75 // terminate the current radio group, if any
76 void EndRadioGroup();
77
78 // if TRUE, insert a breal before appending the next item
79 bool m_doBreak;
80
81 // the position of the first item in the current radio group or -1
82 int m_startRadioGroup;
83
84 // the menu handle of this menu
85 WXHMENU m_hMenu;
86
87 short m_macMenuId;
88
89 static short s_macNextMenuId ;
90
91 DECLARE_DYNAMIC_CLASS(wxMenu)
92};
93
94// ----------------------------------------------------------------------------
95// Menu Bar (a la Windows)
96// ----------------------------------------------------------------------------
97
98class WXDLLEXPORT wxMenuBar : public wxMenuBarBase
99{
100public:
101 // ctors & dtor
102 // default constructor
103 wxMenuBar();
104 // unused under MSW
105 wxMenuBar(long style);
106 // menubar takes ownership of the menus arrays but copies the titles
294ea16d 107 wxMenuBar(size_t n, wxMenu *menus[], const wxString titles[], long style = 0);
8cf73271
SC
108 virtual ~wxMenuBar();
109
110 // menubar construction
111 virtual bool Append( wxMenu *menu, const wxString &title );
112 virtual bool Insert(size_t pos, wxMenu *menu, const wxString& title);
113 virtual wxMenu *Replace(size_t pos, wxMenu *menu, const wxString& title);
114 virtual wxMenu *Remove(size_t pos);
115
116 virtual int FindMenuItem(const wxString& menuString,
117 const wxString& itemString) const;
118 virtual wxMenuItem* FindItem( int id, wxMenu **menu = NULL ) const;
119
120 virtual void EnableTop( size_t pos, bool flag );
121 virtual void SetLabelTop( size_t pos, const wxString& label );
122 virtual wxString GetLabelTop( size_t pos ) const;
c393c740 123 virtual bool Enable( bool enable = TRUE );
f8ca3d72
MB
124 // for virtual function hiding
125 virtual void Enable( int itemid, bool enable )
126 {
127 wxMenuBarBase::Enable( itemid, enable );
128 }
8cf73271
SC
129
130 // implementation from now on
131 WXHMENU Create();
132 int FindMenu(const wxString& title);
133 void Detach();
134
135 // returns TRUE if we're attached to a frame
136 bool IsAttached() const { return m_menuBarFrame != NULL; }
137 // get the frame we live in
138 wxFrame *GetFrame() const { return m_menuBarFrame; }
139 // attach to a frame
140 void Attach(wxFrame *frame);
141
142 // clear the invoking window for all menus and submenus
143 void UnsetInvokingWindow() ;
144
145 // set the invoking window for all menus and submenus
146 void SetInvokingWindow( wxFrame* frame ) ;
147
148 // if the menubar is modified, the display is not updated automatically,
149 // call this function to update it (m_menuBarFrame should be !NULL)
150 void Refresh(bool eraseBackground = TRUE, const wxRect *rect = (const wxRect *) NULL);
151
501db75a
SC
152 static void SetAutoWindowMenu( bool enable ) { s_macAutoWindowMenu = enable ; }
153 static bool GetAutoWindowMenu() { return s_macAutoWindowMenu ; }
8cf73271 154
501db75a
SC
155 void MacInstallMenuBar() ;
156 static wxMenuBar* MacGetInstalledMenuBar() { return s_macInstalledMenuBar ; }
157 static void MacSetCommonMenuBar(wxMenuBar* menubar) { s_macCommonMenuBar=menubar; }
158 static wxMenuBar* MacGetCommonMenuBar() { return s_macCommonMenuBar; }
159
160
161 static WXHMENU MacGetWindowMenuHMenu() { return s_macWindowMenuHandle ; }
8cf73271
SC
162protected:
163 // common part of all ctors
164 void Init();
165 wxWindow *m_invokingWindow;
166
501db75a
SC
167 wxArrayString m_titles;
168 static bool s_macAutoWindowMenu ;
169 static WXHMENU s_macWindowMenuHandle ;
8cf73271
SC
170
171private:
172 static wxMenuBar* s_macInstalledMenuBar ;
173 static wxMenuBar* s_macCommonMenuBar ;
174
175 DECLARE_DYNAMIC_CLASS(wxMenuBar)
176};
177
178#endif // _WX_MENU_H_