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
18 #include "frontends/screen.h"
19 #include "frontends/font_metrics.h"
20 #include "XWorkArea.h"
27 #include "BufferView.h"
28 #include "insets/insettext.h"
29 #include "ColorHandler.h"
42 val.foreground = BlackPixel(fl_get_display(),
43 DefaultScreen(fl_get_display()));
45 val.function = GXcopy;
46 val.graphics_exposures = false;
47 val.line_style = LineSolid;
49 return XCreateGC(fl_get_display(), RootWindow(fl_get_display(), 0),
50 GCForeground | GCFunction | GCGraphicsExposures
51 | GCLineWidth | GCLineStyle, &val);
57 XScreen::XScreen(XWorkArea & o)
58 : LyXScreen(), owner_(o), nocursor_pixmap_(0),
59 cursor_x_(0), cursor_y_(0), cursor_w_(0), cursor_h_(0)
68 XFreeGC(fl_get_display(), gc_copy);
72 void XScreen::setCursorColor()
74 if (!lyxColorHandler.get())
77 GC gc = lyxColorHandler->getGCForeground(LColor::cursor);
80 XGetGCValues(fl_get_display(),
81 gc, GCForeground, &val);
82 XChangeGC(fl_get_display(), gc_copy, GCForeground, &val);
86 void XScreen::showCursor(int x, int y, int h, Cursor_Shape shape)
88 // Update the cursor color. (a little slow dooing it like this ??)
100 cursor_w_ = cursor_h_ / 3;
102 case REVERSED_L_SHAPE:
103 cursor_w_ = cursor_h_ / 3;
104 cursor_x_ = x - cursor_w_ + 1;
108 if (nocursor_pixmap_) {
109 XFreePixmap(fl_get_display(), nocursor_pixmap_);
110 nocursor_pixmap_ = 0;
112 nocursor_pixmap_ = XCreatePixmap(fl_get_display(),
113 fl_root, cursor_w_, cursor_h_, fl_get_visual_depth());
116 XCopyArea(fl_get_display(),
117 owner_.getWin(), nocursor_pixmap_, gc_copy,
118 owner_.xpos() + cursor_x_,
119 owner_.ypos() + cursor_y_,
120 cursor_w_, cursor_h_, 0, 0);
122 // xforms equivalent needed here
124 if (!qApp->focusWidget())
128 XDrawLine(fl_get_display(), owner_.getWin(), gc_copy,
129 owner_.xpos() + x, owner_.ypos() + y,
130 owner_.xpos() + x, owner_.ypos() + y + h - 1);
135 case REVERSED_L_SHAPE:
137 XDrawLine(fl_get_display(), owner_.getWin(), gc_copy,
138 owner_.xpos() + cursor_x_,
139 owner_.ypos() + y + h - 1,
140 owner_.xpos() + cursor_x_ + cursor_w_ - 1,
141 owner_.ypos() + y + h - 1);
147 void XScreen::removeCursor()
149 // before first showCursor
150 if (!nocursor_pixmap_)
153 XCopyArea(fl_get_display(), nocursor_pixmap_, owner_.getWin(),
154 gc_copy, 0, 0, cursor_w_, cursor_h_,
155 owner_.xpos() + cursor_x_,
156 owner_.ypos() + cursor_y_);
160 void XScreen::expose(int x, int y, int w, int h)
162 lyxerr[Debug::GUI] << "expose " << w << 'x' << h
163 << '+' << x << '+' << y << endl;
164 XCopyArea(fl_get_display(),
174 void XScreen::draw(LyXText * text, BufferView * bv, unsigned int y)
176 int const old_first = text->top_y();
179 // make a dumb new-draw
180 drawFromTo(text, bv, 0, owner_.workHeight(), 0, 0);
181 expose(0, 0, owner_.workWidth(), owner_.workHeight());
183 XSync(fl_get_display(), 0);