]> git.saurik.com Git - wxWidgets.git/blame - include/wx/osx/menu.h
MinGW-w64 provides isfinite() in both 32 and 64 bit builds.
[wxWidgets.git] / include / wx / osx / menu.h
CommitLineData
6762286d 1/////////////////////////////////////////////////////////////////////////////
80fdcdb9 2// Name: wx/osx/menu.h
6762286d
SC
3// Purpose: wxMenu, wxMenuBar classes
4// Author: Stefan Csomor
5// Modified by:
6// Created: 1998-01-01
6762286d
SC
7// Copyright: (c) Stefan Csomor
8// Licence: wxWindows licence
9/////////////////////////////////////////////////////////////////////////////
10
11#ifndef _WX_MENU_H_
12#define _WX_MENU_H_
13
14class WXDLLIMPEXP_FWD_CORE wxFrame;
15
16#include "wx/arrstr.h"
17
18// ----------------------------------------------------------------------------
19// Menu
20// ----------------------------------------------------------------------------
21
22class WXDLLIMPEXP_FWD_CORE wxMenuImpl ;
23
24class WXDLLIMPEXP_CORE wxMenu : public wxMenuBase
25{
26public:
27 // ctors & dtor
28 wxMenu(const wxString& title, long style = 0)
29 : wxMenuBase(title, style) { Init(); }
30
31 wxMenu(long style = 0) : wxMenuBase(style) { Init(); }
32
33 virtual ~wxMenu();
34
6762286d
SC
35 virtual void Break();
36
37 virtual void SetTitle(const wxString& title);
38
39 bool ProcessCommand(wxCommandEvent& event);
40
6762286d
SC
41 // get the menu handle
42 WXHMENU GetHMenu() const ;
43
44 // implementation only from now on
45 // -------------------------------
46
47 bool HandleCommandUpdateStatus( wxMenuItem* menuItem, wxWindow* senderWindow = NULL);
48 bool HandleCommandProcess( wxMenuItem* menuItem, wxWindow* senderWindow = NULL);
49 void HandleMenuItemHighlighted( wxMenuItem* menuItem );
50 void HandleMenuOpened();
51 void HandleMenuClosed();
52
53 wxMenuImpl* GetPeer() { return m_peer; }
03647350 54
6762286d
SC
55 // make sure we can veto
56 void SetAllowRearrange( bool allow );
57 bool AllowRearrange() const { return m_allowRearrange; }
03647350 58
6762286d
SC
59 // if a menu is used purely for internal implementation reasons (eg wxChoice)
60 // we don't want native menu events being triggered
61 void SetNoEventsMode( bool noEvents );
62 bool GetNoEventsMode() const { return m_noEventsMode; }
63protected:
64 // hide special menu items like exit, preferences etc
03647350 65 // that are expected in the app menu
6762286d 66 void DoRearrange() ;
03647350 67
6762286d
SC
68 bool DoHandleMenuEvent( wxEvent& evt );
69 virtual wxMenuItem* DoAppend(wxMenuItem *item);
70 virtual wxMenuItem* DoInsert(size_t pos, wxMenuItem *item);
71 virtual wxMenuItem* DoRemove(wxMenuItem *item);
72
73private:
74 // common part of all ctors
75 void Init();
76
924c9b45 77 // common part of Do{Append,Insert}(): behaves as Append if pos == -1
6762286d
SC
78 bool DoInsertOrAppend(wxMenuItem *item, size_t pos = (size_t)-1);
79
7f3f059a
VZ
80 // Common part of HandleMenu{Opened,Closed}().
81 void DoHandleMenuOpenedOrClosed(wxEventType evtType);
82
83
924c9b45 84 // if TRUE, insert a break before appending the next item
6762286d
SC
85 bool m_doBreak;
86
87 // in this menu rearranging of menu items (esp hiding) is allowed
88 bool m_allowRearrange;
03647350 89
6762286d
SC
90 // don't trigger native events
91 bool m_noEventsMode;
03647350 92
6762286d
SC
93 wxMenuImpl* m_peer;
94
95 DECLARE_DYNAMIC_CLASS(wxMenu)
96};
97
98#if wxOSX_USE_COCOA_OR_CARBON
99
100// the iphone only has popup-menus
101
102// ----------------------------------------------------------------------------
103// Menu Bar (a la Windows)
104// ----------------------------------------------------------------------------
105
106class WXDLLIMPEXP_CORE wxMenuBar : public wxMenuBarBase
107{
108public:
109 // ctors & dtor
110 // default constructor
111 wxMenuBar();
112 // unused under MSW
113 wxMenuBar(long style);
114 // menubar takes ownership of the menus arrays but copies the titles
115 wxMenuBar(size_t n, wxMenu *menus[], const wxString titles[], long style = 0);
116 virtual ~wxMenuBar();
117
118 // menubar construction
119 virtual bool Append( wxMenu *menu, const wxString &title );
120 virtual bool Insert(size_t pos, wxMenu *menu, const wxString& title);
121 virtual wxMenu *Replace(size_t pos, wxMenu *menu, const wxString& title);
122 virtual wxMenu *Remove(size_t pos);
123
6762286d 124 virtual void EnableTop( size_t pos, bool flag );
e4a23857 125 virtual bool IsEnabledTop(size_t pos) const;
6762286d
SC
126 virtual void SetMenuLabel( size_t pos, const wxString& label );
127 virtual wxString GetMenuLabel( size_t pos ) const;
8e6efd1f 128 virtual bool Enable( bool enable = true );
6762286d
SC
129 // for virtual function hiding
130 virtual void Enable( int itemid, bool enable )
131 {
132 wxMenuBarBase::Enable( itemid, enable );
133 }
134
135 // implementation from now on
6762286d
SC
136 void Detach();
137
138 // returns TRUE if we're attached to a frame
139 bool IsAttached() const { return m_menuBarFrame != NULL; }
140 // get the frame we live in
141 wxFrame *GetFrame() const { return m_menuBarFrame; }
142 // attach to a frame
143 void Attach(wxFrame *frame);
144
6762286d
SC
145 // if the menubar is modified, the display is not updated automatically,
146 // call this function to update it (m_menuBarFrame should be !NULL)
8e6efd1f 147 void Refresh(bool eraseBackground = true, const wxRect *rect = NULL);
6762286d
SC
148
149 static void SetAutoWindowMenu( bool enable ) { s_macAutoWindowMenu = enable ; }
150 static bool GetAutoWindowMenu() { return s_macAutoWindowMenu ; }
151
152 void MacInstallMenuBar() ;
153 static wxMenuBar* MacGetInstalledMenuBar() { return s_macInstalledMenuBar ; }
154 static void MacSetCommonMenuBar(wxMenuBar* menubar) { s_macCommonMenuBar=menubar; }
155 static wxMenuBar* MacGetCommonMenuBar() { return s_macCommonMenuBar; }
156
157
158 static WXHMENU MacGetWindowMenuHMenu() { return s_macWindowMenuHandle ; }
159protected:
160 // common part of all ctors
161 void Init();
6762286d 162
6762286d
SC
163 static bool s_macAutoWindowMenu ;
164 static WXHMENU s_macWindowMenuHandle ;
165
166private:
167 static wxMenuBar* s_macInstalledMenuBar ;
168 static wxMenuBar* s_macCommonMenuBar ;
03647350 169
6762286d 170 wxMenu* m_rootMenu;
1ea5ef01 171 wxMenu* m_appleMenu;
6762286d
SC
172
173 DECLARE_DYNAMIC_CLASS(wxMenuBar)
174};
175
5c6eb3a8 176#endif
6762286d
SC
177
178#endif // _WX_MENU_H_