} else if (IsHfillChar(c)) {
return 3; /* Because of the representation
* as vertical lines */
+#ifndef NEW_INSETS
} else if (c == LyXParagraph::META_FOOTNOTE ||
c == LyXParagraph::META_MARGIN ||
c == LyXParagraph::META_FIG ||
font.decSize();
font.decSize();
return lyxfont::width(fs, font);
+#endif
} else if (c == LyXParagraph::META_INSET) {
Inset * tmpinset = par->GetInset(pos);
if (tmpinset) {
return rtl != rtl2;
}
+
bool LyXText::IsBoundary(Buffer const * buf, LyXParagraph * par,
LyXParagraph::size_type pos,
LyXFont const & font) const
LyXFont font = GetFont(bview->buffer(), row->par(), pos);
LyXFont font2 = font;
-
+#ifndef NEW_INSETS
if (c == LyXParagraph::META_FOOTNOTE
|| c == LyXParagraph::META_MARGIN
|| c == LyXParagraph::META_FIG
++vpos;
return;
- } else if (c == LyXParagraph::META_INSET) {
- Inset const * tmpinset = row->par()->GetInset(pos);
+ } else
+#endif
+ if (c == LyXParagraph::META_INSET) {
+ Inset * tmpinset = row->par()->GetInset(pos);
if (tmpinset) {
+ tmpinset->update(bview, font, false);
tmpinset->draw(bview, font, offset+row->baseline(), x,
cleared);
}
textclasslist
.TextClass(bview->buffer()->params.textclass)
.defaultfont());
-
+#ifndef NEW_INSETS
if (row->par()->footnoteflag == LyXParagraph::OPEN_FOOTNOTE) {
LyXFont font(LyXFont::ALL_SANE);
font.setSize(LyXFont::SIZE_SMALL);
x += lyxfont::width("Mwide-figM", font)
+ LYX_PAPER_MARGIN/2;
}
-
+#endif
// this is the way, LyX handles the LaTeX-Environments.
// I have had this idea very late, so it seems to be a
// later added hack and this is true
textclasslist
.TextClass(buf->params.textclass)
.defaultfont());
-
+
+#ifndef NEW_INSETS
if (row->par()->footnoteflag == LyXParagraph::OPEN_FOOTNOTE) {
x += LYX_PAPER_MARGIN / 2;
}
-
+#endif
// this is the way, LyX handles the LaTeX-Environments.
// I have had this idea very late, so it seems to be a
// later added hack and this is true
}
+#ifndef NEW_TABULAR
/* table stuff -- begin*/
int LyXText::NumberOfCell(LyXParagraph * par,
LyXParagraph::size_type pos) const
}
-#ifndef NEW_TABULAR
bool LyXText::HitInTable(BufferView * bview, Row * row, int x) const
{
float tmpx;
fill_hfill, fill_label_hfill, false);
return (x > tmpx && x < tmpx + row->par()->table->WidthOfTable());
}
-#endif
bool LyXText::MouseHitInTable(BufferView * bview, int x, long y) const
/* table stuff -- end*/
+#endif
// get the next breakpoint in a given paragraph
par->Last();
// this is the usual handling
int x = LeftMargin(bview, row);
- while (x < width && i < last) {
+ bool doitonetime = true;
+ while (doitonetime || ((x < width) && (i < last))) {
+ doitonetime = false;
char c = par->GetChar(i);
if (IsNewlineChar(c)) {
last_separator = i;
x = width; // this means break
} else if (c == LyXParagraph::META_INSET &&
- par->GetInset(i) && par->GetInset(i)->display()){
+ par->GetInset(i)) {
+
// check wether a Display() inset is
// valid here. if not, change it to
// non-display
- if (layout.isCommand()
- || (layout.labeltype == LABEL_MANUAL
- && i < BeginningOfMainBody(bview->buffer(), par))){
+ if (par->GetInset(i)->display() &&
+ (layout.isCommand() ||
+ ((layout.labeltype == LABEL_MANUAL) &&
+ (i < BeginningOfMainBody(bview->buffer(), par))))) {
// display istn't allowd
par->GetInset(i)->display(false);
x += SingleWidth(bview, par, i, c);
- } else {
- // inset is display. So break the line here
- if (i == pos){
+ } else if (par->GetInset(i)->display() ||
+ par->GetInset(i)->needFullRow()) {
+ // So break the line here
+ if (i == pos) {
if (pos < last-1) {
last_separator = i;
if (IsLineSeparatorChar(par->GetChar(i+1)))
} else
last_separator = i - 1;
x = width; // this means break
+ } else {
+#if 0
+ last_separator = i;
+ x += width;
+#else
+ x += SingleWidth(bview, par, i, c);
+#endif
}
} else {
if (IsLineSeparatorChar(c))
row_ptr->baseline(maxasc + labeladdon);
height += row_ptr->height();
- width = maxwidth;
+ float x, dummy;
+ PrepareToPrint(bview, row_ptr, x, dummy, dummy, dummy);
+ row_ptr->width(maxwidth+x);
+ if (inset_owner) {
+ Row * r = firstrow;
+ width = max(0,workWidth(bview));
+ while(r) {
+ if (r->width() > width)
+ width = r->width();
+ r = r->next();
+ }
+ }
}
}
+#ifndef NEW_INSETS
void LyXText::OpenFootnote(BufferView * bview)
{
LyXParagraph * endpar,* tmppar;
SetCursor(bview, par->next, 0);
sel_cursor = cursor;
}
-
+#endif
+
+#ifndef NEW_TABULAR
/* table stuff -- begin*/
void LyXText::TableFeatures(BufferView * bview, int feature, string const & val) const
Language const * lang = cursor.par()->getParLanguage(bview->buffer()->params);
LyXFont font(LyXFont::ALL_INHERIT,lang);
for (int i = 0; i < number; ++i) {
- cursor.par()->InsertChar(pos, LyXParagraph::META_NEWLINE);
- cursor.par()->SetFont(pos, font);
+ cursor.par()->InsertChar(pos, LyXParagraph::META_NEWLINE, font);
}
/* append the row into the table */
Language const * lang = cursor.par()->getParLanguage(bview->buffer()->params);
LyXFont font(LyXFont::ALL_INHERIT,lang);
for (int i = 0; i < number; ++i) {
- cursor.par()->InsertChar(pos, LyXParagraph::META_NEWLINE);
- cursor.par()->SetFont(pos, font);
+ cursor.par()->InsertChar(pos, LyXParagraph::META_NEWLINE, font);
}
/* append the row into the table */
do{
if (pos && (cursor.par()->IsNewline(pos-1))){
if (cursor.par()->table->AppendCellAfterCell(cell_org, cell)) {
- cursor.par()->InsertChar(pos, LyXParagraph::META_NEWLINE);
- cursor.par()->SetFont(pos, font);
+ cursor.par()->InsertChar(pos,
+ LyXParagraph::META_NEWLINE,
+ font);
if (pos <= cursor.pos())
cursor.pos(cursor.pos() + 1);
++pos;
This saves one byte memory per table ;-) */
if (cursor.par()->table->AppendCellAfterCell(cell_org, cell)) {
LyXParagraph::size_type last = cursor.par()->Last();
- cursor.par()->InsertChar(last, LyXParagraph::META_NEWLINE);
- cursor.par()->SetFont(last, font);
+ cursor.par()->InsertChar(last,
+ LyXParagraph::META_NEWLINE, font);
}
/* append the column into the table */
}
/* table stuff -- end*/
+#endif
// Just a macro to make some thing easier.
// the display inset stuff
if (cursor.row()->par()->GetChar(cursor.row()->pos()) == LyXParagraph::META_INSET
&& cursor.row()->par()->GetInset(cursor.row()->pos())
- && cursor.row()->par()->GetInset(cursor.row()->pos())->display())
+ && (cursor.row()->par()->GetInset(cursor.row()->pos())->display() ||
+ cursor.row()->par()->GetInset(cursor.row()->pos())->needFullRow()))
cursor.row()->fill(-1); // to force a new break
// get the cursor row fist
}
}
+
void LyXText::PrepareToPrint(BufferView * bview,
Row * row, float & x,
float & fill_separator,
fill_separator = 0;
fill_label_hfill = 0;
+#ifndef NEW_INSETS
bool is_rtl = row->par()->isRightToLeftPar(bview->buffer()->params);
if (is_rtl) {
font.setSize(LyXFont::SIZE_SMALL);
x += lyxfont::width("Mwide-figM", font);
}
- } else if (workWidth(bview) > 0)
+ } else
+#endif
+ if (workWidth(bview) > 0)
x = LeftMargin(bview, row);
else
x = 0;
return;
// force complete redo when erasing display insets
// this is a cruel method but safe..... Matthias
- if (cursor.par()->GetInset(cursor.pos())->display()){
+ if (cursor.par()->GetInset(cursor.pos())->display() ||
+ cursor.par()->GetInset(cursor.pos())->needFullRow()) {
cursor.par()->Erase(cursor.pos());
RedoParagraph(bview);
return;
void LyXText::GetVisibleRow(BufferView * bview, int y_offset, int x_offset,
- Row * row_ptr, long y)
+ Row * row_ptr, long y, bool cleared)
{
/* returns a printed row */
Painter & pain = bview->painter();
PrepareToPrint(bview, row_ptr, x, fill_separator,
fill_hfill, fill_label_hfill);
+ if (inset_owner && (x < 0))
+ x = 0;
x += x_offset;
// clear the area where we want to paint/print
ww = bview->workWidth();
bool clear_area = true;
+ Inset * inset = 0;
if ((last == row_ptr->pos()) &&
(row_ptr->par()->GetChar(row_ptr->pos()) == LyXParagraph::META_INSET) &&
- (row_ptr->par()->GetInset(row_ptr->pos())))
+ (inset=row_ptr->par()->GetInset(row_ptr->pos())))
{
- clear_area = row_ptr->par()->GetInset(row_ptr->pos())->doClearArea();
+ clear_area = inset->doClearArea();
}
- if (clear_area) {
+ if (cleared) { // we don't need to clear it's already done!!!
+ clear_area = true;
+ } else if (clear_area) {
int w;
if (inset_owner)
w = inset_owner->width(bview->painter(), font);
else
w = ww;
pain.fillRectangle(x_offset, y_offset, w, row_ptr->height());
+ } else if (inset != 0) {
+ int h = row_ptr->baseline() - inset->ascent(pain, font);
+ if (h > 0) {
+ int w;
+ if (inset_owner)
+ w = inset_owner->width(bview->painter(), font);
+ else
+ w = ww;
+ pain.fillRectangle(x_offset, y_offset, w, h);
+ }
}
if (selection) {
}
int box_x = 0;
+#ifndef NEW_INSETS
if (row_ptr->par()->footnoteflag == LyXParagraph::OPEN_FOOTNOTE) {
LyXFont font(LyXFont::ALL_SANE);
font.setSize(LyXFont::SIZE_FOOTNOTE);
workWidth(bview) - LYX_PAPER_MARGIN,
y_offset, LColor::footnote);
}
-
+#endif
// Draw appendix lines
LyXParagraph * firstpar = row_ptr->par()->FirstPhysicalPar();
if (firstpar->appendix){
return c;
}
-
+
+#ifndef NEW_INSETS
/* turn the selection into a new environment. If there is no selection,
* create an empty environment */
void LyXText::InsertFootnoteEnvironment(BufferView * bview,
ClearSelection();
}
-
+#endif
+
// returns pointer to a specified row
Row * LyXText::GetRow(LyXParagraph * par,