* Licence details can be found in the file COPYING.
*
* \author unknown
+ * \author Lars Gullik Bjønnes
+ * \author John Levon
+ * \author André Pönitz
+ * \author Jürgen Vigna
*
- * Full author contact details are available in file CREDITS
+ * Full author contact details are available in file CREDITS.
*
* Metrics for an on-screen text row.
*/
#include <config.h>
#include "lyxrow.h"
-#include "paragraph.h"
-#include "layout.h"
-#include "lyxlayout.h"
+#include "debug.h"
using lyx::pos_type;
-using std::max;
-using std::min;
Row::Row()
- : par_(0), pos_(0), fill_(0), height_(0), width_(0),
- ascent_of_text_(0), baseline_(0), next_(0), previous_(0)
+ : pos_(0), end_(0), fill_(0), height_(0), width_(0), y_offset_(0),
+ ascent_of_text_(0), baseline_(0),
+ x_(0), fill_separator_(0), fill_hfill_(0), fill_label_hfill_(0)
{}
-void Row::par(Paragraph * p)
-{
- par_ = p;
-}
+Row::Row(pos_type pos)
+ : pos_(pos), end_(0), fill_(0), height_(0), width_(0), y_offset_(0),
+ ascent_of_text_(0), baseline_(0),
+ x_(0), fill_separator_(0), fill_hfill_(0), fill_label_hfill_(0)
+{}
void Row::pos(pos_type p)
}
-void Row::fill(int f)
+void Row::endpos(pos_type p)
{
- fill_ = f;
+ end_ = p;
}
-int Row::fill() const
+pos_type Row::endpos() const
{
- return fill_;
+ return end_;
}
-void Row::height(unsigned short h)
+void Row::fill(int f)
{
- height_ = h;
+ fill_ = f;
+}
+
+
+int Row::fill() const
+{
+ return fill_;
}
}
-void Row::ascent_of_text(unsigned short a)
+void Row::ascent_of_text(unsigned int a)
{
ascent_of_text_ = a;
}
-unsigned short Row::ascent_of_text() const
+unsigned int Row::ascent_of_text() const
{
return ascent_of_text_;
}
top_of_text_ = top;
}
-
+
unsigned int Row::top_of_text() const
{
return top_of_text_;
}
-
+
void Row::baseline(unsigned int b)
{
baseline_ = b;
}
-void Row::next(Row * r)
+float Row::x() const
{
- next_ = r;
+ return x_;
}
-void Row::previous(Row * r)
+void Row::x(float f)
{
- previous_ = r;
+ x_ = f;
}
-Row * Row::previous() const
+float Row::fill_separator() const
{
- return previous_;
+ return fill_separator_;
}
-pos_type Row::lastPos() const
+void Row::fill_separator(float f)
{
- if (!par()->size())
- return 0;
-
- if (!next() || next()->par() != par()) {
- return par()->size() - 1;
- } else {
- return next()->pos() - 1;
- }
+ fill_separator_ = f;
}
-namespace {
-
-bool nextRowIsAllInset(Row const & row, pos_type last)
+float Row::fill_hfill() const
{
- if (!row.next())
- return false;
-
- if (row.par() != row.next()->par())
- return false;
-
- if (!row.par()->isInset(last + 1))
- return false;
-
- Inset * i = row.par()->getInset(last + 1);
- return i->needFullRow() || i->display();
+ return fill_hfill_;
}
-};
-
-pos_type Row::lastPrintablePos() const
+void Row::fill_hfill(float f)
{
- pos_type const last = lastPos();
- bool const ignore_space_at_last = !nextRowIsAllInset(*this, last);
-
- if (ignore_space_at_last && par()->isSeparator(last))
- return last - 1;
-
- return last;
+ fill_hfill_ = f;
}
-int Row::numberOfSeparators() const
+float Row::fill_label_hfill() const
{
- pos_type const last = lastPrintablePos();
- pos_type p = max(pos(), par()->beginningOfMainBody());
-
- int n = 0;
- for (; p <= last; ++p) {
- if (par()->isSeparator(p)) {
- ++n;
- }
- }
- return n;
+ return fill_label_hfill_;
}
-int Row::numberOfHfills() const
+void Row::fill_label_hfill(float f)
{
- pos_type const last = lastPos();
- pos_type first = pos();
-
- // hfill *DO* count at the beginning of paragraphs!
- if (first) {
- while (first <= last && par()->isHfill(first)) {
- ++first;
- }
- }
-
- first = max(first, par()->beginningOfMainBody());
-
- int n = 0;
-
- // last, because the end is ignored!
- for (pos_type p = first; p <= last; ++p) {
- if (par()->isHfill(p))
- ++n;
- }
- return n;
+ fill_label_hfill_ = f;
}
-int Row::numberOfLabelHfills() const
+bool Row::isParStart() const
{
- pos_type last = lastPos();
- pos_type first = pos();
-
- // hfill *DO* count at the beginning of paragraphs!
- if (first) {
- while (first < last && par()->isHfill(first))
- ++first;
- }
-
- last = min(last, par()->beginningOfMainBody());
- int n = 0;
-
- // last, because the end is ignored!
- for (pos_type p = first; p < last; ++p) {
- if (par()->isHfill(p))
- ++n;
- }
- return n;
+ return !pos();
}
-bool Row::hfillExpansion(pos_type pos) const
+void Row::dump(const char * s) const
{
- if (!par()->isHfill(pos))
- return false;
-
- // at the end of a row it does not count
- // unless another hfill exists on the line
- if (pos >= lastPos()) {
- pos_type i = this->pos();
- while (i < pos && !par()->isHfill(i)) {
- ++i;
- }
- if (i == pos) {
- return false;
- }
- }
-
- // at the beginning of a row it does not count, if it is not
- // the first row of a paragaph
- if (!this->pos())
- return true;
-
- // in some labels it does not count
- if (par()->layout()->margintype != MARGIN_MANUAL
- && pos < par()->beginningOfMainBody())
- return false;
-
- // if there is anything between the first char of the row and
- // the sepcified position that is not a newline and not a hfill,
- // the hfill will count, otherwise not
- pos_type i = this->pos();
- while (i < pos && (par()->isNewline(i)
- || par()->isHfill(i)))
- ++i;
-
- return i != pos;
+ lyxerr << s << " pos: " << pos_ << " width: " << width_
+ << " height: " << height_
+ << " fill: " << fill_
+ << " ascent_of_text: " << ascent_of_text_
+ << " top_of_text: " << top_of_text_
+ << " y_offset: " << y_offset_ << std::endl;
}
+