]> git.lyx.org Git - features.git/commitdiff
refactor topCursorVisible() prototype a little. Compile fix
authorJohn Levon <levon@movementarian.org>
Wed, 12 Jun 2002 10:31:34 +0000 (10:31 +0000)
committerJohn Levon <levon@movementarian.org>
Wed, 12 Jun 2002 10:31:34 +0000 (10:31 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@4378 a592a061-630c-0410-9148-cb99ea01b6c8

src/BufferView_pimpl.C
src/ChangeLog
src/frontends/ChangeLog
src/frontends/screen.C
src/frontends/screen.h
src/graphics/ChangeLog
src/graphics/GraphicsImageXPM.C
src/insets/ChangeLog
src/insets/insettext.C

index b4d62a143939b2f73ecc1c895acd2d64c4c0d9b3..771836d9e608decfed59f5bdcc051b226772edaa 100644 (file)
@@ -233,7 +233,7 @@ void BufferView::Pimpl::buffer(Buffer * b)
                        updateScreen();
                        updateScrollbar();
                }
-               bv_->text->first_y = screen().topCursorVisible(bv_->text);
+               bv_->text->first_y = screen().topCursorVisible(bv_->text->cursor, bv_->text->first_y);
                owner_->updateMenubar();
                owner_->updateToolbar();
                // Similarly, buffer-dependent dialogs should be updated or
@@ -390,7 +390,7 @@ int BufferView::Pimpl::resizeCurrentBuffer()
                bv_->theLockingInset(the_locking_inset);
        }
 
-       bv_->text->first_y = screen().topCursorVisible(bv_->text);
+       bv_->text->first_y = screen().topCursorVisible(bv_->text->cursor, bv_->text->first_y);
 
        // this will scroll the screen such that the cursor becomes visible
        updateScrollbar();
index 63d60e37eca567c04f34bccfb91d8c11d4d881a5..fd8b28ed9f5e9c8e0c41b098ae92636bd8985037 100644 (file)
@@ -1,3 +1,8 @@
+2002-06-12  John Levon  <moz@compsoc.man.ac.uk>
+
+       * BufferView_pimpl.C: topCursorVisible
+         prototype change
 2002-06-12  John Levon  <moz@compsoc.man.ac.uk>
 
        * Makefile.am:
index 3de546ddcbd9a21abf0e5cfac4141d84ba372c00..b0bede0952b89abfa51502599f2738570fe652e6 100644 (file)
@@ -1,3 +1,8 @@
+2002-06-12  John Levon  <moz@compsoc.man.ac.uk>
+
+       * screen.h:
+       * screen.C: change topCursorVisible() prototype
 2002-06-12  Angus Leeming  <leeming@lyx.org>
 
        * font_metrics.h: remove trailing semi-colon after the brace closing 
index e9f64b0e29fd7973b84e3ef073413e388f3ac4fc..79dd6542d522a623e8ffe9179e8d673e1b530a8e 100644 (file)
@@ -395,38 +395,39 @@ void LScreen::cursorToggle(BufferView * bv) const
 
 
 /* returns a new top so that the cursor is visible */
-unsigned int LScreen::topCursorVisible(LyXText const * text)
+unsigned int LScreen::topCursorVisible(LyXCursor const & cursor, int top_y)
 {
-       int newtop = text->first_y;
+       int const vheight = owner.workHeight();
+       int newtop = top_y; 
 
-       Row * row = text->cursor.row();
+       Row * row = cursor.row();
 
        // Is this a hack? Yes, probably... (Lgb)
        if (!row)
                return max(newtop, 0);
 
-       if (text->cursor.y() - row->baseline() + row->height()
-           - text->first_y >= owner.workHeight()) {
-               if (row->height() < owner.workHeight()
-                   && row->height() > owner.workHeight() / 4) {
-                       newtop = text->cursor.y()
+       if (cursor.y() - row->baseline() + row->height()
+           - top_y >= vheight) {
+               if (row->height() < vheight
+                   && row->height() > vheight / 4) {
+                       newtop = cursor.y()
                                + row->height()
-                               - row->baseline() - owner.workHeight();
+                               - row->baseline() - vheight;
                } else {
                        // scroll down
-                       newtop = text->cursor.y()
-                               - owner.workHeight() / 2;   /* the scroll region must be so big!! */
+                       newtop = cursor.y()
+                               - vheight / 2;   /* the scroll region must be so big!! */
                }
 
-       } else if (static_cast<int>((text->cursor.y()) - row->baseline()) <
-                  text->first_y && text->first_y > 0) {
-               if (row->height() < owner.workHeight()
-                   && row->height() > owner.workHeight() / 4) {
-                       newtop = text->cursor.y() - row->baseline();
+       } else if (static_cast<int>(cursor.y() - row->baseline()) <
+                  top_y && top_y > 0) {
+               if (row->height() < vheight
+                   && row->height() > vheight / 4) {
+                       newtop = cursor.y() - row->baseline();
                } else {
                        // scroll up
-                       newtop = text->cursor.y() - owner.workHeight() / 2;
-                       newtop = min(newtop, text->first_y);
+                       newtop = cursor.y() - vheight / 2;
+                       newtop = min(newtop, top_y);
                }
        }
 
@@ -441,7 +442,7 @@ unsigned int LScreen::topCursorVisible(LyXText const * text)
 bool LScreen::fitCursor(LyXText * text, BufferView * bv)
 {
        // Is a change necessary?
-       int const newtop = topCursorVisible(text);
+       int const newtop = topCursorVisible(text->cursor, text->first_y);
        bool const result = (newtop != text->first_y);
        if (result)
                draw(text, bv, newtop);
index b1c8dba237df1f940439b3ccd1a544b732d295a6..378d9d991e7936b352caf4e64f40c4ab4fcc2906 100644 (file)
@@ -1,13 +1,12 @@
 // -*- C++ -*-
-/* This file is part of
- * ======================================================
+/**
+ * \file screen.h
+ * Copyright 1995-2002 the LyX Team
+ * Read the file COPYING
  *
- *           LyX, The Document Processor
- *
- *           Copyright 1995 Matthias Ettrich
- *           Copyright 1995-2001 The LyX Team
- *
- * ====================================================== */
+ * \author unknown
+ * \author John Levon <moz@compsoc.man.ac.uk>
+ */ 
 
 #ifndef LYXSCREEN_H
 #define LYXSCREEN_H
 #include <X11/Xlib.h>
 
 class LyXText;
+class LyXCursor;
 class WorkArea;
 class Buffer;
 class BufferView;
 
 struct Row;
 
-/** The class LScreen is used for the main Textbody.
-    Concretely, the screen is held in a pixmap.  This pixmap is kept up to
-    date and used to optimize drawing on the screen.
-    This class also handles the drawing of the cursor and partly the selection.
+/**
+ * LScreen - document rendering management
+ *
+ * This class is used to manage the on-screen rendering inside the
+ * work area; it is responsible for deciding which LyXText rows
+ * need re-drawing.
+ *
+ * This class will arrange for LyXText to paint onto a pixmap
+ * provided by the WorkArea widget.
+ *
+ * The blinking cursor is also handled here.
  */
 class LScreen {
 public:
@@ -60,8 +67,17 @@ public:
        /// Redraws the screen, without using existing pixmap
        void redraw(LyXText *, BufferView *);
 
-       /// Returns a new top so that the cursor is visible
-       unsigned int topCursorVisible(LyXText const *);
+       /**
+        * topCursorVisible - get a new "top" to make the cursor visible
+        * @param c the cursor
+        * @param top_y the current y location of the containing region
+        *
+        * This helper function calculates a new y co-ordinate for
+        * the top of the containing region such that the cursor contained
+        * within the LyXText is "nicely" visible.
+        */ 
+       unsigned int topCursorVisible(LyXCursor const & c, int top_y);
        /// Redraws the screen such that the cursor is visible
        bool fitCursor(LyXText *, BufferView *);
        ///
index 2e0bec6294c0bfee13b3b58fc099588166bf206a..29ea143be6ee21aa0584ebbf530487f51fb3b46f 100644 (file)
@@ -1,3 +1,7 @@
+2002-06-12  John Levon  <moz@compsoc.man.ac.uk>
+
+       * GraphicsCache.C: use right colormap incantation
 2002-06-12  John Levon  <moz@compsoc.man.ac.uk>
 
        * GraphicsCache.C: use lyx_gui namespace
index a165a2904be73fbccebfdef9680978f3e714248b..e3a16dfbf542f0a6fef70096c390888cc9991d4b 100644 (file)
@@ -613,7 +613,7 @@ void mapcolor(char const * c_color, char ** g_color_ptr, char ** m_color_ptr)
                return;
 
        Display * display = fl_get_display();
-       Colormap cmap     = fl_colormap;
+       Colormap cmap     = fl_state[fl_get_vclass()].colormap;
        XColor xcol;
        XColor ccol;
        if (XLookupColor(display, cmap, c_color, &xcol, &ccol) == 0)
index cc3fc13921d196d3153d8e98be14f12e5d848310..dbf08d31136b07868ba122266e76ffab85a71e66 100644 (file)
@@ -1,3 +1,8 @@
+2002-06-12  John Levon  <moz@compsoc.man.ac.uk>
+
+       * insettext.C: change of topCursorVisible()
+         prototype
 2002-06-12  John Levon  <moz@compsoc.man.ac.uk>
 
        * insettext.h:
index 3592cb546e791729e72fd34f01ea343bcb9c5f28..636f981dae1bc49dd3d24701b6f9415314f97c4b 100644 (file)
@@ -2374,7 +2374,7 @@ void InsetText::resizeLyXText(BufferView * bv, bool force) const
                inset_y = ciy(bv) + drawTextYOffset;
        }
 
-       t->first_y = bv->screen().topCursorVisible(t);
+       t->first_y = bv->screen().topCursorVisible(t->cursor, t->first_y);
        if (!owner()) {
                updateLocal(bv, FULL, false);
                // this will scroll the screen such that the cursor becomes visible
@@ -2412,7 +2412,7 @@ void InsetText::reinitLyXText() const
                        inset_x = cix(bv) - top_x + drawTextXOffset;
                        inset_y = ciy(bv) + drawTextYOffset;
                }
-               t->first_y = bv->screen().topCursorVisible(t);
+               t->first_y = bv->screen().topCursorVisible(t->cursor, t->first_y);
                if (!owner()) {
                        updateLocal(bv, FULL, false);
                        // this will scroll the screen such that the cursor becomes visible