3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
9 * Full author contact details are available in file CREDITS.
16 #include "ColorHandler.h"
17 #include "XWorkArea.h"
32 val.foreground = BlackPixel(fl_get_display(),
33 DefaultScreen(fl_get_display()));
35 val.function = GXcopy;
36 val.graphics_exposures = false;
37 val.line_style = LineSolid;
39 return XCreateGC(fl_get_display(), RootWindow(fl_get_display(), 0),
40 GCForeground | GCFunction | GCGraphicsExposures
41 | GCLineWidth | GCLineStyle, &val);
47 XScreen::XScreen(XWorkArea & o)
48 : owner_(o), nocursor_pixmap_(0),
49 cursor_x_(0), cursor_y_(0), cursor_w_(0), cursor_h_(0)
58 XFreeGC(fl_get_display(), gc_copy);
62 void XScreen::setCursorColor()
64 if (!lyxColorHandler.get())
67 GC gc = lyxColorHandler->getGCForeground(LColor::cursor);
70 XGetGCValues(fl_get_display(),
71 gc, GCForeground, &val);
72 XChangeGC(fl_get_display(), gc_copy, GCForeground, &val);
76 void XScreen::showCursor(int x, int y, int h, Cursor_Shape shape)
78 // Update the cursor color. (a little slow doing it like this ??)
90 cursor_w_ = cursor_h_ / 3;
92 case REVERSED_L_SHAPE:
93 cursor_w_ = cursor_h_ / 3;
94 cursor_x_ = x - cursor_w_ + 1;
98 if (nocursor_pixmap_) {
99 XFreePixmap(fl_get_display(), nocursor_pixmap_);
100 nocursor_pixmap_ = 0;
102 nocursor_pixmap_ = XCreatePixmap(fl_get_display(),
103 fl_root, cursor_w_, cursor_h_, fl_get_visual_depth());
106 XCopyArea(fl_get_display(),
107 owner_.getWin(), nocursor_pixmap_, gc_copy,
108 owner_.xpos() + cursor_x_,
109 owner_.ypos() + cursor_y_,
110 cursor_w_, cursor_h_, 0, 0);
112 // xforms equivalent needed here
114 if (!qApp->focusWidget())
118 XDrawLine(fl_get_display(), owner_.getWin(), gc_copy,
119 owner_.xpos() + x, owner_.ypos() + y,
120 owner_.xpos() + x, owner_.ypos() + y + h - 1);
125 case REVERSED_L_SHAPE:
127 XDrawLine(fl_get_display(), owner_.getWin(), gc_copy,
128 owner_.xpos() + cursor_x_,
129 owner_.ypos() + y + h - 1,
130 owner_.xpos() + cursor_x_ + cursor_w_ - 1,
131 owner_.ypos() + y + h - 1);
137 void XScreen::removeCursor()
139 // before first showCursor
140 if (!nocursor_pixmap_)
143 XCopyArea(fl_get_display(), nocursor_pixmap_, owner_.getWin(),
144 gc_copy, 0, 0, cursor_w_, cursor_h_,
145 owner_.xpos() + cursor_x_,
146 owner_.ypos() + cursor_y_);
150 void XScreen::expose(int x, int y, int w, int h)
152 lyxerr[Debug::GUI] << "XScreen::expose " << w << 'x' << h
153 << '+' << x << '+' << y << endl;
155 XCopyArea(fl_get_display(),
164 } // namespace frontend