]>
git.saurik.com Git - wxWidgets.git/blob - include/wx/mac/classic/menu.h
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxMenu, wxMenuBar classes
4 // Author: Stefan Csomor
8 // Copyright: (c) Stefan Csomor
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
15 class WXDLLEXPORT wxFrame
;
17 #include "wx/arrstr.h"
19 // ----------------------------------------------------------------------------
21 // ----------------------------------------------------------------------------
23 class WXDLLEXPORT wxMenu
: public wxMenuBase
27 wxMenu(const wxString
& title
, long style
= 0)
28 : wxMenuBase(title
, style
) { Init(); }
30 wxMenu(long style
= 0) : wxMenuBase(style
) { Init(); }
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
) ;
42 virtual void SetTitle(const wxString
& title
);
45 bool ProcessCommand(wxCommandEvent
& event
);
47 // implementation only from now on
48 // -------------------------------
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
) ;
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
; }
66 short MacGetMenuId() { return m_macMenuId
; }
69 // common part of all ctors
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);
75 // terminate the current radio group, if any
78 // if TRUE, insert a breal before appending the next item
81 // the position of the first item in the current radio group or -1
82 int m_startRadioGroup
;
84 // the menu handle of this menu
89 static short s_macNextMenuId
;
91 DECLARE_DYNAMIC_CLASS(wxMenu
)
94 // ----------------------------------------------------------------------------
95 // Menu Bar (a la Windows)
96 // ----------------------------------------------------------------------------
98 class WXDLLEXPORT wxMenuBar
: public wxMenuBarBase
102 // default constructor
105 wxMenuBar(long style
);
106 // menubar takes ownership of the menus arrays but copies the titles
107 wxMenuBar(size_t n
, wxMenu
*menus
[], const wxString titles
[], long style
= 0);
108 virtual ~wxMenuBar();
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
);
116 virtual int FindMenuItem(const wxString
& menuString
,
117 const wxString
& itemString
) const;
118 virtual wxMenuItem
* FindItem( int id
, wxMenu
**menu
= NULL
) const;
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;
124 // implementation from now on
126 int FindMenu(const wxString
& title
);
129 // returns TRUE if we're attached to a frame
130 bool IsAttached() const { return m_menuBarFrame
!= NULL
; }
131 // get the frame we live in
132 wxFrame
*GetFrame() const { return m_menuBarFrame
; }
134 void Attach(wxFrame
*frame
);
136 // clear the invoking window for all menus and submenus
137 void UnsetInvokingWindow() ;
139 // set the invoking window for all menus and submenus
140 void SetInvokingWindow( wxFrame
* frame
) ;
142 // if the menubar is modified, the display is not updated automatically,
143 // call this function to update it (m_menuBarFrame should be !NULL)
144 void Refresh(bool eraseBackground
= TRUE
, const wxRect
*rect
= (const wxRect
*) NULL
);
146 void MacInstallMenuBar() ;
147 static wxMenuBar
* MacGetInstalledMenuBar() { return s_macInstalledMenuBar
; }
148 static void MacSetCommonMenuBar(wxMenuBar
* menubar
) { s_macCommonMenuBar
=menubar
; }
149 static wxMenuBar
* MacGetCommonMenuBar() { return s_macCommonMenuBar
; }
152 // common part of all ctors
154 wxWindow
*m_invokingWindow
;
156 wxArrayString m_titles
;
159 static wxMenuBar
* s_macInstalledMenuBar
;
160 static wxMenuBar
* s_macCommonMenuBar
;
162 DECLARE_DYNAMIC_CLASS(wxMenuBar
)
165 #endif // _WX_MENU_H_