]>
git.saurik.com Git - wxWidgets.git/blob - include/wx/mac/carbon/menu.h
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxMenu, wxMenuBar classes
4 // Author: Stefan Csomor
8 // Copyright: (c) Stefan Csomor
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
15 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
16 #pragma interface "menu.h"
19 class WXDLLEXPORT wxFrame
;
21 #include "wx/arrstr.h"
23 // ----------------------------------------------------------------------------
25 // ----------------------------------------------------------------------------
27 class WXDLLEXPORT wxMenu
: public wxMenuBase
31 wxMenu(const wxString
& title
, long style
= 0)
32 : wxMenuBase(title
, style
) { Init(); }
34 wxMenu(long style
= 0) : wxMenuBase(style
) { Init(); }
38 // implement base class virtuals
39 virtual wxMenuItem
* DoAppend(wxMenuItem
*item
);
40 virtual wxMenuItem
* DoInsert(size_t pos
, wxMenuItem
*item
);
41 virtual wxMenuItem
* DoRemove(wxMenuItem
*item
);
42 virtual void Attach(wxMenuBarBase
*menubar
) ;
46 virtual void SetTitle(const wxString
& title
);
49 bool ProcessCommand(wxCommandEvent
& event
);
51 // implementation only from now on
52 // -------------------------------
54 int MacGetIndexFromId( int id
) ;
55 int MacGetIndexFromItem( wxMenuItem
*pItem
) ;
56 void MacEnableMenu( bool bDoEnable
) ;
57 // MacOS needs to know about submenus somewhere within this menu
58 // before it can be displayed , also hide special menu items like preferences
59 // that are handled by the OS
60 void MacBeforeDisplay( bool isSubMenu
) ;
61 // undo all changes from the MacBeforeDisplay call
62 void MacAfterDisplay( bool isSubMenu
) ;
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
; }
70 short MacGetMenuId() { return m_macMenuId
; }
73 // common part of all ctors
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);
79 // terminate the current radio group, if any
82 // if TRUE, insert a breal before appending the next item
85 // the position of the first item in the current radio group or -1
86 int m_startRadioGroup
;
88 // the menu handle of this menu
93 static short s_macNextMenuId
;
95 DECLARE_DYNAMIC_CLASS(wxMenu
)
98 // ----------------------------------------------------------------------------
99 // Menu Bar (a la Windows)
100 // ----------------------------------------------------------------------------
102 class WXDLLEXPORT wxMenuBar
: public wxMenuBarBase
106 // default constructor
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();
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
);
120 virtual int FindMenuItem(const wxString
& menuString
,
121 const wxString
& itemString
) const;
122 virtual wxMenuItem
* FindItem( int id
, wxMenu
**menu
= NULL
) const;
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 virtual bool Enable( bool enable
= TRUE
);
128 // for virtual function hiding
129 virtual void Enable( int itemid
, bool enable
)
131 wxMenuBarBase::Enable( itemid
, enable
);
134 // implementation from now on
136 int FindMenu(const wxString
& title
);
139 // returns TRUE if we're attached to a frame
140 bool IsAttached() const { return m_menuBarFrame
!= NULL
; }
141 // get the frame we live in
142 wxFrame
*GetFrame() const { return m_menuBarFrame
; }
144 void Attach(wxFrame
*frame
);
146 // clear the invoking window for all menus and submenus
147 void UnsetInvokingWindow() ;
149 // set the invoking window for all menus and submenus
150 void SetInvokingWindow( wxFrame
* frame
) ;
152 // if the menubar is modified, the display is not updated automatically,
153 // call this function to update it (m_menuBarFrame should be !NULL)
154 void Refresh(bool eraseBackground
= TRUE
, const wxRect
*rect
= (const wxRect
*) NULL
);
156 void MacInstallMenuBar() ;
157 static wxMenuBar
* MacGetInstalledMenuBar() { return s_macInstalledMenuBar
; }
158 static void MacSetCommonMenuBar(wxMenuBar
* menubar
) { s_macCommonMenuBar
=menubar
; }
159 static wxMenuBar
* MacGetCommonMenuBar() { return s_macCommonMenuBar
; }
162 // common part of all ctors
164 wxWindow
*m_invokingWindow
;
166 wxArrayString m_titles
;
169 static wxMenuBar
* s_macInstalledMenuBar
;
170 static wxMenuBar
* s_macCommonMenuBar
;
172 DECLARE_DYNAMIC_CLASS(wxMenuBar
)
175 #endif // _WX_MENU_H_