git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@58443
c3d73ce0-8a6f-49c7-b76d-
6d57e0e08775
{ return m_useNativeStatusBar; }
#endif // wxUSE_STATUSBAR
{ return m_useNativeStatusBar; }
#endif // wxUSE_STATUSBAR
-#if wxUSE_MENUS
- WXHMENU GetWinMenu() const { return m_hMenu; }
-#endif // wxUSE_MENUS
-
// event handlers
bool HandleSize(int x, int y, WXUINT flag);
bool HandleCommand(WXWORD id, WXWORD cmd, WXHWND control);
// event handlers
bool HandleSize(int x, int y, WXUINT flag);
bool HandleCommand(WXWORD id, WXWORD cmd, WXHWND control);
WXWPARAM wParam,
WXLPARAM lParam);
WXWPARAM wParam,
WXLPARAM lParam);
+#if wxUSE_MENUS
+ // get the currently active menu: this is the same as the frame menu for
+ // normal frames but is overridden by wxMDIParentFrame
+ virtual WXHMENU MSWGetActiveMenu() const { return m_hMenu; }
+#endif // wxUSE_MENUS
+
protected:
// common part of all ctors
void Init();
protected:
// common part of all ctors
void Init();
virtual void SetWindowMenu(wxMenu* menu);
virtual void DoMenuUpdates(wxMenu* menu = NULL);
virtual void SetWindowMenu(wxMenu* menu);
virtual void DoMenuUpdates(wxMenu* menu = NULL);
+
+ // return the active child menu, if any
+ virtual WXHMENU MSWGetActiveMenu() const;
// implementation only from now on
// MDI helpers
// implementation only from now on
// MDI helpers
virtual WXLRESULT MSWDefWindowProc(WXUINT, WXWPARAM, WXLPARAM);
virtual bool MSWTranslateMessage(WXMSG* msg);
virtual WXLRESULT MSWDefWindowProc(WXUINT, WXWPARAM, WXLPARAM);
virtual bool MSWTranslateMessage(WXMSG* msg);
// override wxFrameBase function to also look in the active child menu bar
virtual const wxMenuItem *FindItemInMenuBar(int menuId) const;
// override wxFrameBase function to also look in the active child menu bar
virtual const wxMenuItem *FindItemInMenuBar(int menuId) const;
protected:
#if wxUSE_MENUS_NATIVE
protected:
#if wxUSE_MENUS_NATIVE
bool m_parentFrameActive;
private:
bool m_parentFrameActive;
private:
// add/remove window menu if we have it (i.e. m_windowMenu != NULL)
void AddWindowMenu();
void RemoveWindowMenu();
// 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;
// return the number of child frames we currently have (maybe 0)
int GetChildFramesCount() const;
friend class WXDLLIMPEXP_FWD_CORE wxMDIChildFrame;
DECLARE_EVENT_TABLE()
friend class WXDLLIMPEXP_FWD_CORE wxMDIChildFrame;
DECLARE_EVENT_TABLE()
#if wxUSE_MENUS
if (m_fsStyle & wxFULLSCREEN_NOMENUBAR)
{
#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);
// wxMDIParentFrame child management
// ----------------------------------------------------------------------------
// 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;
int wxMDIParentFrame::GetChildFramesCount() const
{
int count = 0;
// ----------------------------------------------------------------------------
// wxMDIParentFrame window menu handling
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
// wxMDIParentFrame window menu handling
// ----------------------------------------------------------------------------
+// ----------------------------------------------------------------------------
+// wxMDIParentFrame other menu-related stuff
+// ----------------------------------------------------------------------------
+
void wxMDIParentFrame::DoMenuUpdates(wxMenu* menu)
{
wxMDIChildFrame *child = GetActiveChild();
void wxMDIParentFrame::DoMenuUpdates(wxMenu* menu)
{
wxMDIChildFrame *child = GetActiveChild();
+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() )
void wxMDIParentFrame::UpdateClientSize()
{
if ( GetClientWindow() )
-// 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)
{
// Responds to colour changes, and passes event on to children.
void wxMDIParentFrame::OnSysColourChanged(wxSysColourChangedEvent& event)
{
{
wxMDIParentFrame * const parent = GetMDIParent();
{
wxMDIParentFrame * const parent = GetMDIParent();
+ WXHMENU hMenuToSet = 0;
activated = true;
parent->m_currentChild = this;
activated = true;
parent->m_currentChild = this;
- HMENU child_menu = (HMENU)GetWinMenu();
- if ( child_menu )
+ WXHMENU hMenuChild = m_hMenu;
+ if ( hMenuChild )
{
parent->m_parentFrameActive = false;
{
parent->m_parentFrameActive = false;
- menuToSet = child_menu;
+ hMenuToSet = hMenuChild;
}
}
else if ( m_hWnd == hwndDeact )
}
}
else if ( m_hWnd == hwndDeact )
activated = false;
parent->m_currentChild = NULL;
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
// 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;
{
parent->m_parentFrameActive = true;
- menuToSet = parent_menu;
+ hMenuToSet = hMenuParent;
{
MDISetMenu(parent->GetClientWindow(),
{
MDISetMenu(parent->GetClientWindow(),
- menuToSet, GetMDIWindowMenu(parent));
+ (HMENU)hMenuToSet, GetMDIWindowMenu(parent));
}
wxActivateEvent event(wxEVT_ACTIVATE, activated, m_windowId);
}
wxActivateEvent event(wxEVT_ACTIVATE, activated, m_windowId);