+// ----------------------------------------------------------------------------
+// Helper class used in the implementation only: sets the invoking window of
+// the given menu in its ctor and resets it in dtor.
+// ----------------------------------------------------------------------------
+
+class wxMenuInvokingWindowSetter
+{
+public:
+ // Ctor sets the invoking window for the given menu.
+ //
+ // The menu lifetime must be greater than that of this class.
+ wxMenuInvokingWindowSetter(wxMenu& menu, wxWindow *win)
+ : m_menu(menu)
+ {
+ menu.SetInvokingWindow(win);
+ }
+
+ // Dtor resets the invoking window.
+ ~wxMenuInvokingWindowSetter()
+ {
+ m_menu.SetInvokingWindow(NULL);
+ }
+
+private:
+ wxMenu& m_menu;
+
+ wxDECLARE_NO_COPY_CLASS(wxMenuInvokingWindowSetter);
+};
+