1999-09-27 18:44:28 +00:00
|
|
|
/* This file is part of
|
1999-11-15 12:01:38 +00:00
|
|
|
* ======================================================
|
1999-10-02 16:21:10 +00:00
|
|
|
*
|
|
|
|
* LyX, The Document Processor
|
|
|
|
*
|
|
|
|
* Copyright 1995 Matthias Ettrich
|
2001-05-30 13:53:44 +00:00
|
|
|
* Copyright 1995-2001 The LyX Team.
|
1999-10-02 16:21:10 +00:00
|
|
|
*
|
1999-11-15 12:01:38 +00:00
|
|
|
* ====================================================== */
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma implementation
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "BufferView.h"
|
2000-04-08 17:02:02 +00:00
|
|
|
#include "BufferView_pimpl.h"
|
2000-04-09 22:48:51 +00:00
|
|
|
#include "lyxtext.h"
|
2000-06-12 11:27:15 +00:00
|
|
|
#include "WorkArea.h"
|
2000-06-19 15:33:58 +00:00
|
|
|
#include "lyxscreen.h"
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
1999-12-13 00:05:34 +00:00
|
|
|
BufferView::BufferView(LyXView * o, int xpos, int ypos,
|
1999-09-27 18:44:28 +00:00
|
|
|
int width, int height)
|
2000-04-08 17:02:02 +00:00
|
|
|
: pimpl_(new Pimpl(this, o, xpos, ypos, width, height))
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
1999-12-10 00:07:59 +00:00
|
|
|
text = 0;
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-12-10 00:07:59 +00:00
|
|
|
BufferView::~BufferView()
|
|
|
|
{
|
|
|
|
delete text;
|
2000-04-08 17:02:02 +00:00
|
|
|
delete pimpl_;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Buffer * BufferView::buffer() const
|
|
|
|
{
|
|
|
|
return pimpl_->buffer_;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-06-19 15:33:58 +00:00
|
|
|
LyXScreen * BufferView::screen() const
|
|
|
|
{
|
2001-03-06 19:29:58 +00:00
|
|
|
return pimpl_->screen_.get();
|
2000-06-19 15:33:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-04-08 17:02:02 +00:00
|
|
|
LyXView * BufferView::owner() const
|
|
|
|
{
|
|
|
|
return pimpl_->owner_;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void BufferView::pushIntoUpdateList(Inset * i)
|
|
|
|
{
|
|
|
|
pimpl_->updatelist.push(i);
|
1999-12-10 00:07:59 +00:00
|
|
|
}
|
|
|
|
|
2000-02-10 17:53:36 +00:00
|
|
|
|
|
|
|
Painter & BufferView::painter()
|
|
|
|
{
|
2000-04-09 22:48:51 +00:00
|
|
|
return pimpl_->painter();
|
2000-02-10 17:53:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-12-13 00:05:34 +00:00
|
|
|
void BufferView::buffer(Buffer * b)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2000-04-09 22:48:51 +00:00
|
|
|
pimpl_->buffer(b);
|
2000-02-10 17:53:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void BufferView::resize(int xpos, int ypos, int width, int height)
|
|
|
|
{
|
2000-04-09 22:48:51 +00:00
|
|
|
pimpl_->resize(xpos, ypos, width, height);
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void BufferView::resize()
|
|
|
|
{
|
2000-04-09 22:48:51 +00:00
|
|
|
pimpl_->resize();
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void BufferView::redraw()
|
|
|
|
{
|
2000-04-09 22:48:51 +00:00
|
|
|
pimpl_->redraw();
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-09-28 14:05:24 +00:00
|
|
|
void BufferView::fitCursor(LyXText * text)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2000-09-28 14:05:24 +00:00
|
|
|
pimpl_->fitCursor(text);
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void BufferView::update()
|
|
|
|
{
|
2000-04-09 22:48:51 +00:00
|
|
|
pimpl_->update();
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void BufferView::updateScrollbar()
|
|
|
|
{
|
2000-04-09 22:48:51 +00:00
|
|
|
pimpl_->updateScrollbar();
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-02-19 16:01:31 +00:00
|
|
|
void BufferView::scrollCB(double value)
|
|
|
|
{
|
|
|
|
pimpl_->scrollCB(value);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-07-04 11:30:07 +00:00
|
|
|
Inset * BufferView::checkInsetHit(LyXText * text, int & x, int & y,
|
|
|
|
unsigned int button)
|
|
|
|
{
|
|
|
|
return pimpl_->checkInsetHit(text, x, y, button);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
void BufferView::redoCurrentBuffer()
|
|
|
|
{
|
2000-04-09 22:48:51 +00:00
|
|
|
pimpl_->redoCurrentBuffer();
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int BufferView::resizeCurrentBuffer()
|
|
|
|
{
|
2000-04-09 22:48:51 +00:00
|
|
|
return pimpl_->resizeCurrentBuffer();
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-10-10 10:38:11 +00:00
|
|
|
void BufferView::cursorPrevious(LyXText * text)
|
2000-02-10 17:53:36 +00:00
|
|
|
{
|
2000-10-10 10:38:11 +00:00
|
|
|
pimpl_->cursorPrevious(text);
|
2000-02-10 17:53:36 +00:00
|
|
|
}
|
1999-12-10 00:07:59 +00:00
|
|
|
|
|
|
|
|
2000-10-10 10:38:11 +00:00
|
|
|
void BufferView::cursorNext(LyXText * text)
|
2000-02-10 17:53:36 +00:00
|
|
|
{
|
2000-10-10 10:38:11 +00:00
|
|
|
pimpl_->cursorNext(text);
|
2000-02-10 17:53:36 +00:00
|
|
|
}
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
|
|
|
bool BufferView::available() const
|
|
|
|
{
|
2000-04-09 22:48:51 +00:00
|
|
|
return pimpl_->available();
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-02-14 10:11:22 +00:00
|
|
|
void BufferView::beforeChange(LyXText * text)
|
2000-01-07 03:42:16 +00:00
|
|
|
{
|
2001-02-14 10:11:22 +00:00
|
|
|
pimpl_->beforeChange(text);
|
2000-01-07 03:42:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-01-28 18:31:36 +00:00
|
|
|
void BufferView::savePosition(unsigned int i)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2001-01-28 18:31:36 +00:00
|
|
|
pimpl_->savePosition(i);
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-01-28 18:31:36 +00:00
|
|
|
void BufferView::restorePosition(unsigned int i)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2001-01-28 18:31:36 +00:00
|
|
|
pimpl_->restorePosition(i);
|
2000-04-09 22:48:51 +00:00
|
|
|
}
|
1999-12-10 00:07:59 +00:00
|
|
|
|
|
|
|
|
2001-01-28 18:31:36 +00:00
|
|
|
bool BufferView::isSavedPosition(unsigned int i)
|
2000-06-05 15:12:09 +00:00
|
|
|
{
|
2001-01-28 18:31:36 +00:00
|
|
|
return pimpl_->isSavedPosition(i);
|
2000-06-05 15:12:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-02-14 08:38:21 +00:00
|
|
|
void BufferView::update(LyXText * text, UpdateCodes f)
|
1999-12-10 00:07:59 +00:00
|
|
|
{
|
2001-02-14 08:38:21 +00:00
|
|
|
pimpl_->update(text, f);
|
1999-12-10 00:07:59 +00:00
|
|
|
}
|
2000-01-06 02:44:26 +00:00
|
|
|
|
|
|
|
|
2000-02-17 19:59:08 +00:00
|
|
|
void BufferView::setState()
|
2000-02-04 09:38:32 +00:00
|
|
|
{
|
2000-04-09 22:48:51 +00:00
|
|
|
pimpl_->setState();
|
2000-02-03 19:51:27 +00:00
|
|
|
}
|
2000-01-07 03:42:16 +00:00
|
|
|
|
2000-02-04 09:38:32 +00:00
|
|
|
|
2000-01-07 03:42:16 +00:00
|
|
|
void BufferView::insetSleep()
|
|
|
|
{
|
2000-04-09 22:48:51 +00:00
|
|
|
pimpl_->insetSleep();
|
2000-01-07 03:42:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void BufferView::insetWakeup()
|
|
|
|
{
|
2000-04-09 22:48:51 +00:00
|
|
|
pimpl_->insetWakeup();
|
2000-01-07 03:42:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void BufferView::insetUnlock()
|
|
|
|
{
|
2000-04-09 22:48:51 +00:00
|
|
|
pimpl_->insetUnlock();
|
2000-01-07 03:42:16 +00:00
|
|
|
}
|
2000-02-10 17:53:36 +00:00
|
|
|
|
|
|
|
|
|
|
|
bool BufferView::focus() const
|
|
|
|
{
|
2000-04-09 22:48:51 +00:00
|
|
|
return pimpl_->focus();
|
2000-02-10 17:53:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void BufferView::focus(bool f)
|
|
|
|
{
|
2000-04-09 22:48:51 +00:00
|
|
|
pimpl_->focus(f);
|
2000-02-10 17:53:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool BufferView::active() const
|
|
|
|
{
|
2000-04-09 22:48:51 +00:00
|
|
|
return pimpl_->active();
|
2000-02-25 12:06:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-06-12 11:27:15 +00:00
|
|
|
int BufferView::workWidth() const
|
2000-02-25 12:06:15 +00:00
|
|
|
{
|
2001-03-06 19:29:58 +00:00
|
|
|
return pimpl_->workarea_.workWidth();
|
2000-02-25 12:06:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-02-23 16:39:03 +00:00
|
|
|
bool BufferView::belowMouse() const
|
|
|
|
{
|
2000-04-09 22:48:51 +00:00
|
|
|
return pimpl_->belowMouse();
|
2000-02-23 16:39:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-02-17 19:59:08 +00:00
|
|
|
void BufferView::showCursor()
|
|
|
|
{
|
2000-04-09 22:48:51 +00:00
|
|
|
pimpl_->showCursor();
|
2000-02-17 19:59:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void BufferView::hideCursor()
|
|
|
|
{
|
2000-04-09 22:48:51 +00:00
|
|
|
pimpl_->hideCursor();
|
2000-02-17 19:59:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void BufferView::toggleSelection(bool b)
|
|
|
|
{
|
2000-04-09 22:48:51 +00:00
|
|
|
pimpl_->toggleSelection(b);
|
2000-02-17 19:59:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void BufferView::toggleToggle()
|
|
|
|
{
|
2000-04-09 22:48:51 +00:00
|
|
|
pimpl_->toggleToggle();
|
2000-02-17 19:59:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void BufferView::center()
|
|
|
|
{
|
2000-04-09 22:48:51 +00:00
|
|
|
pimpl_->center();
|
2000-02-17 19:59:08 +00:00
|
|
|
}
|
2000-05-20 01:38:25 +00:00
|
|
|
|
|
|
|
|
2000-05-20 21:37:05 +00:00
|
|
|
void BufferView::pasteClipboard(bool asPara)
|
2000-05-20 01:38:25 +00:00
|
|
|
{
|
2000-05-20 21:37:05 +00:00
|
|
|
pimpl_->pasteClipboard(asPara);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-05-03 15:38:24 +00:00
|
|
|
string const BufferView::getClipboard() const
|
|
|
|
{
|
|
|
|
return pimpl_->workarea_.getClipboard();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-05-20 21:37:05 +00:00
|
|
|
void BufferView::stuffClipboard(string const & stuff) const
|
|
|
|
{
|
|
|
|
pimpl_->stuffClipboard(stuff);
|
2000-05-20 01:38:25 +00:00
|
|
|
}
|
2000-06-12 11:27:15 +00:00
|
|
|
|
|
|
|
|
|
|
|
BufferView::UpdateCodes operator|(BufferView::UpdateCodes uc1,
|
|
|
|
BufferView::UpdateCodes uc2)
|
|
|
|
{
|
|
|
|
return static_cast<BufferView::UpdateCodes>
|
|
|
|
(static_cast<int>(uc1) | static_cast<int>(uc2));
|
|
|
|
}
|
2001-02-23 16:10:03 +00:00
|
|
|
|
|
|
|
bool BufferView::Dispatch(kb_action action, string const & argument)
|
|
|
|
{
|
2001-04-17 13:43:57 +00:00
|
|
|
return pimpl_->Dispatch(action, argument);
|
2001-02-23 16:10:03 +00:00
|
|
|
}
|