]> git.lyx.org Git - lyx.git/blob - src/screen.C
3cde7c3b707073d669b6dd7b9c7f0b7fadc80e06
[lyx.git] / src / screen.C
1 /* This file is part of
2 * ======================================================
3
4 *           LyX, The Document Processor
5 *        
6 *           Copyright (C) 1995 Matthias Ettrich
7 *           Copyright (C) 1995-1998 The LyX Team
8 *
9 *======================================================*/
10
11 #include <config.h>
12
13 #ifdef __GNUG__
14 #pragma implementation "lyxscreen.h"
15 #endif
16
17 #include "lyxscreen.h"
18 #include "lyxdraw.h"
19 #include "lyxtext.h"
20
21 //      $Id: screen.C,v 1.1 1999/09/27 18:44:38 larsbj Exp $    
22
23 #if !defined(lint) && !defined(WITH_WARNINGS)
24 static char vcid[] = "$Id: screen.C,v 1.1 1999/09/27 18:44:38 larsbj Exp $";
25 #endif /* lint */
26
27 extern int mono_video;
28 extern int fast_selection;
29
30
31 // Constructor
32 LyXScreen::LyXScreen(Window window,
33                      Dimension width, 
34                      Dimension height,
35                      Dimension offset_x,
36                      Dimension offset_y,
37                      LyXText *text_ptr)
38         : text(text_ptr),_window(window), 
39           _width(width),_height(height),
40           _offset_x(offset_x), _offset_y(offset_y)
41 {
42         first = 0;
43    
44         /* the cursor isnt yet visible */ 
45         cursor_visible = false;
46         screen_refresh_y = -1;
47
48         /* create the foreground pixmap */
49         foreground = XCreatePixmap (fl_display,
50                                     fl_root,
51                                     _width, _height, 
52                                     fl_get_visual_depth());
53         cursor_pixmap = 0;
54         cursor_pixmap_x = 0;
55         cursor_pixmap_y = 0;
56         cursor_pixmap_w = 0;
57         cursor_pixmap_h = 0;
58 }
59
60
61 // Destructor
62 LyXScreen::~LyXScreen()
63 {
64         XFreePixmap(fl_display, foreground);
65 }
66
67
68 void LyXScreen::Redraw()
69 {
70         DrawFromTo(0, _height);
71         screen_refresh_y = -1;
72         expose(0, 0, _width, _height);
73         if (cursor_visible) {
74                 cursor_visible = false;
75                 ShowCursor();
76         }
77 }
78
79
80 void LyXScreen::expose(int x, int y, int exp_width, int exp_height)
81 {
82         XCopyArea(fl_display,
83                   foreground,
84                   _window,
85                   getGC(gc_copy),
86                   x, y,
87                   exp_width, exp_height,
88                   x+_offset_x, y+_offset_y);
89 }
90
91
92 void LyXScreen::DrawFromTo(int y1, int y2)
93 {
94         Row* row = 0;
95         long  y_text = 0;
96         long y = 0;
97         
98         y_text = first + y1;
99    
100         /* get the first needed row */ 
101         row = text->GetRowNearY(y_text);
102         /* y_text is now the real beginning of the row */
103    
104         y = y_text - first;
105         /* y1 is now the real beginning of row on the screen */
106         
107         while (row != NULL && y < y2) {
108
109                 text->GetVisibleRow(*this, y, row, y + first);
110                 y += row->height;
111                 row = row -> next;
112
113         }
114    
115         /* maybe we have to clear the screen at the bottom */ 
116         if (y < y2) {
117                 fillRectangle(gc_lighted,
118                               0,
119                               y,
120                               _width,
121                               y2 - y);
122         }
123 }
124
125
126 void LyXScreen::DrawOneRow(Row *row, long &y_text)
127 {
128         long y = 0;
129    
130         y = y_text - first;
131       
132         if (y + row->height > 0 && y - row->height <= _height) {
133                 /* ok there is something visible */
134                 text->GetVisibleRow(*this, y, row, y + first);
135         }
136         y_text+=row->height;
137 }
138
139
140 /* draws the screen, starting with textposition y. uses as much already
141 * printed pixels as possible */
142 void LyXScreen::Draw(long  y)
143 {
144         if (cursor_visible) HideCursor();
145
146         if (y<0) y = 0;
147         long old_first = first;
148         first = y;
149
150         /* is any optimiziation possible? */ 
151         if ((y - old_first) < _height 
152             && (old_first - y) < _height) {
153                 if (first < old_first) {
154                         DrawFromTo(0, old_first - first);
155                         XCopyArea (fl_display,
156                                    _window,
157                                    _window,
158                                    getGC(gc_copy),
159                                    _offset_x, _offset_y, 
160                                    _width , _height - old_first + first,
161                                    _offset_x, _offset_y + old_first - first);
162                         // expose the area drawn
163                         expose(0, 0, _width, old_first - first);
164                 } else  {
165                         DrawFromTo(_height + old_first - first, _height);
166                         XCopyArea (fl_display,
167                                    _window,
168                                    _window,
169                                    getGC(gc_copy),
170                                    _offset_x, _offset_y + first - old_first, 
171                                    _width , _height + old_first - first, 
172                                    _offset_x, _offset_y);
173                         // expose the area drawn
174                         expose(0, _height + old_first - first, 
175                                _width, first - old_first);
176                 }
177         } else {
178                 /* make a dumb new-draw */ 
179                 DrawFromTo(0, _height);
180                 expose(0, 0, _width, _height);
181         }
182 }
183
184
185 void LyXScreen::ShowCursor()
186 {
187         long x = 0;
188         long y1 = 0;
189         long y2 = 0;
190    
191         if (cursor_visible) return;
192    
193         x = text->cursor.x;
194         
195         y1 = text->cursor.y - text->real_current_font.maxAscent() - first;
196         if (y1 < 0) y1 = 0;
197         
198         y2 = text->cursor.y + text->real_current_font.maxDescent() - first;
199         if (y2 > _height) y2 = _height;
200
201         // Secure against very strange situations
202         if (y2 < y1) y2 = y1;
203
204         if (fast_selection || mono_video) {
205                 if (y2 > 0 && y1 < _height) {
206                         XDrawLine(fl_display,
207                                   _window, getGC(gc_select),
208                                   x + _offset_x,
209                                   y1 + _offset_y,
210                                   x + _offset_x,
211                                   y2 + _offset_y);
212                         cursor_visible = true;
213                 }
214         } else {
215                 if (cursor_pixmap){
216                         XFreePixmap(fl_display, cursor_pixmap);
217                         cursor_pixmap = 0;
218                 }
219    
220                 if (y2 > 0 && y1 < _height) {
221                         cursor_pixmap_w = 1;
222                         cursor_pixmap_h = y2 - y1 + 1;
223                         cursor_pixmap_x = x;
224                         cursor_pixmap_y = y1;
225                         cursor_pixmap =
226                                 XCreatePixmap(fl_display,
227                                               fl_root,
228                                               cursor_pixmap_w,
229                                               cursor_pixmap_h,
230                                               fl_get_visual_depth());
231                         XCopyArea(fl_display,
232                                   _window,
233                                   cursor_pixmap,
234                                   getGC(gc_copy),
235                                   _offset_x + cursor_pixmap_x, 
236                                   _offset_y + cursor_pixmap_y,
237                                   cursor_pixmap_w, cursor_pixmap_h,
238                                   0, 0);
239                         XDrawLine(fl_display,
240                                   _window, getGC(gc_copy),
241                                   x + _offset_x,
242                                   y1 + _offset_y,
243                                   x + _offset_x,
244                                   y2 + _offset_y); 
245                         cursor_visible = true;
246                 }
247         }
248 }
249
250
251 /* returns 1 if first has changed, otherwise 0 */ 
252 int LyXScreen::FitManualCursor(long /*x*/, long y, int asc, int desc)
253 {
254         long  newtop = first;
255   
256         if (y + desc  - first >= _height)
257                 newtop = y - 3*_height / 4;   /* the scroll region must be so big!! */
258         else if (y - asc < first 
259                  && first > 0) {
260                 newtop = y - _height / 4;
261         }
262         if (newtop < 0)
263                 newtop = 0;
264   
265         if (newtop != first){
266                 Draw(newtop);
267                 first = newtop;
268                 return 1;
269         }
270         return 0;
271 }
272
273
274 void  LyXScreen::HideManualCursor(long x, long y, int asc, int desc){
275         if (fast_selection || mono_video)
276                 ShowManualCursor(x,y,asc,desc);
277         else
278                 HideCursor();
279 }
280
281
282 void  LyXScreen::ShowManualCursor(long x, long y, int asc, int desc)
283 {
284         long y1 = 0;
285         long y2 = 0;
286         
287         y1 = y - first - asc;
288         if (y1 < 0)
289                 y1 =0;
290         y2 = y -first + desc;
291         if (y2 > _height)
292                 y2 = _height;
293         
294         if (fast_selection || mono_video){
295                 if (y2 > 0 && y1 < _height) {
296                         XDrawLine(fl_display,
297                                   _window, getGC(gc_select),
298                                   x+_offset_x,
299                                   y1+_offset_y,
300                                   x+_offset_x,
301                                   y2+_offset_y);
302                 }
303         } else {
304                 if (cursor_pixmap){
305                         XFreePixmap(fl_display, cursor_pixmap);
306                         cursor_pixmap = 0;
307                 }
308                 
309                 if (y2 > 0 && y1 < _height) {
310                         cursor_pixmap_w = 1;
311                         cursor_pixmap_h = y2 - y1 + 1;
312                         cursor_pixmap_x = x,
313                         cursor_pixmap_y = y1;
314                         cursor_pixmap =
315                                 XCreatePixmap (fl_display,
316                                                fl_root,
317                                                cursor_pixmap_w,
318                                                cursor_pixmap_h,
319                                                fl_get_visual_depth());
320
321                         XCopyArea (fl_display,
322                                    _window,
323                                    cursor_pixmap,
324                                    getGC(gc_copy),
325                                    _offset_x + cursor_pixmap_x,
326                                    _offset_y + cursor_pixmap_y,
327                                    cursor_pixmap_w,
328                                    cursor_pixmap_h,
329                                    0, 0);
330                         XDrawLine(fl_display,
331                                   _window, getGC(gc_copy),
332                                   x+_offset_x,
333                                   y1+_offset_y,
334                                   x+_offset_x,
335                                   y2+_offset_y);                        
336                 }
337                 cursor_visible = true;
338         }
339 }
340
341
342 void LyXScreen::HideCursor()
343 {
344         if (!cursor_visible) return;
345         
346         if (fast_selection || mono_video){
347                 cursor_visible = false;
348                 ShowCursor();
349                 cursor_visible = false;
350         } else {
351                 if (cursor_pixmap){
352                         XCopyArea (fl_display, 
353                                    cursor_pixmap,
354                                    _window,
355                                    getGC(gc_copy),
356                                    0, 0, 
357                                    cursor_pixmap_w, cursor_pixmap_h,
358                                    cursor_pixmap_x + _offset_x,
359                                    cursor_pixmap_y + _offset_y);
360                 }
361                 cursor_visible = false;
362         }
363 }
364
365
366 void LyXScreen::CursorToggle()
367 {
368         if (cursor_visible)
369                 HideCursor();
370         else
371                 ShowCursor();
372 }
373
374
375 /* returns a new top so that the cursor is visible */ 
376 long LyXScreen::TopCursorVisible()
377 {
378         long  newtop = first;
379
380         if (text->cursor.y
381             - text->cursor.row->baseline
382             + text->cursor.row->height
383             - first >= _height) {
384                 if (text->cursor.row->height < _height
385                     && text->cursor.row->height > _height/4)
386                         newtop = text->cursor.y
387                                 + text->cursor.row->height
388                                 - text->cursor.row->baseline - _height;
389                 else
390                         newtop = text->cursor.y
391                                 - 3*_height / 4;   /* the scroll region must be so big!! */
392         } else if (text->cursor.y - text->cursor.row->baseline < first 
393                    && first > 0) {
394                 if (text->cursor.row->height < _height
395                     && text->cursor.row->height > _height/4)
396                         newtop = text->cursor.y - text->cursor.row->baseline;
397                 else {
398                         newtop = text->cursor.y - _height / 4;
399                         if (newtop > first)
400                                 newtop = first;
401                 }
402         }
403         if (newtop < 0)
404                 newtop = 0;
405         
406         return newtop;
407 }
408
409
410 /* scrolls the screen so that the cursor is visible, if necessary.
411 * returns 1 if a change was made, otherwise 0 */ 
412 int LyXScreen::FitCursor()
413 {
414         /* is a change necessary */ 
415         long  newtop = TopCursorVisible();
416         int result = (newtop != first);
417         if (result)
418                 Draw(newtop);
419         return result;
420 }
421
422    
423 void LyXScreen::Update()
424 {
425         long y = 0;
426
427         if (text->status == LyXText::NEED_MORE_REFRESH
428             || screen_refresh_y > -1 ) {
429                 if (screen_refresh_y > -1
430                     && screen_refresh_y < text->refresh_y)
431                         y = screen_refresh_y;
432                 else
433                         y = text->refresh_y;
434                 
435                 if (y < first) y = first;
436                 
437                 DrawFromTo(y - first, _height);
438                 text->refresh_y = 0;
439                 text->status = LyXText::UNCHANGED;
440                 screen_refresh_y = -1;
441                 expose(0, y-first, _width, _height - (y - first));
442         } else if (text->status == LyXText::NEED_VERY_LITTLE_REFRESH) {
443                 /* ok I will update the current cursor row */
444                 y = text->refresh_y;
445                 DrawOneRow(text->refresh_row, y);
446                 text->status = LyXText::UNCHANGED;
447                 expose(0, text->refresh_y-first,
448                      _width, text->refresh_row->height);
449         }
450 }
451
452
453 void LyXScreen::SmallUpdate()
454 {
455         Row *row = 0;
456         long y = 0;
457         long y2 = 0;
458         
459         if (text->status == LyXText::NEED_MORE_REFRESH){
460                 /* ok I will update till the current cursor row */
461                 row = text->refresh_row;
462                 y = text->refresh_y;
463                 y2 = y;
464       
465                 if (y > text->cursor.y) {
466                         Update();
467                         return;
468                 }
469          
470                 while (row && row != text->cursor.row && y < first + _height) {
471                         DrawOneRow(row, y);
472                         row = row->next;
473                 }
474       
475                 DrawOneRow(row, y);
476                 screen_refresh_y = y;
477                 screen_refresh_row = row->next;
478                 text->status = LyXText::UNCHANGED;
479                 // Is the right regin exposed?
480                 expose(0, y2-first, _width, y-y2);
481         } else if (text->status == LyXText::NEED_VERY_LITTLE_REFRESH) {
482                 /* ok I will update the current cursor row */
483                 row = text->refresh_row;
484                 y = text->refresh_y;
485                 DrawOneRow(row, y);
486                 text->status = LyXText::UNCHANGED;
487                 expose(0, text->refresh_y - first,
488                        _width, row->height);
489         }
490 }
491
492
493 void LyXScreen::ToggleSelection(bool kill_selection)
494 {
495         long top = 0;
496         long bottom = 0;
497    
498         /* only if there is a selection */ 
499         if (!text->selection)
500                 return;
501         
502         if (fast_selection || mono_video){
503                 
504                 /* selection only in one row ?*/ 
505                 if (text->sel_start_cursor.y == text->sel_end_cursor.y) {
506                         
507                         /* only if something is visible */ 
508                         if (text->sel_start_cursor.y
509                             - text->sel_start_cursor.row->baseline
510                             - first < _height
511                             && text->sel_start_cursor.y
512                             - text->sel_start_cursor.row->baseline + 
513                             text->sel_start_cursor.row->height - first > 0) {
514                                 top = text->sel_start_cursor.y
515                                         - text->sel_start_cursor.row->baseline
516                                         - first;
517                                 bottom = top
518                                         + text->sel_start_cursor.row->height;
519                                 if (top<0)
520                                         top = 0;
521                                 if (bottom > _height)
522                                         bottom = _height;
523                                 XFillRectangle(fl_display,_window,
524                                                getGC(gc_select),
525                                                text->sel_start_cursor.x
526                                                +_offset_x, 
527                                                top+_offset_y,
528                                                text->sel_end_cursor.x
529                                                - text->sel_start_cursor.x,
530                                                bottom - top);
531                         }
532                 } else {
533                         /* the sel_start_cursor row first */ 
534                         /* only if anything is visible */ 
535                         if (text->sel_start_cursor.y
536                             - text->sel_start_cursor.row->baseline
537                             - first < _height
538                             && text->sel_start_cursor.y
539                             - text->sel_start_cursor.row->baseline + 
540                             text->sel_start_cursor.row->height - first > 0) {
541                                 top = text->sel_start_cursor.y
542                                         - text->sel_start_cursor.row->baseline
543                                         - first;
544                                 bottom = top
545                                         + text->sel_start_cursor.row->height;
546                                 if (top<0)
547                                         top = 0;
548                                 if (bottom > _height)
549                                         bottom = _height;
550                                 XFillRectangle(fl_display,_window,
551                                                getGC(gc_select),
552                                                text->sel_start_cursor.x
553                                                +_offset_x, 
554                                                top+_offset_y,
555                                                _width
556                                                - text->sel_start_cursor.x,
557                                                bottom - top);
558                         }
559                         
560                         /* the main body */ 
561                         
562                         if (text->sel_start_cursor.row->next !=
563                             text->sel_end_cursor.row) {
564                                 top = text->sel_start_cursor.y
565                                         - text->sel_start_cursor.row->baseline
566                                         + text->sel_start_cursor.row->height;
567                                 bottom = text->sel_end_cursor.y
568                                         - text->sel_end_cursor.row->baseline;
569                                 
570                                 if (top - first < 0)
571                                         top = first;
572                                 if (bottom - first < 0)
573                                         bottom = first;
574                                 
575                                 if (bottom - first > _height)
576                                         bottom = first + _height;
577                                 if (top - first > _height)
578                                         top = first + _height;
579                                 
580                                 if (top != bottom) {
581                                         XFillRectangle(fl_display,
582                                                        _window,
583                                                        getGC(gc_select),
584                                                        0+_offset_x, 
585                                                        top - first+_offset_y,
586                                                        _width,
587                                                        bottom - top);
588                                 }
589                         }
590                         
591                         /* the sel_end_cursor row last */ 
592                         if (text->sel_end_cursor.y
593                             - text->sel_end_cursor.row->baseline
594                             - first < _height
595                             && text->sel_end_cursor.y
596                             - text->sel_end_cursor.row->baseline +
597                             text->sel_end_cursor.row->height - first > 0) {
598                                 top = text->sel_end_cursor.y
599                                         - text->sel_end_cursor.row->baseline
600                                         - first;
601                                 bottom = top
602                                         + text->sel_end_cursor.row->height;
603                                 if (top<0)
604                                         top = 0;
605                                 if (bottom > _height)
606                                         bottom = _height;
607                                 XFillRectangle(fl_display,_window,
608                                                getGC(gc_select),
609                                                0+_offset_x, 
610                                                top+_offset_y,
611                                                text->sel_end_cursor.x,
612                                                bottom - top);
613                         }
614                 }
615         } else {
616                 top = text->sel_start_cursor.y
617                         - text->sel_start_cursor.row->baseline;
618                 bottom = text->sel_end_cursor.y
619                         - text->sel_end_cursor.row->baseline 
620                         + text->sel_end_cursor.row->height;
621                 
622                 if (top - first < 0)
623                         top = first;
624                 if (bottom - first < 0)
625                         bottom = first;
626                 
627                 if (bottom - first > _height)
628                         bottom = first + _height;
629                 if (top - first > _height)
630                         top = first + _height;
631                 
632                 if (kill_selection)
633                         text->selection = 0;
634                 DrawFromTo(top - first, bottom - first);
635                 expose(0, top - first, _width, bottom - first - (top - first));
636         }
637 }
638   
639    
640 void LyXScreen::ToggleToggle()
641 {
642         long top = 0;
643         long bottom = 0;
644         
645         if (text->toggle_cursor.par == text->toggle_end_cursor.par
646             && text->toggle_cursor.pos == text->toggle_end_cursor.pos)
647                 return;
648
649         if (fast_selection || mono_video){
650                 
651                 /* selection only in one row ?*/ 
652                 if (text->toggle_cursor.y == text->toggle_end_cursor.y) {
653                         
654                         /* only if anything is visible */ 
655                         if (text->toggle_cursor.y - text->toggle_cursor.row->baseline - first < _height
656                             && text->toggle_cursor.y - text->toggle_cursor.row->baseline + 
657                             text->toggle_cursor.row->height - first > 0) {
658                                 top = text->toggle_cursor.y - text->toggle_cursor.row->baseline - first;
659                                 bottom = top + text->toggle_cursor.row->height;
660                                 if (top < 0) top = 0;
661                                 if (bottom > _height) bottom = _height;
662                                 XFillRectangle(fl_display,_window,
663                                                getGC(gc_select),
664                                                text->toggle_cursor.x+_offset_x, 
665                                                top+_offset_y,
666                                                text->toggle_end_cursor.x  -
667                                                text->toggle_cursor.x,
668                                                bottom - top);
669                         }
670                 } else {
671                         /* the toggle_cursor row first */ 
672                         /* only if anything is visible */ 
673                         if (text->toggle_cursor.y - text->toggle_cursor.row->baseline - first < _height
674                             && text->toggle_cursor.y - text->toggle_cursor.row->baseline + 
675                             text->toggle_cursor.row->height - first > 0) {
676                                 top = text->toggle_cursor.y - text->toggle_cursor.row->baseline - first;
677                                 bottom = top + text->toggle_cursor.row->height;
678                                 if (top<0)
679                                         top = 0;
680                                 if (bottom > _height)
681                                         bottom = _height;
682                                 XFillRectangle(fl_display,_window,
683                                                getGC(gc_select),
684                                                text->toggle_cursor.x+_offset_x, 
685                                                top+_offset_y,
686                                                _width - text->toggle_cursor.x,
687                                                bottom - top);
688                         }
689                         
690                         /* the main body */ 
691                         
692                         if (text->toggle_cursor.row->next !=
693                             text->toggle_end_cursor.row) {
694                                 top = text->toggle_cursor.y
695                                         - text->toggle_cursor.row->baseline
696                                         + text->toggle_cursor.row->height;
697                                 bottom = text->toggle_end_cursor.y
698                                         - text->toggle_end_cursor.row->baseline;
699                                 
700                                 if (top - first < 0)
701                                         top = first;
702                                 if (bottom - first < 0)
703                                         bottom = first;
704                                 
705                                 if (bottom - first > _height)
706                                         bottom = first + _height;
707                                 if (top - first > _height)
708                                         top = first + _height;
709                                 
710                                 if (top != bottom) {
711                                         XFillRectangle(fl_display,_window,
712                                                        getGC(gc_select),
713                                                        0+_offset_x, 
714                                                        top - first+_offset_y,
715                                                        _width,
716                                                        bottom - top);
717                                 }
718                         }
719                         
720                         /* the toggle_end_cursor row last */ 
721                         if (text->toggle_end_cursor.y - text->toggle_end_cursor.row->baseline - first < _height
722                             && text->toggle_end_cursor.y - text->toggle_end_cursor.row->baseline +
723                             text->toggle_end_cursor.row->height - first > 0) {
724                                 top = text->toggle_end_cursor.y
725                                         - text->toggle_end_cursor.row->baseline
726                                         - first;
727                                 bottom = top
728                                         + text->toggle_end_cursor.row->height;
729                                 if (top<0)
730                                         top = 0;
731                                 if (bottom > _height)
732                                         bottom = _height;
733                                 XFillRectangle(fl_display,_window,
734                                                getGC(gc_select),
735                                                0+_offset_x, 
736                                                top+_offset_y,
737                                                text->toggle_end_cursor.x,
738                                                bottom - top);
739                         }
740                 }
741         } else {
742                 top = text->toggle_cursor.y
743                         - text->toggle_cursor.row->baseline;
744                 bottom = text->toggle_end_cursor.y
745                         - text->toggle_end_cursor.row->baseline 
746                         + text->toggle_end_cursor.row->height;
747                 
748                 if (top - first < 0)
749                         top = first;
750                 if (bottom - first < 0)
751                         bottom = first;
752                 
753                 if (bottom - first > _height)
754                         bottom = first + _height;
755                 if (top - first > _height)
756                         top = first + _height;
757                 
758                 DrawFromTo(top - first, bottom - first);
759                 expose(0, top - first, _width, bottom - first - (top - first));
760         }
761 }
762
763
764         
765 void LyXScreen::drawTableLine(int baseline, int x, int length, bool on_off)
766 {
767         GC gc;
768         if (on_off)
769                 gc = getGC(gc_thin_on_off_line);
770         else
771                 gc = getGC(gc_copy);
772         drawLine(gc,
773                  x,
774                  baseline,
775                  x + length,
776                  baseline);
777 }
778
779         
780 void LyXScreen::drawVerticalTableLine(int x, int y1, int y2, bool on_off)
781 {
782         GC gc;
783         if (on_off)
784                 gc = getGC(gc_thin_on_off_line);
785         else
786                 gc = getGC(gc_copy);
787         drawLine(gc,
788                  x,
789                  y1,
790                  x,
791                  y2);
792 }
793
794
795 void LyXScreen::drawFrame(int /*ft*/, int x, int y, int w, int h,
796                           FL_COLOR /*col*/, int /*b*/)
797 {
798 #ifdef WITH_WARNINGS
799 #warning Implement this using X11 calls, and the repaint problems are gone!
800 #endif
801 // At least, I think that should do it since we only have them after
802 // one of these buttons are displayed now! Lars, it seems you've hit the
803 // nail :-) (Asger)
804 //      fl_winset(foreground);
805 //      fl_drw_frame(ft, x,  y,  w,  h, col, b);
806         // This should be changed to draw a button like frame, in the
807         // mean time we'll just use a regular rectangle
808      
809          // I want the buttons back before 0.12. OK, this is very simple,
810          // like what is done in xforms sources.  (Ale)
811
812         // This one is too dirty. Get rid of it.
813         extern GC fl_gc;
814
815         // Please comment this annonymous variable.
816         int d = 2;
817
818         // I think these calls to fl_color might make xforms sometimes
819         // draw the wrong color on other objects.
820         fl_color(FL_TOP_BCOL);
821         XFillRectangle(fl_display, foreground, fl_gc,x-d,y-d,w+2*d,d);
822         fl_color(FL_BOTTOM_BCOL);
823         XFillRectangle(fl_display, foreground, fl_gc,x-d,y+h,w+2*d,d);
824  
825         // Now a couple of trapezoids
826         XPoint pl[4], pr[4]; 
827  
828         pl[0].x = x-d;   pl[0].y = y-d;
829         pl[1].x = x-d;   pl[1].y = y+h+d;
830         pl[2].x = x;     pl[2].y = y+h;
831         pl[3].x = x;     pl[3].y = y;
832         
833         pr[0].x = x+w+d; pr[0].y = y-d;
834         pr[1].x = x+w+d; pr[1].y = y+h+d;
835         pr[2].x = x+w;   pr[2].y = y+h;
836         pr[3].x = x+w;   pr[3].y = y;
837         
838         fl_color(FL_LEFT_BCOL);
839         XFillPolygon(fl_display,
840                      foreground,
841                      fl_gc, pl, 4,
842                      Convex, CoordModeOrigin); 
843         fl_color(FL_RIGHT_BCOL);
844         XFillPolygon(fl_display,
845                      foreground,
846                      fl_gc, pr, 4,
847                      Convex, CoordModeOrigin); 
848 }