]> git.lyx.org Git - features.git/commitdiff
Finally text-insets should draw correctly (also selections), some small fixes.
authorJürgen Vigna <jug@sad.it>
Thu, 19 Oct 2000 09:11:39 +0000 (09:11 +0000)
committerJürgen Vigna <jug@sad.it>
Thu, 19 Oct 2000 09:11:39 +0000 (09:11 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@1140 a592a061-630c-0410-9148-cb99ea01b6c8

ChangeLog
src/insets/insettext.C
src/lyxfunc.C
src/lyxtext.h
src/screen.C
src/support/lyxlib.h
src/tabular.C
src/text2.C

index e3d13e736a5beccba04094a8514bed302db71440..e4bdcde29f2d433e781449e01e9b8e138bf822b8 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,27 @@
+2000-10-19  Juergen Vigna  <jug@sad.it>
+
+       * src/lyxfunc.C (MenuNew): small fix (form John)
+
+       * src/screen.C (Update): removed unneeded code.
+
+       * src/tabular.C (Ascii): refixed int != uint bug!
+
+       * src/support/lyxlib.h: added sys/types.h include for now permits
+       compiling, but I don't like this!
+
+2000-10-18  Juergen Vigna  <jug@sad.it>
+
+       * src/text2.C (ClearSelection): if we clear the selection we need
+       more refresh so set the status aprpriate
+
+       * src/insets/insettext.C (draw): hopefully finally fixed draw
+       problems!
+
+2000-10-12  Juergen Vigna  <jug@sad.it>
+
+       * src/insets/insettext.C (draw): another small fix and make a block
+       so that variables are localized.
+
 2000-10-18  Angus Leeming <a.leeming@ic.ac.uk>
        * src/support/lstrings.C (lowercase, uppercase):
        use explicit casts to remove compiler warnings.
index 21285dbe8a5cce64a1fff4199acd62fd30cf7a31..e4d88f5b062ad9ce9b5ddc4a5ba12b3775b6a07b 100644 (file)
@@ -313,37 +313,43 @@ void InsetText::draw(BufferView * bv, LyXFont const & f,
        return;
     }
     x += TEXT_TO_INSET_OFFSET;
-    int y = 0;
-    Row * row = TEXT(bv)->GetRowNearY(y);
-    int y_offset = baseline - row->ascent_of_text();
-    int ph = pain.paperHeight();
-    y += y_offset;
-    while ((row != 0) && ((y+row->height()) <= 0)) {
-       y += row->height();
-       row = row->next();
-    }
-    y -= y_offset;
-    TEXT(bv)->first = y;
-    if (cleared || !locked || (need_update == FULL)) {
-       int first = y;
-       y = 0;
-       while ((row != 0) && (y < ph)) {
-           TEXT(bv)->GetVisibleRow(bv, y+first+y_offset, int(x), row,
-                                   y+first, cleared);
+    {
+       int y = 0;
+       Row * row = TEXT(bv)->GetRowNearY(y);
+       int y_offset = baseline - row->ascent_of_text();
+       int ph = pain.paperHeight();
+       int first = 0;
+       y = y_offset;
+       while ((row != 0) && ((y+row->height()) <= 0)) {
            y += row->height();
+           first += row->height();
            row = row->next();
        }
-    } else if (need_update == SELECTION) {
-       bv->screen()->ToggleToggle(TEXT(bv), y+y_offset, int(x));
-    } else {
-       locked = false;
-       if (need_update == CURSOR) {
-           bv->screen()->ToggleSelection(TEXT(bv), true, y+y_offset, int(x));
-           TEXT(bv)->ClearSelection();
-           TEXT(bv)->sel_cursor = TEXT(bv)->cursor;
+       if (y_offset < 0)
+           y_offset = y;
+       TEXT(bv)->first = first;
+       if (cleared || !locked || (need_update == FULL)) {
+           int yf = y_offset;
+           y = 0;
+           while ((row != 0) && (yf < ph)) {
+                   TEXT(bv)->GetVisibleRow(bv, y+y_offset, int(x), row,
+                                           y+first, cleared);
+               y += row->height();
+               yf += row->height();
+               row = row->next();
+           }
+       } else if (need_update == SELECTION) {
+           bv->screen()->ToggleToggle(TEXT(bv), y_offset, int(x));
+       } else {
+           locked = false;
+           if (need_update == CURSOR) {
+               bv->screen()->ToggleSelection(TEXT(bv), true, y_offset,int(x));
+               TEXT(bv)->ClearSelection();
+               TEXT(bv)->sel_cursor = TEXT(bv)->cursor;
+           }
+           bv->screen()->Update(TEXT(bv), y_offset, int(x));
+           locked = true;
        }
-       bv->screen()->Update(TEXT(bv), y, int(x));
-       locked = true;
     }
     TEXT(bv)->refresh_y = 0;
     TEXT(bv)->status = LyXText::UNCHANGED;
@@ -813,6 +819,7 @@ InsetText::LocalDispatch(BufferView * bv,
        bv->text->FinishUndo();
        result= moveLeft(bv);
        TEXT(bv)->ClearSelection();
+       TEXT(bv)->sel_cursor = TEXT(bv)->cursor;
        UpdateLocal(bv, CURSOR, false);
        break;
     case LFUN_DOWNSEL:
@@ -825,6 +832,7 @@ InsetText::LocalDispatch(BufferView * bv,
        bv->text->FinishUndo();
        result = moveDown(bv);
        TEXT(bv)->ClearSelection();
+       TEXT(bv)->sel_cursor = TEXT(bv)->cursor;
        UpdateLocal(bv, CURSOR, false);
        break;
     case LFUN_UPSEL:
@@ -837,15 +845,20 @@ InsetText::LocalDispatch(BufferView * bv,
        bv->text->FinishUndo();
        result = moveUp(bv);
        TEXT(bv)->ClearSelection();
+       TEXT(bv)->sel_cursor = TEXT(bv)->cursor;
        UpdateLocal(bv, CURSOR, false);
        break;
     case LFUN_HOME:
        bv->text->FinishUndo();
        TEXT(bv)->CursorHome(bv);
+       TEXT(bv)->ClearSelection();
+       TEXT(bv)->sel_cursor = TEXT(bv)->cursor;
        UpdateLocal(bv, CURSOR, false);
        break;
     case LFUN_END:
        TEXT(bv)->CursorEnd(bv);
+       TEXT(bv)->ClearSelection();
+       TEXT(bv)->sel_cursor = TEXT(bv)->cursor;
        UpdateLocal(bv, CURSOR, false);
        break;
     case LFUN_BACKSPACE:
index 2cc20d2d7a5d6c1fbb3ddd97e157cf42195cc19e..066f0ce7265f5e191ed3008a4b44b2389acbf347 100644 (file)
@@ -3182,6 +3182,8 @@ void LyXFunc::MenuNew(bool fromTemplate)
                fname = fileDlg.Select(_("Choose template"),
                                       lyxrc.template_path,
                                       "*.lyx");
+               if (fname.empty())
+                       return;
                 templname = fname;
                AllowInput(owner->view());
        }
index 8bf6cceb935038ea055fb372756889b1ac4b5333..7a7d551ced8406050502274368fe9575197b7fe1 100644 (file)
@@ -66,7 +66,8 @@ public:
        /// the current font
        mutable LyXFont real_current_font;
        /// first visible pixel-row is set from LyXScreen!!!
-       unsigned int first;
+       // unsigned is wrong here for text-insets!
+       int first;
        ///
        BufferView * bv_owner;
        ///
index db8701de191890007bdbdfc21c72f63c9c14cfc9..d232e94c284a64b9d3f77e1cc6a82573a2664934 100644 (file)
@@ -148,7 +148,7 @@ void LyXScreen::Draw(LyXText * text, unsigned int y)
 {
        if (cursor_visible) HideCursor();
 
-       unsigned int old_first = text->first;
+       int old_first = text->first;
        text->first = y;
 
        // is any optimiziation possible?
@@ -221,7 +221,7 @@ bool LyXScreen::FitManualCursor(LyXText * text,
 {
        int newtop = text->first;
   
-       if (y + desc - text->first >= owner.height())
+       if (y + desc - text->first >= (int)owner.height())
                newtop = y - 3 * owner.height() / 4;  // the scroll region must be so big!!
        else if (y - asc < (int)text->first
                && text->first > 0) {
@@ -242,10 +242,10 @@ bool LyXScreen::FitManualCursor(LyXText * text,
 void LyXScreen::ShowManualCursor(LyXText const * text, int x, int y,
                                 int asc, int desc, Cursor_Shape shape)
 {
-       unsigned int y1 = max(y - text->first - asc, 0U);
+       unsigned int y1 = max(y - text->first - asc, 0);
        typedef unsigned int uint;
        
-       unsigned int y2 = min(y - text->first + desc, owner.height());
+       unsigned int y2 = min(y - text->first + desc, (int)owner.height());
 
        // Secure against very strange situations
        y2 = max(y2, y1);
@@ -360,8 +360,9 @@ unsigned int LyXScreen::TopCursorVisible(LyXText const * text)
                else
                        newtop = text->cursor.y()
                                - 3 * owner.height() / 4;   /* the scroll region must be so big!! */
-       } else if (text->cursor.y() - text->cursor.row()->baseline() < text->first
-                  && text->first > 0) {
+       } else if ((int)(text->cursor.y() - text->cursor.row()->baseline()) <
+                  text->first && text->first > 0)
+       {
                if (text->cursor.row()->height() < owner.height()
                    && text->cursor.row()->height() > owner.height() / 4)
                        newtop = text->cursor.y() - text->cursor.row()->baseline();
@@ -382,7 +383,7 @@ unsigned int LyXScreen::TopCursorVisible(LyXText const * text)
 bool LyXScreen::FitCursor(LyXText * text)
 {
        // Is a change necessary?
-       unsigned int newtop = TopCursorVisible(text);
+       int newtop = TopCursorVisible(text);
        bool result = (newtop != text->first);
        if (result)
                Draw(text, newtop);
@@ -396,19 +397,10 @@ void LyXScreen::Update(LyXText * text, int y_offset, int x_offset)
        case LyXText::NEED_MORE_REFRESH:
        {
                int y = max(int(text->refresh_y - text->first), 0);
-               int height;
-               if (text->inset_owner)
-                       height = text->inset_owner->ascent(owner.owner(),
-                                                          text->real_current_font)
-                               + text->inset_owner->descent(owner.owner(),
-                                                            text->real_current_font);
-               else
-                       height = owner.height();
                DrawFromTo(text, y, owner.height(), y_offset, x_offset);
                text->refresh_y = 0;
                text->status = LyXText::UNCHANGED;
-               expose(0, y,
-                      owner.workWidth(), owner.height() - y);
+               expose(0, y, owner.workWidth(), owner.height() - y);
        }
        break;
        case LyXText::NEED_VERY_LITTLE_REFRESH:
@@ -435,13 +427,14 @@ void LyXScreen::ToggleSelection(LyXText * text,  bool kill_selection,
        // only if there is a selection
        if (!text->selection) return;
 
-       int bottom = min(max(text->sel_end_cursor.y()
+       int bottom = min(max((int)(text->sel_end_cursor.y()
                              - text->sel_end_cursor.row()->baseline()
-                             + text->sel_end_cursor.row()->height(), text->first),
-                         text->first + owner.height());
-       int top = min(max(text->sel_start_cursor.y()
-                          - text->sel_start_cursor.row()->baseline(), text->first),
-                      text->first + owner.height());
+                             + text->sel_end_cursor.row()->height()), text->first),
+                         (int)(text->first + owner.height()));
+       int top = min(max((int)(text->sel_start_cursor.y() -
+                         text->sel_start_cursor.row()->baseline()),
+                         text->first),
+                     (int)(text->first + owner.height()));
 
        if (kill_selection)
                text->selection = 0;
@@ -467,8 +460,8 @@ void LyXScreen::ToggleToggle(LyXText * text, int y_offset, int x_offset)
        
        typedef unsigned int uint;
        
-       bottom = min(max(uint(bottom), text->first), text->first + owner.height());
-       top = min(max(uint(top), text->first), text->first + owner.height());
+       bottom = min(max(bottom, text->first), (int)(text->first + owner.height()));
+       top = min(max(top, text->first), (int)(text->first + owner.height()));
 
        DrawFromTo(text, top - text->first, bottom - text->first, y_offset,
                   x_offset);
index a159ee30d07e111d9e7057fdd3a93fdbbff714e2..4f955a44868b34b0c29aea9702be94f176d979fd 100644 (file)
@@ -13,6 +13,7 @@
 #define LYX_LIB_H
 
 #include "LString.h"
+#include <sys/types.h>
 
 // Where can I put this?  I found the occurence of the same code
 // three/four times. Don't you think it better to use a macro definition
index 7cc4caf16501a570e42332f4fc49386cb3092ae3..2b456f217fb16914646d8e4e6f7649bac273ab2b 100644 (file)
@@ -2425,11 +2425,11 @@ int LyXTabular::Ascii(Buffer const * buf, ostream & os) const
                continue;
            ostringstream sstr;
            GetCellInset(cell)->Ascii(buf, sstr, 0);
-           string::size_type len = sstr.str().length();
+           int len = int(sstr.str().length());
            int const n = cells_in_multicolumn(cell);
            for (int k = j; (len > 0) && (k < (j + n - 1)); ++k)
                len -= clen[k];
-           if (len > clen[j + n - 1])
+           if (len > int(clen[j + n - 1]))
                clen[j + n - 1] = len;
        }
     }
index 3071fa4997d6da7cbe67a246719629f2cd9bb58c..d7047c5c301184334bbe1f1fa57080e9e6e29dfb 100644 (file)
@@ -1203,6 +1203,8 @@ string const LyXText::selectionAsString(Buffer const * buffer) const
 
 void LyXText::ClearSelection() const
 {
+       if (selection)
+               status = LyXText::NEED_MORE_REFRESH;
        selection = false;
        mark_set = false;
 }