#include <cctype>
#include <algorithm>
-//#ifdef __GNUG__
-//#pragma implementation "table.h"
-//#endif
-
#include "layout.h"
#include "lyxparagraph.h"
#include "lyxtext.h"
using std::pair;
static const int LYX_PAPER_MARGIN = 20;
+
extern int bibitemMaxWidth(BufferView *, LyXFont const &);
break;
}
- if (Encoding::is_arabic(next_char))
+ if (Encoding::is_arabic(next_char)) {
if (Encoding::is_arabic(prev_char))
return Encoding::TransformChar(c, Encoding::FORM_MEDIAL);
else
return Encoding::TransformChar(c, Encoding::FORM_INITIAL);
- else
+ } else {
if (Encoding::is_arabic(prev_char))
return Encoding::TransformChar(c, Encoding::FORM_FINAL);
else
return Encoding::TransformChar(c, Encoding::FORM_ISOLATED);
+ }
}
// This is the comments that some of the warnings below refers to.
int LyXText::SingleWidth(BufferView * bview, LyXParagraph * par,
LyXParagraph::size_type pos) const
{
- char c = par->GetChar(pos);
+ char const c = par->GetChar(pos);
return SingleWidth(bview, par, pos, c);
}
if (!bidi_InRange(pos - 1))
return false;
- bool rtl = bidi_level(pos - 1) % 2;
+ bool const rtl = bidi_level(pos - 1) % 2;
bool rtl2 = rtl;
if (pos == par->Last())
rtl2 = par->isRightToLeftPar(buf->params);
if (!lyxrc.rtl_support)
return false; // This is just for speedup
- bool rtl = font.isVisibleRightToLeft();
+ bool const rtl = font.isVisibleRightToLeft();
bool rtl2 = rtl;
if (pos == par->Last())
rtl2 = par->isRightToLeftPar(buf->params);
++vpos;
if (lyxrc.mark_foreign_language &&
- font.language()->lang() != "default" &&
font.language() != bview->buffer()->params.language_info) {
int y = offset + row->height() - 1;
pain.line(int(tmpx), y, int(x), y,
}
if (lyxrc.mark_foreign_language &&
- font.language()->lang() != "default" &&
font.language() != bview->buffer()->params.language_info) {
int y = offset + row->height() - 1;
pain.line(int(tmpx), y, int(x), y,
}
- LyXFont labelfont = GetFont(bview->buffer(), row->par(), -2);
+ LyXFont const labelfont = GetFont(bview->buffer(), row->par(), -2);
switch (layout.margintype) {
case MARGIN_DYNAMIC:
if (!layout.leftmargin.empty()) {
break;
}
if ((workWidth(bview) > 0) &&
- (row->par()->pextra_type == LyXParagraph::PEXTRA_INDENT))
- {
+ (row->par()->pextra_type == LyXParagraph::PEXTRA_INDENT)) {
if (!row->par()->pextra_widthp.empty()) {
x += workWidth(bview) *
- atoi(row->par()->pextra_widthp.c_str()) / 100;
+ lyx::atoi(row->par()->pextra_widthp) / 100;
} else if (!row->par()->pextra_width.empty()) {
int xx = VSpace(row->par()->pextra_width).inPixels(bview);
if (xx > workWidth(bview))
if (paper_width < 0)
return 0;
- int w, fill;
+ int w;
// get the pure distance
LyXParagraph::size_type last = RowLastPrintable(row);
w = left_margin;
}
- fill = paper_width - w - RightMargin(bview->buffer(), row);
+ int const fill = paper_width - w - RightMargin(bview->buffer(), row);
return fill;
}
// returns the minimum space a manual label needs on the screen in pixel
int LyXText::LabelFill(BufferView * bview, Row const * row) const
{
- LyXParagraph::size_type last = BeginningOfMainBody(bview->buffer(), row->par())-1;
+ LyXParagraph::size_type last = BeginningOfMainBody(bview->buffer(), row->par()) - 1;
// -1 because a label ends either with a space that is in the label,
// or with the beginning of a footnote that is outside the label.
// on the very last column doesnt count
int LyXText::NumberOfSeparators(Buffer const * buf, Row const * row) const
{
- int last = RowLast(row);
- int p = max(row->pos(), BeginningOfMainBody(buf, row->par()));
+ LyXParagraph::size_type const last = RowLast(row);
+ LyXParagraph::size_type p =
+ max(row->pos(), BeginningOfMainBody(buf, row->par()));
int n = 0;
for (; p < last; ++p) {
if (row->par()->IsSeparator(p)) {
// ignored. This is *MUCH* more usefull than not to ignore!
int LyXText::NumberOfHfills(Buffer const * buf, Row const * row) const
{
- int last = RowLast(row);
- int first = row->pos();
+ LyXParagraph::size_type const last = RowLast(row);
+ LyXParagraph::size_type first = row->pos();
if (first) { /* hfill *DO* count at the beginning
* of paragraphs! */
while(first <= last && row->par()->IsHfill(first))
void LyXText::SetHeightOfRow(BufferView * bview, Row * row_ptr) const
{
/* get the maximum ascent and the maximum descent */
- int asc = 0, desc = 0, pos = 0;
+ int asc = 0;
+ int desc = 0;
float layoutasc = 0;
float layoutdesc = 0;
float tmptop = 0;
/* this must not happen before the currentrow for clear reasons.
so the trick is just to set the current row onto this row */
- long unused_y;
+ int unused_y;
GetRow(row_ptr->par(), row_ptr->pos(), unused_y);
/* ok , let us initialize the maxasc and maxdesc value.
int maxwidth = 0;
// Check if any insets are larger
- for (pos = row_ptr->pos(); pos <= pos_end; ++pos) {
+ for (int pos = row_ptr->pos(); pos <= pos_end; ++pos) {
if (row_ptr->par()->GetChar(pos) == LyXParagraph::META_INSET) {
tmpfont = GetFont(bview->buffer(), row_ptr->par(), pos);
tmpinset = row_ptr->par()->GetInset(pos);
LyXParagraph * nextpar = row_ptr->par()->Next();
LyXParagraph * comparepar = row_ptr->par();
float usual = 0;
- float unusual = 0;
+ float unusual = 0;
if (comparepar->GetDepth() > nextpar->GetDepth()) {
usual = (textclasslist.Style(bview->buffer()->params.textclass, comparepar->GetLayout()).bottomsep * DefaultHeight());
// The last character position of a paragraph is an invariant so we can
// safely get it here. (Asger)
- int lastposition = row->par()->Last();
+ int const lastposition = row->par()->Last();
do {
// Get the next breakpoint
void LyXText::BreakParagraph(BufferView * bview, char keep_layout)
{
- LyXLayout const & layout = textclasslist.Style(bview->buffer()->params.textclass,
- cursor.par()->GetLayout());
+ LyXLayout const & layout =
+ textclasslist.Style(bview->buffer()->params.textclass,
+ cursor.par()->GetLayout());
// this is only allowed, if the current paragraph is not empty or caption
if ((cursor.par()->Last() <= 0
if (cursor.pos() < cursor.par()->Last() &&
cursor.par()->IsLineSeparator(cursor.pos()))
// newline always after a blank!
- CursorRightIntern(bview);
+ CursorRight(bview);
cursor.row()->fill(-1); // to force a new break
}
// get the cursor row fist
Row * row = cursor.row();
- long y = cursor.y() - row->baseline();
+ int y = cursor.y() - row->baseline();
if (c != LyXParagraph::META_INSET) /* Here case LyXText::InsertInset
* already insertet the character */
cursor.par()->InsertChar(cursor.pos(), c);
old_cursor.par()->previous->id() : 0;
// just move to the right
- CursorRightIntern(bview);
+ CursorRight(bview);
// CHECK Look at the comment here.
// This check is not very good...
tmppar->pagebreak_bottom = cursor.par()->pagebreak_bottom;
}
- CursorLeftIntern(bview);
+ CursorLeft(bview);
// the layout things can change the height of a row !
int tmpheight = cursor.row()->height();
}
Row * row = cursor.row();
- long y = cursor.y() - row->baseline();
+ int y = cursor.y() - row->baseline();
LyXParagraph::size_type z;
/* remember that a space at the end of a row doesnt count
* when calculating the fill */
void LyXText::GetVisibleRow(BufferView * bview, int y_offset, int x_offset,
- Row * row_ptr, long y, bool cleared)
+ Row * row_ptr, int y, bool cleared)
{
/* returns a printed row */
Painter & pain = bview->painter();
sel_end_cursor.x(),
row_ptr->height(),
LColor::selection);
- } else if (y > long(sel_start_cursor.y())
- && y < long(sel_end_cursor.y())) {
+ } else if (y > sel_start_cursor.y()
+ && y < sel_end_cursor.y()) {
pain.fillRectangle(x_offset, y_offset, w,
row_ptr->height(),
LColor::selection);
}
} else if ( sel_start_cursor.row() != row_ptr &&
sel_end_cursor.row() != row_ptr &&
- y > long(sel_start_cursor.y())
- && y < long(sel_end_cursor.y())) {
+ y > sel_start_cursor.y()
+ && y < sel_end_cursor.y()) {
pain.fillRectangle(x_offset, y_offset, w,
row_ptr->height(),
LColor::selection);
y_top += lyxfont::ascent('x',
GetFont(bview->buffer(),
row_ptr->par(), 0));
-
- pain.line(0, y_offset + y_top,
- ww, y_offset + y_top,
+ int w = (inset_owner ? inset_owner->width(bview, font) : ww);
+ int xp = static_cast<int>(inset_owner ? x : 0);
+ pain.line(xp, y_offset + y_top,
+ w, y_offset + y_top,
LColor::topline,
Painter::line_solid,
Painter::line_thick);
/* draw a bottom line */
y_bottom -= lyxfont::ascent('x', GetFont(bview->buffer(),
par, par->Last() - 1));
- pain.line(0, y_offset + y_bottom,
- ww, y_offset + y_bottom,
+ int w = (inset_owner ? inset_owner->width(bview, font) : ww);
+ int xp = static_cast<int>(inset_owner ? x : 0);
+ pain.line(xp, y_offset + y_bottom,
+ w, y_offset + y_bottom,
LColor::topline, Painter::line_solid,
Painter::line_thick);
y_bottom -= lyxfont::ascent('x', GetFont(bview->buffer(),
// returns pointer to a specified row
Row * LyXText::GetRow(LyXParagraph * par,
- LyXParagraph::size_type pos, long & y) const
+ LyXParagraph::size_type pos, int & y) const
{
Row * tmprow = firstrow;
y = 0;