2002-06-19 03:38:44 +00:00
|
|
|
/**
|
|
|
|
* \file QWorkArea.C
|
|
|
|
* Copyright 1995-2002 the LyX Team
|
|
|
|
* Read the file COPYING
|
|
|
|
*
|
|
|
|
* \author John Levon <moz@compsoc.man.ac.uk>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma implementation
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "debug.h"
|
|
|
|
#include "LyXView.h"
|
|
|
|
#include "version.h" // lyx_version
|
|
|
|
|
|
|
|
#include "support/filetools.h" // LibFileSearch
|
|
|
|
#include "support/lstrings.h"
|
|
|
|
#include "support/LAssert.h"
|
|
|
|
|
|
|
|
#include <cmath>
|
|
|
|
#include <cctype>
|
|
|
|
|
|
|
|
#include "QWorkArea.h"
|
|
|
|
|
|
|
|
#include <qapplication.h>
|
|
|
|
#include <qevent.h>
|
|
|
|
#include <qpainter.h>
|
|
|
|
#include <qmainwindow.h>
|
|
|
|
#include <qlayout.h>
|
2002-07-12 01:48:53 +00:00
|
|
|
#include <qclipboard.h>
|
2002-06-19 03:38:44 +00:00
|
|
|
|
|
|
|
using std::endl;
|
|
|
|
using std::abs;
|
|
|
|
using std::hex;
|
|
|
|
|
|
|
|
|
|
|
|
QWorkArea::QWorkArea(int, int, int, int)
|
|
|
|
: WorkArea(), QWidget(qApp->mainWidget()), painter_(*this)
|
|
|
|
{
|
|
|
|
scrollbar_ = new QScrollBar(QScrollBar::Vertical, this);
|
|
|
|
content_ = new QContentPane(this);
|
|
|
|
|
|
|
|
(static_cast<QMainWindow*>(qApp->mainWidget()))->setCentralWidget(this);
|
|
|
|
|
|
|
|
content_->show();
|
|
|
|
|
|
|
|
content_->setBackgroundColor(lcolor.getX11Name(LColor::background).c_str());
|
|
|
|
|
|
|
|
QHBoxLayout * vl = new QHBoxLayout(this);
|
|
|
|
vl->addWidget(content_, 5);
|
|
|
|
vl->addWidget(scrollbar_, 0);
|
|
|
|
|
|
|
|
show();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
QWorkArea::~QWorkArea()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void QWorkArea::setScrollbarParams(int h, int pos, int line_h)
|
|
|
|
{
|
|
|
|
// do what cursor movement does (some grey)
|
|
|
|
h += height() / 4;
|
|
|
|
|
|
|
|
int max = h - height();
|
|
|
|
if (max < 0)
|
|
|
|
max = 0;
|
|
|
|
scrollbar_->setRange(0, max);
|
|
|
|
scrollbar_->setValue(pos);
|
|
|
|
scrollbar_->setLineStep(line_h);
|
|
|
|
scrollbar_->setPageStep(height());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-07-12 01:48:53 +00:00
|
|
|
void QWorkArea::haveSelection(bool) const
|
2002-06-19 03:38:44 +00:00
|
|
|
{
|
2002-07-12 01:48:53 +00:00
|
|
|
// not possible in Qt !
|
2002-06-19 03:38:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
string const QWorkArea::getClipboard() const
|
|
|
|
{
|
2002-07-12 01:48:53 +00:00
|
|
|
QString str = QApplication::clipboard()->text();
|
|
|
|
if (str.isNull())
|
|
|
|
return string();
|
|
|
|
return str.latin1();
|
2002-06-19 03:38:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-07-12 01:48:53 +00:00
|
|
|
void QWorkArea::putClipboard(string const & str) const
|
2002-06-19 03:38:44 +00:00
|
|
|
{
|
2002-07-12 01:48:53 +00:00
|
|
|
QApplication::clipboard()->setText(str.c_str());
|
2002-06-19 03:38:44 +00:00
|
|
|
}
|