1
//--------------------------------------------------------------------------------------
2
// LenMus Phonascus: The teacher of music
3
// Copyright (c) 2002-2007 Cecilio Salmeron
5
// This program is free software; you can redistribute it and/or modify it under the
6
// terms of the GNU General Public License as published by the Free Software Foundation;
7
// either version 2 of the License, or (at your option) any later version.
9
// This program is distributed in the hope that it will be useful, but WITHOUT ANY
10
// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
11
// PARTICULAR PURPOSE. See the GNU General Public License for more details.
13
// You should have received a copy of the GNU General Public License along with this
14
// program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street,
15
// Fifth Floor, Boston, MA 02110-1301, USA.
17
// For any comment, suggestion or feature request, please contact the manager of
18
// the project at cecilios@users.sourceforge.net
20
//-------------------------------------------------------------------------------------
22
#include "../app/global.h"
24
#if lmUSE_NOTEBOOK_MDI
27
// For compilers that support precompilation, includes "wx.h".
28
#include "wx/wxprec.h"
35
#include "ParentFrame.h"
36
#include "ChildFrame.h"
37
#include "ClientWindow.h"
48
//-----------------------------------------------------------------------------
50
// The client window is the area where MDI child windows exist. It doesn't
51
// have to cover the whole parent frame; other windows such as toolbars and
52
// a help window might coexist with it. There can be scrollbars on a client
53
// window, which are controlled by the parent window style.
54
// As client I will use wxAuiNotebook
56
// The MDIClientWindow object is created by the MDI parent frame, in the
57
// constructor. And is deleted also by MDIParentFrame in its destructor.
59
//-----------------------------------------------------------------------------
61
#define lmID_NOTEBOOK wxID_HIGHEST + 100
63
IMPLEMENT_DYNAMIC_CLASS(lmMDIClientWindow, wxAuiNotebook)
65
BEGIN_EVENT_TABLE(lmMDIClientWindow, wxAuiNotebook)
66
EVT_SIZE(lmMDIClientWindow::OnSize)
67
EVT_AUINOTEBOOK_PAGE_CLOSE(wxID_ANY, lmMDIClientWindow::OnChildClose)
71
lmMDIClientWindow::lmMDIClientWindow()
75
lmMDIClientWindow::lmMDIClientWindow( lmMDIParentFrame *parent, long style )
77
//SetWindowStyleFlag(style);
78
wxAuiNotebook::Create(parent, lmID_NOTEBOOK, wxPoint(0,0),
79
wxSize(100, 100), style);
82
lmMDIClientWindow::~lmMDIClientWindow()
86
int lmMDIClientWindow::SetSelection(size_t nPage)
88
int oldSelection = wxAuiNotebook::SetSelection(nPage);
92
void lmMDIClientWindow::PageChanged(int OldSelection, int newSelection)
94
// Don't do to much work, only when something realy should change!
95
if (OldSelection == newSelection)
97
// Again check if we realy need to do this...
98
if (newSelection != -1)
100
lmMDIChildFrame* child = (lmMDIChildFrame *)GetPage(newSelection);
102
if (child->GetMDIParentFrame()->GetActiveChild() == child)
107
void lmMDIClientWindow::OnSize(wxSizeEvent& event)
109
wxAuiNotebook::OnSize(event);
112
for (pos = 0; pos < GetPageCount(); pos++)
114
((lmMDIChildFrame *)GetPage(pos))->ApplyMDIChildFrameRect();
118
lmMDIChildFrame* lmMDIClientWindow::GetSelectedPage()
120
if (GetPageCount() > 0)
121
return (lmMDIChildFrame*)GetPage(GetSelection());
123
return (lmMDIChildFrame*) NULL;
126
void lmMDIClientWindow::OnChildClose(wxAuiNotebookEvent& evt)
128
//Do not allow direct closing of lmMDIChildFrame by wxAuiNotebook as it deletes
129
//the child frames and this causes problems with the view/doc model.
130
//So lets veto page closing and proceed to a controlled close.
133
//proceed to a controlled close
134
int iPage = GetSelection();
135
GetPage(iPage)->Close();
140
#endif //lmUSE_NOTEBOOK_MDI