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