2 /* This file is part of
3 * ======================================================
5 * LyX, The Document Processor
7 * Copyright 1995 Matthias Ettrich
8 * Copyright 1995-1999 The LyX Team
10 * ====================================================== */
19 #include FORMS_H_LOCATION
25 typedef unsigned short Dimension;
27 /** The class LyXScreen is used for the main Textbody.
28 Concretely, the screen is held in a pixmap. This pixmap is kept up to
29 date and used to optimize drawing on the screen.
30 This class also handles the drawing of the cursor and partly the selection.
35 LyXScreen(Window window,
44 /** Return the forground pixmap. This function is a _hack_,
45 we should be rid of it as soon as possible. But to do that
46 a lot in the mathcode and the figinset has to be rewritten.
48 Pixmap getForeground() { return foreground; };
50 /** Draws the screen form textposition y. Uses as much of
51 the already printed pixmap as possible */
54 /// Redraws the screen, without using existing pixmap
57 /// Returns a new top so that the cursor is visible
58 long TopCursorVisible();
59 /// Redraws the screen such that the cursor is visible
68 void ShowManualCursor(long x, long y, int asc, int desc);
70 void HideManualCursor(long x, long y, int asc, int desc);
71 /// returns 1 if first has changed, otherwise 0
72 int FitManualCursor(long, long, int, int);
74 void ToggleSelection(bool = true);
78 /** Updates part of the screen. If text->status is
79 LyXText::NEED_MORE_REFRESH, we update from the
80 point of change and to the end of the screen.
81 If text->status is LyXText::NEED_VERY_LITTLE_REFRESH,
82 we only update the current row. */
85 /** Updates part of the screen. Updates till row with cursor,
86 or only current row */
89 /** Functions for drawing into the LyXScreen. The number of
90 drawing functions should be minimized, now there
91 is too many. And also there is mixed X and XForms drawing
92 functions called. Not good. */
93 void drawPoint(GC gc, int x, int y);
95 void drawLine(gc_type t, int baseline, int x, int length);
97 void drawLine(GC gc, int a, int b, int c, int d);
99 void drawLines(GC gc, XPoint * p, int np);
101 void drawVerticalLine(gc_type t, int x, int y1, int y2);
103 void drawOnOffLine(int baseline, int x, int length);
105 void drawThickLine(int baseline, int x, int length);
107 void drawTableLine(int baseline, int x, int length, bool on_off);
109 void drawVerticalTableLine(int x, int y1, int y2, bool on_off);
111 void drawVerticalOnOffLine(int x, int y1, int y2);
113 void fillArc(GC gc, int x, int y,
114 unsigned int w, unsigned int h,
117 void drawArc(GC gc, int x, int y,
118 unsigned int w, unsigned int h,
121 void drawSegments(GC gc, XSegment * s, int ns);
123 void fillRectangle(gc_type t, int, int, int, int);
125 void drawRectangle(gc_type t, int x, int y, int width, int height);
127 void drawFrame(int ft, int x, int y, int w, int h,
128 FL_COLOR col, int b);
130 int drawText(LyXFont const & font, char const *,
131 int n, int baseline, int x);
133 int drawString(LyXFont const & font, string const & str,
134 int baseline, int x);
136 /// first visible pixel-row
142 /// Copies specified area of pixmap to screen
143 void expose(int x, int y, int exp_width, int exp_height);
145 /// y1 and y2 are coordinates of the screen
146 void DrawFromTo(int y1, int y2);
148 /// y is a coordinate of the text
149 void DrawOneRow(Row * row, long & y_text);
157 Pixmap cursor_pixmap;
177 long screen_refresh_y;
179 Row * screen_refresh_row;
181 friend class InsetFormula;
184 // Some of the easy to inline draw methods:
187 void LyXScreen::drawPoint(GC gc, int x, int y)
189 XDrawPoint(fl_display, foreground, gc,
195 void LyXScreen::drawLine(GC gc, int a, int b, int c, int d)
197 XDrawLine(fl_display, foreground, gc, a, b, c, d);
202 void LyXScreen::drawLine(gc_type t, int baseline, int x, int length)
204 drawLine(getGC(t), x, baseline, x + length, baseline);
209 void LyXScreen::drawLines(GC gc, XPoint * p, int np)
211 XDrawLines(fl_display, foreground, gc, p, np, CoordModeOrigin);
216 void LyXScreen::drawVerticalLine(gc_type t, int x, int y1, int y2)
227 void LyXScreen::drawOnOffLine(int baseline, int x, int length)
229 drawLine(getGC(gc_on_off_line),
238 void LyXScreen::drawThickLine(int baseline, int x, int length)
240 drawLine(getGC(gc_thick_line),
249 void LyXScreen::drawVerticalOnOffLine(int x, int y1, int y2)
251 drawLine(getGC(gc_fill),
260 void LyXScreen::fillArc(GC gc, int x, int y,
261 unsigned int w, unsigned int h,
264 XFillArc(fl_display, foreground, gc,
271 void LyXScreen::drawArc(GC gc, int x, int y,
272 unsigned int w, unsigned int h,
275 XDrawArc(fl_display, foreground, gc,
282 void LyXScreen::drawSegments(GC gc, XSegment * s, int ns)
284 XDrawSegments(fl_display, foreground, gc, s, ns);
289 void LyXScreen::fillRectangle(gc_type t, int a, int b, int c, int d)
291 XFillRectangle(fl_display, foreground, getGC(t),
297 void LyXScreen::drawRectangle(gc_type t, int x, int y, int width, int height)
299 XDrawRectangle(fl_display, foreground, getGC(t),
300 x, y, width, height);
305 int LyXScreen::drawText(LyXFont const & font, char const * fs,
306 int n, int baseline, int x)
308 return font.drawText(fs, n, foreground, baseline, x);
313 int LyXScreen::drawString(LyXFont const & font, string const & str,
316 return font.drawString(str, foreground, baseline, x);