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.
13 // Dear Lord, deliver us from Evil, aka the Qt headers
14 // Qt defines a macro 'signals' that clashes with a boost namespace.
15 // All is well if the namespace is visible first.
17 #include "QWorkArea.h"
20 #include "lcolorcache.h"
22 #include <qapplication.h>
27 /// copy some horizontal regions about inside a pixmap
28 void copyInPixmap(QPixmap * p, int dest_y, int src_y, int src_w, int src_h)
30 // bitBlt(dest, dest_x, dest_y, source, src_x, src_y, src_w, src_h)
31 bitBlt(p, 0, dest_y, p, 0, src_y, src_w, src_h);
39 QScreen::QScreen(QWorkArea & o)
50 void QScreen::repaint()
52 QWidget * content = owner_.getContent();
53 content->repaint(0, 0, content->width(), content->height());
57 void QScreen::expose(int x, int y, int w, int h)
59 lyxerr[Debug::GUI] << "expose " << w << 'x' << h
60 << '+' << x << '+' << y << std::endl;
62 owner_.getContent()->update(x, y, w, h);
66 void QScreen::showCursor(int x, int y, int h, CursorShape shape)
68 if (!qApp->focusWidget())
71 // Cache the dimensions of the cursor.
81 cursor_w_ = cursor_h_ / 3;
83 case REVERSED_L_SHAPE:
84 cursor_w_ = cursor_h_ / 3;
85 cursor_x_ = x - cursor_w_ + 1;
89 // We cache three pixmaps:
90 // 1 the rectangle of the original screen.
91 // 2 the vertical line of the cursor.
92 // 3 the horizontal line of the L-shaped cursor (if necessary).
94 // Initialise storage for these pixmaps as necessary.
95 if (cursor_w_ != nocursor_pixmap_.width() ||
96 cursor_h_ != nocursor_pixmap_.height()) {
97 nocursor_pixmap_.resize(cursor_w_, cursor_h_);
100 QColor const & required_color = lcolorcache.get(LColor::cursor);
101 bool const cursor_color_changed = required_color != cursor_color_;
102 if (cursor_color_changed)
103 cursor_color_ = required_color;
105 if (cursor_h_ != vcursor_pixmap_.height() || cursor_color_changed) {
106 if (cursor_h_ != vcursor_pixmap_.height())
107 vcursor_pixmap_.resize(1, cursor_h_);
108 vcursor_pixmap_.fill(cursor_color_);
114 case REVERSED_L_SHAPE:
116 if (cursor_w_ != hcursor_pixmap_.width() ||
117 cursor_color_changed) {
118 if (cursor_w_ != hcursor_pixmap_.width())
119 hcursor_pixmap_.resize(cursor_w_, 1);
120 hcursor_pixmap_.fill(cursor_color_);
125 // Save the old area (no cursor).
126 bitBlt(&nocursor_pixmap_, 0, 0, owner_.getPixmap(),
127 cursor_x_, cursor_y_, cursor_w_, cursor_h_);
129 // Draw the new (vertical) cursor using the cached store.
130 bitBlt(owner_.getPixmap(), x, y,
131 &vcursor_pixmap_, 0, 0,
132 vcursor_pixmap_.width(), vcursor_pixmap_.height());
134 // Draw the new (horizontal) cursor if necessary.
138 case REVERSED_L_SHAPE:
140 bitBlt(owner_.getPixmap(), cursor_x_, y + h - 1,
141 &hcursor_pixmap_, 0, 0,
142 hcursor_pixmap_.width(), hcursor_pixmap_.height());
146 owner_.getContent()->update(
147 cursor_x_, cursor_y_,
148 cursor_w_, cursor_h_);
152 void QScreen::removeCursor()
154 // before first showCursor
155 if (nocursor_pixmap_.isNull())
158 bitBlt(owner_.getPixmap(), cursor_x_, cursor_y_,
159 &nocursor_pixmap_, 0, 0, cursor_w_, cursor_h_);
162 ->update(cursor_x_, cursor_y_, cursor_w_, cursor_h_);
166 } // namespace frontend