]> git.lyx.org Git - features.git/commitdiff
fix the outstanding painter drawing problems, now tablelines, mathframe, specialchars...
authorLars Gullik Bjønnes <larsbj@gullik.org>
Fri, 11 Feb 2000 16:56:34 +0000 (16:56 +0000)
committerLars Gullik Bjønnes <larsbj@gullik.org>
Fri, 11 Feb 2000 16:56:34 +0000 (16:56 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@552 a592a061-630c-0410-9148-cb99ea01b6c8

ChangeLog
src/BufferView.C
src/Painter.C
src/Painter.h
src/insets/figinset.C
src/insets/insetspecialchar.C
src/mathed/math_cursor.C
src/text.C
src/text2.C

index 6baf57cd83718db2611f44eb5adc69c796a9d2b8..47ef58bef36adaaf1c84c1d65bae75176fe7e59c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2000-02-11  Lars Gullik Bjønnes  <larsbj@lyx.org>
+
+       * src/text2.C (owner): only complain if owner_ is set and bv != 0
+
+       * src/BufferView.C (resizeCurrentBuffer): set the owner of the
+       newly found text in textcache to this.
+       (buffer): set the owner of the text put into the textcache to 0
+
+       * src/insets/figinset.C (draw): fixed the drawing of figures with
+       the new Painter.
+
+       * src/text.C src/mathed/math_cursor.C: nailed and fixed the
+       drawing of mathframe, hfills, protected space, table lines. I have
+       now no outstanding drawing problems with the new Painter code. 
+
 2000-02-11  Jean-Marc Lasgouttes  <Jean-Marc.Lasgouttes@inria.fr>
 
        * src/PainterBase.C (ellipse, circle): do not specify the default
index 0cb2be39dbe55c408aabcc2a764b38878d3da90b..d8f6c40950e159fbc6e49865653054d77efe3126 100644 (file)
@@ -132,6 +132,8 @@ void BufferView::buffer(Buffer * b)
 
                // Put the old text into the TextCache, but
                // only if the buffer is still loaded.
+               // Also set the owner of the test to 0
+               text->owner(0);
                textcache.add(text);
                if (lyxerr.debugging())
                        textcache.show(lyxerr, "BufferView::buffer");
@@ -431,6 +433,8 @@ int BufferView::resizeCurrentBuffer()
                                lyxerr << "Found a LyXText that fits:\n";
                                textcache.show(lyxerr, text);
                        }
+                       // Set the owner of the newly found text
+                       text->owner(this);
                        if (lyxerr.debugging())
                                textcache.show(lyxerr, "resizeCurrentBuffer");
                } else {
index b46b1cef75dc2a7a3583763e44dc458baf0cde75..68f26780c85a6b184d6a8063703e75095ac6d9a3 100644 (file)
@@ -236,7 +236,7 @@ PainterBase & Painter::segments(int const * x1, int const * y1,
 }
 
 
-PainterBase & Painter::pixmap(int x, int y, Pixmap bitmap)
+PainterBase & Painter::pixmap(int x, int y, int w, int h, Pixmap bitmap)
 {
        if (lyxerr.debugging()) {
                if (!Lgb_bug_find_hack)
@@ -249,7 +249,6 @@ PainterBase & Painter::pixmap(int x, int y, Pixmap bitmap)
        val.function = GXcopy;
        GC gc = XCreateGC(display, drawable,
                          GCFunction, &val);
-        int w = 0, h = 0;
        XCopyArea(display, bitmap, drawable, gc,
                  0, 0, w, h, x, y);
        XFreeGC(display, gc);
index ddc5dea23ba011d74b41daf162a02efa71548e34..cd492b7d09e170d071d2de8d3315f169f6280426 100644 (file)
@@ -89,7 +89,7 @@ public:
        /**@Image stuff */
        
        /// For the figure inset
-       PainterBase & pixmap(int x, int y, Pixmap bitmap);
+       PainterBase & pixmap(int x, int y, int w, int h, Pixmap bitmap);
 
        /**@String functions */
        
index 0c43edfb020f85aaa5e7f410428930f73fee3a3b..4a798fc42d09aae9242efeda32e3aed2271bce91 100644 (file)
@@ -1101,19 +1101,17 @@ void InsetFig::draw(Painter & pain, LyXFont const & f,
        // but the figinset code is so complicated so
        // I don't want to fiddle with it now.
 
-#if 0
-       unsigned long pm = pain.getScreen()->getForeground();
        if (figure && figure->data && figure->data->bitmap &&
            !figure->data->reading && !figure->data->broken) {
                // draw the bitmap
-               XCopyArea(fl_display, figure->data->bitmap, pm, getGC(gc_copy),
-                         0, 0, wid, hgh, int(x+1), baseline-hgh);
-               XFlush(fl_display);
-               if (flags & 4) XDrawRectangle(fl_display, pm, getGC(gc_copy),
-                                             int(x), baseline - hgh - 1,
-                                             wid+1, hgh+1);
+               pain.pixmap(int(x + 1), baseline - hgh,
+                           wid, hgh, figure->data->bitmap);
+
+               if (flags & 4)
+                       pain.rectangle(int(x), baseline - hgh - 1,
+                                      wid + 1, hgh + 1);
+               
        } else {
-#endif
                char * msg = 0;
                // draw frame
                pain.rectangle(x, baseline - hgh - 1, wid + 1, hgh + 1);
@@ -1136,9 +1134,7 @@ void InsetFig::draw(Painter & pain, LyXFont const & f,
                
                font.setSize(LyXFont::SIZE_TINY);
                pain.text(int(x + 8), baseline - 4, msg, strlen(msg), font);
-#if 0
        }
-#endif
        x += width(pain, font);    // ?
 }
 #else
index 3b831ed654accfbfb23fd4514f02b93ad501021b..cbc9f67f23282709a9483ec2ce04f809cfe3e163 100644 (file)
@@ -113,39 +113,39 @@ void InsetSpecialChar::draw(Painter & pain, LyXFont const & f,
        switch (kind) {
        case HYPHENATION:
        {
-               font.setColor(LColor::magenta);
+               font.setColor(LColor::special);
                pain.text(int(x), baseline, "-", font);
                x += width(pain, font);
                break;
        }
        case END_OF_SENTENCE:
        {
-               font.setColor(LColor::magenta);
+               font.setColor(LColor::special);
                pain.text(int(x), baseline, ".", font);
                x += width(pain, font);
                break;
        }
        case LDOTS:
        {
-               font.setColor(LColor::magenta);
+               font.setColor(LColor::special);
                pain.text(int(x), baseline, ". . .", font);
                x += width(pain, font);
                break;
        }
        case MENU_SEPARATOR:
        {
-#if 0
                // A triangle the width and height of an 'x'
                int w = font.textWidth("x", 1);
                int ox = font.textWidth(" ", 1) + int(x);
                int h = font.ascent('x');
-               XPoint p[4];
-               p[0].x = ox;    p[0].y = baseline;
-               p[1].x = ox;    p[1].y = baseline - h;
-               p[2].x = ox + w;p[2].y = baseline - h/2;
-               p[3].x = ox;    p[3].y = baseline;
-               scr.drawLines(getGC(gc_copy), p, 4);
-#endif
+               int xp[4], yp[4];
+               
+               xp[0] = ox;     yp[0] = baseline;
+               xp[1] = ox;     yp[1] = baseline - h;
+               xp[2] = ox + w; yp[2] = baseline - h/2;
+               xp[3] = ox;     yp[3] = baseline;
+               
+               pain.lines(xp, yp, 4, LColor::special);
                x += width(pain, font);
        }
        }
index 90c5beb193c46ba6639ae4aab0fee33c232326da..c98affa961716e777b093b4d727f3075bc0aa3f5 100644 (file)
@@ -162,9 +162,7 @@ void MathedCursor::draw(Painter & pain, int x, int y)
        int h = par->Height() + 1;
        if (par->GetType() > LM_OT_PAR) { a += 4;  h += 8; }
        
-       pain.rectangle(x - 1, y - a,
-                      x - 1 + w, y - a + h,
-                      LColor::mathframe);
+       pain.rectangle(x - 1, y - a, w, h, LColor::mathframe);
        
        par->draw(pain, x, y);
        cursor->Adjust();
index 6f9d5cb112b84f57e8efea62b7513866ae80eb04..45bd46d8989e83718b92bcab5936cc0cabbedd3c 100644 (file)
@@ -4112,12 +4112,12 @@ void LyXText::GetVisibleRow(int offset,
                    sel_end_cursor.row == row_ptr) {
                        if (sel_start_cursor.x < sel_end_cursor.x)
                                pain.fillRectangle(sel_start_cursor.x, offset,
-                                                  sel_end_cursor.x,
+                                                  sel_end_cursor.x - sel_start_cursor.x,
                                                   row_ptr->height,
                                                   LColor::selection);
                        else
                                pain.fillRectangle(sel_end_cursor.x, offset,
-                                                  sel_start_cursor.x,
+                                                  sel_start_cursor.x - sel_end_cursor.x,
                                                   row_ptr->height,
                                                   LColor::selection);
                }
@@ -4172,7 +4172,7 @@ void LyXText::GetVisibleRow(int offset,
        if (row_ptr->par->footnoteflag == LyXParagraph::OPEN_FOOTNOTE) {
                LyXFont font(LyXFont::ALL_SANE);
                font.setSize(LyXFont::SIZE_FOOTNOTE);
-               font.setColor(LColor::red);
+               font.setColor(LColor::footnote);
                
                int box_x = LYX_PAPER_MARGIN;
                box_x += font.textWidth(" wide-tab ", 10);
@@ -4279,9 +4279,9 @@ void LyXText::GetVisibleRow(int offset,
                
                 /* start of appendix? */
                if (row_ptr->par->start_of_appendix){
-                       owner_->painter().line(1, offset,
-                                              paperwidth - 2, offset,
-                                              LColor::appendixline);
+                       pain.line(1, offset,
+                                 paperwidth - 2, offset,
+                                 LColor::appendixline);
                }
 
                /* think about the margins */ 
@@ -4290,7 +4290,8 @@ void LyXText::GetVisibleRow(int offset,
                
                if (row_ptr->par->pagebreak_top){ /* draw a top pagebreak  */
                        pain.line(0, offset + y_top + 2 * DefaultHeight(),
-                                 paperwidth, offset + y_top + 2 * DefaultHeight(),
+                                 paperwidth,
+                                 offset + y_top + 2 * DefaultHeight(),
                                  LColor::pagebreak, Painter::line_onoffdash);
                        y_top += 3 * DefaultHeight();
                }
@@ -4505,9 +4506,10 @@ void LyXText::GetVisibleRow(int offset,
                                    !row_ptr->par->table->IsContRow(cell))
                                        pain.line(int(x_old),
                                                  offset + row_ptr->baseline - row_ptr->ascent_of_text,
-                                                 int(x - x_old),
+                                                 int(x),
                                                  offset + row_ptr->baseline - row_ptr->ascent_of_text,
-                                                 LColor::tableline);
+                                                 LColor::tableline,
+                                                 on_off ? Painter::line_onoffdash : Painter::line_solid);
                                
                                on_off = !row_ptr->par->table->BottomLine(cell);
                                if ((!on_off && !row_ptr->par->table->RowHasContRow(cell)) ||
@@ -4515,18 +4517,19 @@ void LyXText::GetVisibleRow(int offset,
 
                                        pain.line(int(x_old),
                                                  offset + y_bottom - 1,
-                                                 int(x - x_old),
+                                                 int(x),
                                                  offset + y_bottom - 1,
-                                                 LColor::tableline);
+                                                 LColor::tableline,
+                                                 on_off ? Painter::line_onoffdash : Painter::line_solid);
 
                                on_off = !row_ptr->par->table->LeftLine(cell);
 
                                pain.line(int(x_old),
                                          offset + row_ptr->baseline - row_ptr->ascent_of_text,
                                          int(x_old),
-                                         offset + y_bottom,
+                                         offset + y_bottom - 1,
                                          LColor::tableline,
-                                         Painter::line_onoffdash);
+                                         on_off ? Painter::line_onoffdash : Painter::line_solid);
                                
                                on_off = !row_ptr->par->table->RightLine(cell);
 
@@ -4535,7 +4538,7 @@ void LyXText::GetVisibleRow(int offset,
                                          int(x) - row_ptr->par->table->AdditionalWidth(cell),
                                          offset + y_bottom - 1,
                                          LColor::tableline,
-                                         Painter::line_onoffdash);
+                                         on_off ? Painter::line_onoffdash : Painter::line_solid);
                                
                                x_old = x;
                 /* take care about the alignment and other spaces */
@@ -4570,7 +4573,7 @@ void LyXText::GetVisibleRow(int offset,
                                                
                                                pain.line(int(tmpx),
                                                          offset + row_ptr->baseline - 1,
-                                                         int(x - tmpx - 2),
+                                                         int(x - 2),
                                                          offset + row_ptr->baseline - 1,
                                                          LColor::vfillline);
                                                
@@ -4607,20 +4610,20 @@ void LyXText::GetVisibleRow(int offset,
 
                                pain.line(int(x_old),
                                          offset + row_ptr->baseline - row_ptr->ascent_of_text,
-                                         int(x - x_old),
+                                         int(x),
                                          offset + row_ptr->baseline - row_ptr->ascent_of_text,
                                          LColor::tableline,
-                                         Painter::line_onoffdash);
+                                         on_off ? Painter::line_onoffdash : Painter::line_solid);
                        on_off = !row_ptr->par->table->BottomLine(cell);
                        if ((!on_off && !row_ptr->par->table->RowHasContRow(cell)) ||
                            row_ptr->par->table->VeryLastRow(cell))
 
                                pain.line(int(x_old),
                                          offset + y_bottom - 1,
-                                         int(x - x_old),
+                                         int(x),
                                          offset + y_bottom - 1,
                                          LColor::tableline,
-                                         Painter::line_onoffdash);
+                                         on_off ? Painter::line_onoffdash : Painter::line_solid);
                        
                        on_off = !row_ptr->par->table->LeftLine(cell);
 
@@ -4629,7 +4632,7 @@ void LyXText::GetVisibleRow(int offset,
                                  int(x_old),
                                  offset + y_bottom - 1,
                                  LColor::tableline,
-                                 Painter::line_onoffdash);
+                                 on_off ? Painter::line_onoffdash : Painter::line_solid);
                        
                        on_off = !row_ptr->par->table->RightLine(cell);
 
@@ -4638,7 +4641,7 @@ void LyXText::GetVisibleRow(int offset,
                                  int(x) - row_ptr->par->table->AdditionalWidth(cell),
                                  offset + y_bottom - 1,
                                  LColor::tableline,
-                                 Painter::line_onoffdash);
+                                 on_off ? Painter::line_onoffdash : Painter::line_solid);
                }
        } else {
                /* table stuff -- end*/
@@ -4669,7 +4672,7 @@ void LyXText::GetVisibleRow(int offset,
                                        if (pos >= main_body) {
                                                pain.line(int(x),
                                                          offset + row_ptr->baseline - DefaultHeight() / 4,
-                                                         int(fill_hfill),
+                                                         int(x + fill_hfill),
                                                          offset + row_ptr->baseline - DefaultHeight() / 4,
                                                          LColor::vfillline,
                                                          Painter::line_onoffdash);
@@ -4677,7 +4680,7 @@ void LyXText::GetVisibleRow(int offset,
                     } else {
                            pain.line(int(x),
                                      offset + row_ptr->baseline - DefaultHeight() / 4,
-                                     int(fill_label_hfill),
+                                     int(x + fill_label_hfill),
                                      offset + row_ptr->baseline - DefaultHeight() / 4,
                                      LColor::vfillline,
                                      Painter::line_onoffdash);
@@ -4710,7 +4713,7 @@ void LyXText::GetVisibleRow(int offset,
                                                
                                                pain.line(int(tmpx),
                                                          offset + row_ptr->baseline - 1,
-                                                         int(tmpx),
+                                                         int(x - 2),
                                                          offset + row_ptr->baseline - 1,
                                                          LColor::vfillline);
 
index 4652c1c803e7b9e81ab39273c0b0fa5cf0bfb9a0..ba3a801fa652657f5262a7508e84e1f9e5d8b5b0 100644 (file)
@@ -99,7 +99,7 @@ LyXText::~LyXText()
 
 void LyXText::owner(BufferView * bv)
 {
-       if (owner_) lyxerr << "LyXText::owner_ already set!" << endl;
+       if (owner_ && bv) lyxerr << "LyXText::owner_ already set!" << endl;
        owner_ = bv;
 }