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"
31 val.foreground = BlackPixel(fl_get_display(),
32 DefaultScreen(fl_get_display()));
34 val.function = GXcopy;
35 val.graphics_exposures = false;
36 val.line_style = LineSolid;
38 return XCreateGC(fl_get_display(), RootWindow(fl_get_display(), 0),
39 GCForeground | GCFunction | GCGraphicsExposures
40 | GCLineWidth | GCLineStyle, &val);
46 XScreen::XScreen(XWorkArea & o)
47 : LyXScreen(), owner_(o), nocursor_pixmap_(0),
48 cursor_x_(0), cursor_y_(0), cursor_w_(0), cursor_h_(0)
57 XFreeGC(fl_get_display(), gc_copy);
61 WorkArea & XScreen::workarea() const
67 void XScreen::setCursorColor()
69 if (!lyxColorHandler.get())
72 GC gc = lyxColorHandler->getGCForeground(LColor::cursor);
75 XGetGCValues(fl_get_display(),
76 gc, GCForeground, &val);
77 XChangeGC(fl_get_display(), gc_copy, GCForeground, &val);
81 void XScreen::showCursor(int x, int y, int h, Cursor_Shape shape)
83 // Update the cursor color. (a little slow dooing it like this ??)
95 cursor_w_ = cursor_h_ / 3;
97 case REVERSED_L_SHAPE:
98 cursor_w_ = cursor_h_ / 3;
99 cursor_x_ = x - cursor_w_ + 1;
103 if (nocursor_pixmap_) {
104 XFreePixmap(fl_get_display(), nocursor_pixmap_);
105 nocursor_pixmap_ = 0;
107 nocursor_pixmap_ = XCreatePixmap(fl_get_display(),
108 fl_root, cursor_w_, cursor_h_, fl_get_visual_depth());
111 XCopyArea(fl_get_display(),
112 owner_.getWin(), nocursor_pixmap_, gc_copy,
113 owner_.xpos() + cursor_x_,
114 owner_.ypos() + cursor_y_,
115 cursor_w_, cursor_h_, 0, 0);
117 // xforms equivalent needed here
119 if (!qApp->focusWidget())
123 XDrawLine(fl_get_display(), owner_.getWin(), gc_copy,
124 owner_.xpos() + x, owner_.ypos() + y,
125 owner_.xpos() + x, owner_.ypos() + y + h - 1);
130 case REVERSED_L_SHAPE:
132 XDrawLine(fl_get_display(), owner_.getWin(), gc_copy,
133 owner_.xpos() + cursor_x_,
134 owner_.ypos() + y + h - 1,
135 owner_.xpos() + cursor_x_ + cursor_w_ - 1,
136 owner_.ypos() + y + h - 1);
142 void XScreen::removeCursor()
144 // before first showCursor
145 if (!nocursor_pixmap_)
148 XCopyArea(fl_get_display(), nocursor_pixmap_, owner_.getWin(),
149 gc_copy, 0, 0, cursor_w_, cursor_h_,
150 owner_.xpos() + cursor_x_,
151 owner_.ypos() + cursor_y_);
155 void XScreen::expose(int x, int y, int w, int h)
157 lyxerr[Debug::GUI] << "expose " << w << 'x' << h
158 << '+' << x << '+' << y << endl;
159 XCopyArea(fl_get_display(),