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 #include "QWorkArea.h"
17 #include "lcolorcache.h"
19 #include <qapplication.h>
24 /// copy some horizontal regions about inside a pixmap
25 void copyInPixmap(QPixmap * p, int dest_y, int src_y, int src_w, int src_h)
27 // bitBlt(dest, dest_x, dest_y, source, src_x, src_y, src_w, src_h)
28 bitBlt(p, 0, dest_y, p, 0, src_y, src_w, src_h);
36 QScreen::QScreen(QWorkArea & o)
47 void QScreen::repaint()
49 QWidget * content = owner_.getContent();
50 content->repaint(0, 0, content->width(), content->height());
54 void QScreen::expose(int x, int y, int w, int h)
56 lyxerr[Debug::GUI] << "expose " << w << 'x' << h
57 << '+' << x << '+' << y << std::endl;
59 owner_.getContent()->update(x, y, w, h);
63 void QScreen::showCursor(int x, int y, int h, Cursor_Shape shape)
65 if (!qApp->focusWidget())
68 // Cache the dimensions of the cursor.
78 cursor_w_ = cursor_h_ / 3;
80 case REVERSED_L_SHAPE:
81 cursor_w_ = cursor_h_ / 3;
82 cursor_x_ = x - cursor_w_ + 1;
86 // We cache three pixmaps:
87 // 1 the rectangle of the original screen.
88 // 2 the vertical line of the cursor.
89 // 3 the horizontal line of the L-shaped cursor (if necessary).
91 // Initialise storage for these pixmaps as necessary.
92 if (cursor_w_ != nocursor_pixmap_.width() ||
93 cursor_h_ != nocursor_pixmap_.height()) {
94 nocursor_pixmap_.resize(cursor_w_, cursor_h_);
97 QColor const & required_color = lcolorcache.get(LColor::cursor);
98 bool const cursor_color_changed = required_color != cursor_color_;
99 if (cursor_color_changed)
100 cursor_color_ = required_color;
102 if (cursor_h_ != vcursor_pixmap_.height() || cursor_color_changed) {
103 if (cursor_h_ != vcursor_pixmap_.height())
104 vcursor_pixmap_.resize(1, cursor_h_);
105 vcursor_pixmap_.fill(cursor_color_);
111 case REVERSED_L_SHAPE:
113 if (cursor_w_ != hcursor_pixmap_.width() ||
114 cursor_color_changed) {
115 if (cursor_w_ != hcursor_pixmap_.width())
116 hcursor_pixmap_.resize(cursor_w_, 1);
117 hcursor_pixmap_.fill(cursor_color_);
122 // Save the old area (no cursor).
123 bitBlt(&nocursor_pixmap_, 0, 0, owner_.getPixmap(),
124 cursor_x_, cursor_y_, cursor_w_, cursor_h_);
126 // Draw the new (vertical) cursor using the cached store.
127 bitBlt(owner_.getPixmap(), x, y,
128 &vcursor_pixmap_, 0, 0,
129 vcursor_pixmap_.width(), vcursor_pixmap_.height());
131 // Draw the new (horizontal) cursor if necessary.
135 case REVERSED_L_SHAPE:
137 bitBlt(owner_.getPixmap(), cursor_x_, y + h - 1,
138 &hcursor_pixmap_, 0, 0,
139 hcursor_pixmap_.width(), hcursor_pixmap_.height());
143 owner_.getContent()->update(
144 cursor_x_, cursor_y_,
145 cursor_w_, cursor_h_);
149 void QScreen::removeCursor()
151 // before first showCursor
152 if (nocursor_pixmap_.isNull())
155 bitBlt(owner_.getPixmap(), cursor_x_, cursor_y_,
156 &nocursor_pixmap_, 0, 0, cursor_w_, cursor_h_);
159 ->update(cursor_x_, cursor_y_, cursor_w_, cursor_h_);
163 } // namespace frontend