2006-06-20 08:39:16 +00:00
|
|
|
// -*- C++ -*-
|
|
|
|
/**
|
|
|
|
* \file GuiImplementation.C
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
*
|
|
|
|
* \author John Levon
|
|
|
|
* \author Abdelrazak Younes
|
|
|
|
*
|
|
|
|
* Full author contact details are available in file CREDITS.
|
|
|
|
*/
|
|
|
|
|
2006-07-08 13:27:43 +00:00
|
|
|
#include <config.h>
|
|
|
|
|
2006-06-26 16:55:35 +00:00
|
|
|
// This include must be declared before everything else because
|
|
|
|
// of boost/Qt/LyX clash...
|
|
|
|
#include "GuiView.h"
|
|
|
|
|
2006-06-20 08:39:16 +00:00
|
|
|
#include "GuiImplementation.h"
|
|
|
|
#include "GuiWorkArea.h"
|
2006-06-26 16:55:35 +00:00
|
|
|
|
|
|
|
#include "BufferView.h"
|
2006-06-20 08:39:16 +00:00
|
|
|
|
|
|
|
using boost::shared_ptr;
|
|
|
|
|
|
|
|
namespace lyx {
|
|
|
|
namespace frontend {
|
|
|
|
|
2006-06-26 16:55:35 +00:00
|
|
|
GuiImplementation::GuiImplementation(): max_view_id_(0), max_wa_id_(0)
|
2006-06-20 08:39:16 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-06-26 16:55:35 +00:00
|
|
|
int GuiImplementation::newView(unsigned int /*w*/, unsigned int /*h*/)
|
2006-06-20 08:39:16 +00:00
|
|
|
{
|
2006-06-26 16:55:35 +00:00
|
|
|
size_t const id = max_view_id_;
|
|
|
|
++max_view_id_;
|
|
|
|
|
2006-09-22 15:02:41 +00:00
|
|
|
views_[id].reset(new GuiView());
|
2006-06-26 16:55:35 +00:00
|
|
|
|
2006-06-20 08:39:16 +00:00
|
|
|
return id;
|
|
|
|
}
|
|
|
|
|
2006-06-26 16:55:35 +00:00
|
|
|
|
|
|
|
LyXView& GuiImplementation::view(int id)
|
2006-06-20 08:39:16 +00:00
|
|
|
{
|
2006-06-26 16:55:35 +00:00
|
|
|
BOOST_ASSERT(views_.find(id) != views_.end());
|
|
|
|
|
|
|
|
return *views_[id].get();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void GuiImplementation::destroyView(int id)
|
|
|
|
{
|
|
|
|
views_.erase(id);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int GuiImplementation::newWorkArea(unsigned int w, unsigned int h, int view_id)
|
|
|
|
{
|
|
|
|
size_t const id = max_wa_id_;
|
|
|
|
++max_wa_id_;
|
|
|
|
|
|
|
|
GuiView * view = views_[view_id].get();
|
|
|
|
|
2006-08-15 21:57:23 +00:00
|
|
|
work_areas_[id].reset(new GuiWorkArea(w, h, *view));
|
2006-06-26 16:55:35 +00:00
|
|
|
|
|
|
|
// FIXME BufferView creation should be independant of WorkArea creation
|
2006-09-26 12:46:27 +00:00
|
|
|
buffer_views_[id].reset(new BufferView);
|
2006-06-26 16:55:35 +00:00
|
|
|
work_areas_[id]->setBufferView(buffer_views_[id].get());
|
2006-07-03 22:31:51 +00:00
|
|
|
view->setWorkArea(work_areas_[id].get());
|
2006-06-26 16:55:35 +00:00
|
|
|
|
2006-08-12 16:25:51 +00:00
|
|
|
view->setCentralWidget(work_areas_[id].get());
|
2006-06-20 08:39:16 +00:00
|
|
|
|
2006-06-26 16:55:35 +00:00
|
|
|
return id;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
WorkArea& GuiImplementation::workArea(int id)
|
|
|
|
{
|
|
|
|
BOOST_ASSERT(work_areas_.find(id) != work_areas_.end());
|
|
|
|
|
2006-06-20 08:39:16 +00:00
|
|
|
return *work_areas_[id].get();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void GuiImplementation::destroyWorkArea(int id)
|
|
|
|
{
|
|
|
|
work_areas_.erase(id);
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace frontend
|
|
|
|
} // namespace lyx
|