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"
29 val.foreground = BlackPixel(fl_get_display(),
30 DefaultScreen(fl_get_display()));
32 val.function = GXcopy;
33 val.graphics_exposures = false;
34 val.line_style = LineSolid;
36 return XCreateGC(fl_get_display(), RootWindow(fl_get_display(), 0),
37 GCForeground | GCFunction | GCGraphicsExposures
38 | GCLineWidth | GCLineStyle, &val);
44 XScreen::XScreen(XWorkArea & o)
45 : LyXScreen(), owner_(o), nocursor_pixmap_(0),
46 cursor_x_(0), cursor_y_(0), cursor_w_(0), cursor_h_(0)
55 XFreeGC(fl_get_display(), gc_copy);
59 WorkArea & XScreen::workarea() const
65 void XScreen::setCursorColor()
67 if (!lyxColorHandler.get())
70 GC gc = lyxColorHandler->getGCForeground(LColor::cursor);
73 XGetGCValues(fl_get_display(),
74 gc, GCForeground, &val);
75 XChangeGC(fl_get_display(), gc_copy, GCForeground, &val);
79 void XScreen::showCursor(int x, int y, int h, Cursor_Shape shape)
81 // Update the cursor color. (a little slow dooing it like this ??)
93 cursor_w_ = cursor_h_ / 3;
95 case REVERSED_L_SHAPE:
96 cursor_w_ = cursor_h_ / 3;
97 cursor_x_ = x - cursor_w_ + 1;
101 if (nocursor_pixmap_) {
102 XFreePixmap(fl_get_display(), nocursor_pixmap_);
103 nocursor_pixmap_ = 0;
105 nocursor_pixmap_ = XCreatePixmap(fl_get_display(),
106 fl_root, cursor_w_, cursor_h_, fl_get_visual_depth());
109 XCopyArea(fl_get_display(),
110 owner_.getWin(), nocursor_pixmap_, gc_copy,
111 owner_.xpos() + cursor_x_,
112 owner_.ypos() + cursor_y_,
113 cursor_w_, cursor_h_, 0, 0);
115 // xforms equivalent needed here
117 if (!qApp->focusWidget())
121 XDrawLine(fl_get_display(), owner_.getWin(), gc_copy,
122 owner_.xpos() + x, owner_.ypos() + y,
123 owner_.xpos() + x, owner_.ypos() + y + h - 1);
128 case REVERSED_L_SHAPE:
130 XDrawLine(fl_get_display(), owner_.getWin(), gc_copy,
131 owner_.xpos() + cursor_x_,
132 owner_.ypos() + y + h - 1,
133 owner_.xpos() + cursor_x_ + cursor_w_ - 1,
134 owner_.ypos() + y + h - 1);
140 void XScreen::removeCursor()
142 // before first showCursor
143 if (!nocursor_pixmap_)
146 XCopyArea(fl_get_display(), nocursor_pixmap_, owner_.getWin(),
147 gc_copy, 0, 0, cursor_w_, cursor_h_,
148 owner_.xpos() + cursor_x_,
149 owner_.ypos() + cursor_y_);
153 void XScreen::expose(int x, int y, int w, int h)
155 lyxerr[Debug::GUI] << "expose " << w << 'x' << h
156 << '+' << x << '+' << y << endl;
157 XCopyArea(fl_get_display(),