X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/e9576ca53db96b462ed4c0b4bdf47d64c40203e4..253293c10326afa0226932eab4753d188e1e22e2:/src/mac/mdi.cpp diff --git a/src/mac/mdi.cpp b/src/mac/mdi.cpp index 4869697cd7..f0d2f53138 100644 --- a/src/mac/mdi.cpp +++ b/src/mac/mdi.cpp @@ -17,7 +17,7 @@ #include "wx/menu.h" #include "wx/settings.h" -extern wxList wxModelessWindows; +extern wxWindowList wxModelessWindows; #if !USE_SHARED_LIBRARY IMPLEMENT_DYNAMIC_CLASS(wxMDIParentFrame, wxFrame) @@ -36,10 +36,28 @@ END_EVENT_TABLE() #endif +static const int IDM_WINDOWTILE = 4001; +static const int IDM_WINDOWTILEHOR = 4001; +static const int IDM_WINDOWCASCADE = 4002; +static const int IDM_WINDOWICONS = 4003; +static const int IDM_WINDOWNEXT = 4004; +static const int IDM_WINDOWTILEVERT = 4005; + +// This range gives a maximum of 500 MDI children. Should be enough :-) +static const int wxFIRST_MDI_CHILD = 4100; +static const int wxLAST_MDI_CHILD = 4600; + +// Status border dimensions +static const int wxTHICK_LINE_BORDER = 3; + // Parent frame wxMDIParentFrame::wxMDIParentFrame() { + m_clientWindow = NULL; + m_currentChild = NULL; + m_windowMenu = (wxMenu*) NULL; + m_parentFrameActive = TRUE; } bool wxMDIParentFrame::Create(wxWindow *parent, @@ -50,49 +68,67 @@ bool wxMDIParentFrame::Create(wxWindow *parent, long style, const wxString& name) { - if (!parent) - wxTopLevelWindows.Append(this); - - SetName(name); - m_windowStyle = style; - - if (parent) parent->AddChild(this); - - if ( id > -1 ) - m_windowId = id; - else - m_windowId = (int)NewControlId(); - - // TODO: create MDI parent frame - - wxModelessWindows.Append(this); + 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 = (wxMenu *)NULL; + style -= wxFRAME_NO_WINDOW_MENU ; + } + else // normal case: we have the window menu, so construct it + { + m_windowMenu = new wxMenu; + + m_windowMenu->Append(IDM_WINDOWCASCADE, wxT("&Cascade")); + m_windowMenu->Append(IDM_WINDOWTILEHOR, wxT("Tile &Horizontally")); + m_windowMenu->Append(IDM_WINDOWTILEVERT, wxT("Tile &Vertically")); + m_windowMenu->AppendSeparator(); + m_windowMenu->Append(IDM_WINDOWICONS, wxT("&Arrange Icons")); + m_windowMenu->Append(IDM_WINDOWNEXT, wxT("&Next")); + } + + wxFrame::Create( parent , id , title , wxPoint( 2000 , 2000 ) , size , style , name ) ; + m_parentFrameActive = TRUE; + + OnCreateClient(); return TRUE; } wxMDIParentFrame::~wxMDIParentFrame() { + DestroyChildren(); + // already delete by DestroyChildren() + m_frameToolBar = NULL; + m_frameStatusBar = NULL; + m_clientWindow = NULL ; + + if (m_windowMenu) + { + delete m_windowMenu; + m_windowMenu = (wxMenu*) NULL; + } + + if ( m_clientWindow ) + { + delete m_clientWindow; + m_clientWindow = NULL ; + } } + // Get size *available for subwindows* i.e. excluding menu bar. -void wxMDIParentFrame::GetClientSize(int *x, int *y) const +void wxMDIParentFrame::DoGetClientSize(int *x, int *y) const { - // TODO + wxDisplaySize( x , y ) ; } void wxMDIParentFrame::SetMenuBar(wxMenuBar *menu_bar) { - // TODO - if (!menu_bar) - { - m_frameMenuBar = NULL; - return; - } - - if (menu_bar->m_menuBarFrame) - return; - - m_frameMenuBar = menu_bar; + wxFrame::SetMenuBar( menu_bar ) ; } void wxMDIParentFrame::OnSize(wxSizeEvent& event) @@ -112,21 +148,34 @@ void wxMDIParentFrame::OnSize(wxSizeEvent& event) void wxMDIParentFrame::OnActivate(wxActivateEvent& event) { - // Do nothing + if ( m_currentChild && event.GetActive() ) + { + wxActivateEvent event(wxEVT_ACTIVATE, TRUE, m_currentChild->GetId()); + event.SetEventObject( m_currentChild ); + m_currentChild->GetEventHandler()->ProcessEvent(event) ; + } + else if ( event.GetActive() ) + { + if ( m_frameMenuBar != NULL ) + { + m_frameMenuBar->MacInstallMenuBar() ; + } + + } } // Returns the active MDI child window wxMDIChildFrame *wxMDIParentFrame::GetActiveChild() const { - // TODO - return NULL; + return m_currentChild ; } // Create the client window class (don't Create the window, // just return a new class) wxMDIClientWindow *wxMDIParentFrame::OnCreateClient() { - return new wxMDIClientWindow ; + m_clientWindow = new wxMDIClientWindow( this ); + return m_clientWindow; } // Responds to colour changes, and passes event on to children. @@ -167,6 +216,10 @@ void wxMDIParentFrame::ActivatePrevious() // Child frame wxMDIChildFrame::wxMDIChildFrame() +{ + Init() ; +} +void wxMDIChildFrame::Init() { } @@ -187,7 +240,9 @@ bool wxMDIChildFrame::Create(wxMDIParentFrame *parent, if (parent) parent->AddChild(this); - // TODO: create child frame + MacCreateRealWindow( title, pos , size , MacRemoveBordersFromStyle(style) , name ) ; + + m_macWindowData->m_macWindowBackgroundTheme = kThemeBrushDocumentWindowBackground ; wxModelessWindows.Append(this); return FALSE; @@ -195,51 +250,35 @@ bool wxMDIChildFrame::Create(wxMDIParentFrame *parent, wxMDIChildFrame::~wxMDIChildFrame() { -} - -// Set the client size (i.e. leave the calculation of borders etc. -// to wxWindows) -void wxMDIChildFrame::SetClientSize(int width, int height) -{ - // TODO -} - -void wxMDIChildFrame::GetPosition(int *x, int *y) const -{ - // TODO + DestroyChildren(); + // already delete by DestroyChildren() + m_frameToolBar = NULL; + m_frameStatusBar = NULL; } void wxMDIChildFrame::SetMenuBar(wxMenuBar *menu_bar) { - // TODO - if (!menu_bar) - { - m_frameMenuBar = NULL; - return; - } - - if (menu_bar->m_menuBarFrame) - return; - m_frameMenuBar = menu_bar; + return wxFrame::SetMenuBar( menu_bar ) ; } // MDI operations void wxMDIChildFrame::Maximize() { - // TODO + wxFrame::Maximize() ; } void wxMDIChildFrame::Restore() { - // TODO + wxFrame::Restore() ; } void wxMDIChildFrame::Activate() { - // TODO } -// Client window +//----------------------------------------------------------------------------- +// wxMDIClientWindow +//----------------------------------------------------------------------------- wxMDIClientWindow::wxMDIClientWindow() { @@ -247,19 +286,26 @@ wxMDIClientWindow::wxMDIClientWindow() wxMDIClientWindow::~wxMDIClientWindow() { + DestroyChildren(); } bool wxMDIClientWindow::CreateClient(wxMDIParentFrame *parent, long style) { - // TODO create client window + + m_windowId = (int)NewControlId(); + + if ( parent ) + { + parent->AddChild(this); + } m_backgroundColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_APPWORKSPACE); - return FALSE; + wxModelessWindows.Append(this); + return TRUE; } // Explicitly call default scroll behaviour void wxMDIClientWindow::OnScroll(wxScrollEvent& event) { - Default(); // Default processing }