3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
7 * \author Abdelrazak Younes
9 * Full author contact details are available in file CREDITS.
14 #include "QWorkArea.h"
19 #include <QApplication>
22 #include "lcolorcache.h"
30 QScreen::QScreen(QWorkArea & o)
31 : LyXScreen(), owner_(o), nocursor_(0,0)
41 WorkArea & QScreen::workarea() const
46 void QScreen::expose(int x, int y, int w, int h)
48 lyxerr[Debug::GUI] << "expose " << w << 'x' << h
49 << '+' << x << '+' << y << std::endl;
51 owner_.update(x, y, w, h);
54 void QScreen::showCursor(int x, int y, int h, Cursor_Shape shape)
56 if (!qApp->focusWidget())
59 if (x==cursor_x_ && y==cursor_y_ && h==cursor_h_) {
60 // Draw the new (vertical) cursor using the cached store.
61 owner_.drawScreen(cursor_x_, cursor_y_, vcursor_);
65 // Cache the dimensions of the cursor.
75 cursor_w_ = cursor_h_ / 3;
77 case REVERSED_L_SHAPE:
78 cursor_w_ = cursor_h_ / 3;
79 cursor_x_ = x - cursor_w_ + 1;
84 // We cache three pixmaps:
85 // 1 the rectangle of the original screen.
86 // 2 the vertical line of the cursor.
87 // 3 the horizontal line of the L-shaped cursor (if necessary).
89 QColor const & required_color = lcolorcache.get(LColor::cursor);
90 bool const cursor_color_changed = required_color != cursor_color_;
91 if (cursor_color_changed)
92 cursor_color_ = required_color;
94 vcursor_ = QPixmap(cursor_w_, cursor_h_);
95 vcursor_ .fill(cursor_color_);
100 case REVERSED_L_SHAPE:
102 if (cursor_w_ != hcursor_.width() ||
103 cursor_color_changed) {
104 if (cursor_w_ != hcursor_.width())
105 hcursor_ = QPixmap(cursor_w_, 1);
106 hcursor_.fill(cursor_color_);
111 // Save the old area (no cursor).
112 nocursor_ = owner_.copyScreen(cursor_x_, cursor_y_, cursor_w_, cursor_h_);
114 // Draw the new (vertical) cursor using the cached store.
115 owner_.drawScreen(cursor_x_, cursor_y_, vcursor_);
117 // Draw the new (horizontal) cursor if necessary.
121 case REVERSED_L_SHAPE:
123 owner_.drawScreen(cursor_x_, y + h - 1, hcursor_);
129 void QScreen::removeCursor()
131 // before first showCursor
132 if (nocursor_.isNull())
135 owner_.drawScreen(cursor_x_, cursor_y_, nocursor_);