]> git.lyx.org Git - features.git/commitdiff
cosmetics
authorAndré Pönitz <poenitz@gmx.net>
Sat, 29 Sep 2007 08:02:37 +0000 (08:02 +0000)
committerAndré Pönitz <poenitz@gmx.net>
Sat, 29 Sep 2007 08:02:37 +0000 (08:02 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@20577 a592a061-630c-0410-9148-cb99ea01b6c8

src/BufferView.cpp
src/BufferView.h
src/Cursor.cpp
src/TextMetrics.cpp
src/bufferview_funcs.cpp
src/bufferview_funcs.h

index 77c53e507a8334ba81e899f5a2529d899a77a742..9793597cde779def9e924d4d4c651c53e22fe7c0 100644 (file)
@@ -252,7 +252,7 @@ Buffer const & BufferView::buffer() const
 
 bool BufferView::fitCursor()
 {
-       if (bv_funcs::status(this, cursor_) == bv_funcs::CUR_INSIDE) {
+       if (cursorStatus(cursor_) == CUR_INSIDE) {
                frontend::FontMetrics const & fm =
                        theFontMetrics(cursor_.getFont());
                int const asc = fm.maxAscent();
@@ -446,24 +446,22 @@ void BufferView::setCursorFromScrollbar()
        int const last = height_ - height;
        Cursor & cur = cursor_;
 
-       bv_funcs::CurStatus st = bv_funcs::status(this, cur);
-
-       switch (st) {
-       case bv_funcs::CUR_ABOVE:
-               // We reset the cursor because bv_funcs::status() does not
+       switch (cursorStatus(cur)) {
+       case CUR_ABOVE:
+               // We reset the cursor because cursorStatus() does not
                // work when the cursor is within mathed.
                cur.reset(buffer_.inset());
                tm.setCursorFromCoordinates(cur, 0, first);
                cur.clearSelection();
                break;
-       case bv_funcs::CUR_BELOW:
-               // We reset the cursor because bv_funcs::status() does not
+       case CUR_BELOW:
+               // We reset the cursor because cursorStatus() does not
                // work when the cursor is within mathed.
                cur.reset(buffer_.inset());
                tm.setCursorFromCoordinates(cur, 0, last);
                cur.clearSelection();
                break;
-       case bv_funcs::CUR_INSIDE:
+       case CUR_INSIDE:
                int const y = bv_funcs::getPos(*this, cur, cur.boundary()).y_;
                int const newy = min(last, max(y, first));
                if (y != newy) {
@@ -484,6 +482,19 @@ Change const BufferView::getCurrentChange() const
 }
 
 
+// this could be used elsewhere as well?
+// FIXME: This does not work within mathed!
+CursorStatus BufferView::cursorStatus(DocIterator const & dit) const
+{
+       Point const p = bv_funcs::getPos(*this, dit, dit.boundary());
+       if (p.y_ < 0)
+               return CUR_ABOVE;
+       if (p.y_ > workHeight())
+               return CUR_BELOW;
+       return CUR_INSIDE;
+}
+
+
 void BufferView::saveBookmark(unsigned int idx)
 {
        // tenatively save bookmark, id and pos will be used to
index de433e09e92b66bafe785a3b5763e54e03deaa23..234d86a8169461b16c4143eb9653c963d409dc1c 100644 (file)
@@ -48,6 +48,12 @@ class Text;
 class ParIterator;
 class ParagraphMetrics;
 class ViewMetricsInfo;
+enum CursorStatus {
+       CUR_INSIDE,
+       CUR_ABOVE,
+       CUR_BELOW
+};
 
 /// Scrollbar Parameters.
 struct ScrollbarParameters
@@ -171,6 +177,8 @@ public:
        /// access to anchor.
        pit_type anchor_ref() const;
 
+       ///
+       CursorStatus cursorStatus(DocIterator const & dit) const;
        /// access to full cursor.
        Cursor & cursor();
        /// access to full cursor.
@@ -210,13 +218,9 @@ public:
        ParagraphMetrics const & parMetrics(Text const *, pit_type) const;
 
        ///
-       CoordCache & coordCache() {
-               return coord_cache_;
-       }
+       CoordCache & coordCache() { return coord_cache_; }
        ///
-       CoordCache const & coordCache() const {
-               return coord_cache_;
-       }
+       CoordCache const & coordCache() const { return coord_cache_; }
 
        ///
        void draw(frontend::Painter & pain);
index 285a370b0ef282fd34241e46967faf6b4d81feb5..b5712f8816edd6c81bfcefd01f379ce440cb7744 100644 (file)
@@ -218,7 +218,7 @@ namespace {
 
                for ( ; it != et; it.forwardPos()) {
                        // avoid invalid nesting when selecting
-                       if (bv_funcs::status(&bv, it) == bv_funcs::CUR_INSIDE
+                       if (bv.cursorStatus(it) == CUR_INSIDE
                            && (!cur.selection() || positionable(it, cur.anchor_))) {
                                Point p = bv_funcs::getPos(bv, it, false);
                                int xo = p.x_;
index 6591de87606ad02cf320b5f06f91c0a1224c85c1..a5f9cdba16fb6c0fc9f31321d3a99af8682b12c6 100644 (file)
@@ -1177,7 +1177,7 @@ void TextMetrics::newParMetricsDown()
 {
        pair<pit_type, ParagraphMetrics> const & last = *par_metrics_.rbegin();
        pit_type const pit = last.first + 1;
-       if (pit == text_->paragraphs().size())
+       if (pit == int(text_->paragraphs().size()))
                return;
 
        // do it and update its position.
@@ -1995,8 +1995,7 @@ void TextMetrics::drawSelection(PainterInfo & pi,
 
        // clip above
        int middleTop;
-       bool const clipAbove = 
-               (bv_funcs::status(bv_, beg) == bv_funcs::CUR_ABOVE);
+       bool const clipAbove = (bv_->cursorStatus(beg) == CUR_ABOVE);
        if (clipAbove)
                middleTop = 0;
        else
@@ -2004,15 +2003,14 @@ void TextMetrics::drawSelection(PainterInfo & pi,
        
        // clip below
        int middleBottom;
-       bool const clipBelow = 
-               (bv_funcs::status(bv_, end) == bv_funcs::CUR_BELOW);
+       bool const clipBelow = (bv_->cursorStatus(end) == CUR_BELOW);
        if (clipBelow)
                middleBottom = bv_->workHeight();
        else
                middleBottom = bv_funcs::getPos(*bv_, end, end.boundary()).y_ - row2.ascent();
 
        // start and end in the same line?
-       if (!(clipAbove || clipBelow) && &row1 == &row2)
+       if (!clipAbove && !clipBelow && &row1 == &row2)
                // then only draw this row's selection
                drawRowSelection(pi, x, row1, beg, end, false, false);
        else {
index 6d4283bd9343d4e820950098d52e99227e9906e5..ed8dbd90194dd462dc1d1c7f225f7650492671f0 100644 (file)
@@ -253,21 +253,6 @@ Point getPos(BufferView const & bv, DocIterator const & dit, bool boundary)
        return p;
 }
 
-
-// this could be used elsewhere as well?
-// FIXME: This does not work within mathed!
-CurStatus status(BufferView const * bv, DocIterator const & dit)
-{
-       Point const p = bv_funcs::getPos(*bv, dit, dit.boundary());
-       if (p.y_ < 0)
-               return CUR_ABOVE;
-       if (p.y_ > bv->workHeight())
-               return CUR_BELOW;
-               
-       return CUR_INSIDE;
-}
-
-
 } // namespace bv_funcs
 
 
index cbfd04c3af712c92547bca946fb916fc1e0deeb9..05dce330b3ebd03cb244b7dc4246265115f825aa 100644 (file)
@@ -15,7 +15,6 @@
 #define BUFFERVIEW_FUNCS_H
 
 #include <string>
-#include <vector>
 
 namespace lyx {
 
@@ -40,16 +39,6 @@ std::string const freefont2string();
 
 Point getPos(BufferView const & bv, DocIterator const & dit, bool boundary);
 
-enum CurStatus {
-       CUR_INSIDE,
-       CUR_ABOVE,
-       CUR_BELOW
-};
-
-
-CurStatus status(BufferView const * bv, DocIterator const & dit);
-
-
 Point coordOffset(BufferView const & bv, DocIterator const & dit, bool boundary);
 
 } // namespace bv_funcs