extern wxMenu *wxCurrentPopupMenu;
-extern const wxChar *wxMDIFrameClassName; // from app.cpp
-extern const wxChar *wxMDIChildFrameClassName;
-extern const wxChar *wxMDIChildFrameClassNameNoRedraw;
extern void wxRemoveHandleAssociation(wxWindow *win);
// ---------------------------------------------------------------------------
wxMDIParentFrame::wxMDIParentFrame()
{
- m_clientWindow = NULL;
- m_currentChild = NULL;
- m_windowMenu = NULL;
m_parentFrameActive = true;
}
long style,
const wxString& name)
{
- m_clientWindow = NULL;
- m_currentChild = NULL;
-
// this style can be used to prevent a window from having the standard MDI
// "Window" menu
- if ( style & wxFRAME_NO_WINDOW_MENU )
- {
- m_windowMenu = NULL;
- }
- else // normal case: we have the window menu, so construct it
+ if ( !(style & wxFRAME_NO_WINDOW_MENU) )
{
+ // normal case: we have the window menu, so construct it
m_windowMenu = new wxMenu;
m_windowMenu->Append(IDM_WINDOWCASCADE, _("&Cascade"));
msflags &= ~WS_VSCROLL;
msflags &= ~WS_HSCROLL;
- if ( !wxWindow::MSWCreate(wxMDIFrameClassName,
+ if ( !wxWindow::MSWCreate(wxApp::GetRegisteredClassName(_T("wxMDIFrame")),
title.wx_str(),
pos, size,
msflags,
DestroyChildren();
- delete m_windowMenu;
-
// the MDI frame menubar is not automatically deleted by Windows unlike for
// the normal frames
if ( m_hMenu )
void wxMDIParentFrame::SetWindowMenu(wxMenu* menu)
{
- if (m_windowMenu)
- {
- RemoveWindowMenu();
+ // notice that Remove/AddWindowMenu() are safe to call even when
+ // m_windowMenu is NULL
+ RemoveWindowMenu();
- delete m_windowMenu;
- m_windowMenu = NULL;
- }
+ delete m_windowMenu;
- if (menu)
- {
- m_windowMenu = menu;
+ m_windowMenu = menu;
- AddWindowMenu();
- }
+ AddWindowMenu();
}
void wxMDIParentFrame::DoMenuUpdates(wxMenu* menu)
return (wxMDIChildFrame *)wxFindWinFromHandle(hWnd);
}
-// Create the client window class (don't Create the window, just return a new
-// class)
-wxMDIClientWindow *wxMDIParentFrame::OnCreateClient()
-{
- return new wxMDIClientWindow;
-}
-
// Responds to colour changes, and passes event on to children.
void wxMDIParentFrame::OnSysColourChanged(wxSysColourChangedEvent& event)
{
long style,
const wxString& name)
{
+ m_mdiParent = parent;
+
SetName(name);
if ( id != wxID_ANY )
MDICREATESTRUCT mcs;
- mcs.szClass = style & wxFULL_REPAINT_ON_RESIZE
- ? wxMDIChildFrameClassName
- : wxMDIChildFrameClassNameNoRedraw;
+ wxString className =
+ wxApp::GetRegisteredClassName(_T("wxMDIChildFrame"), COLOR_WINDOW);
+ if ( !(style & wxFULL_REPAINT_ON_RESIZE) )
+ className += wxApp::GetNoRedrawClassSuffix();
+
+ mcs.szClass = className.wx_str();
mcs.szTitle = title.wx_str();
mcs.hOwner = wxGetInstance();
if (x != wxDefaultCoord)
// we need to refresh the MDI frame window menu to include (or exclude if
// we've been hidden) this frame
- wxMDIParentFrame *parent = GetMDIParent();
+ wxMDIParentFrame * const parent = GetMDIParent();
MDISetMenu(parent->GetClientWindow(), NULL, NULL);
return true;
// If there's an MDI parent, must subtract the parent's top left corner
// since MoveWindow moves relative to the parent
- wxMDIParentFrame *mdiParent = GetMDIParent();
- ::ScreenToClient((HWND) mdiParent->GetClientWindow()->GetHWND(), &point);
+ wxMDIParentFrame * const mdiParent = GetMDIParent();
+ ::ScreenToClient(GetHwndOf(mdiParent->GetClientWindow()), &point);
MoveWindow(hWnd, point.x, point.y, actual_width, actual_height, (BOOL)true);
// Since we now have the absolute screen coords,
// if there's a parent we must subtract its top left corner
- wxMDIParentFrame *mdiParent = GetMDIParent();
- ::ScreenToClient((HWND) mdiParent->GetClientWindow()->GetHWND(), &point);
+ wxMDIParentFrame * const mdiParent = GetMDIParent();
+ ::ScreenToClient(GetHwndOf(mdiParent->GetClientWindow()), &point);
if (x)
*x = point.x;
void wxMDIChildFrame::InternalSetMenuBar()
{
- wxMDIParentFrame *parent = GetMDIParent();
+ wxMDIParentFrame * const parent = GetMDIParent();
MDIInsertWindowMenu(parent->GetClientWindow(),
m_hMenu, GetMDIWindowMenu(parent));
void wxMDIChildFrame::Maximize(bool maximize)
{
- wxMDIParentFrame *parent = GetMDIParent();
+ wxMDIParentFrame * const parent = GetMDIParent();
if ( parent && parent->GetClientWindow() )
{
::SendMessage(GetWinHwnd(parent->GetClientWindow()),
void wxMDIChildFrame::Restore()
{
- wxMDIParentFrame *parent = GetMDIParent();
+ wxMDIParentFrame * const parent = GetMDIParent();
if ( parent && parent->GetClientWindow() )
{
::SendMessage(GetWinHwnd(parent->GetClientWindow()), WM_MDIRESTORE,
void wxMDIChildFrame::Activate()
{
- wxMDIParentFrame *parent = GetMDIParent();
+ wxMDIParentFrame * const parent = GetMDIParent();
if ( parent && parent->GetClientWindow() )
{
::SendMessage(GetWinHwnd(parent->GetClientWindow()), WM_MDIACTIVATE,
WXHWND hwndAct,
WXHWND hwndDeact)
{
- wxMDIParentFrame *parent = GetMDIParent();
+ wxMDIParentFrame * const parent = GetMDIParent();
HMENU menuToSet = 0;
void wxMDIChildFrame::MSWDestroyWindow()
{
- wxMDIParentFrame *parent = GetMDIParent();
+ wxMDIParentFrame * const parent = GetMDIParent();
// Must make sure this handle is invalidated (set to NULL) since all sorts
// of things could happen after the child client is destroyed, but before
bool wxMDIChildFrame::ResetWindowStyle(void *vrect)
{
RECT *rect = (RECT *)vrect;
- wxMDIParentFrame* pFrameWnd = GetMDIParent();
+ wxMDIParentFrame * const pFrameWnd = GetMDIParent();
wxMDIChildFrame* pChild = pFrameWnd->GetActiveChild();
if (!pChild || (pChild == this))