]> git.lyx.org Git - features.git/commitdiff
Fixed update of insets in insets.
authorJürgen Vigna <jug@sad.it>
Mon, 26 Jun 2000 15:10:49 +0000 (15:10 +0000)
committerJürgen Vigna <jug@sad.it>
Mon, 26 Jun 2000 15:10:49 +0000 (15:10 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@835 a592a061-630c-0410-9148-cb99ea01b6c8

16 files changed:
ChangeLog
forms/cite.fd
src/insets/inset.C
src/insets/insetcite.C
src/insets/insetcollapsable.C
src/insets/insetcollapsable.h
src/insets/insetfoot.h
src/insets/insettabular.C
src/insets/insettext.C
src/insets/insettext.h
src/insets/lyxinset.h
src/lyxrow.C
src/lyxrow.h
src/lyxtext.h
src/text.C
src/text2.C

index 8910e6d1fa3d58455e88ae61427dbbb2212fb07a..49ef11e540830d818402dd62d7ef647e6182fbfd 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2000-06-26  Juergen Vigna  <jug@sad.it>
+
+       * src/lyxrow.C (width): added this functions and variable.
+
+       * src/insets/insetcite.C (create_form_citation_form): some Gravity
+       changes.
+
+       * src/text.C (SetHeightOfRow): fixed calcualting of width.
+
 2000-06-26  Jean-Marc Lasgouttes  <Jean-Marc.Lasgouttes@inria.fr>
 
        * src/BufferView.h: add a magic "friend" declaration to please
index 74cfed86de185edf633611bbcba4486fb7b15e1a..a5543f2096cef634d3ec62165fc9f448347ca93a 100644 (file)
@@ -78,11 +78,29 @@ size: FL_DEFAULT_SIZE
 lcol: FL_BLACK
 label: @4->
 shortcut: 
-resize: FL_RESIZE_NONE
+resize: FL_RESIZE_ALL
 gravity: FL_NoGravity FL_NoGravity
-name: addBtn
+name: bibBrsr
 callback: citation_cb
-argument: InsetCitation::ADD
+argument: InsetCitation::BIBBRSR
+
+--------------------
+class: FL_BUTTON
+type: NORMAL_BUTTON
+box: 200 40 40 40
+boxtype: FL_UP_BOX
+colors: FL_COL1 FL_COL1
+alignment: FL_ALIGN_CENTER
+style: FL_NORMAL_STYLE
+size: FL_DEFAULT_SIZE
+lcol: FL_BLACK
+label: Button
+shortcut: 
+resize: FL_RESIZE_ALL
+gravity: FL_South FL_South
+name: bibBrsr
+callback: citation_cb
+argument: InsetCitation::BIBBRSR
 
 --------------------
 class: FL_BUTTON
@@ -96,11 +114,29 @@ size: FL_DEFAULT_SIZE
 lcol: FL_BLACK
 label: @9+
 shortcut: 
-resize: FL_RESIZE_NONE
+resize: FL_RESIZE_ALL
 gravity: FL_NoGravity FL_NoGravity
-name: delBtn
+name: bibBrsr
+callback: citation_cb
+argument: InsetCitation::BIBBRSR
+
+--------------------
+class: FL_BUTTON
+type: NORMAL_BUTTON
+box: 200 90 40 40
+boxtype: FL_UP_BOX
+colors: FL_COL1 FL_COL1
+alignment: FL_ALIGN_CENTER
+style: FL_NORMAL_STYLE
+size: FL_DEFAULT_SIZE
+lcol: FL_BLACK
+label: Button
+shortcut: 
+resize: FL_RESIZE_ALL
+gravity: FL_South FL_South
+name: bibBrsr
 callback: citation_cb
-argument: InsetCitation::DELETE
+argument: InsetCitation::BIBBRSR
 
 --------------------
 class: FL_BUTTON
@@ -114,11 +150,29 @@ size: FL_DEFAULT_SIZE
 lcol: FL_BLACK
 label: @8->
 shortcut: 
-resize: FL_RESIZE_NONE
+resize: FL_RESIZE_ALL
 gravity: FL_NoGravity FL_NoGravity
-name: upBtn
+name: bibBrsr
 callback: citation_cb
-argument: InsetCitation::UP
+argument: InsetCitation::BIBBRSR
+
+--------------------
+class: FL_BUTTON
+type: NORMAL_BUTTON
+box: 200 140 40 40
+boxtype: FL_UP_BOX
+colors: FL_COL1 FL_COL1
+alignment: FL_ALIGN_CENTER
+style: FL_NORMAL_STYLE
+size: FL_DEFAULT_SIZE
+lcol: FL_BLACK
+label: Button
+shortcut: 
+resize: FL_RESIZE_ALL
+gravity: FL_South FL_South
+name: bibBrsr
+callback: citation_cb
+argument: InsetCitation::BIBBRSR
 
 --------------------
 class: FL_BUTTON
@@ -132,11 +186,29 @@ size: FL_DEFAULT_SIZE
 lcol: FL_BLACK
 label: @2->
 shortcut: 
-resize: FL_RESIZE_NONE
+resize: FL_RESIZE_ALL
 gravity: FL_NoGravity FL_NoGravity
-name: downBtn
+name: bibBrsr
+callback: citation_cb
+argument: InsetCitation::BIBBRSR
+
+--------------------
+class: FL_BUTTON
+type: NORMAL_BUTTON
+box: 200 190 40 40
+boxtype: FL_UP_BOX
+colors: FL_COL1 FL_COL1
+alignment: FL_ALIGN_CENTER
+style: FL_NORMAL_STYLE
+size: FL_DEFAULT_SIZE
+lcol: FL_BLACK
+label: Button
+shortcut: 
+resize: FL_RESIZE_ALL
+gravity: FL_South FL_South
+name: bibBrsr
 callback: citation_cb
-argument: InsetCitation::DOWN
+argument: InsetCitation::BIBBRSR
 
 --------------------
 class: FL_BROWSER
@@ -174,77 +246,5 @@ name: style
 callback: 
 argument: 
 
---------------------
-class: FL_INPUT
-type: NORMAL_INPUT
-box: 100 620 250 30
-boxtype: FL_DOWN_BOX
-colors: FL_COL1 FL_MCOL
-alignment: FL_ALIGN_LEFT
-style: FL_NORMAL_STYLE
-size: FL_DEFAULT_SIZE
-lcol: FL_BLACK
-label: Text before
-shortcut: 
-resize: FL_RESIZE_X
-gravity: FL_NoGravity FL_NoGravity
-name: textBefore
-callback: 
-argument: 
-
---------------------
-class: FL_INPUT
-type: NORMAL_INPUT
-box: 100 660 250 30
-boxtype: FL_DOWN_BOX
-colors: FL_COL1 FL_MCOL
-alignment: FL_ALIGN_LEFT
-style: FL_NORMAL_STYLE
-size: FL_DEFAULT_SIZE
-lcol: FL_BLACK
-label: Text after
-shortcut: 
-resize: FL_RESIZE_X
-gravity: FL_NoGravity FL_NoGravity
-name: textAftr
-callback: 
-argument: 
-
---------------------
-class: FL_BUTTON
-type: RETURN_BUTTON
-box: 190 730 110 40
-boxtype: FL_UP_BOX
-colors: FL_COL1 FL_COL1
-alignment: FL_ALIGN_CENTER
-style: FL_NORMAL_STYLE
-size: FL_DEFAULT_SIZE
-lcol: FL_BLACK
-label: OK
-shortcut: ^M
-resize: FL_RESIZE_ALL
-gravity: FL_SouthEast FL_SouthEast
-name: ok
-callback: citation_cb
-argument: InsetCitation::OK
-
---------------------
-class: FL_BUTTON
-type: NORMAL_BUTTON
-box: 310 730 110 40
-boxtype: FL_UP_BOX
-colors: FL_COL1 FL_COL1
-alignment: FL_ALIGN_CENTER
-style: FL_NORMAL_STYLE
-size: FL_DEFAULT_SIZE
-lcol: FL_BLACK
-label: Cancel
-shortcut: ^[
-resize: FL_RESIZE_ALL
-gravity: FL_SouthEast FL_SouthEast
-name: cancel
-callback: citation_cb
-argument: InsetCitation::CANCEL
-
 ==============================
-create_the_forms
+--------------------
index 35052a6dda2bbfd89d35cd0f59de0d318734d1a9..775921433e9afea85d8af2deb37a569acbd90df0 100644 (file)
@@ -137,7 +137,7 @@ void UpdatableInset::Edit(BufferView * bv, int, int, unsigned int)
 
 
 void UpdatableInset::draw(BufferView *, LyXFont const &,
-                         int /* baseline */, float & x) const
+                         int /* baseline */, float & x, bool/*cleared*/) const
 {
     if (scx) x += float(scx);
 // ATTENTION: don't do the following here!!!
index 7117bd906388650de54ff8faafe5ce86abb42861..579f55c1e94e93d1141655c6eacfd39485df9432 100644 (file)
@@ -66,21 +66,25 @@ FD_citation_form *create_form_citation_form(void)
 
   fdui->addBtn = obj =
     fl_add_button(FL_NORMAL_BUTTON,200,40,40,40,"@4->");
+    fl_set_object_gravity(obj, FL_South, FL_South);
     fl_set_object_resize(obj, FL_RESIZE_NONE);
     fl_set_object_callback(obj,citation_cb,InsetCitation::ADD);
 
   fdui->delBtn = obj =
     fl_add_button(FL_NORMAL_BUTTON,200,90,40,40,"@9+");
+    fl_set_object_gravity(obj, FL_South, FL_South);
     fl_set_object_resize(obj, FL_RESIZE_NONE);
     fl_set_object_callback(obj,citation_cb,InsetCitation::DELETE);
 
   fdui->upBtn = obj =
     fl_add_button(FL_NORMAL_BUTTON,200,140,40,40,"@8->");
+    fl_set_object_gravity(obj, FL_South, FL_South);
     fl_set_object_resize(obj, FL_RESIZE_NONE);
     fl_set_object_callback(obj,citation_cb,InsetCitation::UP);
 
   fdui->downBtn = obj =
     fl_add_button(FL_NORMAL_BUTTON,200,190,40,40,"@2->");
+    fl_set_object_gravity(obj, FL_South, FL_South);
     fl_set_object_resize(obj, FL_RESIZE_NONE);
     fl_set_object_callback(obj,citation_cb,InsetCitation::DOWN);
 
@@ -102,6 +106,7 @@ FD_citation_form *create_form_citation_form(void)
 
   fdui->textAftr = obj =
     fl_add_input(FL_NORMAL_INPUT,100,660,250,30,_("Text after"));
+    fl_set_object_gravity(obj, FL_SouthWest, FL_SouthEast);
     fl_set_object_resize(obj, FL_RESIZE_X);
 
   fdui->ok = obj =
@@ -384,7 +389,7 @@ void InsetCitation::setSize( FD_citation_form * form,
        fl_set_form_size( form->form, 430, formHeight );
 
        // No resizing is alowed in the y-direction
-       fl_set_form_minsize( form->form, 300, formHeight );
+       fl_set_form_minsize( form->form, 430, formHeight );
        fl_set_form_maxsize( form->form, 1000, formHeight );
 
        int ypos = 0;
index 24457fba6dd235230d5a6f2fbbf0343e7034ba11..4d1d4c3973282921ff7ec696be524881d9655084 100644 (file)
@@ -29,7 +29,7 @@ InsetCollapsable::InsetCollapsable() : InsetText()
     autocollapse = true;
     autoBreakRows = true;
     framecolor = LColor::footnoteframe;
-    widthOffset = 6; // 2+2 (behind+back), 1+1 (frame)
+    widthOffset = 2 * TEXT_TO_INSET_OFFSET + 2; // 1+1 (frame)
     button_length = button_top_y = button_bottom_y = 0;
     setInsetName("Collapsable");
 }
@@ -153,11 +153,10 @@ void InsetCollapsable::draw(BufferView * bv, LyXFont const & f,
     draw_collapsed(pain, f, baseline, x);
     x -= TEXT_TO_INSET_OFFSET;
 
-    int w =  InsetText::width(pain, f) + 2 * TEXT_TO_INSET_OFFSET;
+    int w =  InsetText::width(pain, f) + (2 * TEXT_TO_INSET_OFFSET);
     int h = ascent(pain,f) + descent(pain, f);
     int save_x = static_cast<int>(x);
     x += TEXT_TO_INSET_OFFSET;
-    drawTextXOffset = int(x) - top_x;
     InsetText::draw(bv, f, baseline, x, cleared);
     pain.rectangle(save_x, baseline - ascent(pain, f), w, h, framecolor);
 }
@@ -251,3 +250,9 @@ int InsetCollapsable::getMaxTextWidth(Painter & pain,
     return getMaxWidth(pain, inset) -
        width_collapsed(pain, labelfont) - widthOffset;
 }
+
+void InsetCollapsable::update(BufferView * bv, LyXFont const & font, bool dodraw)
+{
+    drawTextXOffset = width_collapsed(bv->painter(), font);
+    InsetText::update(bv, font, dodraw);
+}
index 73bbc42d4ea2094f5dbb6468c86855600dff572e..a290e8e59cace9b3e820d4f877a0b2c74e83cec9 100644 (file)
@@ -53,6 +53,8 @@ public:
     ///
     void draw(BufferView *, const LyXFont &, int , float &, bool) const;
     ///
+    void update(BufferView *, LyXFont const &, bool =false); 
+    ///
     void Edit(BufferView *, int, int, unsigned int);
     ///
     EDITABLE Editable() const;
index a5404b4556183dba0a3664b3a848fd30963af642..938226e0156bb7815dd4eb6ed7108739cb8ede02 100644 (file)
@@ -46,7 +46,6 @@ public:
     bool InsertInsetAllowed(Inset * inset) const;
     ///
     LyXFont GetDrawFont(BufferView *, LyXParagraph * par, int pos) const;
-    ///
 };
 
 #endif
index 2acf66517863d27e647cbd0177db5b1ea6cb2348..cbffdc4647320ff59f5853c88a2283b4f9d66cf0 100644 (file)
@@ -157,7 +157,7 @@ void InsetTabular::draw(BufferView * bv, LyXFont const & font, int baseline,
     int nx;
     float cx;
 
-    UpdatableInset::draw(bv,font,baseline,x);
+    UpdatableInset::draw(bv,font,baseline,x,cleared);
     if ((need_update == INIT)|| (top_x != int(x)) || (top_baseline != baseline)) {
        need_update = FULL;
        top_x = int(x);
index 44d51639331f8751bd02b3dc93a7a63e60bd9098..427e4689f0c83c48cc2cb09dda0a1996c23a3018 100644 (file)
@@ -83,6 +83,7 @@ InsetText & InsetText::operator=(InsetText const & it)
 
 void InsetText::init(InsetText const * ins)
 {
+    top_y = last_width = last_height = 0;
     insetAscent = insetDescent = insetWidth = 0;
     the_locking_inset = 0;
     cursor_visible = false;
@@ -216,11 +217,11 @@ void InsetText::draw(BufferView * bv, LyXFont const & f,
 {
     Painter & pain = bv->painter();
 
-    xpos = x;
-    UpdatableInset::draw(bv, f, baseline, x);
-    if (!cleared && locked && ((need_update==FULL) || (top_x!=int(x)) ||
-                  (top_baseline!=baseline))) {
+    if (!cleared && ((need_update==FULL) || (top_x!=int(x)) ||
+                    (top_baseline!=baseline))) {
+#if 0
+           // && locked && ((need_update==FULL) || (top_x!=int(x)) ||
+           //    (top_baseline!=baseline))) {
        need_update = NONE;
        top_x = int(x);
        top_baseline = baseline;
@@ -232,9 +233,24 @@ void InsetText::draw(BufferView * bv, LyXFont const & f,
                               width(pain, f), ascent(pain,f)+descent(pain, f),
                               frame_color);
        return;
+#else
+       pain.fillRectangle(top_x+drawTextXOffset, top_y, last_width,
+                          last_height);
+       need_update = FULL;
+#endif
     }
+
+    if (!cleared && (need_update == NONE))
+       return;
+
+    xpos = x;
+    UpdatableInset::draw(bv, f, baseline, x, cleared);
     top_baseline = baseline;
     top_x = int(x);
+    top_y = baseline - ascent(pain, f);
+    last_width = width(pain, f);
+    last_height = ascent(pain, f) + descent(pain, f);
 
     if (the_locking_inset && (cpos(bv) == inset_pos)) {
        inset_x = cx(bv) - top_x + drawTextXOffset;
@@ -295,7 +311,8 @@ void InsetText::update(BufferView * bv, LyXFont const & font, bool dodraw)
     insetAscent = row->ascent_of_text() + TEXT_TO_INSET_OFFSET;
     insetDescent = TEXT(bv)->height - row->ascent_of_text() +
        TEXT_TO_INSET_OFFSET;
-    insetWidth = max(textWidth(bv->painter()), TEXT(bv)->width) +
+    insetWidth = max(textWidth(bv->painter()),
+                    static_cast<int>(TEXT(bv)->width)) +
        (2 * TEXT_TO_INSET_OFFSET);
 }
 
@@ -336,12 +353,10 @@ void InsetText::InsetUnlock(BufferView * bv)
        the_locking_inset = 0;
     }
     HideInsetCursor(bv);
-    lyxerr[Debug::INSETS] << "InsetText::InsetUnlock(" << this <<
-           ")" << endl;
     no_selection = false;
     locked = false;
     TEXT(bv)->selection = 0;
-    UpdateLocal(bv, FULL, false);
+    UpdateLocal(bv, CURSOR_PAR, false);
     bv->owner()->getToolbar()->combox->select(bv->text->cursor.par()->GetLayout()+1);
 }
 
@@ -384,9 +399,11 @@ bool InsetText::UnlockInsetInInset(BufferView * bv, UpdatableInset * inset,
         return false;
     if (the_locking_inset == inset) {
         the_locking_inset->InsetUnlock(bv);
+       TEXT(bv)->UpdateInset(bv, inset);
         the_locking_inset = 0;
         if (lr)
             moveRight(bv, false);
+       UpdateLocal(bv, FULL, false);
         return true;
     }
     return the_locking_inset->UnlockInsetInInset(bv, inset, lr);
@@ -399,9 +416,8 @@ bool InsetText::UpdateInsetInInset(BufferView * bv, Inset * inset)
         return false;
     if (the_locking_inset != inset)
         return the_locking_inset->UpdateInsetInInset(bv, inset);
-    lyxerr[Debug::INSETS] << "InsetText::UpdateInsetInInset(" << inset <<
-           ")" << endl;
-    UpdateLocal(bv, FULL, false);
+//    UpdateLocal(bv, FULL, false);
+    TEXT(bv)->UpdateInset(bv, inset);
     if (cpos(bv) == inset_pos) {
        inset_x = cx(bv) - top_x + drawTextXOffset;
        inset_y = cy(bv) + drawTextYOffset;
@@ -530,17 +546,13 @@ InsetText::LocalDispatch(BufferView * bv,
        if (result == DISPATCHED_NOUPDATE)
            return result;
        else if (result == DISPATCHED) {
-           the_locking_inset->ToggleInsetCursor(bv);
-           UpdateLocal(bv, FULL, false);
-           the_locking_inset->ToggleInsetCursor(bv);
+           UpdateLocal(bv, CURSOR_PAR, false);
             return result;
         } else if (result == FINISHED) {
            switch(action) {
            case -1:
            case LFUN_RIGHT:
-               moveRight(bv);
-//             TEXT(bv)->cursor.pos(inset_pos + 1);
-//             resetPos(bv->painter());
+               moveRight(bv, false);
                break;
            case LFUN_DOWN:
                moveDown(bv);
@@ -969,7 +981,7 @@ bool InsetText::checkAndActivateInset(BufferView * bv, int x, int y,
 
 int InsetText::getMaxTextWidth(Painter & pain, UpdatableInset const * inset) const
 {
-    return getMaxWidth(pain, inset) - 4; // 2+2 width of eventual border
+    return getMaxWidth(pain, inset) - (2 * TEXT_TO_INSET_OFFSET);
 }
 
 void InsetText::SetParagraphData(LyXParagraph *p)
index 50cfd1044e567e9a924a608829a4ca85097deb91..98c44b51473b4c644c3323ca5a83c3645b6fb753 100644 (file)
@@ -203,6 +203,9 @@ private:
     int insetAscent;
     int insetDescent;
     int insetWidth;
+    mutable int last_width;
+    mutable int last_height;
+    mutable int top_y;
     ///
     int inset_pos;
     ///
index 6f13fa4f838baf6e952e9bb3f6c72933d38ddaf4..29559385725e7aba7607a7b78cf8b5a54f51e785 100644 (file)
@@ -291,7 +291,7 @@ public:
        virtual void Edit(BufferView *, int x, int y, unsigned int button);
        ///
        virtual void draw(BufferView *, LyXFont const &,
-                         int baseline, float & x) const;
+                         int baseline, float & x, bool cleared) const;
        ///
        virtual void SetFont(BufferView *, LyXFont const &,
                             bool toggleall = false);
index 497748628f6538a7cb9a57b2a313bebaab6ad7f3..f5b816e511806188a79a45a0280f0619779e6464 100644 (file)
@@ -14,7 +14,7 @@
 
 
 Row::Row()
-       : par_(0), pos_(0), fill_(0), height_(0),
+       : par_(0), pos_(0), fill_(0), height_(0), width_(0),
          ascent_of_text_(0), baseline_(0), next_(0), previous_(0)
 {}
 
@@ -73,6 +73,18 @@ unsigned short Row::height() const
 }
 
 
+void Row::width(unsigned int w)
+{
+       width_ = w;
+}
+
+
+unsigned int Row::width() const
+{
+       return width_;
+}
+
+
 void Row::ascent_of_text(unsigned short a)
 {
        ascent_of_text_ = a;
index e480cfaf18b6d140ad390d724b83480e388fa6a9..9da3170342946a616f99e1c04c768c614f563ee9 100644 (file)
@@ -38,6 +38,10 @@ public:
        ///
        unsigned short height() const;
        ///
+       void width(unsigned int w);
+       ///
+       unsigned int width() const;
+       ///
        void ascent_of_text(unsigned short a);
        ///
        unsigned short ascent_of_text() const;
@@ -64,6 +68,8 @@ private:
        ///
        unsigned short height_;
        ///
+       unsigned int width_;
+       ///
        unsigned short ascent_of_text_;
        ///
        unsigned int baseline_;
index 938752c3e0d0d8e9f1ff16157bd817884f72cc75..87ef88642f8336d3273cf105d20c9fc7d2ec5313 100644 (file)
@@ -63,7 +63,7 @@ public:
        mutable int number_of_rows;
        ///
        mutable long height;
-       mutable int  width;
+       mutable unsigned int width;
        /// the current font settings
        mutable LyXFont current_font;
        /// the current font
index d77d5f4644c48e8c0b122ed6f8c478d2f28d13f3..00250ee27ab68ab5e70515141049305a8d24350d 100644 (file)
@@ -1675,7 +1675,18 @@ void LyXText::SetHeightOfRow(BufferView * bview, Row * row_ptr) const
    row_ptr->baseline(maxasc + labeladdon);
    
    height += row_ptr->height();
-   width = maxwidth;
+   float x, dummy;
+   PrepareToPrint(bview, row_ptr, x, dummy, dummy, dummy);
+   row_ptr->width(maxwidth+x);
+   if (inset_owner) {
+          Row * r = firstrow;
+          width = 0;
+          while(r) {
+                  if (r->width() > width)
+                          width = r->width();
+                  r = r->next();
+          }
+   }
 }
 
 
index ab6d84ba4996e06917a3b693d38695f1720eb1b6..ecf2b2eb2bc9db08f46a984fed72c105e70e8917 100644 (file)
@@ -70,7 +70,7 @@ void LyXText::init()
        number_of_rows = 0;
        refresh_y = 0;
        height = 0;
-       width = -1;
+       width = 0;
        first = 0;
        status = LyXText::UNCHANGED;
        // set cursor at the very top position