From bc4646a58eacf8b67f8fd9c6b91d117a2d985127 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars=20Gullik=20Bj=C3=B8nnes?= Date: Fri, 11 Feb 2000 16:56:34 +0000 Subject: [PATCH] fix the outstanding painter drawing problems, now tablelines, mathframe, specialchars, selection and images work as they should again. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@552 a592a061-630c-0410-9148-cb99ea01b6c8 --- ChangeLog | 15 +++++++++++ src/BufferView.C | 4 +++ src/Painter.C | 3 +-- src/Painter.h | 2 +- src/insets/figinset.C | 18 +++++-------- src/insets/insetspecialchar.C | 22 +++++++-------- src/mathed/math_cursor.C | 4 +-- src/text.C | 51 ++++++++++++++++++----------------- src/text2.C | 2 +- 9 files changed, 68 insertions(+), 53 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6baf57cd83..47ef58bef3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,18 @@ +2000-02-11 Lars Gullik Bjønnes + + * 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 * src/PainterBase.C (ellipse, circle): do not specify the default diff --git a/src/BufferView.C b/src/BufferView.C index 0cb2be39db..d8f6c40950 100644 --- a/src/BufferView.C +++ b/src/BufferView.C @@ -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 { diff --git a/src/Painter.C b/src/Painter.C index b46b1cef75..68f26780c8 100644 --- a/src/Painter.C +++ b/src/Painter.C @@ -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); diff --git a/src/Painter.h b/src/Painter.h index ddc5dea23b..cd492b7d09 100644 --- a/src/Painter.h +++ b/src/Painter.h @@ -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 */ diff --git a/src/insets/figinset.C b/src/insets/figinset.C index 0c43edfb02..4a798fc42d 100644 --- a/src/insets/figinset.C +++ b/src/insets/figinset.C @@ -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 diff --git a/src/insets/insetspecialchar.C b/src/insets/insetspecialchar.C index 3b831ed654..cbc9f67f23 100644 --- a/src/insets/insetspecialchar.C +++ b/src/insets/insetspecialchar.C @@ -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); } } diff --git a/src/mathed/math_cursor.C b/src/mathed/math_cursor.C index 90c5beb193..c98affa961 100644 --- a/src/mathed/math_cursor.C +++ b/src/mathed/math_cursor.C @@ -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(); diff --git a/src/text.C b/src/text.C index 6f9d5cb112..45bd46d898 100644 --- a/src/text.C +++ b/src/text.C @@ -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); diff --git a/src/text2.C b/src/text2.C index 4652c1c803..ba3a801fa6 100644 --- a/src/text2.C +++ b/src/text2.C @@ -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; }