]> git.lyx.org Git - lyx.git/blob - src/frontends/qt2/QWorkArea.C
Lots and lots of little trivial bits.
[lyx.git] / src / frontends / qt2 / QWorkArea.C
1 /**
2  * \file QWorkArea.C
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author John Levon 
7  *
8  * Full author contact details are available in file CREDITS
9  */
10
11 #include <config.h>
12
13 #ifdef __GNUG__
14 #pragma implementation
15 #endif
16
17 #include "debug.h"
18 #include "LyXView.h"
19 #include "version.h" // lyx_version
20
21 #include "support/filetools.h" // LibFileSearch
22 #include "support/lstrings.h"
23 #include "support/LAssert.h"
24
25 #include <cmath>
26 #include <cctype>
27
28 #include "QWorkArea.h"
29  
30 #include <qapplication.h>
31 #include <qevent.h> 
32 #include <qpainter.h>
33 #include <qmainwindow.h>
34 #include <qlayout.h>
35 #include <qclipboard.h>
36  
37 using std::endl;
38 using std::abs;
39 using std::hex;
40
41  
42 QWorkArea::QWorkArea(int, int, int, int)
43         : WorkArea(), QWidget(qApp->mainWidget()), painter_(*this)
44 {
45         scrollbar_ = new QScrollBar(QScrollBar::Vertical, this);
46         content_ = new QContentPane(this);
47
48         (static_cast<QMainWindow*>(qApp->mainWidget()))->setCentralWidget(this);
49  
50         setFocusProxy(content_);
51  
52         content_->show();
53
54         content_->setBackgroundColor(lcolor.getX11Name(LColor::background).c_str());
55
56         QHBoxLayout * vl = new QHBoxLayout(this);
57         vl->addWidget(content_, 5);
58         vl->addWidget(scrollbar_, 0);
59  
60         show();
61 }
62
63
64 QWorkArea::~QWorkArea()
65 {
66 }
67
68
69 void QWorkArea::setScrollbarParams(int h, int pos, int line_h)
70 {
71         // do what cursor movement does (some grey)
72         h += height() / 4;
73  
74         int max = h - height();
75         if (max < 0)
76                 max = 0;
77         scrollbar_->setRange(0, max);
78         scrollbar_->setValue(pos);
79         scrollbar_->setLineStep(line_h);
80         scrollbar_->setPageStep(height());
81 }
82
83
84 void QWorkArea::haveSelection(bool) const
85 {
86         // not possible in Qt !
87 }
88
89  
90 string const QWorkArea::getClipboard() const 
91 {
92         QString str = QApplication::clipboard()->text(); 
93         if (str.isNull())
94                 return string();
95         return str.latin1();
96 }
97
98         
99 void QWorkArea::putClipboard(string const & str) const
100 {
101         QApplication::clipboard()->setText(str.c_str());
102 }