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;
34 /** The class LyXScreen is used for the main Textbody.
35 Concretely, the screen is held in a pixmap. This pixmap is kept up to
36 date and used to optimize drawing on the screen.
37 This class also handles the drawing of the cursor and partly the selection.
42 LyXScreen(BufferView *, Window window,
53 /** Return the forground pixmap. This function is a _hack_,
54 we should be rid of it as soon as possible. But to do that
55 a lot in the mathcode and the figinset has to be rewritten.
57 Pixmap getForeground() { return foreground; };
60 /** Draws the screen form textposition y. Uses as much of
61 the already printed pixmap as possible */
64 /// Redraws the screen, without using existing pixmap
67 /// Returns a new top so that the cursor is visible
68 long TopCursorVisible();
69 /// Redraws the screen such that the cursor is visible
78 void ShowManualCursor(long x, long y, int asc, int desc);
80 void HideManualCursor(long x, long y, int asc, int desc);
81 /// returns 1 if first has changed, otherwise 0
82 int FitManualCursor(long, long, int, int);
84 void ToggleSelection(bool = true);
88 /** Updates part of the screen. If text->status is
89 LyXText::NEED_MORE_REFRESH, we update from the
90 point of change and to the end of the screen.
91 If text->status is LyXText::NEED_VERY_LITTLE_REFRESH,
92 we only update the current row. */
95 /** Updates part of the screen. Updates till row with cursor,
96 or only current row */
100 /** Functions for drawing into the LyXScreen. The number of
101 drawing functions should be minimized, now there
102 is too many. And also there is mixed X and XForms drawing
103 functions called. Not good. */
104 void drawPoint(GC gc, int x, int y);
106 void drawLine(gc_type t, int baseline, int x, int length);
108 void drawLine(GC gc, int a, int b, int c, int d);
110 void drawLines(GC gc, XPoint * p, int np);
112 void drawVerticalLine(gc_type t, int x, int y1, int y2);
114 void drawOnOffLine(int baseline, int x, int length);
116 void drawThickLine(int baseline, int x, int length);
118 void drawTableLine(int baseline, int x, int length, bool on_off);
120 void drawVerticalTableLine(int x, int y1, int y2, bool on_off);
122 void drawVerticalOnOffLine(int x, int y1, int y2);
124 void fillArc(GC gc, int x, int y,
125 unsigned int w, unsigned int h,
128 void drawArc(GC gc, int x, int y,
129 unsigned int w, unsigned int h,
132 void drawSegments(GC gc, XSegment * s, int ns);
134 void fillRectangle(gc_type t, int, int, int, int);
136 void drawRectangle(gc_type t, int x, int y, int width, int height);
138 void drawFrame(int ft, int x, int y, int w, int h,
139 FL_COLOR col, int b);
141 int drawText(LyXFont const & font, char const *,
142 int n, int baseline, int x);
144 int drawString(LyXFont const & font, string const & str,
145 int baseline, int x);
147 /// first visible pixel-row
153 /// Copies specified area of pixmap to screen
154 void expose(int x, int y, int exp_width, int exp_height);
156 /// y1 and y2 are coordinates of the screen
157 void DrawFromTo(int y1, int y2);
159 /// y is a coordinate of the text
160 void DrawOneRow(Row * row, long & y_text);
171 Pixmap cursor_pixmap;
191 long screen_refresh_y;
193 Row * screen_refresh_row;
195 //friend class InsetFormula;
202 // Some of the easy to inline draw methods:
205 void LyXScreen::drawPoint(GC gc, int x, int y)
207 XDrawPoint(fl_display, foreground, gc,
213 void LyXScreen::drawLine(GC gc, int a, int b, int c, int d)
215 XDrawLine(fl_display, foreground, gc, a, b, c, d);
220 void LyXScreen::drawLine(gc_type t, int baseline, int x, int length)
222 drawLine(getGC(t), x, baseline, x + length, baseline);
227 void LyXScreen::drawLines(GC gc, XPoint * p, int np)
229 XDrawLines(fl_display, foreground, gc, p, np, CoordModeOrigin);
234 void LyXScreen::drawVerticalLine(gc_type t, int x, int y1, int y2)
245 void LyXScreen::drawOnOffLine(int baseline, int x, int length)
247 drawLine(getGC(gc_on_off_line),
256 void LyXScreen::drawThickLine(int baseline, int x, int length)
258 drawLine(getGC(gc_thick_line),
267 void LyXScreen::drawVerticalOnOffLine(int x, int y1, int y2)
269 drawLine(getGC(gc_fill),
278 void LyXScreen::fillArc(GC gc, int x, int y,
279 unsigned int w, unsigned int h,
282 XFillArc(fl_display, foreground, gc,
289 void LyXScreen::drawArc(GC gc, int x, int y,
290 unsigned int w, unsigned int h,
293 XDrawArc(fl_display, foreground, gc,
300 void LyXScreen::drawSegments(GC gc, XSegment * s, int ns)
302 XDrawSegments(fl_display, foreground, gc, s, ns);
307 void LyXScreen::fillRectangle(gc_type t, int a, int b, int c, int d)
309 XFillRectangle(fl_display, foreground, getGC(t),
315 void LyXScreen::drawRectangle(gc_type t, int x, int y, int width, int height)
317 XDrawRectangle(fl_display, foreground, getGC(t),
318 x, y, width, height);
323 int LyXScreen::drawText(LyXFont const & font, char const * fs,
324 int n, int baseline, int x)
326 return font.drawText(fs, n, foreground, baseline, x);
331 int LyXScreen::drawString(LyXFont const & font, string const & str,
334 return font.drawString(str, foreground, baseline, x);