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"
30 val.foreground = BlackPixel(fl_get_display(),
31 DefaultScreen(fl_get_display()));
33 val.function = GXcopy;
34 val.graphics_exposures = false;
35 val.line_style = LineSolid;
37 return XCreateGC(fl_get_display(), RootWindow(fl_get_display(), 0),
38 GCForeground | GCFunction | GCGraphicsExposures
39 | GCLineWidth | GCLineStyle, &val);
45 XScreen::XScreen(XWorkArea & o)
46 : LyXScreen(), owner_(o), nocursor_pixmap_(0),
47 cursor_x_(0), cursor_y_(0), cursor_w_(0), cursor_h_(0)
56 XFreeGC(fl_get_display(), gc_copy);
60 WorkArea & XScreen::workarea() const
66 void XScreen::setCursorColor()
68 if (!lyxColorHandler.get())
71 GC gc = lyxColorHandler->getGCForeground(LColor::cursor);
74 XGetGCValues(fl_get_display(),
75 gc, GCForeground, &val);
76 XChangeGC(fl_get_display(), gc_copy, GCForeground, &val);
80 void XScreen::showCursor(int x, int y, int h, Cursor_Shape shape)
82 // Update the cursor color. (a little slow doing it like this ??)
94 cursor_w_ = cursor_h_ / 3;
96 case REVERSED_L_SHAPE:
97 cursor_w_ = cursor_h_ / 3;
98 cursor_x_ = x - cursor_w_ + 1;
102 if (nocursor_pixmap_) {
103 XFreePixmap(fl_get_display(), nocursor_pixmap_);
104 nocursor_pixmap_ = 0;
106 nocursor_pixmap_ = XCreatePixmap(fl_get_display(),
107 fl_root, cursor_w_, cursor_h_, fl_get_visual_depth());
110 XCopyArea(fl_get_display(),
111 owner_.getWin(), nocursor_pixmap_, gc_copy,
112 owner_.xpos() + cursor_x_,
113 owner_.ypos() + cursor_y_,
114 cursor_w_, cursor_h_, 0, 0);
116 // xforms equivalent needed here
118 if (!qApp->focusWidget())
122 XDrawLine(fl_get_display(), owner_.getWin(), gc_copy,
123 owner_.xpos() + x, owner_.ypos() + y,
124 owner_.xpos() + x, owner_.ypos() + y + h - 1);
129 case REVERSED_L_SHAPE:
131 XDrawLine(fl_get_display(), owner_.getWin(), gc_copy,
132 owner_.xpos() + cursor_x_,
133 owner_.ypos() + y + h - 1,
134 owner_.xpos() + cursor_x_ + cursor_w_ - 1,
135 owner_.ypos() + y + h - 1);
141 void XScreen::removeCursor()
143 // before first showCursor
144 if (!nocursor_pixmap_)
147 XCopyArea(fl_get_display(), nocursor_pixmap_, owner_.getWin(),
148 gc_copy, 0, 0, cursor_w_, cursor_h_,
149 owner_.xpos() + cursor_x_,
150 owner_.ypos() + cursor_y_);
154 void XScreen::expose(int x, int y, int w, int h)
156 lyxerr[Debug::GUI] << "XScreen::expose " << w << 'x' << h
157 << '+' << x << '+' << y << endl;
162 ev.xexpose.window = owner_.getWin();
163 // Adjust the x,y data so that XWorkArea can handle XEvents
164 // received from here in identical fashion to those it receives
166 ev.xexpose.x = owner_.xpos() + x;
167 ev.xexpose.y = owner_.ypos() + y;
168 ev.xexpose.width = w;
169 ev.xexpose.height = h;
170 ev.xexpose.count = 0;
172 XSendEvent(fl_get_display(), owner_.getWin(), False, 0, &ev);