the lyxrow changes including accessors.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7583 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
André Pönitz 2003-08-22 09:40:56 +00:00
parent 979b3c8c1e
commit 0510f56da8
7 changed files with 124 additions and 44 deletions

View File

@ -1,4 +1,13 @@
2003-08-22 André Pönitz <poenitz@gmx.net>
* lyxrow.[Ch]: add x_ and *fill_ members
* lyxtext.h:
* text.C:
* rowpainter.C:
* text2.C: adjust/remove prepareToPrint() calls
2003-08-22 André Pönitz <poenitz@gmx.net>
* lyxrow.[Ch]: add end_ member
@ -12,6 +21,7 @@
* text.C (redoParagraph): simplify row breaking logic
2003-08-19 André Pönitz <poenitz@gmx.net>
* funcrequest.C: initialize button_ member

View File

@ -22,13 +22,15 @@ using std::min;
Row::Row()
: pos_(0), end_(0), fill_(0), height_(0), width_(0), y_(0),
ascent_of_text_(0), baseline_(0)
ascent_of_text_(0), baseline_(0),
x_(0), fill_separator_(0), fill_hfill_(0), fill_label_hfill_(0)
{}
Row::Row(pos_type pos)
: pos_(pos), end_(0), fill_(0), height_(0), width_(0), y_(0),
ascent_of_text_(0), baseline_(0)
ascent_of_text_(0), baseline_(0),
x_(0), fill_separator_(0), fill_hfill_(0), fill_label_hfill_(0)
{}
@ -140,6 +142,54 @@ unsigned int Row::baseline() const
}
float Row::x() const
{
return x_;
}
void Row::x(float f)
{
x_ = f;
}
float Row::fill_separator() const
{
return fill_separator_;
}
void Row::fill_separator(float f)
{
fill_separator_ = f;
}
float Row::fill_hfill() const
{
return fill_hfill_;
}
void Row::fill_hfill(float f)
{
fill_hfill_ = f;
}
float Row::fill_label_hfill() const
{
return fill_label_hfill_;
}
void Row::fill_label_hfill(float f)
{
fill_label_hfill_ = f;
}
bool Row::isParStart() const
{
return !pos();

View File

@ -62,6 +62,22 @@ public:
unsigned int y() const;
/// cache the y position
void y(unsigned int newy);
///
float x() const;
///
void x(float);
///
float fill_separator() const;
///
void fill_separator(float);
///
float fill_hfill() const;
///
void fill_hfill(float);
///
float fill_label_hfill() const;
///
void fill_label_hfill(float);
/// current debugging only
void dump(const char * = "") const;
private:
@ -84,6 +100,14 @@ private:
unsigned int top_of_text_;
///
unsigned int baseline_;
/// offet from left border
float x_;
///
float fill_separator_;
///
float fill_hfill_;
///
float fill_label_hfill_;
};
#endif

View File

@ -425,13 +425,8 @@ public:
/** this calculates the specified parameters. needed when setting
* the cursor and when creating a visible row */
void prepareToPrint(
ParagraphList::iterator pit,
RowList::iterator row, double & x,
double & fill_separator,
double & fill_hfill,
double & fill_label_hfill,
bool bidi = true) const;
void prepareToPrint(ParagraphList::iterator pit,
RowList::iterator row) const;
private:
///

View File

@ -1002,11 +1002,11 @@ void RowPainter::paintText()
void RowPainter::paint()
{
width_ = text_.workWidth();
// FIXME: must be a cleaner way here. Aren't these calculations
// belonging to row metrics ?
text_.prepareToPrint(pit_, row_, x_, separator_, hfill_, label_hfill_);
width_ = text_.workWidth();
x_ = row_->x();
separator_ = row_->fill_separator();
hfill_ = row_->fill_hfill();
label_hfill_ = row_->fill_label_hfill();
// FIXME: what is this fixing ?
if (text_.isInInset() && x_ < 0)

View File

@ -721,6 +721,10 @@ pos_type LyXText::rowBreakPoint(ParagraphList::iterator pit,
}
char const c = pit->getChar(i);
if (i > endPosOfFontSpan) {
font = getFont(pit, i);
endPosOfFontSpan = pit->getEndPosOfFontSpan(i);
}
int thiswidth;
@ -1230,10 +1234,13 @@ void LyXText::setHeightOfRow(ParagraphList::iterator pit, RowList::iterator rit)
double x = 0;
if (layout->margintype != MARGIN_RIGHT_ADDRESS_BOX) {
#warning needed?
#if 0
// this IS needed
rit->width(maxwidth);
double dummy;
prepareToPrint(pit, rit, x, dummy, dummy, dummy, false);
#endif
}
rit->width(int(maxwidth + x));
if (inset_owner) {
@ -1449,7 +1456,7 @@ void LyXText::insertChar(char c)
void LyXText::charInserted()
{
// Here we could call FinishUndo for every 20 characters inserted.
// Here we could call finishUndo for every 20 characters inserted.
// This is from my experience how emacs does it. (Lgb)
static unsigned int counter;
if (counter < 20) {
@ -1462,17 +1469,13 @@ void LyXText::charInserted()
void LyXText::prepareToPrint(ParagraphList::iterator pit,
RowList::iterator rit, double & x,
double & fill_separator,
double & fill_hfill,
double & fill_label_hfill,
bool bidi) const
RowList::iterator const rit) const
{
double w = rit->fill();
fill_hfill = 0;
fill_label_hfill = 0;
fill_separator = 0;
fill_label_hfill = 0;
double fill_hfill = 0;
double fill_label_hfill = 0;
double fill_separator = 0;
double x = 0;
bool const is_rtl =
pit->isRightToLeftPar(bv()->buffer()->params);
@ -1563,8 +1566,6 @@ void LyXText::prepareToPrint(ParagraphList::iterator pit,
break;
}
}
if (!bidi)
return;
computeBidiTables(pit, bv()->buffer(), rit);
if (is_rtl) {
@ -1572,13 +1573,18 @@ void LyXText::prepareToPrint(ParagraphList::iterator pit,
pos_type last = lastPos(*pit, rit);
if (body_pos > 0 &&
(body_pos - 1 > last ||
!pit->isLineSeparator(body_pos - 1))) {
(body_pos - 1 > last ||
!pit->isLineSeparator(body_pos - 1))) {
x += font_metrics::width(layout->labelsep, getLabelFont(pit));
if (body_pos - 1 <= last)
x += fill_label_hfill;
}
}
rit->fill_hfill(fill_hfill);
rit->fill_label_hfill(fill_label_hfill);
rit->fill_separator(fill_separator);
rit->x(x);
}

View File

@ -566,6 +566,7 @@ void LyXText::redoParagraph(ParagraphList::iterator pit)
// set height and fill of rows
for (rit = pit->rows.begin(); rit != end; ++rit) {
rit->fill(fill(pit, rit, workWidth()));
prepareToPrint(pit, rit);
setHeightOfRow(pit, rit);
}
@ -1404,16 +1405,12 @@ void LyXText::setCursor(LyXCursor & cur, ParagraphList::iterator pit,
float LyXText::getCursorX(ParagraphList::iterator pit, RowList::iterator rit,
pos_type pos, pos_type last, bool boundary) const
{
pos_type cursor_vpos = 0;
double x;
double fill_separator;
double fill_hfill;
double fill_label_hfill;
// This call HAS to be here because of the BidiTables!!!
prepareToPrint(pit, rit, x, fill_separator, fill_hfill,
fill_label_hfill);
pos_type const rit_pos = rit->pos();
pos_type cursor_vpos = 0;
double x = rit->x();
double fill_separator = rit->fill_separator();
double fill_hfill = rit->fill_hfill();
double fill_label_hfill = rit->fill_label_hfill();
pos_type const rit_pos = rit->pos();
if (last < rit_pos)
cursor_vpos = rit_pos;
@ -1513,12 +1510,10 @@ void LyXText::setCurrentFont()
pos_type LyXText::getColumnNearX(ParagraphList::iterator pit,
RowList::iterator rit, int & x, bool & boundary) const
{
double tmpx = 0;
double fill_separator;
double fill_hfill;
double fill_label_hfill;
prepareToPrint(pit, rit, tmpx, fill_separator, fill_hfill, fill_label_hfill);
double tmpx = rit->x();
double fill_separator = rit->fill_separator();
double fill_hfill = rit->fill_hfill();
double fill_label_hfill = rit->fill_label_hfill();
pos_type vc = rit->pos();
pos_type last = lastPrintablePos(*pit, rit);