]> git.lyx.org Git - lyx.git/blobdiff - src/text.C
small changes to ButtonController usage
[lyx.git] / src / text.C
index 974e68c8415522ee308c4c9b502d9300e0f796d9..0783fe9753bee37361c04ea47de743a87df94196 100644 (file)
@@ -330,7 +330,8 @@ void LyXText::ComputeBidiTables(Buffer const * buf, Row * row) const
        }
 
        LyXParagraph::size_type vpos = bidi_start - 1;
-       for (LyXParagraph::size_type lpos = bidi_start; lpos <= bidi_end; ++lpos) {
+       for (LyXParagraph::size_type lpos = bidi_start;
+            lpos <= bidi_end; ++lpos) {
                vpos += log2vis_list[lpos - bidi_start];
                vis2log_list[vpos - bidi_start] = lpos;
                log2vis_list[lpos - bidi_start] = vpos;
@@ -516,8 +517,10 @@ void LyXText::draw(BufferView * bview, Row const * row,
 //                     tmpinset->update(bview, font, false);
                        tmpinset->draw(bview, font, offset+row->baseline(), x,
                                       cleared);
-                       if (status == CHANGED_IN_DRAW)
+                       if (status == CHANGED_IN_DRAW) {
                                UpdateInset(bview, tmpinset);
+                               status = CHANGED_IN_DRAW;
+                       }
                }
                ++vpos;
 
@@ -1628,7 +1631,12 @@ void LyXText::SetHeightOfRow(BufferView * bview, Row * row_ptr) const
    }
    
    /* is it a bottom line? */ 
-   if (row_ptr->par()->ParFromPos(RowLast(row_ptr) + 1) == par
+   if (
+#ifndef NEW_INSETS
+          row_ptr->par()->ParFromPos(RowLast(row_ptr) + 1) == par
+#else
+          row_ptr->par() == par
+#endif
        && (!row_ptr->next() || row_ptr->next()->par() != row_ptr->par())) {     
          
          /* the paper margins */ 
@@ -1701,7 +1709,7 @@ void LyXText::SetHeightOfRow(BufferView * bview, Row * row_ptr) const
    height += row_ptr->height();
    float x, dummy;
    PrepareToPrint(bview, row_ptr, x, dummy, dummy, dummy, false);
-   row_ptr->width(maxwidth+x);
+   row_ptr->width(int(maxwidth + x));
    if (inset_owner) {
           Row * r = firstrow;
           width = max(0,workWidth(bview));
@@ -1859,9 +1867,15 @@ void LyXText::BreakParagraph(BufferView * bview, char keep_layout)
        layout.labeltype!= LABEL_SENSITIVE)
      return;
 
-   SetUndo(bview->buffer(), Undo::INSERT, 
+   SetUndo(bview->buffer(), Undo::INSERT,
+#ifndef NEW_INSETS
           cursor.par()->ParFromPos(cursor.pos())->previous, 
-          cursor.par()->ParFromPos(cursor.pos())->next); 
+          cursor.par()->ParFromPos(cursor.pos())->next
+#else
+          cursor.par()->previous, 
+          cursor.par()->next
+#endif
+          ); 
 
 #ifndef NEW_TABULAR
    /* table stuff -- begin */
@@ -2709,9 +2723,15 @@ void LyXText::RedoParagraph(BufferView * bview) const
  * same Paragraph one to the right and make a rebreak */
 void LyXText::InsertChar(BufferView * bview, char c)
 {
-       SetUndo(bview->buffer(), Undo::INSERT, 
+       SetUndo(bview->buffer(), Undo::INSERT,
+#ifndef NEW_INSETS
                cursor.par()->ParFromPos(cursor.pos())->previous, 
-               cursor.par()->ParFromPos(cursor.pos())->next);
+               cursor.par()->ParFromPos(cursor.pos())->next
+#else
+               cursor.par()->previous, 
+               cursor.par()->next
+#endif
+               );
 
        // When the free-spacing option is set for the current layout,
        // disable the double-space checking
@@ -3018,9 +3038,10 @@ void LyXText::PrepareToPrint(BufferView * bview,
 #endif
           
        // center displayed insets 
+       Inset * inset;
           if (row->par()->GetChar(row->pos()) == LyXParagraph::META_INSET
-              && row->par()->GetInset(row->pos())
-              && row->par()->GetInset(row->pos())->display())
+              && (inset=row->par()->GetInset(row->pos()))
+              && (inset->display())) // || (inset->scroll() < 0)))
             align = LYX_ALIGN_CENTER;
 
           switch (align) {
@@ -3432,12 +3453,20 @@ void LyXText::DeleteLineForward(BufferView * bview)
 // version did. (JMarc) 
 void LyXText::ChangeWordCase(BufferView * bview, LyXText::TextCase action) 
 {
+#ifndef NEW_INSETS
        LyXParagraph * tmppar = cursor.par()->ParFromPos(cursor.pos());
+#else
+       LyXParagraph * tmppar = cursor.par();
+#endif
 
        SetUndo(bview->buffer(),Undo::FINISH, tmppar->previous, tmppar->next); 
 
+#ifndef NEW_INSETS
        LyXParagraph::size_type tmppos = 
                cursor.par()->PositionInParFromPos(cursor.pos());
+#else
+       LyXParagraph::size_type tmppos = cursor.pos();
+#endif
        while (tmppos < tmppar->size()) {
                unsigned char c = tmppar->GetChar(tmppos);
                if (IsKommaChar(c) || IsLineSeparatorChar(c))
@@ -3493,9 +3522,15 @@ void LyXText::Delete(BufferView * bview)
        if (old_cursor.par() != cursor.par() || old_cursor.pos() != cursor.pos()) {
                LyXCursor tmpcursor = cursor;
                cursor = old_cursor; // to make sure undo gets the right cursor position
-               SetUndo(bview->buffer(), Undo::DELETE, 
+               SetUndo(bview->buffer(), Undo::DELETE,
+#ifndef NEW_INSETS
                        cursor.par()->ParFromPos(cursor.pos())->previous, 
-                       cursor.par()->ParFromPos(cursor.pos())->next); 
+                       cursor.par()->ParFromPos(cursor.pos())->next
+#else
+                       cursor.par()->previous, 
+                       cursor.par()->next
+#endif
+                       ); 
                cursor = tmpcursor;
                Backspace(bview);
        }
@@ -3573,12 +3608,20 @@ void LyXText::Backspace(BufferView * bview)
                                return;
                        }
                }
-               
+
+#ifndef NEW_INSETS
                if (cursor.par()->ParFromPos(cursor.pos())->previous){
                        SetUndo(bview->buffer(), Undo::DELETE,
                                cursor.par()->ParFromPos(cursor.pos())->previous->previous,
                                cursor.par()->ParFromPos(cursor.pos())->next);
                }
+#else
+               if (cursor.par()->previous) {
+                       SetUndo(bview->buffer(), Undo::DELETE,
+                               cursor.par()->previous->previous,
+                               cursor.par()->next);
+               }
+#endif
                
                LyXParagraph * tmppar = cursor.par();
                Row * tmprow = cursor.row();
@@ -3651,9 +3694,15 @@ void LyXText::Backspace(BufferView * bview)
        } else {
                /* this is the code for a normal backspace, not pasting
                 * any paragraphs */ 
-               SetUndo(bview->buffer(), Undo::DELETE, 
+               SetUndo(bview->buffer(), Undo::DELETE,
+#ifndef NEW_INSETS
                        cursor.par()->ParFromPos(cursor.pos())->previous, 
-                       cursor.par()->ParFromPos(cursor.pos())->next); 
+                       cursor.par()->ParFromPos(cursor.pos())->next
+#else
+                       cursor.par()->previous, 
+                       cursor.par()->next
+#endif
+                       ); 
                // We used to do CursorLeftIntern() here, but it is
                // not a good idea since it triggers the auto-delete
                // mechanism. So we do a CursorLeftIntern()-lite,
@@ -3850,9 +3899,10 @@ void LyXText::GetVisibleRow(BufferView * bview, int y_offset, int x_offset,
        LyXParagraph::size_type last = RowLastPrintable(row_ptr);
 
        LyXParagraph::size_type vpos, pos;
-       float x, tmpx;
-       int y_top, y_bottom;
-       float fill_separator, fill_hfill, fill_label_hfill;
+       float x;
+       float tmpx;
+       int y_top;
+       int y_bottom;
 
        LyXFont font(LyXFont::ALL_SANE);
        int maxdesc;
@@ -3861,6 +3911,10 @@ void LyXText::GetVisibleRow(BufferView * bview, int y_offset, int x_offset,
                       << row_ptr->height() << endl;
                return;
        }
+
+       float fill_separator;
+       float fill_hfill;
+       float fill_label_hfill;
        PrepareToPrint(bview, row_ptr, x, fill_separator,
                       fill_hfill, fill_label_hfill);
        
@@ -3869,45 +3923,33 @@ void LyXText::GetVisibleRow(BufferView * bview, int y_offset, int x_offset,
        x += x_offset;
        
        // clear the area where we want to paint/print
-       int ww;
-       ww = bview->workWidth();
+       int ww = bview->workWidth();
 
        bool clear_area = true;
        Inset * inset = 0;
 
        if ((last == row_ptr->pos()) &&
            (row_ptr->par()->GetChar(row_ptr->pos()) == LyXParagraph::META_INSET) &&
-           (inset=row_ptr->par()->GetInset(row_ptr->pos())))
-       {
+           (inset = row_ptr->par()->GetInset(row_ptr->pos()))) {
                clear_area = inset->doClearArea();
        }
        if (cleared) { // we don't need to clear it's already done!!!
                clear_area = true;
        } else if (clear_area) {
-               int w;
-               if (inset_owner)
-                       w = inset_owner->width(bview, font);
-               else
-                       w = ww;
+               int w = (inset_owner ? inset_owner->width(bview, font) : ww);
                pain.fillRectangle(x_offset, y_offset, w, row_ptr->height());
        } else if (inset != 0) {
                int h = row_ptr->baseline() - inset->ascent(bview, font);
                if (h > 0) {
-                       int w;
-                       if (inset_owner)
-                               w = inset_owner->width(bview, font);
-                       else
-                               w = ww;
+                       int w = (inset_owner ?
+                                inset_owner->width(bview, font) : ww);
                        pain.fillRectangle(x_offset, y_offset, w, h);
                }
                h += inset->ascent(bview, font) + inset->descent(bview, font);
                if ((row_ptr->height() - h) > 0) {
-                       int w;
-                       if (inset_owner)
-                               w = inset_owner->width(bview, font);
-                       else
-                               w = ww;
-                       pain.fillRectangle(x_offset,h, w, row_ptr->height()-h);
+                       int w = (inset_owner ?
+                                inset_owner->width(bview, font) : ww);
+                       pain.fillRectangle(x_offset,y_offset+h, w, row_ptr->height()-h);
                }
                if (!inset_owner && !inset->display() && !inset->needFullRow())
                {
@@ -3917,11 +3959,7 @@ void LyXText::GetVisibleRow(BufferView * bview, int y_offset, int x_offset,
        }
        
        if (selection) {
-               int w;
-               if (inset_owner)
-                       w = inset_owner->width(bview, font);
-               else
-                       w = ww;
+               int w = (inset_owner ? inset_owner->width(bview, font) : ww);
                /* selection code */
                if (bidi_same_direction) {
                        if (sel_start_cursor.row() == row_ptr &&
@@ -4459,8 +4497,13 @@ void LyXText::GetVisibleRow(BufferView * bview, int y_offset, int x_offset,
 #else
        LyXParagraph * par = row_ptr->par();
 #endif
-       if ((row_ptr->par()->ParFromPos(last + 1) == par) &&
-           (!row_ptr->next() || (row_ptr->next()->par() != row_ptr->par())))
+       if (
+#ifndef NEW_INSETS
+               (row_ptr->par()->ParFromPos(last + 1) == par)
+#else
+               (row_ptr->par() == par)
+#endif
+           && (!row_ptr->next() || (row_ptr->next()->par() != row_ptr->par())))
        {
                /* think about the margins */ 
                if (!row_ptr->next() && bv_owner)