207
208
//#define lmID_NOTEBOOK wxID_HIGHEST + 100
209
210
//IMPLEMENT_DYNAMIC_CLASS(ContentWindow, wxAuiNotebook)
211
//BEGIN_EVENT_TABLE(ContentWindow, wxAuiNotebook)
212
// EVT_AUINOTEBOOK_PAGE_CLOSE(wxID_ANY, ContentWindow::OnChildClose)
213
// EVT_AUINOTEBOOK_PAGE_CHANGED(wxID_ANY, ContentWindow::OnPageChanged)
212
BEGIN_EVENT_TABLE(ContentWindow, wxAuiNotebook)
213
//EVT_AUINOTEBOOK_PAGE_CLOSE(wxID_ANY, ContentWindow::OnChildClose)
214
EVT_AUINOTEBOOK_PAGE_CHANGED(wxID_ANY, ContentWindow::on_page_changed)
217
218
ContentWindow::ContentWindow(ContentFrame* parent, long style)
218
219
: wxAuiNotebook(parent, -1 /*lmID_NOTEBOOK*/ , wxDefaultPosition,
244
//int ContentWindow::SetSelection(size_t nPage)
246
// int oldSelection = wxAuiNotebook::SetSelection(nPage);
247
// return oldSelection;
250
//void ContentWindow::OnPageChanged(wxAuiNotebookEvent& event)
252
// int OldSelection = event.GetOldSelection();
253
// int newSelection = event.GetSelection();
254
// if (OldSelection == newSelection) return; //nothing to do
255
// if (newSelection != -1)
258
// if (OldSelection != -1)
260
// child = (Canvas*)GetPage(OldSelection);
261
// child->OnChildFrameDeactivated();
263
// child = (Canvas*)GetPage(newSelection);
264
// child->OnChildFrameActivated();
268
//void ContentWindow::OnChildClose(wxAuiNotebookEvent& evt)
270
// //Do not allow direct closing of Canvas by wxAuiNotebook as it deletes
271
// //the child frames and this causes problems with the view/doc model.
272
// //So lets veto page closing and proceed to a controlled close.
275
// //proceed to a controlled close
276
// int iPage = GetSelection();
277
// GetPage(iPage)->Close();
278
// RemovePage(iPage);
245
//---------------------------------------------------------------------------------------
246
void ContentWindow::on_page_changed(wxAuiNotebookEvent& event)
248
wxAuiNotebook::SetSelection( event.GetSelection() );
284
252
//=======================================================================================
285
253
// Canvas implementation
286
254
//=======================================================================================
288
//IMPLEMENT_DYNAMIC_CLASS(Canvas, wxPanel)
290
//BEGIN_EVENT_TABLE(Canvas, wxPanel)
291
// EVT_SIZE(Canvas::OnSize)
294
//---------------------------------------------------------------------------------------
295
Canvas::Canvas(ContentFrame* parent,
296
wxWindowID id, const wxString& title,
297
const wxPoint& WXUNUSED(pos), const wxSize& size,
298
long style, const wxString& name )
299
: m_pContentFrame(parent)
255
Canvas::Canvas(ContentFrame* parent, wxWindowID id, const wxString& title, long style)
256
: wxSplitterWindow(parent->get_content_window(), id, wxDefaultPosition,
257
wxDefaultSize, style, _T("Canvas"))
258
, m_pContentFrame(parent)
301
ContentWindow* pContentWindow = parent->get_content_window();
302
wxPanel::Create(pContentWindow, id, wxDefaultPosition, size, style, name);
303
set_content_frame(parent);
305
261
parent->add_canvas(this, title);
308
264
//---------------------------------------------------------------------------------------
309
265
Canvas::~Canvas()
311
// //The Child frame has been deleted by the view.
312
// //Inform the parent so that it can remove the tab form the Notebook
313
// ContentFrame* pParentFrame = get_content_frame();
315
// pParentFrame->remove_canvas(this);
320
//void Canvas::SetTitle(const wxString& title)
324
// ContentFrame* pParentFrame = get_content_frame();
326
// if (pParentFrame != NULL)
328
// ContentWindow* pClientWindow = pParentFrame->get_content_window();
330
// if (pClientWindow != NULL)
333
// for (pos = 0; pos < pClientWindow->GetPageCount(); pos++)
335
// if (pClientWindow->GetPage(pos) == this)
337
// pClientWindow->SetPageText(pos, m_Title);
345
//wxString Canvas::GetTitle() const
350
//void Canvas::Activate()
352
// ContentFrame* pParentFrame = get_content_frame();
354
// if (pParentFrame != NULL)
356
// ContentWindow* pClientWindow = pParentFrame->get_content_window();
358
// if (pClientWindow != NULL)
361
// for (pos = 0; pos < pClientWindow->GetPageCount(); pos++)
363
// if (pClientWindow->GetPage(pos) == this)
365
// pClientWindow->SetSelection(pos);
269
//---------------------------------------------------------------------------------------
270
void Canvas::set_title(const wxString& title)
274
if (m_pContentFrame != NULL)
276
ContentWindow* pClientWindow = m_pContentFrame->get_content_window();
277
if (pClientWindow != NULL)
280
for (pos = 0; pos < pClientWindow->GetPageCount(); pos++)
282
if (pClientWindow->GetPage(pos) == this)
284
pClientWindow->SetPageText(pos, m_Title);
374
292
} //namespace lenmus