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 : LyXScreen(), 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 WorkArea & XScreen::workarea() const
68 void XScreen::setCursorColor()
70 if (!lyxColorHandler.get())
73 GC gc = lyxColorHandler->getGCForeground(LColor::cursor);
76 XGetGCValues(fl_get_display(),
77 gc, GCForeground, &val);
78 XChangeGC(fl_get_display(), gc_copy, GCForeground, &val);
82 void XScreen::showCursor(int x, int y, int h, Cursor_Shape shape)
84 // Update the cursor color. (a little slow doing it like this ??)
96 cursor_w_ = cursor_h_ / 3;
98 case REVERSED_L_SHAPE:
99 cursor_w_ = cursor_h_ / 3;
100 cursor_x_ = x - cursor_w_ + 1;
104 if (nocursor_pixmap_) {
105 XFreePixmap(fl_get_display(), nocursor_pixmap_);
106 nocursor_pixmap_ = 0;
108 nocursor_pixmap_ = XCreatePixmap(fl_get_display(),
109 fl_root, cursor_w_, cursor_h_, fl_get_visual_depth());
112 XCopyArea(fl_get_display(),
113 owner_.getWin(), nocursor_pixmap_, gc_copy,
114 owner_.xpos() + cursor_x_,
115 owner_.ypos() + cursor_y_,
116 cursor_w_, cursor_h_, 0, 0);
118 // xforms equivalent needed here
120 if (!qApp->focusWidget())
124 XDrawLine(fl_get_display(), owner_.getWin(), gc_copy,
125 owner_.xpos() + x, owner_.ypos() + y,
126 owner_.xpos() + x, owner_.ypos() + y + h - 1);
131 case REVERSED_L_SHAPE:
133 XDrawLine(fl_get_display(), owner_.getWin(), gc_copy,
134 owner_.xpos() + cursor_x_,
135 owner_.ypos() + y + h - 1,
136 owner_.xpos() + cursor_x_ + cursor_w_ - 1,
137 owner_.ypos() + y + h - 1);
143 void XScreen::removeCursor()
145 // before first showCursor
146 if (!nocursor_pixmap_)
149 XCopyArea(fl_get_display(), nocursor_pixmap_, owner_.getWin(),
150 gc_copy, 0, 0, cursor_w_, cursor_h_,
151 owner_.xpos() + cursor_x_,
152 owner_.ypos() + cursor_y_);
156 void XScreen::expose(int x, int y, int w, int h)
158 lyxerr[Debug::GUI] << "XScreen::expose " << w << 'x' << h
159 << '+' << x << '+' << y << endl;
164 ev.xexpose.window = owner_.getWin();
165 // Adjust the x,y data so that XWorkArea can handle XEvents
166 // received from here in identical fashion to those it receives
168 ev.xexpose.x = owner_.xpos() + x;
169 ev.xexpose.y = owner_.ypos() + y;
170 ev.xexpose.width = w;
171 ev.xexpose.height = h;
172 ev.xexpose.count = 0;
174 XSendEvent(fl_get_display(), owner_.getWin(), False, 0, &ev);
177 } // namespace frontend