]>
git.saurik.com Git - wxWidgets.git/blob - include/wx/mac/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 // ----------------------------------------------------------------------------
23 // ----------------------------------------------------------------------------
25 class WXDLLEXPORT wxMenu
: public wxMenuBase
29 wxMenu(const wxString
& title
, long style
= 0)
30 : wxMenuBase(title
, style
) { Init(); }
32 wxMenu(long style
= 0) : wxMenuBase(style
) { Init(); }
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
) ;
44 virtual void SetTitle(const wxString
& title
);
47 bool ProcessCommand(wxCommandEvent
& event
);
49 // implementation only from now on
50 // -------------------------------
52 int MacGetIndexFromId( int id
) ;
53 int MacGetIndexFromItem( wxMenuItem
*pItem
) ;
54 void MacEnableMenu( bool bDoEnable
) ;
55 // MacOS needs to know about submenus somewhere within this menu
56 // before it can be displayed , also hide special menu items like preferences
57 // that are handled by the OS
58 void MacBeforeDisplay( bool isSubMenu
) ;
59 // undo all changes from the MacBeforeDisplay call
60 void MacAfterDisplay( bool isSubMenu
) ;
62 // semi-private accessors
63 // get the window which contains this menu
64 wxWindow
*GetWindow() const;
65 // get the menu handle
66 WXHMENU
GetHMenu() const { return m_hMenu
; }
68 short MacGetMenuId() { return m_macMenuId
; }
71 // common part of all ctors
74 // common part of Append/Insert (behaves as Append is pos == (size_t)-1)
75 bool DoInsertOrAppend(wxMenuItem
*item
, size_t pos
= (size_t)-1);
77 // terminate the current radio group, if any
80 // if TRUE, insert a breal before appending the next item
83 // the position of the first item in the current radio group or -1
84 int m_startRadioGroup
;
86 // the menu handle of this menu
91 static short s_macNextMenuId
;
93 DECLARE_DYNAMIC_CLASS(wxMenu
)
96 // ----------------------------------------------------------------------------
97 // Menu Bar (a la Windows)
98 // ----------------------------------------------------------------------------
100 class WXDLLEXPORT wxMenuBar
: public wxMenuBarBase
104 // default constructor
107 wxMenuBar(long style
);
108 // menubar takes ownership of the menus arrays but copies the titles
109 wxMenuBar(int n
, wxMenu
*menus
[], const wxString titles
[]);
110 virtual ~wxMenuBar();
112 // menubar construction
113 virtual bool Append( wxMenu
*menu
, const wxString
&title
);
114 virtual bool Insert(size_t pos
, wxMenu
*menu
, const wxString
& title
);
115 virtual wxMenu
*Replace(size_t pos
, wxMenu
*menu
, const wxString
& title
);
116 virtual wxMenu
*Remove(size_t pos
);
118 virtual int FindMenuItem(const wxString
& menuString
,
119 const wxString
& itemString
) const;
120 virtual wxMenuItem
* FindItem( int id
, wxMenu
**menu
= NULL
) const;
122 virtual void EnableTop( size_t pos
, bool flag
);
123 virtual void SetLabelTop( size_t pos
, const wxString
& label
);
124 virtual wxString
GetLabelTop( size_t pos
) const;
126 // implementation from now on
128 int FindMenu(const wxString
& title
);
131 // returns TRUE if we're attached to a frame
132 bool IsAttached() const { return m_menuBarFrame
!= NULL
; }
133 // get the frame we live in
134 wxFrame
*GetFrame() const { return m_menuBarFrame
; }
136 void Attach(wxFrame
*frame
);
138 // clear the invoking window for all menus and submenus
139 void UnsetInvokingWindow() ;
141 // set the invoking window for all menus and submenus
142 void SetInvokingWindow( wxFrame
* frame
) ;
144 // if the menubar is modified, the display is not updated automatically,
145 // call this function to update it (m_menuBarFrame should be !NULL)
146 void Refresh(bool eraseBackground
= TRUE
, const wxRect
*rect
= (const wxRect
*) NULL
);
148 void MacInstallMenuBar() ;
149 static wxMenuBar
* MacGetInstalledMenuBar() { return s_macInstalledMenuBar
; }
150 static void MacSetCommonMenuBar(wxMenuBar
* menubar
) { s_macCommonMenuBar
=menubar
; }
151 static wxMenuBar
* MacGetCommonMenuBar() { return s_macCommonMenuBar
; }
154 // common part of all ctors
156 wxWindow
*m_invokingWindow
;
158 wxArrayString m_titles
;
161 static wxMenuBar
* s_macInstalledMenuBar
;
162 static wxMenuBar
* s_macCommonMenuBar
;
164 DECLARE_DYNAMIC_CLASS(wxMenuBar
)
167 #endif // _WX_MENU_H_