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
This commit is contained in:
Lars Gullik Bjønnes 2000-02-11 16:56:34 +00:00
parent 391d71dab2
commit bc4646a58e
9 changed files with 68 additions and 53 deletions

View File

@ -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> 2000-02-11 Jean-Marc Lasgouttes <Jean-Marc.Lasgouttes@inria.fr>
* src/PainterBase.C (ellipse, circle): do not specify the default * src/PainterBase.C (ellipse, circle): do not specify the default

View File

@ -132,6 +132,8 @@ void BufferView::buffer(Buffer * b)
// Put the old text into the TextCache, but // Put the old text into the TextCache, but
// only if the buffer is still loaded. // only if the buffer is still loaded.
// Also set the owner of the test to 0
text->owner(0);
textcache.add(text); textcache.add(text);
if (lyxerr.debugging()) if (lyxerr.debugging())
textcache.show(lyxerr, "BufferView::buffer"); textcache.show(lyxerr, "BufferView::buffer");
@ -431,6 +433,8 @@ int BufferView::resizeCurrentBuffer()
lyxerr << "Found a LyXText that fits:\n"; lyxerr << "Found a LyXText that fits:\n";
textcache.show(lyxerr, text); textcache.show(lyxerr, text);
} }
// Set the owner of the newly found text
text->owner(this);
if (lyxerr.debugging()) if (lyxerr.debugging())
textcache.show(lyxerr, "resizeCurrentBuffer"); textcache.show(lyxerr, "resizeCurrentBuffer");
} else { } else {

View 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 (lyxerr.debugging()) {
if (!Lgb_bug_find_hack) if (!Lgb_bug_find_hack)
@ -249,7 +249,6 @@ PainterBase & Painter::pixmap(int x, int y, Pixmap bitmap)
val.function = GXcopy; val.function = GXcopy;
GC gc = XCreateGC(display, drawable, GC gc = XCreateGC(display, drawable,
GCFunction, &val); GCFunction, &val);
int w = 0, h = 0;
XCopyArea(display, bitmap, drawable, gc, XCopyArea(display, bitmap, drawable, gc,
0, 0, w, h, x, y); 0, 0, w, h, x, y);
XFreeGC(display, gc); XFreeGC(display, gc);

View File

@ -89,7 +89,7 @@ public:
/**@Image stuff */ /**@Image stuff */
/// For the figure inset /// 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 */ /**@String functions */

View File

@ -1101,19 +1101,17 @@ void InsetFig::draw(Painter & pain, LyXFont const & f,
// but the figinset code is so complicated so // but the figinset code is so complicated so
// I don't want to fiddle with it now. // I don't want to fiddle with it now.
#if 0
unsigned long pm = pain.getScreen()->getForeground();
if (figure && figure->data && figure->data->bitmap && if (figure && figure->data && figure->data->bitmap &&
!figure->data->reading && !figure->data->broken) { !figure->data->reading && !figure->data->broken) {
// draw the bitmap // draw the bitmap
XCopyArea(fl_display, figure->data->bitmap, pm, getGC(gc_copy), pain.pixmap(int(x + 1), baseline - hgh,
0, 0, wid, hgh, int(x+1), baseline-hgh); wid, hgh, figure->data->bitmap);
XFlush(fl_display);
if (flags & 4) XDrawRectangle(fl_display, pm, getGC(gc_copy), if (flags & 4)
int(x), baseline - hgh - 1, pain.rectangle(int(x), baseline - hgh - 1,
wid+1, hgh+1); wid + 1, hgh + 1);
} else { } else {
#endif
char * msg = 0; char * msg = 0;
// draw frame // draw frame
pain.rectangle(x, baseline - hgh - 1, wid + 1, hgh + 1); 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); font.setSize(LyXFont::SIZE_TINY);
pain.text(int(x + 8), baseline - 4, msg, strlen(msg), font); pain.text(int(x + 8), baseline - 4, msg, strlen(msg), font);
#if 0
} }
#endif
x += width(pain, font); // ? x += width(pain, font); // ?
} }
#else #else

View File

@ -113,39 +113,39 @@ void InsetSpecialChar::draw(Painter & pain, LyXFont const & f,
switch (kind) { switch (kind) {
case HYPHENATION: case HYPHENATION:
{ {
font.setColor(LColor::magenta); font.setColor(LColor::special);
pain.text(int(x), baseline, "-", font); pain.text(int(x), baseline, "-", font);
x += width(pain, font); x += width(pain, font);
break; break;
} }
case END_OF_SENTENCE: case END_OF_SENTENCE:
{ {
font.setColor(LColor::magenta); font.setColor(LColor::special);
pain.text(int(x), baseline, ".", font); pain.text(int(x), baseline, ".", font);
x += width(pain, font); x += width(pain, font);
break; break;
} }
case LDOTS: case LDOTS:
{ {
font.setColor(LColor::magenta); font.setColor(LColor::special);
pain.text(int(x), baseline, ". . .", font); pain.text(int(x), baseline, ". . .", font);
x += width(pain, font); x += width(pain, font);
break; break;
} }
case MENU_SEPARATOR: case MENU_SEPARATOR:
{ {
#if 0
// A triangle the width and height of an 'x' // A triangle the width and height of an 'x'
int w = font.textWidth("x", 1); int w = font.textWidth("x", 1);
int ox = font.textWidth(" ", 1) + int(x); int ox = font.textWidth(" ", 1) + int(x);
int h = font.ascent('x'); int h = font.ascent('x');
XPoint p[4]; int xp[4], yp[4];
p[0].x = ox; p[0].y = baseline;
p[1].x = ox; p[1].y = baseline - h; xp[0] = ox; yp[0] = baseline;
p[2].x = ox + w;p[2].y = baseline - h/2; xp[1] = ox; yp[1] = baseline - h;
p[3].x = ox; p[3].y = baseline; xp[2] = ox + w; yp[2] = baseline - h/2;
scr.drawLines(getGC(gc_copy), p, 4); xp[3] = ox; yp[3] = baseline;
#endif
pain.lines(xp, yp, 4, LColor::special);
x += width(pain, font); x += width(pain, font);
} }
} }

View File

@ -162,9 +162,7 @@ void MathedCursor::draw(Painter & pain, int x, int y)
int h = par->Height() + 1; int h = par->Height() + 1;
if (par->GetType() > LM_OT_PAR) { a += 4; h += 8; } if (par->GetType() > LM_OT_PAR) { a += 4; h += 8; }
pain.rectangle(x - 1, y - a, pain.rectangle(x - 1, y - a, w, h, LColor::mathframe);
x - 1 + w, y - a + h,
LColor::mathframe);
par->draw(pain, x, y); par->draw(pain, x, y);
cursor->Adjust(); cursor->Adjust();

View File

@ -4112,12 +4112,12 @@ void LyXText::GetVisibleRow(int offset,
sel_end_cursor.row == row_ptr) { sel_end_cursor.row == row_ptr) {
if (sel_start_cursor.x < sel_end_cursor.x) if (sel_start_cursor.x < sel_end_cursor.x)
pain.fillRectangle(sel_start_cursor.x, offset, pain.fillRectangle(sel_start_cursor.x, offset,
sel_end_cursor.x, sel_end_cursor.x - sel_start_cursor.x,
row_ptr->height, row_ptr->height,
LColor::selection); LColor::selection);
else else
pain.fillRectangle(sel_end_cursor.x, offset, pain.fillRectangle(sel_end_cursor.x, offset,
sel_start_cursor.x, sel_start_cursor.x - sel_end_cursor.x,
row_ptr->height, row_ptr->height,
LColor::selection); LColor::selection);
} }
@ -4172,7 +4172,7 @@ void LyXText::GetVisibleRow(int offset,
if (row_ptr->par->footnoteflag == LyXParagraph::OPEN_FOOTNOTE) { if (row_ptr->par->footnoteflag == LyXParagraph::OPEN_FOOTNOTE) {
LyXFont font(LyXFont::ALL_SANE); LyXFont font(LyXFont::ALL_SANE);
font.setSize(LyXFont::SIZE_FOOTNOTE); font.setSize(LyXFont::SIZE_FOOTNOTE);
font.setColor(LColor::red); font.setColor(LColor::footnote);
int box_x = LYX_PAPER_MARGIN; int box_x = LYX_PAPER_MARGIN;
box_x += font.textWidth(" wide-tab ", 10); box_x += font.textWidth(" wide-tab ", 10);
@ -4279,9 +4279,9 @@ void LyXText::GetVisibleRow(int offset,
/* start of appendix? */ /* start of appendix? */
if (row_ptr->par->start_of_appendix){ if (row_ptr->par->start_of_appendix){
owner_->painter().line(1, offset, pain.line(1, offset,
paperwidth - 2, offset, paperwidth - 2, offset,
LColor::appendixline); LColor::appendixline);
} }
/* think about the margins */ /* think about the margins */
@ -4290,7 +4290,8 @@ void LyXText::GetVisibleRow(int offset,
if (row_ptr->par->pagebreak_top){ /* draw a top pagebreak */ if (row_ptr->par->pagebreak_top){ /* draw a top pagebreak */
pain.line(0, offset + y_top + 2 * DefaultHeight(), 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); LColor::pagebreak, Painter::line_onoffdash);
y_top += 3 * DefaultHeight(); y_top += 3 * DefaultHeight();
} }
@ -4505,9 +4506,10 @@ void LyXText::GetVisibleRow(int offset,
!row_ptr->par->table->IsContRow(cell)) !row_ptr->par->table->IsContRow(cell))
pain.line(int(x_old), pain.line(int(x_old),
offset + row_ptr->baseline - row_ptr->ascent_of_text, offset + row_ptr->baseline - row_ptr->ascent_of_text,
int(x - x_old), int(x),
offset + row_ptr->baseline - row_ptr->ascent_of_text, 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); on_off = !row_ptr->par->table->BottomLine(cell);
if ((!on_off && !row_ptr->par->table->RowHasContRow(cell)) || if ((!on_off && !row_ptr->par->table->RowHasContRow(cell)) ||
@ -4515,18 +4517,19 @@ void LyXText::GetVisibleRow(int offset,
pain.line(int(x_old), pain.line(int(x_old),
offset + y_bottom - 1, offset + y_bottom - 1,
int(x - x_old), int(x),
offset + y_bottom - 1, offset + y_bottom - 1,
LColor::tableline); LColor::tableline,
on_off ? Painter::line_onoffdash : Painter::line_solid);
on_off = !row_ptr->par->table->LeftLine(cell); on_off = !row_ptr->par->table->LeftLine(cell);
pain.line(int(x_old), pain.line(int(x_old),
offset + row_ptr->baseline - row_ptr->ascent_of_text, offset + row_ptr->baseline - row_ptr->ascent_of_text,
int(x_old), int(x_old),
offset + y_bottom, offset + y_bottom - 1,
LColor::tableline, LColor::tableline,
Painter::line_onoffdash); on_off ? Painter::line_onoffdash : Painter::line_solid);
on_off = !row_ptr->par->table->RightLine(cell); 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), int(x) - row_ptr->par->table->AdditionalWidth(cell),
offset + y_bottom - 1, offset + y_bottom - 1,
LColor::tableline, LColor::tableline,
Painter::line_onoffdash); on_off ? Painter::line_onoffdash : Painter::line_solid);
x_old = x; x_old = x;
/* take care about the alignment and other spaces */ /* take care about the alignment and other spaces */
@ -4570,7 +4573,7 @@ void LyXText::GetVisibleRow(int offset,
pain.line(int(tmpx), pain.line(int(tmpx),
offset + row_ptr->baseline - 1, offset + row_ptr->baseline - 1,
int(x - tmpx - 2), int(x - 2),
offset + row_ptr->baseline - 1, offset + row_ptr->baseline - 1,
LColor::vfillline); LColor::vfillline);
@ -4607,20 +4610,20 @@ void LyXText::GetVisibleRow(int offset,
pain.line(int(x_old), pain.line(int(x_old),
offset + row_ptr->baseline - row_ptr->ascent_of_text, offset + row_ptr->baseline - row_ptr->ascent_of_text,
int(x - x_old), int(x),
offset + row_ptr->baseline - row_ptr->ascent_of_text, offset + row_ptr->baseline - row_ptr->ascent_of_text,
LColor::tableline, LColor::tableline,
Painter::line_onoffdash); on_off ? Painter::line_onoffdash : Painter::line_solid);
on_off = !row_ptr->par->table->BottomLine(cell); on_off = !row_ptr->par->table->BottomLine(cell);
if ((!on_off && !row_ptr->par->table->RowHasContRow(cell)) || if ((!on_off && !row_ptr->par->table->RowHasContRow(cell)) ||
row_ptr->par->table->VeryLastRow(cell)) row_ptr->par->table->VeryLastRow(cell))
pain.line(int(x_old), pain.line(int(x_old),
offset + y_bottom - 1, offset + y_bottom - 1,
int(x - x_old), int(x),
offset + y_bottom - 1, offset + y_bottom - 1,
LColor::tableline, LColor::tableline,
Painter::line_onoffdash); on_off ? Painter::line_onoffdash : Painter::line_solid);
on_off = !row_ptr->par->table->LeftLine(cell); on_off = !row_ptr->par->table->LeftLine(cell);
@ -4629,7 +4632,7 @@ void LyXText::GetVisibleRow(int offset,
int(x_old), int(x_old),
offset + y_bottom - 1, offset + y_bottom - 1,
LColor::tableline, LColor::tableline,
Painter::line_onoffdash); on_off ? Painter::line_onoffdash : Painter::line_solid);
on_off = !row_ptr->par->table->RightLine(cell); 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), int(x) - row_ptr->par->table->AdditionalWidth(cell),
offset + y_bottom - 1, offset + y_bottom - 1,
LColor::tableline, LColor::tableline,
Painter::line_onoffdash); on_off ? Painter::line_onoffdash : Painter::line_solid);
} }
} else { } else {
/* table stuff -- end*/ /* table stuff -- end*/
@ -4669,7 +4672,7 @@ void LyXText::GetVisibleRow(int offset,
if (pos >= main_body) { if (pos >= main_body) {
pain.line(int(x), pain.line(int(x),
offset + row_ptr->baseline - DefaultHeight() / 4, offset + row_ptr->baseline - DefaultHeight() / 4,
int(fill_hfill), int(x + fill_hfill),
offset + row_ptr->baseline - DefaultHeight() / 4, offset + row_ptr->baseline - DefaultHeight() / 4,
LColor::vfillline, LColor::vfillline,
Painter::line_onoffdash); Painter::line_onoffdash);
@ -4677,7 +4680,7 @@ void LyXText::GetVisibleRow(int offset,
} else { } else {
pain.line(int(x), pain.line(int(x),
offset + row_ptr->baseline - DefaultHeight() / 4, offset + row_ptr->baseline - DefaultHeight() / 4,
int(fill_label_hfill), int(x + fill_label_hfill),
offset + row_ptr->baseline - DefaultHeight() / 4, offset + row_ptr->baseline - DefaultHeight() / 4,
LColor::vfillline, LColor::vfillline,
Painter::line_onoffdash); Painter::line_onoffdash);
@ -4710,7 +4713,7 @@ void LyXText::GetVisibleRow(int offset,
pain.line(int(tmpx), pain.line(int(tmpx),
offset + row_ptr->baseline - 1, offset + row_ptr->baseline - 1,
int(tmpx), int(x - 2),
offset + row_ptr->baseline - 1, offset + row_ptr->baseline - 1,
LColor::vfillline); LColor::vfillline);

View File

@ -99,7 +99,7 @@ LyXText::~LyXText()
void LyXText::owner(BufferView * bv) void LyXText::owner(BufferView * bv)
{ {
if (owner_) lyxerr << "LyXText::owner_ already set!" << endl; if (owner_ && bv) lyxerr << "LyXText::owner_ already set!" << endl;
owner_ = bv; owner_ = bv;
} }