3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
8 * Full author contact details are available in file CREDITS
14 #pragma implementation
19 #include "version.h" // lyx_version
21 #include "support/filetools.h" // LibFileSearch
22 #include "support/lstrings.h"
23 #include "support/LAssert.h"
25 #include "QWorkArea.h"
27 #include <qapplication.h>
30 #include <qmainwindow.h>
32 #include <qclipboard.h>
46 QWorkArea::QWorkArea(int, int, int, int)
47 : WorkArea(), QWidget(qApp->mainWidget()), painter_(*this)
49 scrollbar_ = new QScrollBar(QScrollBar::Vertical, this);
50 content_ = new QContentPane(this);
52 (static_cast<QMainWindow*>(qApp->mainWidget()))->setCentralWidget(this);
54 setFocusProxy(content_);
58 content_->setBackgroundColor(lcolor.getX11Name(LColor::background).c_str());
60 QHBoxLayout * vl = new QHBoxLayout(this);
61 vl->addWidget(content_, 5);
62 vl->addWidget(scrollbar_, 0);
68 QWorkArea::~QWorkArea()
73 void QWorkArea::setScrollbarParams(int h, int pos, int line_h)
75 // do what cursor movement does (some grey)
78 int max = std::max(0, h - height());
80 scrollbar_->setRange(0, max);
81 scrollbar_->setValue(pos);
82 scrollbar_->setLineStep(line_h);
83 scrollbar_->setPageStep(height());
87 QWorkArea const * wa_ptr = 0;
91 bool lyxX11EventFilter(XEvent * xev)
94 case SelectionRequest:
95 lyxerr[Debug::GUI] << "X requested selection." << endl;
97 wa_ptr->selectionRequested();
100 lyxerr[Debug::GUI] << "Lost selection." << endl;
102 wa_ptr->selectionLost();
109 void QWorkArea::haveSelection(bool own) const
113 #if QT_VERSION >= 300
114 if (!QApplication::clipboard()->supportsSelection())
118 QApplication::clipboard()->setSelectionMode(true);
119 QApplication::clipboard()->setText(QString());
121 // We don't need to do anything if own = false, as this case is
127 string const QWorkArea::getClipboard() const
129 #if QT_VERSION >= 300
130 QApplication::clipboard()->setSelectionMode(true);
132 QString str = QApplication::clipboard()->text();
139 void QWorkArea::putClipboard(string const & str) const
141 #if QT_VERSION >= 300
142 QApplication::clipboard()->setSelectionMode(true);
144 QApplication::clipboard()->setText(str.c_str());