Extracted from r14281 from the younes branch.

* BufferView,BufferView::Pimple:
	-  workArea_ removed
* frontends/LyXView:
	- now contains a pointer reference to the current
	  WorkArea instead of the BufferView.
        - workArea(): temporary access method
* frontends/WorkArea:
	- bufferView(): new access methods.

* GuiImplementation: updated due to above changes


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@14329 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Lars Gullik Bjønnes 2006-07-03 22:31:51 +00:00
parent 48a5df5ffe
commit b1a87cc778
11 changed files with 56 additions and 39 deletions

View File

@ -43,7 +43,6 @@
#include "frontends/Dialogs.h"
#include "frontends/LyXView.h"
#include "frontends/Gui.h"
#include "frontends/WorkArea.h"
#include "insets/insetcommand.h" // ChangeRefs
#include "insets/insettext.h"
@ -62,8 +61,8 @@ using std::vector;
extern BufferList bufferlist;
BufferView::BufferView(LyXView * owner, lyx::frontend::WorkArea * workArea)
: pimpl_(new Pimpl(*this, owner, workArea))
BufferView::BufferView(LyXView * owner)
: pimpl_(new Pimpl(*this, owner))
{}

View File

@ -38,7 +38,6 @@ class ParIterator;
namespace lyx {
namespace frontend {
class Painter;
class WorkArea;
}
}
@ -94,7 +93,7 @@ public:
* Create a view with the given owner main window,
* of the given dimensions.
*/
BufferView(LyXView * owner, lyx::frontend::WorkArea * workArea);
BufferView(LyXView * owner);
~BufferView();

View File

@ -137,9 +137,9 @@ T * getInsetByCode(LCursor & cur, InsetBase::Code code)
} // anon namespace
BufferView::Pimpl::Pimpl(BufferView & bv, LyXView * owner, WorkArea * workArea)
: bv_(&bv), owner_(owner), buffer_(0), wh_(0), cursor_timeout(400),
using_xterm_cursor(false), workArea_(workArea), cursor_(bv),
BufferView::Pimpl::Pimpl(BufferView & bv, LyXView * owner)
: bv_(&bv), owner_(owner), buffer_(0), wh_(0), cursor_timeout(400),
using_xterm_cursor(false), cursor_(bv),
multiparsel_cache_(false), anchor_ref_(0), offset_ref_(0)
{
xsel_cache_.set = false;
@ -149,7 +149,7 @@ BufferView::Pimpl::Pimpl(BufferView & bv, LyXView * owner, WorkArea * workArea)
.connect(boost::bind(&BufferView::Pimpl::cursorToggle, this));
cursor_timeout.start();
saved_positions.resize(saved_positions_num);
// load saved bookmarks
lyx::Session::BookmarkList & bmList = LyX::ref().session().loadBookmarks();
@ -321,7 +321,7 @@ lyx::frontend::Gui & BufferView::Pimpl::gui() const
lyx::frontend::Painter & BufferView::Pimpl::painter() const
{
return workArea_->getPainter();
return owner_->workArea()->getPainter();
}
@ -724,14 +724,14 @@ void BufferView::Pimpl::update(Update::flags flags)
}
if (forceupdate) {
// Second drawing step
workArea_->redraw(*bv_, vi);
owner_->workArea()->redraw(*bv_, vi);
} else {
// Abort updating of the coord
// cache - just restore the old one
std::swap(theCoords, backup);
}
} else
workArea_->greyOut();
owner_->workArea()->greyOut();
owner_->view_state_changed();
}
@ -1249,7 +1249,7 @@ bool BufferView::Pimpl::dispatch(FuncRequest const & cmd)
case LFUN_OUTLINE_IN:
lyx::toc::outline(lyx::toc::In, cursor_);
updateLabels(*buffer_);
break;
break;
case LFUN_OUTLINE_OUT:
lyx::toc::outline(lyx::toc::Out, cursor_);
updateLabels(*buffer_);

View File

@ -39,7 +39,6 @@ class ViewMetricsInfo;
namespace lyx {
namespace frontend {
class Gui;
class WorkArea;
class Painter;
}
}
@ -49,7 +48,7 @@ class Painter;
class BufferView::Pimpl : public boost::signals::trackable {
public:
///
Pimpl(BufferView & bv, LyXView * owner, lyx::frontend::WorkArea * workArea);
Pimpl(BufferView & bv, LyXView * owner);
///
lyx::frontend::Painter & painter() const;
///
@ -193,8 +192,6 @@ private:
///
void menuInsertLyXFile(std::string const & filen);
lyx::frontend::WorkArea * workArea_;
/// this is used to handle XSelection events in the right manner
struct {
CursorSlice cursor;

View File

@ -17,6 +17,7 @@
#include "Timeout.h"
#include "Toolbars.h"
#include "Menubar.h"
#include "WorkArea.h"
#include "buffer.h"
#include "bufferparams.h"
@ -48,6 +49,7 @@
#endif
using lyx::frontend::Gui;
using lyx::frontend::WorkArea;
using lyx::support::makeDisplayPath;
using lyx::support::onlyFilename;
@ -64,6 +66,7 @@ Gui & LyXView::gui()
return owner_;
}
LyXView::LyXView(Gui & owner)
: owner_(owner),
toolbars_(new Toolbars(*this)),
@ -72,14 +75,15 @@ LyXView::LyXView(Gui & owner)
lyxfunc_(new LyXFunc(this)),
dialogs_(new Dialogs(*this)),
controlcommand_(new ControlCommandBuffer(*this)),
bufferview_(0)
work_area_(0)
{
lyxerr[Debug::INIT] << "Initializing LyXFunc" << endl;
}
void LyXView::setBufferView(BufferView * buffer_view)
void LyXView::setWorkArea(WorkArea * work_area)
{
bufferview_ = buffer_view;
work_area_ = work_area;
}
@ -106,13 +110,13 @@ void LyXView::init()
Buffer * LyXView::buffer() const
{
return bufferview_->buffer();
return work_area_->bufferView().buffer();
}
BufferView * LyXView::view() const
{
return bufferview_;
return &work_area_->bufferView();
}
@ -124,7 +128,7 @@ void LyXView::setLayout(string const & layout)
void LyXView::updateToolbars()
{
bool const math = bufferview_->cursor().inMathed();
bool const math = work_area_->bufferView().cursor().inMathed();
bool const table =
getLyXFunc().getStatus(FuncRequest(LFUN_LAYOUT_TABULAR)).enabled();
toolbars_->update(math, table);
@ -171,11 +175,11 @@ void LyXView::updateLayoutChoice()
current_layout = buffer()->params().getLyXTextClass().defaultLayoutName();
}
if (bufferview_->cursor().inMathed())
if (work_area_->bufferView().cursor().inMathed())
return;
string const & layout =
bufferview_->cursor().paragraph().layout()->name();
work_area_->bufferView().cursor().paragraph().layout()->name();
if (layout != current_layout) {
toolbars_->setLayout(layout);
@ -221,9 +225,9 @@ Buffer const * const LyXView::updateInset(InsetBase const * inset) const
{
Buffer const * buffer_ptr = 0;
if (inset) {
buffer_ptr = bufferview_->buffer();
buffer_ptr = work_area_->bufferView().buffer();
// No FitCursor:
bufferview_->update(Update::Force);
work_area_->bufferView().update(Update::Force);
}
return buffer_ptr;
}

View File

@ -35,6 +35,7 @@ class FuncRequest;
namespace lyx {
namespace frontend {
class Gui;
class WorkArea;
class ControlCommandBuffer;
} // namespace frontend
@ -60,8 +61,7 @@ public:
virtual ~LyXView();
void setBufferView(BufferView * buffer_view);
void setWorkArea(lyx::frontend::WorkArea * work_area);
/**
* This is called after the concrete view has been created.
* We have to have the toolbar and the other stuff created
@ -152,12 +152,13 @@ public:
///
virtual lyx::frontend::Gui & gui();
lyx::frontend::WorkArea * workArea() const { return work_area_; }
protected:
/// current bufferview (view of a buffer).
/// current work area (screen view of a BufferView).
/**
\todo FIXME: this should be moved out of LyXView.
\todo FIXME: there is only one workArea per LyXView for now.
*/
BufferView * bufferview_;
lyx::frontend::WorkArea * work_area_;
/// view's menubar
boost::scoped_ptr<Menubar> menubar_;

View File

@ -136,6 +136,18 @@ void WorkArea::setBufferView(BufferView * buffer_view)
}
BufferView & WorkArea::bufferView()
{
return *buffer_view_;
}
BufferView const & WorkArea::bufferView() const
{
return *buffer_view_;
}
void WorkArea::checkAndGreyOut()
{
if (greyed_out_)

View File

@ -42,6 +42,11 @@ public:
void setBufferView(BufferView * buffer_view);
///
BufferView & bufferView();
///
BufferView const & bufferView() const;
/// return the painter object for this work area
virtual Painter & getPainter() = 0;

View File

@ -31,11 +31,11 @@ int GuiImplementation::newWorkArea(unsigned int w, unsigned int h, int /*view_id
work_area_.reset(new GuiWorkArea(old_screen_.get(), old_work_area_.get()));
clipboard_.reset(new GuiClipboard(old_work_area_.get()));
guiCursor().connect(work_area_.get());
// FIXME BufferView creation should be independant of WorkArea creation
buffer_views_[0].reset(new BufferView(view_.get(), work_area_.get()));
buffer_views_[0].reset(new BufferView(view_.get()));
work_area_->setBufferView(buffer_views_[0].get());
view_->setBufferView(buffer_views_[0].get());
view_->setWorkArea(work_area_.get());
return 0;
}

View File

@ -78,9 +78,9 @@ public:
guiCursor().connect(work_area_.get());
// FIXME BufferView creation should be independant of WorkArea creation
buffer_views_[0].reset(new BufferView(view_.get(), work_area_.get()));
buffer_views_[0].reset(new BufferView(view_.get()));
work_area_->setBufferView(buffer_views_[0].get());
view_->setBufferView(buffer_views_[0].get());
view_->setWorkArea(work_area_.get());
return 0;
}

View File

@ -70,9 +70,9 @@ int GuiImplementation::newWorkArea(unsigned int w, unsigned int h, int view_id)
work_areas_[id].reset(new GuiWorkArea(w, h, view));
// FIXME BufferView creation should be independant of WorkArea creation
buffer_views_[id].reset(new BufferView(view, work_areas_[id].get()));
buffer_views_[id].reset(new BufferView(view));
work_areas_[id]->setBufferView(buffer_views_[id].get());
view->setBufferView(buffer_views_[id].get());
view->setWorkArea(work_areas_[id].get());
view->mainWidget()->setCentralWidget(work_areas_[id].get());