1999-09-27 18:44:28 +00:00
|
|
|
// -*- C++ -*-
|
|
|
|
/* 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
|
2000-02-04 09:38:32 +00:00
|
|
|
* Copyright 1995-2000 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;
|
2000-01-07 03:42:16 +00:00
|
|
|
the_locking_inset = 0;
|
|
|
|
inset_slept = false;
|
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
|
|
|
|
{
|
|
|
|
return pimpl_->screen_;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-06-21 15:07:57 +00:00
|
|
|
WorkArea * BufferView::workarea() const
|
|
|
|
{
|
|
|
|
return pimpl_->workarea_;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void BufferView::gotoError()
|
|
|
|
{
|
2000-04-09 22:48:51 +00:00
|
|
|
pimpl_->gotoError();
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
1999-11-04 01:40:20 +00:00
|
|
|
|
2000-04-14 19:20:33 +00:00
|
|
|
void BufferView::enterView()
|
|
|
|
{
|
|
|
|
pimpl_->enterView();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void BufferView::leaveView()
|
|
|
|
{
|
|
|
|
pimpl_->leaveView();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
// Callback for scrollbar slider
|
2000-02-17 19:59:08 +00:00
|
|
|
void BufferView::scrollCB(double value)
|
2000-02-10 17:53:36 +00:00
|
|
|
{
|
2000-04-09 22:48:51 +00:00
|
|
|
pimpl_->scrollCB(value);
|
2000-02-10 17:53:36 +00:00
|
|
|
}
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
2000-02-17 19:59:08 +00:00
|
|
|
void BufferView::workAreaMotionNotify(int x, int y, unsigned int state)
|
2000-02-10 17:53:36 +00:00
|
|
|
{
|
2000-04-08 17:02:02 +00:00
|
|
|
pimpl_->workAreaMotionNotify(x, y, state);
|
2000-02-10 17:53:36 +00:00
|
|
|
}
|
2000-02-15 14:28:15 +00:00
|
|
|
|
|
|
|
|
2000-04-08 17:02:02 +00:00
|
|
|
/// Single-click on work area
|
2000-02-17 19:59:08 +00:00
|
|
|
void BufferView::workAreaButtonPress(int xpos, int ypos, unsigned int button)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2000-04-08 17:02:02 +00:00
|
|
|
pimpl_->workAreaButtonPress(xpos, ypos, button);
|
2000-02-10 17:53:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-04-08 17:02:02 +00:00
|
|
|
void BufferView::doubleClick(int x, int y, unsigned int button)
|
2000-02-23 16:39:03 +00:00
|
|
|
{
|
2000-04-08 17:02:02 +00:00
|
|
|
pimpl_->doubleClick(x, y, button);
|
2000-02-23 16:39:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-04-08 17:02:02 +00:00
|
|
|
void BufferView::tripleClick(int x, int y, unsigned int button)
|
2000-02-23 16:39:03 +00:00
|
|
|
{
|
2000-04-08 17:02:02 +00:00
|
|
|
pimpl_->tripleClick(x, y, button);
|
2000-02-23 16:39:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-02-17 19:59:08 +00:00
|
|
|
void BufferView::workAreaButtonRelease(int x, int y, unsigned int button)
|
2000-02-10 17:53:36 +00:00
|
|
|
{
|
2000-04-08 17:02:02 +00:00
|
|
|
pimpl_->workAreaButtonRelease(x, y, button);
|
2000-02-10 17:53:36 +00:00
|
|
|
}
|
1999-12-10 00:07:59 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2000-02-10 17:53:36 +00:00
|
|
|
void BufferView::workAreaExpose()
|
|
|
|
{
|
2000-04-08 17:02:02 +00:00
|
|
|
pimpl_->workAreaExpose();
|
2000-02-10 17:53:36 +00:00
|
|
|
}
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
2000-02-10 17:53:36 +00:00
|
|
|
void BufferView::cursorPrevious()
|
|
|
|
{
|
2000-04-09 22:48:51 +00:00
|
|
|
pimpl_->cursorPrevious();
|
2000-02-10 17:53:36 +00:00
|
|
|
}
|
1999-12-10 00:07:59 +00:00
|
|
|
|
|
|
|
|
2000-02-10 17:53:36 +00:00
|
|
|
void BufferView::cursorNext()
|
|
|
|
{
|
2000-04-09 22:48:51 +00:00
|
|
|
pimpl_->cursorNext();
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-01-07 03:42:16 +00:00
|
|
|
void BufferView::beforeChange()
|
|
|
|
{
|
2000-04-09 22:48:51 +00:00
|
|
|
pimpl_->beforeChange();
|
2000-01-07 03:42:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
void BufferView::savePosition()
|
|
|
|
{
|
2000-04-09 22:48:51 +00:00
|
|
|
pimpl_->savePosition();
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void BufferView::restorePosition()
|
|
|
|
{
|
2000-04-09 22:48:51 +00:00
|
|
|
pimpl_->restorePosition();
|
|
|
|
}
|
1999-12-10 00:07:59 +00:00
|
|
|
|
|
|
|
|
2000-06-05 15:12:09 +00:00
|
|
|
bool BufferView::NoSavedPositions()
|
|
|
|
{
|
|
|
|
return pimpl_->NoSavedPositions();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-06-12 11:27:15 +00:00
|
|
|
void BufferView::update(UpdateCodes f)
|
1999-12-10 00:07:59 +00:00
|
|
|
{
|
2000-04-09 22:48:51 +00:00
|
|
|
pimpl_->update(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
|
|
|
{
|
2000-06-12 11:27:15 +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);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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));
|
|
|
|
}
|