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