2 /* This file is part of
3 * ======================================================
5 * LyX, The Document Processor
7 * Copyright (C) 1995 Matthias Ettrich
8 * Copyright (C) 1995-1998 The LyX Team
10 *======================================================*/
18 #include FORMS_H_LOCATION
24 typedef unsigned short Dimension;
26 /** The class LyXScreen is used for the main Textbody.
27 Concretely, the screen is held in a pixmap. This pixmap is kept up to
28 date and used to optimize drawing on the screen.
29 This class also handles the drawing of the cursor and partly the selection.
34 LyXScreen(Window window,
43 /** Return the forground pixmap. This function is a _hack_,
44 we should be rid of it as soon as possible. But to do that
45 a lot in the mathcode and the figinset has to be rewritten.
47 Pixmap getForeground() { return foreground; };
49 /** Draws the screen form textposition y. Uses as much of
50 the already printed pixmap as possible */
53 /// Redraws the screen, without using existing pixmap
56 /// Returns a new top so that the cursor is visible
57 long TopCursorVisible();
58 /// Redraws the screen such that the cursor is visible
67 void ShowManualCursor(long x, long y, int asc, int desc);
69 void HideManualCursor(long x, long y, int asc, int desc);
70 /// returns 1 if first has changed, otherwise 0
71 int FitManualCursor(long, long, int, int);
73 void ToggleSelection(bool = true);
77 /** Updates part of the screen. If text->status is
78 LyXText::NEED_MORE_REFRESH, we update from the
79 point of change and to the end of the screen.
80 If text->status is LyXText::NEED_VERY_LITTLE_REFRESH,
81 we only update the current row. */
84 /** Updates part of the screen. Updates till row with cursor,
85 or only current row */
88 /** Functions for drawing into the LyXScreen. The number of
89 drawing functions should be minimized, now there
90 is too many. And also there is mixed X and XForms drawing
91 functions called. Not good. */
92 void drawPoint(GC gc, int x, int y);
94 void drawLine(gc_type t, int baseline, int x, int length);
96 void drawLine(GC gc, int a, int b, int c, int d);
98 void drawLines(GC gc, XPoint *p, int np);
100 void drawVerticalLine(gc_type t, int x, int y1, int y2);
102 void drawOnOffLine(int baseline, int x, int length);
104 void drawThickLine(int baseline, int x, int length);
106 void drawTableLine(int baseline, int x, int length, bool on_off);
108 void drawVerticalTableLine(int x, int y1, int y2, bool on_off);
110 void drawVerticalOnOffLine(int x, int y1, int y2);
112 void drawArc(GC gc, int x, int y,
113 unsigned int w, unsigned int h,
116 void drawSegments(GC gc, XSegment *s, int ns);
118 void fillRectangle(gc_type t, int, int, int, int);
120 void drawRectangle(gc_type t, int x, int y, int width, int height);
122 void drawFrame(int ft, int x, int y, int w, int h,
123 FL_COLOR col, int b);
125 int drawText(LyXFont const &font, char const*,
126 int n, int baseline, int x);
128 int drawString(LyXFont const &font, LString const &str,
129 int baseline, int x);
131 /// first visible pixel-row
137 /// Copies specified area of pixmap to screen
138 void expose(int x, int y, int exp_width, int exp_height);
140 /// y1 and y2 are coordinates of the screen
141 void DrawFromTo(int y1, int y2);
143 /// y is a coordinate of the text
144 void DrawOneRow(Row* row, long &y_text);
152 Pixmap cursor_pixmap;
172 long screen_refresh_y;
174 Row *screen_refresh_row;
176 friend class InsetFormula;
179 // Some of the easy to inline draw methods:
181 inline void LyXScreen::drawPoint(GC gc, int x, int y)
183 XDrawPoint(fl_display, foreground, gc,
188 inline void LyXScreen::drawLine(GC gc, int a, int b, int c, int d)
190 XDrawLine(fl_display, foreground, gc, a, b, c, d);
194 inline void LyXScreen::drawLine(gc_type t, int baseline, int x, int length)
196 drawLine(getGC(t), x, baseline, x + length, baseline);
200 inline void LyXScreen::drawLines(GC gc, XPoint *p, int np)
202 XDrawLines(fl_display, foreground, gc, p, np, CoordModeOrigin);
206 inline void LyXScreen::drawVerticalLine(gc_type t, int x, int y1, int y2)
216 inline void LyXScreen::drawOnOffLine(int baseline, int x, int length)
218 drawLine(getGC(gc_on_off_line),
226 inline void LyXScreen::drawThickLine(int baseline, int x, int length)
228 drawLine(getGC(gc_thick_line),
236 inline void LyXScreen::drawVerticalOnOffLine(int x, int y1, int y2)
238 drawLine(getGC(gc_fill),
246 inline void LyXScreen::drawArc(GC gc, int x, int y,
247 unsigned int w, unsigned int h,
250 XDrawArc(fl_display, foreground, gc,
256 inline void LyXScreen::drawSegments(GC gc, XSegment *s, int ns)
258 XDrawSegments(fl_display, foreground, gc, s, ns);
262 inline void LyXScreen::fillRectangle(gc_type t, int a, int b, int c, int d)
264 XFillRectangle(fl_display, foreground, getGC(t),
269 inline void LyXScreen::drawRectangle(gc_type t, int x, int y, int width, int height)
271 XDrawRectangle(fl_display, foreground, getGC(t),
272 x, y, width, height);
276 inline int LyXScreen::drawText(LyXFont const &font, char const*fs,
277 int n, int baseline, int x)
279 return font.drawText(fs, n, foreground, baseline, x);
283 inline int LyXScreen::drawString(LyXFont const &font, LString const &str,
286 return font.drawString(str, foreground, baseline, x);