2002-08-20 05:27:29 -04:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: wx/generic/mdig.h
|
|
|
|
// Purpose: Generic MDI (Multiple Document Interface) classes
|
|
|
|
// Author: Hans Van Leemputten
|
2008-11-03 21:46:19 -05:00
|
|
|
// Modified by: 2008-10-31 Vadim Zeitlin: derive from the base classes
|
2002-08-20 05:27:29 -04:00
|
|
|
// Created: 29/07/2002
|
|
|
|
// RCS-ID: $Id$
|
2008-11-03 21:46:19 -05:00
|
|
|
// Copyright: (c) 2002 Hans Van Leemputten
|
|
|
|
// (c) 2008 Vadim Zeitlin
|
2004-05-23 16:53:33 -04:00
|
|
|
// Licence: wxWindows licence
|
2002-08-20 05:27:29 -04:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2008-11-03 21:46:19 -05:00
|
|
|
#ifndef _WX_GENERIC_MDIG_H_
|
|
|
|
#define _WX_GENERIC_MDIG_H_
|
2002-08-20 05:27:29 -04:00
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// headers
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#include "wx/panel.h"
|
|
|
|
|
2008-11-03 21:46:19 -05:00
|
|
|
class WXDLLIMPEXP_FWD_CORE wxBookCtrlBase;
|
|
|
|
class WXDLLIMPEXP_FWD_CORE wxBookCtrlEvent;
|
2008-01-27 07:43:46 -05:00
|
|
|
class WXDLLIMPEXP_FWD_CORE wxIcon;
|
|
|
|
class WXDLLIMPEXP_FWD_CORE wxIconBundle;
|
2008-11-03 21:46:19 -05:00
|
|
|
class WXDLLIMPEXP_FWD_CORE wxNotebook;
|
2008-01-27 07:43:46 -05:00
|
|
|
|
2008-11-03 21:46:19 -05:00
|
|
|
#if wxUSE_GENERIC_MDI_AS_NATIVE
|
|
|
|
#define wxGenericMDIParentFrame wxMDIParentFrame
|
|
|
|
#define wxGenericMDIChildFrame wxMDIChildFrame
|
|
|
|
#define wxGenericMDIClientWindow wxMDIClientWindow
|
|
|
|
#else // !wxUSE_GENERIC_MDI_AS_NATIVE
|
|
|
|
class WXDLLIMPEXP_FWD_CORE wxGenericMDIParentFrame;
|
|
|
|
class WXDLLIMPEXP_FWD_CORE wxGenericMDIChildFrame;
|
|
|
|
class WXDLLIMPEXP_FWD_CORE wxGenericMDIClientWindow;
|
|
|
|
#endif // wxUSE_GENERIC_MDI_AS_NATIVE/!wxUSE_GENERIC_MDI_AS_NATIVE
|
2002-08-20 05:27:29 -04:00
|
|
|
|
2008-11-03 21:46:19 -05:00
|
|
|
// ----------------------------------------------------------------------------
|
2002-08-20 05:27:29 -04:00
|
|
|
// wxGenericMDIParentFrame
|
2008-11-03 21:46:19 -05:00
|
|
|
// ----------------------------------------------------------------------------
|
2002-08-20 05:27:29 -04:00
|
|
|
|
2008-11-03 21:46:19 -05:00
|
|
|
class WXDLLIMPEXP_CORE wxGenericMDIParentFrame : public wxMDIParentFrameBase
|
2002-08-20 05:27:29 -04:00
|
|
|
{
|
|
|
|
public:
|
2008-11-03 21:46:19 -05:00
|
|
|
wxGenericMDIParentFrame() { Init(); }
|
2002-08-20 05:27:29 -04:00
|
|
|
wxGenericMDIParentFrame(wxWindow *parent,
|
2003-11-06 13:09:48 -05:00
|
|
|
wxWindowID winid,
|
2002-08-20 05:27:29 -04:00
|
|
|
const wxString& title,
|
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
const wxSize& size = wxDefaultSize,
|
|
|
|
long style = wxDEFAULT_FRAME_STYLE | wxVSCROLL | wxHSCROLL,
|
2008-11-03 21:46:19 -05:00
|
|
|
const wxString& name = wxFrameNameStr)
|
|
|
|
{
|
|
|
|
Init();
|
|
|
|
|
|
|
|
Create(parent, winid, title, pos, size, style, name);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Create(wxWindow *parent,
|
|
|
|
wxWindowID winid,
|
|
|
|
const wxString& title,
|
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
const wxSize& size = wxDefaultSize,
|
|
|
|
long style = wxDEFAULT_FRAME_STYLE | wxVSCROLL | wxHSCROLL,
|
|
|
|
const wxString& name = wxFrameNameStr);
|
2002-08-20 05:27:29 -04:00
|
|
|
|
2006-09-05 16:47:48 -04:00
|
|
|
virtual ~wxGenericMDIParentFrame();
|
2008-11-03 21:46:19 -05:00
|
|
|
|
|
|
|
// implement base class pure virtuals
|
|
|
|
static bool IsTDI() { return true; }
|
|
|
|
|
|
|
|
virtual void ActivateNext() { AdvanceActive(true); }
|
|
|
|
virtual void ActivatePrevious() { AdvanceActive(false); }
|
2002-08-20 05:27:29 -04:00
|
|
|
|
|
|
|
#if wxUSE_MENUS
|
2008-11-03 21:46:19 -05:00
|
|
|
virtual void SetWindowMenu(wxMenu* pMenu);
|
2002-08-20 05:27:29 -04:00
|
|
|
|
|
|
|
virtual void SetMenuBar(wxMenuBar *pMenuBar);
|
|
|
|
#endif // wxUSE_MENUS
|
|
|
|
|
2008-11-03 21:46:19 -05:00
|
|
|
virtual wxGenericMDIClientWindow *OnCreateGenericClient();
|
2002-08-20 05:27:29 -04:00
|
|
|
|
|
|
|
|
2008-11-03 21:46:19 -05:00
|
|
|
// implementation only from now on
|
|
|
|
void WXSetChildMenuBar(wxGenericMDIChildFrame *child);
|
|
|
|
void WXUpdateChildTitle(wxGenericMDIChildFrame *child);
|
|
|
|
void WXActivateChild(wxGenericMDIChildFrame *child);
|
|
|
|
void WXRemoveChild(wxGenericMDIChildFrame *child);
|
|
|
|
bool WXIsActiveChild(wxGenericMDIChildFrame *child) const;
|
|
|
|
bool WXIsInsideChildHandler(wxGenericMDIChildFrame *child) const;
|
|
|
|
|
|
|
|
// return the book control used by the client window to manage the pages
|
|
|
|
wxBookCtrlBase *GetBookCtrl() const;
|
2002-08-20 05:27:29 -04:00
|
|
|
|
|
|
|
protected:
|
|
|
|
#if wxUSE_MENUS
|
2008-11-03 21:46:19 -05:00
|
|
|
wxMenuBar *m_pMyMenuBar;
|
2002-08-20 05:27:29 -04:00
|
|
|
#endif // wxUSE_MENUS
|
|
|
|
|
2008-11-03 21:46:19 -05:00
|
|
|
// advance the activation forward or backwards
|
|
|
|
void AdvanceActive(bool forward);
|
|
|
|
|
|
|
|
private:
|
2002-08-20 05:27:29 -04:00
|
|
|
void Init();
|
|
|
|
|
|
|
|
#if wxUSE_MENUS
|
|
|
|
void RemoveWindowMenu(wxMenuBar *pMenuBar);
|
|
|
|
void AddWindowMenu(wxMenuBar *pMenuBar);
|
|
|
|
|
2008-11-03 21:46:19 -05:00
|
|
|
void OnWindowMenu(wxCommandEvent& event);
|
2002-08-20 05:27:29 -04:00
|
|
|
#endif // wxUSE_MENUS
|
|
|
|
|
2009-01-25 06:58:39 -05:00
|
|
|
virtual bool ProcessEvent(wxEvent& event);
|
|
|
|
|
2008-11-03 21:46:19 -05:00
|
|
|
void OnClose(wxCloseEvent& event);
|
|
|
|
|
|
|
|
// return the client window, may be NULL if we hadn't been created yet
|
|
|
|
wxGenericMDIClientWindow *GetGenericClientWindow() const;
|
|
|
|
|
|
|
|
// close all children, return false if any of them vetoed it
|
|
|
|
bool CloseAll();
|
|
|
|
|
|
|
|
|
|
|
|
// this pointer is non-NULL if we're currently inside our ProcessEvent()
|
|
|
|
// and we forwarded the event to this child (as we do with menu events)
|
|
|
|
wxMDIChildFrameBase *m_childHandler;
|
2002-08-20 05:27:29 -04:00
|
|
|
|
|
|
|
DECLARE_EVENT_TABLE()
|
|
|
|
DECLARE_DYNAMIC_CLASS(wxGenericMDIParentFrame)
|
|
|
|
};
|
|
|
|
|
2008-11-03 21:46:19 -05:00
|
|
|
// ----------------------------------------------------------------------------
|
2002-08-20 05:27:29 -04:00
|
|
|
// wxGenericMDIChildFrame
|
2008-11-03 21:46:19 -05:00
|
|
|
// ----------------------------------------------------------------------------
|
2002-08-20 05:27:29 -04:00
|
|
|
|
2008-11-03 21:46:19 -05:00
|
|
|
class WXDLLIMPEXP_CORE wxGenericMDIChildFrame : public wxTDIChildFrame
|
2002-08-20 05:27:29 -04:00
|
|
|
{
|
|
|
|
public:
|
2008-11-03 21:46:19 -05:00
|
|
|
wxGenericMDIChildFrame() { Init(); }
|
|
|
|
wxGenericMDIChildFrame(wxGenericMDIParentFrame *parent,
|
|
|
|
wxWindowID winid,
|
|
|
|
const wxString& title,
|
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
const wxSize& size = wxDefaultSize,
|
|
|
|
long style = wxDEFAULT_FRAME_STYLE,
|
|
|
|
const wxString& name = wxFrameNameStr)
|
|
|
|
{
|
|
|
|
Init();
|
|
|
|
|
|
|
|
Create(parent, winid, title, pos, size, style, name);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Create(wxGenericMDIParentFrame *parent,
|
|
|
|
wxWindowID winid,
|
|
|
|
const wxString& title,
|
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
const wxSize& size = wxDefaultSize,
|
|
|
|
long style = wxDEFAULT_FRAME_STYLE,
|
|
|
|
const wxString& name = wxFrameNameStr);
|
2002-08-20 05:27:29 -04:00
|
|
|
|
|
|
|
virtual ~wxGenericMDIChildFrame();
|
2008-11-03 21:46:19 -05:00
|
|
|
|
|
|
|
// implement MDI operations
|
|
|
|
virtual void Activate();
|
|
|
|
|
2002-08-20 05:27:29 -04:00
|
|
|
|
2002-09-16 00:54:25 -04:00
|
|
|
#if wxUSE_MENUS
|
2002-08-20 05:27:29 -04:00
|
|
|
virtual void SetMenuBar( wxMenuBar *menu_bar );
|
|
|
|
virtual wxMenuBar *GetMenuBar() const;
|
2002-09-16 00:54:25 -04:00
|
|
|
#endif // wxUSE_MENUS
|
2002-08-20 05:27:29 -04:00
|
|
|
|
2008-11-03 21:46:19 -05:00
|
|
|
virtual wxString GetTitle() const { return m_title; }
|
2002-08-20 05:27:29 -04:00
|
|
|
virtual void SetTitle(const wxString& title);
|
|
|
|
|
2009-02-26 11:16:31 -05:00
|
|
|
virtual bool TryAfter(wxEvent& event);
|
2002-08-20 05:27:29 -04:00
|
|
|
|
2008-11-03 21:46:19 -05:00
|
|
|
// implementation only from now on
|
2002-08-20 05:27:29 -04:00
|
|
|
|
2008-11-03 21:46:19 -05:00
|
|
|
wxGenericMDIParentFrame* GetGenericMDIParent() const
|
|
|
|
{
|
|
|
|
#if wxUSE_GENERIC_MDI_AS_NATIVE
|
|
|
|
return GetMDIParent();
|
|
|
|
#else // generic != native
|
|
|
|
return m_mdiParentGeneric;
|
2002-08-20 05:27:29 -04:00
|
|
|
#endif
|
2008-11-03 21:46:19 -05:00
|
|
|
}
|
2002-08-20 05:27:29 -04:00
|
|
|
|
|
|
|
protected:
|
2008-11-03 21:46:19 -05:00
|
|
|
wxString m_title;
|
2002-08-20 05:27:29 -04:00
|
|
|
|
|
|
|
#if wxUSE_MENUS
|
|
|
|
wxMenuBar *m_pMenuBar;
|
2002-09-16 00:54:25 -04:00
|
|
|
#endif // wxUSE_MENUS
|
2002-08-20 05:27:29 -04:00
|
|
|
|
2008-11-03 21:46:19 -05:00
|
|
|
#if !wxUSE_GENERIC_MDI_AS_NATIVE
|
|
|
|
wxGenericMDIParentFrame *m_mdiParentGeneric;
|
|
|
|
#endif
|
|
|
|
|
2002-08-20 05:27:29 -04:00
|
|
|
protected:
|
|
|
|
void Init();
|
|
|
|
|
|
|
|
private:
|
2008-11-03 21:46:19 -05:00
|
|
|
void OnMenuHighlight(wxMenuEvent& event);
|
|
|
|
void OnClose(wxCloseEvent& event);
|
|
|
|
|
2002-08-20 05:27:29 -04:00
|
|
|
DECLARE_DYNAMIC_CLASS(wxGenericMDIChildFrame)
|
|
|
|
DECLARE_EVENT_TABLE()
|
|
|
|
|
|
|
|
friend class wxGenericMDIClientWindow;
|
|
|
|
};
|
|
|
|
|
2008-11-03 21:46:19 -05:00
|
|
|
// ----------------------------------------------------------------------------
|
2002-08-20 05:27:29 -04:00
|
|
|
// wxGenericMDIClientWindow
|
2008-11-03 21:46:19 -05:00
|
|
|
// ----------------------------------------------------------------------------
|
2002-08-20 05:27:29 -04:00
|
|
|
|
2008-11-03 21:46:19 -05:00
|
|
|
class WXDLLIMPEXP_CORE wxGenericMDIClientWindow : public wxMDIClientWindowBase
|
2002-08-20 05:27:29 -04:00
|
|
|
{
|
|
|
|
public:
|
2008-11-03 21:46:19 -05:00
|
|
|
wxGenericMDIClientWindow() { }
|
|
|
|
|
|
|
|
// unfortunately we need to provide our own version of CreateClient()
|
|
|
|
// because of the difference in the type of the first parameter and
|
|
|
|
// implement the base class pure virtual method in terms of it
|
|
|
|
// (CreateGenericClient() is virtual itself to allow customizing the client
|
|
|
|
// window creation by overriding it in the derived classes)
|
|
|
|
virtual bool CreateGenericClient(wxWindow *parent);
|
|
|
|
virtual bool CreateClient(wxMDIParentFrame *parent,
|
|
|
|
long WXUNUSED(style) = wxVSCROLL | wxHSCROLL)
|
|
|
|
{
|
|
|
|
return CreateGenericClient(parent);
|
|
|
|
}
|
2002-08-20 05:27:29 -04:00
|
|
|
|
2008-11-03 21:46:19 -05:00
|
|
|
// implementation only
|
|
|
|
wxBookCtrlBase *GetBookCtrl() const;
|
|
|
|
wxGenericMDIChildFrame *GetChild(size_t pos) const;
|
|
|
|
int FindChild(wxGenericMDIChildFrame *child) const;
|
2002-08-20 05:27:29 -04:00
|
|
|
|
2008-11-03 21:46:19 -05:00
|
|
|
private:
|
2002-08-20 05:27:29 -04:00
|
|
|
void PageChanged(int OldSelection, int newSelection);
|
|
|
|
|
2008-08-01 09:46:46 -04:00
|
|
|
void OnPageChanged(wxBookCtrlEvent& event);
|
2002-08-20 05:27:29 -04:00
|
|
|
void OnSize(wxSizeEvent& event);
|
|
|
|
|
2008-11-03 21:46:19 -05:00
|
|
|
// the notebook containing all MDI children as its pages
|
|
|
|
wxNotebook *m_notebook;
|
2002-08-20 05:27:29 -04:00
|
|
|
|
2008-11-03 21:46:19 -05:00
|
|
|
DECLARE_DYNAMIC_CLASS(wxGenericMDIClientWindow)
|
2002-08-20 05:27:29 -04:00
|
|
|
};
|
|
|
|
|
2008-11-03 21:46:19 -05:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// inline functions implementation
|
|
|
|
// ----------------------------------------------------------------------------
|
2002-08-20 05:27:29 -04:00
|
|
|
|
2008-11-03 21:46:19 -05:00
|
|
|
inline bool
|
|
|
|
wxGenericMDIParentFrame::
|
|
|
|
WXIsInsideChildHandler(wxGenericMDIChildFrame *child) const
|
2002-08-20 05:27:29 -04:00
|
|
|
{
|
2008-11-03 21:46:19 -05:00
|
|
|
return child == m_childHandler;
|
|
|
|
}
|
2002-08-20 05:27:29 -04:00
|
|
|
|
2008-11-03 21:46:19 -05:00
|
|
|
#endif // _WX_GENERIC_MDIG_H_
|