+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
// 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");
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 {
}
-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)
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);
/**@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 */
// 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);
font.setSize(LyXFont::SIZE_TINY);
pain.text(int(x + 8), baseline - 4, msg, strlen(msg), font);
-#if 0
}
-#endif
x += width(pain, font); // ?
}
#else
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);
}
}
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();
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);
}
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);
/* 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 */
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();
}
!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)) ||
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);
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 */
pain.line(int(tmpx),
offset + row_ptr->baseline - 1,
- int(x - tmpx - 2),
+ int(x - 2),
offset + row_ptr->baseline - 1,
LColor::vfillline);
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);
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);
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*/
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);
} 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);
pain.line(int(tmpx),
offset + row_ptr->baseline - 1,
- int(tmpx),
+ int(x - 2),
offset + row_ptr->baseline - 1,
LColor::vfillline);
void LyXText::owner(BufferView * bv)
{
- if (owner_) lyxerr << "LyXText::owner_ already set!" << endl;
+ if (owner_ && bv) lyxerr << "LyXText::owner_ already set!" << endl;
owner_ = bv;
}