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 drawArc(GC gc, int x, int y,
114 unsigned int w, unsigned int h,
117 void drawSegments(GC gc, XSegment *s, int ns);
119 void fillRectangle(gc_type t, int, int, int, int);
121 void drawRectangle(gc_type t, int x, int y, int width, int height);
123 void drawFrame(int ft, int x, int y, int w, int h,
124 FL_COLOR col, int b);
126 int drawText(LyXFont const &font, char const*,
127 int n, int baseline, int x);
129 int drawString(LyXFont const &font, string const &str,
130 int baseline, int x);
132 /// first visible pixel-row
138 /// Copies specified area of pixmap to screen
139 void expose(int x, int y, int exp_width, int exp_height);
141 /// y1 and y2 are coordinates of the screen
142 void DrawFromTo(int y1, int y2);
144 /// y is a coordinate of the text
145 void DrawOneRow(Row* row, long &y_text);
153 Pixmap cursor_pixmap;
173 long screen_refresh_y;
175 Row *screen_refresh_row;
177 friend class InsetFormula;
180 // Some of the easy to inline draw methods:
182 inline void LyXScreen::drawPoint(GC gc, int x, int y)
184 XDrawPoint(fl_display, foreground, gc,
189 inline void LyXScreen::drawLine(GC gc, int a, int b, int c, int d)
191 XDrawLine(fl_display, foreground, gc, a, b, c, d);
195 inline void LyXScreen::drawLine(gc_type t, int baseline, int x, int length)
197 drawLine(getGC(t), x, baseline, x + length, baseline);
201 inline void LyXScreen::drawLines(GC gc, XPoint *p, int np)
203 XDrawLines(fl_display, foreground, gc, p, np, CoordModeOrigin);
207 inline void LyXScreen::drawVerticalLine(gc_type t, int x, int y1, int y2)
217 inline void LyXScreen::drawOnOffLine(int baseline, int x, int length)
219 drawLine(getGC(gc_on_off_line),
227 inline void LyXScreen::drawThickLine(int baseline, int x, int length)
229 drawLine(getGC(gc_thick_line),
237 inline void LyXScreen::drawVerticalOnOffLine(int x, int y1, int y2)
239 drawLine(getGC(gc_fill),
247 inline void LyXScreen::drawArc(GC gc, int x, int y,
248 unsigned int w, unsigned int h,
251 XDrawArc(fl_display, foreground, gc,
257 inline void LyXScreen::drawSegments(GC gc, XSegment *s, int ns)
259 XDrawSegments(fl_display, foreground, gc, s, ns);
263 inline void LyXScreen::fillRectangle(gc_type t, int a, int b, int c, int d)
265 XFillRectangle(fl_display, foreground, getGC(t),
270 inline void LyXScreen::drawRectangle(gc_type t, int x, int y, int width, int height)
272 XDrawRectangle(fl_display, foreground, getGC(t),
273 x, y, width, height);
277 inline int LyXScreen::drawText(LyXFont const &font, char const*fs,
278 int n, int baseline, int x)
280 return font.drawText(fs, n, foreground, baseline, x);
284 inline int LyXScreen::drawString(LyXFont const &font, string const &str,
287 return font.drawString(str, foreground, baseline, x);