2 /* This file is part of
3 * ======================================================
5 * LyX, The Document Processor
7 * Copyright 1995 Matthias Ettrich
8 * Copyright 1995-2000 The LyX Team
10 * ====================================================== */
19 #include FORMS_H_LOCATION
30 typedef unsigned short Dimension;
36 /** The class LyXScreen is used for the main Textbody.
37 Concretely, the screen is held in a pixmap. This pixmap is kept up to
38 date and used to optimize drawing on the screen.
39 This class also handles the drawing of the cursor and partly the selection.
44 LyXScreen(BufferView *, Window window,
57 /** Return the forground pixmap. This function is a _hack_,
58 we should be rid of it as soon as possible. But to do that
59 a lot in the mathcode and the figinset has to be rewritten.
61 Pixmap getForeground() { return foreground; };
64 /** Draws the screen form textposition y. Uses as much of
65 the already printed pixmap as possible */
68 /// Redraws the screen, without using existing pixmap
71 /// Returns a new top so that the cursor is visible
72 long TopCursorVisible();
73 /// Redraws the screen such that the cursor is visible
82 void ShowManualCursor(long x, long y, int asc, int desc);
84 void HideManualCursor(long x, long y, int asc, int desc);
85 /// returns 1 if first has changed, otherwise 0
86 int FitManualCursor(long, long, int, int);
88 void ToggleSelection(bool = true);
92 /** Updates part of the screen. If text->status is
93 LyXText::NEED_MORE_REFRESH, we update from the
94 point of change and to the end of the screen.
95 If text->status is LyXText::NEED_VERY_LITTLE_REFRESH,
96 we only update the current row. */
99 /** Updates part of the screen. Updates till row with cursor,
100 or only current row */
104 /** Functions for drawing into the LyXScreen. The number of
105 drawing functions should be minimized, now there
106 is too many. And also there is mixed X and XForms drawing
107 functions called. Not good. */
108 void drawPoint(GC gc, int x, int y);
110 void drawLine(gc_type t, int baseline, int x, int length);
112 void drawLine(GC gc, int a, int b, int c, int d);
114 void drawLines(GC gc, XPoint * p, int np);
116 void drawVerticalLine(gc_type t, int x, int y1, int y2);
118 void drawOnOffLine(int baseline, int x, int length);
120 void drawThickLine(int baseline, int x, int length);
122 void drawTableLine(int baseline, int x, int length, bool on_off);
124 void drawVerticalTableLine(int x, int y1, int y2, bool on_off);
126 void drawVerticalOnOffLine(int x, int y1, int y2);
128 void fillArc(GC gc, int x, int y,
129 unsigned int w, unsigned int h,
132 void drawArc(GC gc, int x, int y,
133 unsigned int w, unsigned int h,
136 void drawSegments(GC gc, XSegment * s, int ns);
138 void fillRectangle(gc_type t, int, int, int, int);
140 void drawRectangle(gc_type t, int x, int y, int width, int height);
142 void drawFrame(int ft, int x, int y, int w, int h,
143 FL_COLOR col, int b);
145 int drawText(LyXFont const & font, char const *,
146 int n, int baseline, int x);
148 int drawString(LyXFont const & font, string const & str,
149 int baseline, int x);
151 /// first visible pixel-row
157 /// Copies specified area of pixmap to screen
158 void expose(int x, int y, int exp_width, int exp_height);
160 /// y1 and y2 are coordinates of the screen
161 void DrawFromTo(int y1, int y2);
163 /// y is a coordinate of the text
164 void DrawOneRow(Row * row, long & y_text);
175 Pixmap cursor_pixmap;
195 long screen_refresh_y;
197 Row * screen_refresh_row;
199 //friend class InsetFormula;
206 // Some of the easy to inline draw methods:
209 void LyXScreen::drawPoint(GC gc, int x, int y)
211 XDrawPoint(fl_display, foreground, gc,
217 void LyXScreen::drawLine(GC gc, int a, int b, int c, int d)
219 XDrawLine(fl_display, foreground, gc, a, b, c, d);
224 void LyXScreen::drawLine(gc_type t, int baseline, int x, int length)
226 drawLine(getGC(t), x, baseline, x + length, baseline);
231 void LyXScreen::drawLines(GC gc, XPoint * p, int np)
233 XDrawLines(fl_display, foreground, gc, p, np, CoordModeOrigin);
238 void LyXScreen::drawVerticalLine(gc_type t, int x, int y1, int y2)
249 void LyXScreen::drawOnOffLine(int baseline, int x, int length)
251 drawLine(getGC(gc_on_off_line),
260 void LyXScreen::drawThickLine(int baseline, int x, int length)
262 drawLine(getGC(gc_thick_line),
271 void LyXScreen::drawVerticalOnOffLine(int x, int y1, int y2)
273 drawLine(getGC(gc_fill),
282 void LyXScreen::fillArc(GC gc, int x, int y,
283 unsigned int w, unsigned int h,
286 XFillArc(fl_display, foreground, gc,
293 void LyXScreen::drawArc(GC gc, int x, int y,
294 unsigned int w, unsigned int h,
297 XDrawArc(fl_display, foreground, gc,
304 void LyXScreen::drawSegments(GC gc, XSegment * s, int ns)
306 XDrawSegments(fl_display, foreground, gc, s, ns);
311 void LyXScreen::fillRectangle(gc_type t, int a, int b, int c, int d)
313 XFillRectangle(fl_display, foreground, getGC(t),
319 void LyXScreen::drawRectangle(gc_type t, int x, int y, int width, int height)
321 XDrawRectangle(fl_display, foreground, getGC(t),
322 x, y, width, height);
327 int LyXScreen::drawText(LyXFont const & font, char const * fs,
328 int n, int baseline, int x)
330 return font.drawText(fs, n, foreground, baseline, x);
335 int LyXScreen::drawString(LyXFont const & font, string const & str,
338 return font.drawString(str, foreground, baseline, x);