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
25 typedef unsigned short Dimension;
31 /** The class LyXScreen is used for the main Textbody.
32 Concretely, the screen is held in a pixmap. This pixmap is kept up to
33 date and used to optimize drawing on the screen.
34 This class also handles the drawing of the cursor and partly the selection.
39 LyXScreen(BufferView *, Window window,
51 /** Return the forground pixmap. This function is a _hack_,
52 we should be rid of it as soon as possible. But to do that
53 a lot in the mathcode and the figinset has to be rewritten.
55 Pixmap getForeground() { return foreground; };
57 /** Draws the screen form textposition y. Uses as much of
58 the already printed pixmap as possible */
61 /// Redraws the screen, without using existing pixmap
64 /// Returns a new top so that the cursor is visible
65 long TopCursorVisible();
66 /// Redraws the screen such that the cursor is visible
75 void ShowManualCursor(long x, long y, int asc, int desc);
77 void HideManualCursor(long x, long y, int asc, int desc);
78 /// returns 1 if first has changed, otherwise 0
79 int FitManualCursor(long, long, int, int);
81 void ToggleSelection(bool = true);
85 /** Updates part of the screen. If text->status is
86 LyXText::NEED_MORE_REFRESH, we update from the
87 point of change and to the end of the screen.
88 If text->status is LyXText::NEED_VERY_LITTLE_REFRESH,
89 we only update the current row. */
92 /** Updates part of the screen. Updates till row with cursor,
93 or only current row */
97 /** Functions for drawing into the LyXScreen. The number of
98 drawing functions should be minimized, now there
99 is too many. And also there is mixed X and XForms drawing
100 functions called. Not good. */
101 void drawPoint(GC gc, int x, int y);
103 void drawLine(gc_type t, int baseline, int x, int length);
105 void drawLine(GC gc, int a, int b, int c, int d);
107 void drawLines(GC gc, XPoint * p, int np);
109 void drawVerticalLine(gc_type t, int x, int y1, int y2);
111 void drawOnOffLine(int baseline, int x, int length);
113 void drawThickLine(int baseline, int x, int length);
115 void drawTableLine(int baseline, int x, int length, bool on_off);
117 void drawVerticalTableLine(int x, int y1, int y2, bool on_off);
119 void drawVerticalOnOffLine(int x, int y1, int y2);
121 void fillArc(GC gc, int x, int y,
122 unsigned int w, unsigned int h,
125 void drawArc(GC gc, int x, int y,
126 unsigned int w, unsigned int h,
129 void drawSegments(GC gc, XSegment * s, int ns);
131 void fillRectangle(gc_type t, int, int, int, int);
133 void drawRectangle(gc_type t, int x, int y, int width, int height);
135 void drawFrame(int ft, int x, int y, int w, int h,
136 FL_COLOR col, int b);
138 int drawText(LyXFont const & font, char const *,
139 int n, int baseline, int x);
141 int drawString(LyXFont const & font, string const & str,
142 int baseline, int x);
144 /// first visible pixel-row
150 /// Copies specified area of pixmap to screen
151 void expose(int x, int y, int exp_width, int exp_height);
153 /// y1 and y2 are coordinates of the screen
154 void DrawFromTo(int y1, int y2);
156 /// y is a coordinate of the text
157 void DrawOneRow(Row * row, long & y_text);
168 Pixmap cursor_pixmap;
188 long screen_refresh_y;
190 Row * screen_refresh_row;
192 friend class InsetFormula;
199 // Some of the easy to inline draw methods:
202 void LyXScreen::drawPoint(GC gc, int x, int y)
204 XDrawPoint(fl_display, foreground, gc,
210 void LyXScreen::drawLine(GC gc, int a, int b, int c, int d)
212 XDrawLine(fl_display, foreground, gc, a, b, c, d);
217 void LyXScreen::drawLine(gc_type t, int baseline, int x, int length)
219 drawLine(getGC(t), x, baseline, x + length, baseline);
224 void LyXScreen::drawLines(GC gc, XPoint * p, int np)
226 XDrawLines(fl_display, foreground, gc, p, np, CoordModeOrigin);
231 void LyXScreen::drawVerticalLine(gc_type t, int x, int y1, int y2)
242 void LyXScreen::drawOnOffLine(int baseline, int x, int length)
244 drawLine(getGC(gc_on_off_line),
253 void LyXScreen::drawThickLine(int baseline, int x, int length)
255 drawLine(getGC(gc_thick_line),
264 void LyXScreen::drawVerticalOnOffLine(int x, int y1, int y2)
266 drawLine(getGC(gc_fill),
275 void LyXScreen::fillArc(GC gc, int x, int y,
276 unsigned int w, unsigned int h,
279 XFillArc(fl_display, foreground, gc,
286 void LyXScreen::drawArc(GC gc, int x, int y,
287 unsigned int w, unsigned int h,
290 XDrawArc(fl_display, foreground, gc,
297 void LyXScreen::drawSegments(GC gc, XSegment * s, int ns)
299 XDrawSegments(fl_display, foreground, gc, s, ns);
304 void LyXScreen::fillRectangle(gc_type t, int a, int b, int c, int d)
306 XFillRectangle(fl_display, foreground, getGC(t),
312 void LyXScreen::drawRectangle(gc_type t, int x, int y, int width, int height)
314 XDrawRectangle(fl_display, foreground, getGC(t),
315 x, y, width, height);
320 int LyXScreen::drawText(LyXFont const & font, char const * fs,
321 int n, int baseline, int x)
323 return font.drawText(fs, n, foreground, baseline, x);
328 int LyXScreen::drawString(LyXFont const & font, string const & str,
331 return font.drawString(str, foreground, baseline, x);