X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FRow.h;h=c26752bde861c7c557630cc3ba41938612dc242b;hb=53f8d6d6d373460bdcfebd20d6f826e3915c84ff;hp=7d9a891fd13d2a0c16173375f6d152ed65bdabf3;hpb=f630be890494c849981e4fb52ea4740506e92bed;p=lyx.git diff --git a/src/Row.h b/src/Row.h index 7d9a891fd1..c26752bde8 100644 --- a/src/Row.h +++ b/src/Row.h @@ -5,7 +5,7 @@ * Licence details can be found in the file COPYING. * * \author Matthias Ettrich - * \author Lars Gullik Bjønnes + * \author Lars Gullik Bjønnes * * Full author contact details are available in file CREDITS. * @@ -17,9 +17,13 @@ #include "support/types.h" +#include "Dimension.h" + namespace lyx { +class DocIterator; + /** * An on-screen row of text. A paragraph is broken into a * RowList for display. Each Row contains position pointers @@ -30,59 +34,84 @@ public: /// Row(); /// - Row(pos_type pos); + bool changed() const { return changed_; } /// - void pos(pos_type p); + void setChanged(bool c) { changed_ = c; } /// - pos_type pos() const; + void setCrc(size_type crc) const; + /// Set the selection begin and end. + /** + * This is const because we update the selection status only at draw() + * time. + */ + void setSelection(pos_type sel_beg, pos_type sel_end) const; /// - void endpos(pos_type p); + bool selection() const; + /// Set the selection begin and end and whether the left and/or right + /// margins are selected. + void setSelectionAndMargins(DocIterator const & beg, + DocIterator const & end) const; + /// - pos_type endpos() const; + void pos(pos_type p); /// - int height() const { return ascent_ + descent_; } + pos_type pos() const { return pos_; } /// - void width(int w); + void endpos(pos_type p); /// - int width() const; + pos_type endpos() const { return end_; } /// - void ascent(int b); + void setDimension(Dimension const & dim); /// - int ascent() const; + Dimension const & dimension() const { return dim_; } /// - void descent(int b) { descent_ = b; } + int height() const { return dim_.height(); } /// - int descent() const { return descent_; } - /// current debugging only - void dump(const char * = "") const; - -private: - /// first pos covered by this row - pos_type pos_; - /// one behind last pos covered by this row - pos_type end_; - /// - int ascent_; + int width() const { return dim_.wid; } /// - int descent_; + int ascent() const { return dim_.asc; } /// - int width_; -}; + int descent() const { return dim_.des; } + /// current debugging only + void dump(char const * = "") const; -class RowMetrics { -public: - RowMetrics(); /// width of a separator (i.e. space) double separator; - /// width of hfills in the body - double hfill; /// width of hfills in the label double label_hfill; /// the x position of the row double x; -}; + /// + mutable pos_type sel_beg; + /// + mutable pos_type sel_end; + /// + mutable bool begin_margin_sel; + /// + mutable bool end_margin_sel; +private: + /// Decides whether the margin is selected. + /** + * \param margin_begin + * \param beg + * \param end + */ + bool isMarginSelected(bool left_margin, DocIterator const & beg, + DocIterator const & end) const; + + /// has the Row appearance changed since last drawing? + mutable bool changed_; + /// CRC of row contents. + mutable size_type crc_; + /// first pos covered by this row + pos_type pos_; + /// one behind last pos covered by this row + pos_type end_; + /// Row dimension. + Dimension dim_; +}; } // namespace lyx