virtual void SetWindowMenu(wxMenu* menu);
virtual void DoMenuUpdates(wxMenu* menu = NULL);
+
+ // return the active child menu, if any
+ virtual WXHMENU MSWGetActiveMenu() const;
#endif // wxUSE_MENUS
+
// implementation only from now on
// MDI helpers
virtual WXLRESULT MSWDefWindowProc(WXUINT, WXWPARAM, WXLPARAM);
virtual bool MSWTranslateMessage(WXMSG* msg);
+#if wxUSE_MENUS
// override wxFrameBase function to also look in the active child menu bar
virtual const wxMenuItem *FindItemInMenuBar(int menuId) const;
+#endif // wxUSE_MENUS
protected:
#if wxUSE_MENUS_NATIVE
bool m_parentFrameActive;
private:
+#if wxUSE_MENUS
// add/remove window menu if we have it (i.e. m_windowMenu != NULL)
void AddWindowMenu();
void RemoveWindowMenu();
+ // update the window menu (if we have it) to enable or disable the commands
+ // which only make sense when we have more than one child
+ void UpdateWindowMenu(bool enable);
+#endif // wxUSE_MENUS
+
// return the number of child frames we currently have (maybe 0)
int GetChildFramesCount() const;
+
friend class WXDLLIMPEXP_FWD_CORE wxMDIChildFrame;
DECLARE_EVENT_TABLE()
#if wxUSE_MENUS
if (m_fsStyle & wxFULLSCREEN_NOMENUBAR)
{
- WXHMENU menu = m_hMenu;
-
-#if wxUSE_MDI_ARCHITECTURE
- wxMDIParentFrame *frame = wxDynamicCast(this, wxMDIParentFrame);
- if (frame)
- {
- wxMDIChildFrame *child = frame->GetActiveChild();
- if (child)
- {
- menu = child->GetWinMenu();
- }
- }
-#endif // wxUSE_MDI_ARCHITECTURE
-
- if (menu)
- {
- ::SetMenu(GetHwnd(), (HMENU)menu);
- }
+ const WXHMENU hmenu = MSWGetActiveMenu();
+ if ( hmenu )
+ ::SetMenu(GetHwnd(), (HMENU)hmenu);
}
#endif // wxUSE_MENUS
// wxMDIParentFrame child management
// ----------------------------------------------------------------------------
+wxMDIChildFrame *wxMDIParentFrame::GetActiveChild() const
+{
+ HWND hWnd = (HWND)::SendMessage(GetWinHwnd(GetClientWindow()),
+ WM_MDIGETACTIVE, 0, 0L);
+ if ( hWnd == 0 )
+ return NULL;
+
+ return (wxMDIChildFrame *)wxFindWinFromHandle(hWnd);
+}
+
int wxMDIParentFrame::GetChildFramesCount() const
{
int count = 0;
}
}
+#if wxUSE_MENUS
+
// ----------------------------------------------------------------------------
// wxMDIParentFrame window menu handling
// ----------------------------------------------------------------------------
AddWindowMenu();
}
+// ----------------------------------------------------------------------------
+// wxMDIParentFrame other menu-related stuff
+// ----------------------------------------------------------------------------
+
void wxMDIParentFrame::DoMenuUpdates(wxMenu* menu)
{
wxMDIChildFrame *child = GetActiveChild();
return item;
}
+WXHMENU wxMDIParentFrame::MSWGetActiveMenu() const
+{
+ wxMDIChildFrame * const child = GetActiveChild();
+ if ( child )
+ {
+ const WXHMENU hmenu = child->MSWGetActiveMenu();
+ if ( hmenu )
+ return hmenu;
+ }
+
+ return wxFrame::MSWGetActiveMenu();
+}
+
+#endif // wxUSE_MENUS
+
+// ----------------------------------------------------------------------------
+// wxMDIParentFrame event handling
+// ----------------------------------------------------------------------------
+
void wxMDIParentFrame::UpdateClientSize()
{
if ( GetClientWindow() )
UpdateClientSize();
}
-// Returns the active MDI child window
-wxMDIChildFrame *wxMDIParentFrame::GetActiveChild() const
-{
- HWND hWnd = (HWND)::SendMessage(GetWinHwnd(GetClientWindow()),
- WM_MDIGETACTIVE, 0, 0L);
- if ( hWnd == 0 )
- return NULL;
-
- return (wxMDIChildFrame *)wxFindWinFromHandle(hWnd);
-}
-
// Responds to colour changes, and passes event on to children.
void wxMDIParentFrame::OnSysColourChanged(wxSysColourChangedEvent& event)
{
{
wxMDIParentFrame * const parent = GetMDIParent();
- HMENU menuToSet = 0;
+ WXHMENU hMenuToSet = 0;
bool activated;
activated = true;
parent->m_currentChild = this;
- HMENU child_menu = (HMENU)GetWinMenu();
- if ( child_menu )
+ WXHMENU hMenuChild = m_hMenu;
+ if ( hMenuChild )
{
parent->m_parentFrameActive = false;
- menuToSet = child_menu;
+ hMenuToSet = hMenuChild;
}
}
else if ( m_hWnd == hwndDeact )
activated = false;
parent->m_currentChild = NULL;
- HMENU parent_menu = (HMENU)parent->GetWinMenu();
+ WXHMENU hMenuParent = parent->m_hMenu;
// activate the the parent menu only when there is no other child
// that has been activated
- if ( parent_menu && !hwndAct )
+ if ( hMenuParent && !hwndAct )
{
parent->m_parentFrameActive = true;
- menuToSet = parent_menu;
+ hMenuToSet = hMenuParent;
}
}
else
return false;
}
- if ( menuToSet )
+ if ( hMenuToSet )
{
MDISetMenu(parent->GetClientWindow(),
- menuToSet, GetMDIWindowMenu(parent));
+ (HMENU)hMenuToSet, GetMDIWindowMenu(parent));
}
wxActivateEvent event(wxEVT_ACTIVATE, activated, m_windowId);