]> git.lyx.org Git - lyx.git/blob - src/frontends/qt2/QWorkArea.C
Some Qt graphics dialog improvements. Yet more work needed :/
[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         setFocusProxy(content_);
49  
50         content_->show();
51
52         content_->setBackgroundColor(lcolor.getX11Name(LColor::background).c_str());
53
54         QHBoxLayout * vl = new QHBoxLayout(this);
55         vl->addWidget(content_, 5);
56         vl->addWidget(scrollbar_, 0);
57  
58         show();
59 }
60
61
62 QWorkArea::~QWorkArea()
63 {
64 }
65
66
67 void QWorkArea::setScrollbarParams(int h, int pos, int line_h)
68 {
69         // do what cursor movement does (some grey)
70         h += height() / 4;
71  
72         int max = h - height();
73         if (max < 0)
74                 max = 0;
75         scrollbar_->setRange(0, max);
76         scrollbar_->setValue(pos);
77         scrollbar_->setLineStep(line_h);
78         scrollbar_->setPageStep(height());
79 }
80
81
82 void QWorkArea::haveSelection(bool) const
83 {
84         // not possible in Qt !
85 }
86
87  
88 string const QWorkArea::getClipboard() const 
89 {
90         QString str = QApplication::clipboard()->text(); 
91         if (str.isNull())
92                 return string();
93         return str.latin1();
94 }
95
96         
97 void QWorkArea::putClipboard(string const & str) const
98 {
99         QApplication::clipboard()->setText(str.c_str());
100 }