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"
|
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_;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void BufferView::fitCursor()
|
|
|
|
{
|
2000-04-09 22:48:51 +00:00
|
|
|
pimpl_->fitCursor();
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
1999-12-13 00:05:34 +00:00
|
|
|
extern "C" {
|
|
|
|
void C_BufferView_CursorToggleCB(FL_OBJECT * ob, long buf)
|
|
|
|
{
|
2000-02-17 19:59:08 +00:00
|
|
|
BufferView::cursorToggleCB(ob, buf);
|
1999-12-13 00:05:34 +00:00
|
|
|
}
|
1999-10-25 14:18:30 +00:00
|
|
|
}
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
// Callback for scrollbar up button
|
2000-02-17 19:59:08 +00:00
|
|
|
void BufferView::upCB(long time, int button)
|
2000-02-10 17:53:36 +00:00
|
|
|
{
|
2000-04-08 17:02:02 +00:00
|
|
|
if (pimpl_->buffer_ == 0) return;
|
2000-02-10 17:53:36 +00:00
|
|
|
|
|
|
|
switch (button) {
|
|
|
|
case 3:
|
2000-04-08 17:02:02 +00:00
|
|
|
pimpl_->scrollUpOnePage();
|
2000-02-10 17:53:36 +00:00
|
|
|
break;
|
|
|
|
case 2:
|
2000-04-08 17:02:02 +00:00
|
|
|
pimpl_->scrollDownOnePage();
|
2000-02-10 17:53:36 +00:00
|
|
|
break;
|
|
|
|
default:
|
2000-04-08 17:02:02 +00:00
|
|
|
pimpl_->scrollUp(time);
|
2000-02-10 17:53:36 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
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
|
|
|
|
|
|
|
|
|
|
|
// Callback for scrollbar down button
|
2000-02-17 19:59:08 +00:00
|
|
|
void BufferView::downCB(long time, int button)
|
2000-02-10 17:53:36 +00:00
|
|
|
{
|
2000-04-09 22:48:51 +00:00
|
|
|
pimpl_->downCB(time, button);
|
2000-02-10 17:53:36 +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
|
|
|
|
|
|
|
|
|
|
|
extern int bibitemMaxWidth(Painter &, LyXFont const &);
|
2000-02-17 19:59:08 +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-04-09 22:48:51 +00:00
|
|
|
// // Callback for cursor timer
|
|
|
|
void BufferView::cursorToggleCB(FL_OBJECT * ob, long )
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
1999-12-16 06:43:25 +00:00
|
|
|
BufferView * view = static_cast<BufferView*>(ob->u_vdata);
|
2000-04-09 22:48:51 +00:00
|
|
|
view->pimpl_->cursorToggle();
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-02-17 19:59:08 +00:00
|
|
|
void BufferView::workAreaSelectionNotify(Window win, XEvent * event)
|
2000-02-10 17:53:36 +00:00
|
|
|
{
|
2000-04-08 17:02:02 +00:00
|
|
|
pimpl_->workAreaSelectionNotify(win, event);
|
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
|
|
|
|
|
|
|
|
|
|
|
void BufferView::update(signed char f)
|
|
|
|
{
|
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
|
|
|
|
|
|
|
|
|
|
|
void BufferView::smallUpdate(signed char f)
|
|
|
|
{
|
2000-04-09 22:48:51 +00:00
|
|
|
pimpl_->smallUpdate(f);
|
2000-01-06 02:44:26 +00:00
|
|
|
}
|
2000-01-07 03:42:16 +00:00
|
|
|
|
2000-02-03 19:51:27 +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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
unsigned short BufferView::paperWidth() const
|
|
|
|
{
|
|
|
|
return text->paperWidth();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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
|
|
|
}
|