]> git.lyx.org Git - features.git/commitdiff
Various updates for insets mostly regarding fixes for text-insets.
authorJürgen Vigna <jug@sad.it>
Wed, 8 Mar 2000 13:52:57 +0000 (13:52 +0000)
committerJürgen Vigna <jug@sad.it>
Wed, 8 Mar 2000 13:52:57 +0000 (13:52 +0000)
Added a new BaseClass InsetCollapsable and changed InsetERT to this
new BaseClass, also added a footnote-inset.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@591 a592a061-630c-0410-9148-cb99ea01b6c8

38 files changed:
ChangeLog
po/POTFILES.in
src/BufferView.C
src/LyXAction.C
src/buffer.C
src/commandtags.h
src/insets/Makefile.am
src/insets/figinset.C
src/insets/figinset.h
src/insets/inset.C
src/insets/insetbib.h
src/insets/insetcollapsable.C [new file with mode: 0644]
src/insets/insetcollapsable.h [new file with mode: 0644]
src/insets/inseterror.C
src/insets/inseterror.h
src/insets/insetert.C
src/insets/insetert.h
src/insets/insetfoot.C [new file with mode: 0644]
src/insets/insetfoot.h [new file with mode: 0644]
src/insets/insetgraphics.C
src/insets/insetgraphics.h
src/insets/insetinclude.h
src/insets/insetindex.h
src/insets/insetinfo.C
src/insets/insetinfo.h
src/insets/insetlabel.h
src/insets/insetloa.h
src/insets/insetlof.h
src/insets/insetlot.h
src/insets/insetparent.h
src/insets/insetref.h
src/insets/insettext.C
src/insets/insettext.h
src/insets/insettoc.h
src/insets/inseturl.h
src/insets/lyxinset.h
src/lyxfunc.C
src/text2.C

index ea4825fbdf39f5f7fa95aa8e952368c10ca1779f..432daf84986366efd237a6b5a9e64e78b6c4ac8b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,20 @@
+2000-03-08  Juergen Vigna  <jug@sad.it>
+
+       * src/insets/lyxinset.h: added owner call which tells us if
+       this inset is inside another inset. Changed also the return-type
+       of Editable to an enum so it tells clearer what the return-value is.
+
+       * src/insets/insettext.C (computeTextRows): fixed computing of
+       textinsets which split automatically on more rows.
+
+       * src/insets/insetert.[Ch]: changed this to be of BaseType
+       InsetCollapsable.
+
+       * src/insets/insetfoot.[Ch]: added footnote inset
+
+       * src/insets/insetcollapsable.[Ch]: added this BaseClass for
+       collapsable insets (like footnote, ert, ...)
+
 2000-03-08  Lars Gullik Bjønnes  <larsbj@lyx.org>
 
        * src/lyxdraw.h: remvoe file
index ea2a66716e3b48630867cc652db55f71d9bbc1a9..73d80d592cd067febcf89d3c8f7815cf0ce08720 100644 (file)
@@ -30,6 +30,8 @@ src/insets/insetbib.C
 src/insets/inseterror.C
 src/insets/inseterror.h
 src/insets/insetert.C
+src/insets/insetert.h
+src/insets/insetfoot.C
 src/insets/insetinclude.C
 src/insets/insetindex.C
 src/insets/insetinfo.C
index c7a675e2189a3ca99ccfbce4f149c9222bce8d9e..1fd4c3cd4ab0770e4804ac507a9ac7f16a6a0984 100644 (file)
@@ -731,7 +731,7 @@ void BufferView::workAreaButtonPress(int xpos, int ypos, unsigned int button)
        updateScrollbar();
        
        // Single left click in math inset?
-       if (inset_hit != 0 && inset_hit->Editable() == 2) {
+       if (inset_hit != 0 && inset_hit->Editable()==Inset::HIGHLY_EDITABLE) {
                // Highly editable inset, like math
                selection_possible = false;
                owner_->updateLayoutChoice();
index 275c59f07b494ac8804f2559bbffdeb7d5d989ed..a1077e2ab5cd0cf0b6bc8077109a03cf3be7c241 100644 (file)
@@ -207,6 +207,8 @@ void LyXAction::init()
                  N_("Toggle font underline"), Noop },
                { LFUN_FOOTMELT, "footnote-insert", N_("Insert Footnote"),
                  Noop },
+               { LFUN_INSET_FOOTNOTE, "footnote-inset-insert",
+                 N_("Insert Footnote"), Noop },
                { LFUN_RIGHTSEL, "forward-select", N_("Select next char"),
                  ReadOnly },
                { LFUN_HFILL, "hfill-insert",
index 2cc1ffe5ad1c920f4f612b50e55415d203cc7207..25ebd0258594e03cab6f6b47c8b907c3240d4f38 100644 (file)
@@ -76,6 +76,7 @@ using std::setw;
 #include "insets/insettext.h"
 #include "insets/insetert.h"
 #include "insets/insetgraphics.h"
+#include "insets/insetfoot.h"
 #include "support/filetools.h"
 #include "support/path.h"
 #include "LaTeX.h"
@@ -789,6 +790,13 @@ bool Buffer::parseSingleLyXformat2Token(LyXLex & lex, LyXParagraph *& par,
                        par->InsertInset(pos, inset);
                        par->SetFont(pos, font);
                        ++pos;
+               } else if (tmptok == "Foot") {
+                       inset = new InsetFoot(this);
+                       inset->Read(lex);
+                       par->InsertChar(pos, LyXParagraph::META_INSET);
+                       par->InsertInset(pos, inset);
+                       par->SetFont(pos, font);
+                       ++pos;
                } else if (tmptok == "GRAPHICS") {
                        inset = new InsetGraphics;
                                //inset->Read(lex);
index 25bce4ff7348fd0d028674765aebd7be1ce1aa33..1ab764389be4573157f18985f682b77340786d9e 100644 (file)
@@ -243,6 +243,7 @@ enum kb_action {
        LFUN_INSET_TEXT,                // Jug 20000214
        LFUN_INSET_ERT,                 // Jug 20000218
        LFUN_INSERT_GRAPHICS,           // Lgb 20000226
+       LFUN_INSET_FOOTNOTE,            // Jug 20000307
        LFUN_LASTACTION  /* this marks the end of the table */
 };
 
index 17fed21dac328bb25443c381ce104b4108037485..1431772c7beb8d435f62de20af18820e9429c672 100644 (file)
@@ -14,12 +14,16 @@ libinsets_la_SOURCES = \
        inset.C \
        insetbib.C \
        insetbib.h \
+       insetcollapsable.C \
+       insetcollapsable.h \
        insetcommand.C \
        insetcommand.h \
        inseterror.C \
        inseterror.h \
        insetert.C \
        insetert.h \
+       insetfoot.C \
+       insetfoot.h \
        insetgraphics.C \
        insetgraphics.h \
        insetinclude.C \
index 490a8b0fc1c8f3480fa3b5a091836e891632ce87..58697d0dfc1fb24b008637a68b5225626e4d8f68 100644 (file)
@@ -1256,9 +1256,9 @@ void InsetFig::Validate(LaTeXFeatures & features) const
 }
 
 
-unsigned char InsetFig::Editable() const
+Inset::EDITABLE InsetFig::Editable() const
 {
-       return 1;
+       return IS_EDITABLE;
 }
 
 
index 3b0a2b3ab6b2f79003658df26b14bed7cd64cc7d..d06e404e645fd0cd41e857beed5ac9455d22a8b9 100644 (file)
@@ -60,7 +60,7 @@ public:
        ///
        void Edit(BufferView *, int, int, unsigned int);
        ///
-       unsigned char Editable() const;
+       EDITABLE Editable() const;
        ///
        bool Deletable() const;
        ///
index a8dce4e1b83fd59aa38e0babd3b87896483c255c..3a1fcb939d2b61266e233c1bf05c4845633d6755 100644 (file)
@@ -18,6 +18,7 @@
 #include "debug.h"
 #include "BufferView.h"
 #include "support/lstrings.h"
+#include "Painter.h"
 
 /* Insets default methods */
 
@@ -33,9 +34,9 @@ bool Inset::DirectWrite() const
 }
 
 
-unsigned char Inset::Editable() const
+Inset::EDITABLE Inset::Editable() const
 {
-  return 0;
+  return NOT_EDITABLE;
 }
 
 
@@ -97,9 +98,9 @@ void UpdatableInset::InsetUnlock(BufferView *)
 
 
 // An updatable inset is highly editable by definition
-unsigned char UpdatableInset::Editable() const
+Inset::EDITABLE UpdatableInset::Editable() const
 {
-       return 2; // and what does "2" siginify? (Lgb)
+       return HIGHLY_EDITABLE;
 }
 
 
@@ -154,3 +155,11 @@ UpdatableInset::LocalDispatch(BufferView *, int, string const &)
 #endif
     return UNDISPATCHED; 
 }
+
+int UpdatableInset::getMaxWidth(Painter & pain) const
+{
+    if (owner_)
+        return owner_->getMaxWidth(pain);
+    return pain.paperWidth();
+}
+
index 32063d1b86de39cb7be5bc5789406c788d824238..da680c2889860c16d7080c74ca012100a3e54b7e 100644 (file)
@@ -39,8 +39,8 @@ public:
         ///
        void Edit(BufferView *, int x, int y, unsigned int button);
         ///
-       unsigned char Editable() const {
-               return 1;
+       EDITABLE Editable() const {
+               return IS_EDITABLE;
        }
        ///
        struct Holder {
@@ -78,8 +78,8 @@ public:
         ///
        void Edit(BufferView *, int x, int y, unsigned int button);
        ///
-       unsigned char Editable() const {
-               return 1;
+       EDITABLE Editable() const {
+               return IS_EDITABLE;
        }
        /// A user can't neither insert nor delete this inset
        bool Deletable() const {
@@ -135,8 +135,8 @@ public:
        ///
        string getKeys(char delim);
        ///
-       unsigned char Editable() const {
-               return 1;
+       EDITABLE Editable() const {
+               return IS_EDITABLE;
        }
         ///
         bool addDatabase(string const &);
diff --git a/src/insets/insetcollapsable.C b/src/insets/insetcollapsable.C
new file mode 100644 (file)
index 0000000..1a218c4
--- /dev/null
@@ -0,0 +1,196 @@
+/* This file is part of
+ * ======================================================
+ * 
+ *           LyX, The Document Processor
+ *      
+ *          Copyright (C) 1998 The LyX Team.
+ *
+ *======================================================*/
+
+#include <config.h>
+
+#ifdef __GNUG__
+#pragma implementation
+#endif
+
+#include "insetcollapsable.h"
+#include "gettext.h"
+#include "lyxfont.h"
+#include "BufferView.h"
+#include "Painter.h"
+
+
+InsetCollapsable::InsetCollapsable(Buffer * bf): InsetText(bf)
+{
+    collapsed = true;
+    label = "Label";
+    autocolapse = true;
+    autoBreakRows = true;
+    framecolor = LColor::footnoteframe;
+    widthOffset = 7;
+}
+
+
+Inset * InsetCollapsable::Clone()
+{
+    Inset * result = new InsetCollapsable(buffer);
+    return result;
+}
+
+int InsetCollapsable::ascent_collapsed(Painter & pain, LyXFont const &) const
+{
+    int width = 0, ascent = 0, descent = 0;
+    pain.buttonText(0, 0, label.c_str(), labelfont, false, 
+                   width, ascent, descent);
+    return ascent;
+}
+
+
+int InsetCollapsable::descent_collapsed(Painter & pain, LyXFont const &) const
+{
+    int width = 0, ascent = 0, descent = 0;
+    pain.buttonText(0, 0, label.c_str(), labelfont, false, 
+                   width, ascent, descent);
+    return descent;
+}
+
+
+int InsetCollapsable::width_collapsed(Painter & pain, LyXFont const &) const
+{
+    int width, ascent, descent;
+    pain.buttonText(TEXT_TO_INSET_OFFSET, 0, label.c_str(), labelfont, false,
+                   width, ascent, descent);
+    return width + (2*TEXT_TO_INSET_OFFSET);
+}
+
+
+int InsetCollapsable::ascent(Painter & pain, LyXFont const & font) const
+{
+    if (collapsed) 
+       return ascent_collapsed(pain, font);
+    else 
+       return InsetText::ascent(pain, font) + TEXT_TO_TOP_OFFSET;
+}
+
+
+int InsetCollapsable::descent(Painter & pain, LyXFont const & font) const
+{
+    if (collapsed) 
+       return descent_collapsed(pain, font);
+    else 
+       return InsetText::descent(pain, font) + TEXT_TO_BOTTOM_OFFSET;
+}
+
+
+int InsetCollapsable::width(Painter & pain, LyXFont const & font) const
+{
+    if (collapsed) 
+       return width_collapsed(pain, font);
+
+    return getMaxWidth(pain);
+}
+
+
+void InsetCollapsable::draw_collapsed(Painter & pain, LyXFont const &,
+                                     int baseline, float & x) const
+{
+    int width = 0;
+    pain.buttonText(int(x) + TEXT_TO_INSET_OFFSET, baseline,
+                   label.c_str(), labelfont, true, width);
+    x += width + (2 * TEXT_TO_INSET_OFFSET);
+}
+
+
+void InsetCollapsable::draw(Painter & pain, LyXFont const & f, 
+                           int baseline, float & x) const
+{
+    if (collapsed) {
+       draw_collapsed(pain, f, baseline, x);
+       return;
+    }
+    top_x = int(x);
+    top_baseline = baseline;
+    draw_collapsed(pain, f, baseline, x);
+    button_x = int(x - top_x);
+    
+    maxWidth = getMaxWidth(pain) - button_x;
+    x += 2;
+    int
+       w = maxWidth - widthOffset,
+       h = ascent(pain,f) + descent(pain,f);
+    
+    pain.rectangle(int(x), baseline - ascent(pain, f), w, h, framecolor);
+
+    x += 4;
+    top_x = int(x - top_x);
+    InsetText::draw(pain, f, baseline, x);
+}
+
+
+void InsetCollapsable::Edit(BufferView *bv, int x, int y, unsigned int button)
+{
+    if (collapsed) {
+       collapsed = false;
+       UpdateLocal(bv, true);
+       InsetText::Edit(bv, 0, 0, button);
+    } else if (button && (x < button_x)  &&
+       (y < (labelfont.maxDescent()+labelfont.maxAscent()))) {
+       collapsed = true;
+       UpdateLocal(bv, false);
+        bv->unlockInset(this);
+    } else {
+       InsetText::Edit(bv, x-top_x, y, button);
+    }
+}
+
+
+Inset::EDITABLE InsetCollapsable::Editable() const
+{
+       if (collapsed)
+               return IS_EDITABLE;
+       return HIGHLY_EDITABLE;
+}
+
+void InsetCollapsable::InsetUnlock(BufferView *bv)
+{
+    if (autocolapse) {
+       collapsed = true;
+    }
+    InsetText::InsetUnlock(bv);
+    UpdateLocal(bv, true);
+}
+
+
+void InsetCollapsable::UpdateLocal(BufferView *bv, bool flag)
+{
+    maxWidth = getMaxWidth(bv->getPainter()) -
+       width_collapsed(bv->getPainter(), labelfont);
+    InsetText::UpdateLocal(bv, flag);
+}
+
+
+void InsetCollapsable::InsetButtonPress(BufferView *bv,int x,int y,int button)
+{
+    if ((x < button_x)  &&
+       (y < (labelfont.maxDescent()+labelfont.maxAscent()))) {
+       collapsed = true;
+       UpdateLocal(bv, false);
+        bv->unlockInset(this);
+    } else if (x >= button_x) {
+       InsetText::InsetButtonPress(bv, x-top_x, y, button);
+    }
+}
+
+
+void InsetCollapsable::InsetButtonRelease(BufferView *bv, int x, int y, int button)
+{
+    if (x >= button_x)
+       InsetText::InsetButtonRelease(bv, x-top_x, y, button);
+}
+
+
+void InsetCollapsable::InsetMotionNotify(BufferView *bv, int x, int y, int button)
+{
+    if (x >= button_x)
+       InsetText::InsetMotionNotify(bv, x-top_x, y, button);
+}
diff --git a/src/insets/insetcollapsable.h b/src/insets/insetcollapsable.h
new file mode 100644 (file)
index 0000000..6408e11
--- /dev/null
@@ -0,0 +1,101 @@
+// -*- C++ -*-
+/* This file is part of
+ * ======================================================
+ * 
+ *           LyX, The Document Processor
+ *
+ *           Copyright (C) 2000 The LyX Team.
+ *
+ *======================================================
+ */
+
+
+#ifndef INSETCOLLAPSABLE_H
+#define INSETCOLLAPSABLE_H
+
+#ifdef __GNUG__
+#pragma interface
+#endif
+
+#include "insettext.h"
+#include "lyxfont.h"
+#include "LColor.h"
+
+
+class Painter;
+
+/** A colapsable text inset
+  
+*/
+class InsetCollapsable : public InsetText {
+public:
+    ///
+    static int const TEXT_TO_TOP_OFFSET = 2;
+    ///
+    static int const TEXT_TO_BOTTOM_OFFSET = 2;
+    ///
+    InsetCollapsable(Buffer *);
+    ///
+    ~InsetCollapsable() {}
+    ///
+    Inset * InsetCollapsable::Clone();
+    ///
+    int ascent(Painter &, LyXFont const &) const;
+    ///
+    int descent(Painter &, LyXFont const &) const;
+    ///
+    int width(Painter &, LyXFont const & f) const;
+    ///
+    void draw(Painter & pain, const LyXFont &, int , float &) const;
+    ///
+    void Edit(BufferView *, int, int, unsigned int);
+    ///
+    EDITABLE Editable() const;
+    ///
+    void InsetUnlock(BufferView *);
+    ///
+    bool display() const { return (!collapsed); }
+    ///
+    void InsetButtonRelease(BufferView *, int, int, int);
+    ///
+    void InsetButtonPress(BufferView *, int, int, int);
+    ///
+    void InsetMotionNotify(BufferView *, int, int, int);
+    ///
+    void setLabel(string const & l) { label = l; }
+    ///
+    void setLabelFont(LyXFont & f) { labelfont = f; }
+    ///
+    void setAutoCollapse(bool f) { autocolapse = f; }
+
+protected:
+    ///
+    int ascent_collapsed(Painter &, LyXFont const &) const;
+    ///
+    int descent_collapsed(Painter &, LyXFont const &) const;
+    ///
+    int width_collapsed(Painter &, LyXFont const & f) const;
+    ///
+    void draw_collapsed(Painter & pain, const LyXFont &, int , float &) const;
+    ///
+    void UpdateLocal(BufferView *, bool);
+    
+    ///
+    bool collapsed;
+    ///
+    LColor::color framecolor;
+
+private:
+    ///
+    string label;
+    ///
+    LyXFont labelfont;
+    ///
+    bool autocolapse;
+    ///
+    mutable int
+        top_baseline, top_x,
+       button_x;
+};
+
+#endif
index c2c873cf9082ebb3d5500e8ebc343f1d57506edc..8385c4bf842a198c8f7ec0b325ce293b74491454 100644 (file)
@@ -146,9 +146,9 @@ bool InsetError::AutoDelete() const
 }
 
 
-unsigned char InsetError::Editable() const
+Inset::EDITABLE InsetError::Editable() const
 {
-       return 1;
+       return IS_EDITABLE;
 }
 
 
index 47892510a68fa234c02a7690b85b6f7d13fd9427..ede6b82fcc8176b3e9397768eea6a2f8745f87a8 100644 (file)
@@ -68,7 +68,7 @@ public:
        ///
        void Edit(BufferView *, int x, int y, unsigned int button);
        ///
-       unsigned char Editable() const;
+       EDITABLE Editable() const;
        ///
        Inset * Clone() const;
        ///
index 698ff3435a7db3e7316029e8553a783aea28c186..27ddcdd7d8b95552c7af2e417252b8553948cbc4 100644 (file)
 #include "gettext.h"
 #include "lyxfont.h"
 #include "Painter.h"
-#include "lyx_gui_misc.h"
+#include "buffer.h"
+//#include "lyx_gui_misc.h"
 
 
 InsetERT::InsetERT(Buffer * bf)
-       : InsetText(bf)
+       : InsetCollapsable(bf)
 {
-       closed = true;
-       nomotion = false;
-       autoBreakRows = true;
+    setLabel(_("ERT"));
+    LyXFont font(LyXFont::ALL_SANE);
+    font.setLatex (LyXFont::ON);
+    real_current_font = current_font = font;
+    LyXFont labelfont(LyXFont::ALL_SANE);
+    labelfont.decSize();
+    labelfont.decSize();
+    labelfont.setColor(LColor::ert);
+    setLabelFont(labelfont);
+    setAutoCollapse(false);
 }
 
 
@@ -42,151 +50,13 @@ void InsetERT::Write(ostream & os) const
     WriteParagraphData(os);
 }
 
-
-int InsetERT::ascent_closed(Painter & pain, LyXFont const & f) const
-{
-       int width, ascent, descent;
-       LyXFont font(LyXFont::ALL_SANE);
-       font.setSize(f.size());
-       font.decSize();
-       font.decSize();
-       pain.buttonText(0, 0, _("ERT"), font, false, width, ascent, descent);
-       return ascent;
-}
-
-
-int InsetERT::descent_closed(Painter & pain, LyXFont const & f) const
-{
-       int width, ascent, descent;
-       LyXFont font(LyXFont::ALL_SANE);
-       font.setSize(f.size());
-       font.decSize();
-       font.decSize();
-       pain.buttonText(0, 0, _("ERT"), font, false, width, ascent, descent);
-       return descent;
-}
-
-
-int InsetERT::width_closed(Painter & pain, LyXFont const & f) const
-{
-       int width, ascent, descent;
-       LyXFont font(LyXFont::ALL_SANE);
-       font.setSize(f.size());
-       font.decSize();
-       font.decSize();
-       pain.buttonText(TEXT_TO_INSET_OFFSET, 0, _("ERT"), font, false,
-                       width, ascent, descent);
-       return width + (2*TEXT_TO_INSET_OFFSET);
-}
-
-
-int InsetERT::ascent(Painter & pain, LyXFont const & font) const
-{
-    if (closed) 
-       return ascent_closed(pain, font);
-    else 
-       return InsetText::ascent(pain, font);
-}
-
-
-int InsetERT::descent(Painter & pain, LyXFont const & font) const
-{
-
-    if (closed) 
-       return descent_closed(pain, font);
-    else 
-       return InsetText::descent(pain, font);
-}
-
-
-int InsetERT::width(Painter & pain, LyXFont const & font) const
-{
-    if (closed) 
-       return width_closed(pain, font);
-    else 
-       return InsetText::width(pain, font);
-}
-
-
-void InsetERT::draw_closed(Painter & pain, LyXFont const & f,
-                          int baseline, float & x) const
-{
-       LyXFont font(LyXFont::ALL_SANE);
-       font.setSize(f.size());
-       font.decSize();
-       font.decSize();
-       font.setColor(LColor::ert);
-       int width;
-       pain.buttonText(int(x) + TEXT_TO_INSET_OFFSET, baseline,
-                       _("ERT"), font, true, width);
-       x += width + (2 * TEXT_TO_INSET_OFFSET);
-}
-
-
-void InsetERT::draw(Painter & pain, LyXFont const & f,
-                   int baseline, float & x) const
-{
-    if (closed) {
-       top_x = int(x);
-       top_baseline = baseline;
-       draw_closed(pain, f, baseline, x);
-    } else {
-       InsetText::draw(pain, f, baseline, x);
-    }
-//    resetPos(bv);
-}
-
-
-void InsetERT::InsetButtonRelease(BufferView * bv, int x, int y, int button)
-{
-    nomotion = false;
-    InsetText::InsetButtonRelease(bv, x, y, button);
-}
-
-
-void InsetERT::InsetButtonPress(BufferView * bv, int x, int y, int button)
-{
-    nomotion = false;
-    InsetText::InsetButtonPress(bv, x, y, button);
-}
-
-
-void InsetERT::InsetMotionNotify(BufferView * bv, int x, int y, int button)
-{
-    if (nomotion)
-       return;
-    InsetText::InsetMotionNotify(bv, x, y, button);
-}
-
-
-void InsetERT::Edit(BufferView * bv, int x, int y, unsigned int button)
-{
-    closed = false;
-    nomotion = true;
-    LyXFont font(LyXFont::ALL_SANE);
-    font.setLatex (LyXFont::ON);
-    InsetText::Edit(bv, (x > (width_closed(bv->getPainter(),font)-5) ?
-                    width(bv->getPainter(), font) : 0), y, button);
-    real_current_font = current_font = font;
-    bv->updateInset(this, false);
-}
-
-
-void InsetERT::InsetUnlock(BufferView * bv)
-{
-    closed = true;
-    InsetText::InsetUnlock(bv);
-    bv->updateInset(this, false);
-}
-
-
-bool InsetERT::InsertInset(Inset *)
+bool InsetERT::InsertInset(BufferView *, Inset *)
 {
     return false;
 }
 
 
-void InsetERT::SetFont(LyXFont const &, bool)
+void InsetERT::SetFont(BufferView *, LyXFont const &, bool)
 {
     WriteAlert(_("Impossible Operation!"),
               _("Not permitted to change font-types inside ERT-insets!"),
index 162fe8924feee8cbf86e52a4fc383e4806bc3054..cea113cb60e7181c110568628e3cee8fe809c103 100644 (file)
@@ -18,7 +18,7 @@
 #pragma interface
 #endif
 
-#include "insettext.h"
+#include "insetcollapsable.h"
 
 class Painter;
 
@@ -27,60 +27,23 @@ class Painter;
   To write full ert (including styles and other insets) in a given
   space. 
 */
-class InsetERT : public InsetText {
+class InsetERT : public InsetCollapsable {
 public:
     ///
     InsetERT(Buffer *);
     ///
-    //     InsetERT(InsetERT const &, Buffer *);
-    ///
     ~InsetERT() {}
     ///
     Inset * Clone() const;
     ///
-    //    void Read(LyXLex &);
-    ///
     void Write(ostream &) const;
     ///
-    int ascent(Painter &, LyXFont const &) const;
-    ///
-    int descent(Painter &, LyXFont const &) const;
-    ///
-    int width(Painter &, LyXFont const & f) const;
-    ///
-    void draw(Painter & pain, const LyXFont &, int , float &) const;
-    ///
-    //LString EditMessage() const;
-    ///
-    void InsetButtonRelease(BufferView *, int, int, int);
-    ///
-    void InsetButtonPress(BufferView *, int, int, int);
+    const char * EditMessage() const { return _("Opened ERT Inset");}
     ///
-    void InsetMotionNotify(BufferView *, int, int, int);
+    bool InsertInset(BufferView *, Inset *);
     ///
-    void Edit(BufferView *, int, int, unsigned int);
+    void SetFont(BufferView *, LyXFont const &, bool toggleall = false);
     ///
-    void InsetUnlock(BufferView *);
-    ///
-    bool InsertInset(Inset *);
-    ///
-    void SetFont(LyXFont const &, bool toggleall);
-
-protected:
-    ///
-    int ascent_closed(Painter &, LyXFont const &) const;
-    ///
-    int descent_closed(Painter &, LyXFont const &) const;
-    ///
-    int width_closed(Painter &, LyXFont const & f) const;
-    ///
-    void draw_closed(Painter & pain, LyXFont const &, int , float &) const;
-
-private:
-       ///
-       bool closed;
-       ///
-       bool nomotion;
 };
 
 #endif
diff --git a/src/insets/insetfoot.C b/src/insets/insetfoot.C
new file mode 100644 (file)
index 0000000..2b01a0e
--- /dev/null
@@ -0,0 +1,114 @@
+/* This file is part of
+ * ======================================================
+ * 
+ *           LyX, The Document Processor
+ *      
+ *          Copyright (C) 1998 The LyX Team.
+ *
+ *======================================================*/
+
+#include <config.h>
+
+#ifdef __GNUG__
+#pragma implementation
+#endif
+
+#include "insetfoot.h"
+#include "gettext.h"
+#include "lyxfont.h"
+#include "BufferView.h"
+#include "lyxscreen.h"
+#include "Painter.h"
+
+
+InsetFoot::InsetFoot(Buffer * bf): InsetCollapsable(bf)
+{
+    setLabel(_("foot"));
+    LyXFont font(LyXFont::ALL_SANE);
+    font.decSize();
+    font.decSize();
+    font.setColor(LColor::footnote);
+    setLabelFont(font);
+    setAutoCollapse(false);
+}
+
+
+InsetFoot * InsetFoot::Clone() const
+{
+    InsetFoot * result = new InsetFoot(buffer);
+    return result;
+}
+
+
+const char * InsetFoot::EditMessage() const
+{
+    return _("Opened Footnote Inset");
+}
+
+#ifndef USE_OSTREAM_ONLY
+int InsetFoot::Latex(string & l, signed char fragile) const
+{
+    int i;
+    
+    if (fragile) 
+       l += "\\footnotetext{";
+    else 
+       l += "\\footnote{";
+
+    i = InsetText::Latex(l, fragile);
+    l += "}";
+
+    return i;
+}
+#endif
+
+int InsetFoot::Latex(ostream & os, signed char fragile) const
+{
+    int i;
+    
+    if (fragile) 
+       os << "\\footnotetext{";
+    else 
+       os << "\\footnote{";
+
+    i = InsetText::Latex(os, fragile);
+    os << "}";
+
+    return i;
+}
+
+void InsetFoot::Write(ostream & os) const
+{
+    os << "Foot\n";
+    os << "\ncollapsed ";
+    if (display())
+       os << "false";
+    else
+       os << "true";
+    os << "\n";
+    WriteParagraphData(os);
+}
+
+void InsetFoot::Read(LyXLex & lex)
+{
+    if (lex.IsOK()) {
+       string token, tmptok;
+        
+       lex.next();
+        token = lex.GetString();
+       if (token == "collapsed") {
+           lex.next();
+           collapsed = lex.GetBool();
+       }
+    }
+    InsetText::Read(lex);
+}
+
+bool InsetFoot::InsertInset(BufferView *bv, Inset * inset)
+{
+    if ((inset->LyxCode() == Inset::FOOT_CODE) ||
+       (inset->LyxCode() == Inset::MARGIN_CODE)) {
+       return false;
+    }
+    return InsetText::InsertInset(bv, inset);
+}
diff --git a/src/insets/insetfoot.h b/src/insets/insetfoot.h
new file mode 100644 (file)
index 0000000..03e0f01
--- /dev/null
@@ -0,0 +1,55 @@
+// -*- C++ -*-
+/* This file is part of
+ * ======================================================
+ * 
+ *           LyX, The Document Processor
+ *
+ *           Copyright (C) 1998 The LyX Team.
+ *
+ *======================================================
+ */
+// The pristine updatable inset: Text
+
+
+#ifndef INSETFOOT_H
+#define INSETFOOT_H
+
+#ifdef __GNUG__
+#pragma interface
+#endif
+
+#include "insetcollapsable.h"
+
+
+class Painter;
+
+/** The footnote inset
+  
+*/
+class InsetFoot : public InsetCollapsable {
+public:
+    ///
+    InsetFoot(Buffer *);
+    ///
+    ~InsetFoot() {}
+    ///
+    InsetFoot * InsetFoot::Clone() const;
+    ///
+    Inset::Code LyxCode() const { return Inset::FOOT_CODE; }
+#ifndef USE_OSTREAM_ONLY
+    ///
+    int Latex(string &, signed char) const;
+#endif
+    ///
+    int Latex(ostream &, signed char) const;
+    ///
+    void Write(ostream &) const;
+    ///
+    void Read(LyXLex &);
+    ///
+    const char * EditMessage() const;
+    ///
+    bool InsertInset(BufferView *, Inset * inset);
+};
+
+#endif
index 348546d42d647c8de336b420071795852eac0272..a61086ec3ae553287268fdfdcf2769711d8fa6da 100644 (file)
@@ -59,9 +59,9 @@ void InsetGraphics::Edit(BufferView *, int, int, unsigned int)
 }
 
 
-unsigned char InsetGraphics::Editable() const
+Inset::EDITABLE InsetGraphics::Editable() const
 {
-       return 1;
+       return IS_EDITABLE;
 }
 
 
index df7fadf0d184f33767c27708fbaf23da805a2db7..0d184f4d7a42edb6c45fbbda7e8728f763517a57 100644 (file)
@@ -36,7 +36,7 @@ public:
        ///
        void Edit(BufferView *, int, int, unsigned int);
        ///
-       unsigned char Editable() const;
+       EDITABLE Editable() const;
        ///
        void Write(ostream &) const;
        ///
index 7ea9085fa0eeca45bc7792bd87d37e7323d4d16d..94179bdbe382285f3c54fcf85e7fe9f78d92e7f4 100644 (file)
@@ -49,9 +49,9 @@ public:
        ///
        void Edit(BufferView *, int x, int y, unsigned int button);
        ///
-       unsigned char Editable() const
+       EDITABLE Editable() const
        {
-               return 1;
+               return IS_EDITABLE;
        }
         /// With lyx3 we won't overload these 3 methods
         void Write(ostream &) const;
index b4905bf0b06950ecd14e9016be271f4d5b08a0db..4b9610b8447acf6723767de3c17d21e211c40ea9 100644 (file)
@@ -39,9 +39,9 @@ public:
        ///
        void Edit(BufferView *, int, int, unsigned int);
        ///
-       unsigned char Editable() const
+       EDITABLE Editable() const
        {
-               return 1;
+               return IS_EDITABLE;
        }
        ///
        string getScreenLabel() const;
@@ -61,8 +61,8 @@ public:
        ///
        void Edit(BufferView *, int, int, unsigned int) {}
        ///
-       unsigned char Editable() const{
-               return 1;
+       EDITABLE Editable() const{
+               return IS_EDITABLE;
        }
        /// WHY is clone missing? (Lgb)
        ///
index fc9038013080e71b49e153ca71d8b391c23be1a0..9e0d9f575539524c8f005ac38e07c5123fb47072 100644 (file)
@@ -165,9 +165,9 @@ int InsetInfo::DocBook(ostream &) const
 #endif
 
 
-unsigned char InsetInfo::Editable() const
+Inset::EDITABLE InsetInfo::Editable() const
 {
-       return 1;
+       return IS_EDITABLE;
 }
 
 
index 3ae6a47e7c40186a52395439a379bfee854e0d84..2ff60dde43e65732b7294ce579ec953c0f95e3c1 100644 (file)
@@ -68,7 +68,7 @@ public:
        ///
        void Edit(BufferView *, int, int, unsigned int);
        ///
-       unsigned char Editable() const;
+       EDITABLE Editable() const;
        ///
        Inset::Code LyxCode() const;
        ///
index be251cb1defbba005bcba9d5e1e40b36fc529e6d..9932bdfdba23e44b7511aa5f3745643bdadc9b7e 100644 (file)
@@ -37,7 +37,7 @@ public:
        ///
        string getScreenLabel() const { return getContents(); }
        ///
-       unsigned char Editable() const { return 0; }
+       EDITABLE Editable() const { return NOT_EDITABLE; }
        ///
        int Latex(ostream &, signed char fragile) const;
 #ifndef USE_OSTREAM_ONLY
index 49ca447356a696a01683386310831eb69c0699a4..6853205e0ab290818c1b40317b19f208a8907dc2 100644 (file)
@@ -37,8 +37,8 @@ public:
        string getScreenLabel() const { return _("List of Algorithms"); }
 
         ///
-       unsigned char Editable() const {
-               return 0; // not yet
+       EDITABLE Editable() const {
+               return NOT_EDITABLE; // not yet
        }
        ///
        bool display() const { return true; }
index ee95d46c394186cb010528e8725177c156c45337..4eea16c155fe2b99eee734e6dd73dcb59f33b9d7 100644 (file)
@@ -35,8 +35,8 @@ public:
        string getScreenLabel() const { return _("List of Figures"); }
         
         ///
-       unsigned char Editable() const {
-               return 0; // not yet
+       EDITABLE Editable() const {
+               return NOT_EDITABLE; // not yet
        }
        ///
        bool display() const { return true; }
index 6600c3bf3aab136535e0123961575eb0acf1cfbb..ba6ce17f79509fda57c4a809fd48abc69e491066 100644 (file)
@@ -35,8 +35,8 @@ public:
        string getScreenLabel() const { return _("List of Tables"); }
         
         ///
-       unsigned char Editable() const {
-               return 0; // not yet
+       EDITABLE Editable() const {
+               return NOT_EDITABLE; // not yet
        }
        ///
        bool display() const { return true; }
index cc0ecb319d9cd313941dcf337273a12721ef6e9d..745b3b874904fb66506db58589c4092cc4211cb4 100644 (file)
@@ -46,8 +46,8 @@ public:
         ///
        void Edit(BufferView *, int, int, unsigned int);
         ///
-       unsigned char Editable() const {
-               return 1;
+       EDITABLE Editable() const {
+               return IS_EDITABLE;
        }
         ///
         Inset::Code LyxCode() const { return Inset::PARENT_CODE; }
index 2d6d2b45fcfdfbb65dd9d4df707afa258c0cbb9a..2e6f990f3eaa18568efe6b177ff69fb6aabb6dcf 100644 (file)
@@ -47,8 +47,8 @@ public:
        ///
        void Edit(BufferView *, int, int, unsigned int);
        ///
-       unsigned char Editable() const {
-               return 1;
+       EDITABLE Editable() const {
+               return IS_EDITABLE;
        }
         ///
        bool display() const { return false; }
index 4e187ef8d713311b3027a25f0adfe11498fed79e..b029c52dd98f577033ffb9a583e2a881cd2ecc18 100644 (file)
@@ -66,8 +66,9 @@ InsetText::InsetText(Buffer * buf)
     interline_space = 1;
     no_selection = false;
     init_inset = true;
-    maxAscent = maxDescent = insetWidth = 0;
+    maxAscent = maxDescent = insetWidth = widthOffset = 0;
     autoBreakRows = false;
+    xpos = 0.0;
 }
 
 
@@ -82,8 +83,9 @@ InsetText::InsetText(InsetText const & ins, Buffer * buf)
     interline_space = 1;
     no_selection = false;
     init_inset = true;
-    maxAscent = maxDescent = insetWidth = 0;
+    maxAscent = maxDescent = insetWidth = widthOffset = 0;
     autoBreakRows = false;
+    xpos = 0.0;
 }
 
 
@@ -153,7 +155,7 @@ void InsetText::Read(LyXLex & lex)
 int InsetText::ascent(Painter & pain, LyXFont const & font) const
 {
     if (init_inset) {
-       computeTextRows(pain);
+       computeTextRows(pain, xpos);
        init_inset = false;
     }
     if (maxAscent)
@@ -165,7 +167,7 @@ int InsetText::ascent(Painter & pain, LyXFont const & font) const
 int InsetText::descent(Painter & pain, LyXFont const & font) const
 {
     if (init_inset) {
-       computeTextRows(pain);
+       computeTextRows(pain, xpos);
        init_inset = false;
     }
     if (maxDescent)
@@ -177,34 +179,18 @@ int InsetText::descent(Painter & pain, LyXFont const & font) const
 int InsetText::width(Painter & pain, LyXFont const &) const
 {
     if (init_inset) {
-       computeTextRows(pain);
+       computeTextRows(pain, xpos);
        init_inset = false;
     }
     return insetWidth;
 }
 
 
-int InsetText::getMaxWidth(UpdatableInset * inset) const
-{
-    if (!the_locking_inset) {
-           lyxerr << "Text: No locking inset in this inset.\n";
-       return 0;
-    }
-
-    if (the_locking_inset == inset) 
-       return maxWidth;
-
-    return the_locking_inset->getMaxWidth(inset);
-}
-
-
 void InsetText::draw(Painter & pain, LyXFont const & f,
                     int baseline, float & x) const
 {
-//    if (init_inset) {
-       computeTextRows(pain, x);
-//     init_inset = false;
-//    }
+    xpos = x;
+    computeTextRows(pain, x);
     UpdatableInset::draw(pain, f, baseline, x);
     
     bool do_reset_pos = (x != top_x) || (baseline != top_baseline);
@@ -324,7 +310,7 @@ void InsetText::InsetUnlock(BufferView * bv)
     HideInsetCursor(bv);
     if (hasSelection()) {
        selection_start = selection_end = actpos;
-       bv->updateInset(this, false);
+       UpdateLocal(bv, false);
     }
     the_locking_inset = 0;
     no_selection = false;
@@ -354,7 +340,7 @@ bool InsetText::UpdateInsetInInset(BufferView * bv, Inset * inset)
         return the_locking_inset->UpdateInsetInInset(bv, inset);
     float x = inset_x;
     inset->draw(bv->getPainter(), real_current_font, inset_y, x);
-    bv->updateInset(this, true);
+    UpdateLocal(bv, true);
     return true;
 }
 
@@ -373,7 +359,7 @@ void InsetText::InsetButtonPress(BufferView * bv, int x, int y, int button)
 {
     if (hasSelection()) {
        selection_start = selection_end = actpos;
-       bv->updateInset(this, false);
+       UpdateLocal(bv, false);
     }
     no_selection = false;
     if (the_locking_inset) {
@@ -419,7 +405,7 @@ void InsetText::InsetMotionNotify(BufferView * bv, int x, int y, int button)
        setPos(bv, x, y, false);
        selection_end = actpos;
        if (old != selection_end)
-           bv->updateInset(this, false);
+           UpdateLocal(bv, false);
     }
     no_selection = false;
 }
@@ -457,7 +443,7 @@ InsetText::LocalDispatch(BufferView * bv,
         result = the_locking_inset->LocalDispatch(bv, action, arg);
        if (result == DISPATCHED) {
            the_locking_inset->ToggleInsetCursor(bv);
-           bv->updateInset(this, false);
+           UpdateLocal(bv, false);
            the_locking_inset->ToggleInsetCursor(bv);
             return result;
         } else if (result == FINISHED) {
@@ -475,8 +461,7 @@ InsetText::LocalDispatch(BufferView * bv,
       case -1:
           par->InsertChar(actpos,arg[0]);
          par->SetFont(actpos,real_current_font);
-         computeTextRows(bv->getPainter());
-         bv->updateInset(this, true);
+         UpdateLocal(bv, true);
           ++actpos;
          selection_start = selection_end = actpos;
           resetPos(bv);
@@ -485,13 +470,13 @@ InsetText::LocalDispatch(BufferView * bv,
       case LFUN_RIGHTSEL:
           moveRight(bv, false);
          selection_end = actpos;
-         bv->updateInset(this, false);
+         UpdateLocal(bv, false);
          break;
       case LFUN_RIGHT:
           result= DISPATCH_RESULT(moveRight(bv));
          if (hasSelection()) {
              selection_start = selection_end = actpos;
-             bv->updateInset(this, false);
+             UpdateLocal(bv, false);
          } else {
              selection_start = selection_end = actpos;
          }
@@ -499,13 +484,13 @@ InsetText::LocalDispatch(BufferView * bv,
       case LFUN_LEFTSEL:
           moveLeft(bv, false);
          selection_end = actpos;
-         bv->updateInset(this, false);
+         UpdateLocal(bv, false);
          break;
       case LFUN_LEFT:
           result= DISPATCH_RESULT(moveLeft(bv));
          if (hasSelection()) {
              selection_start = selection_end = actpos;
-             bv->updateInset(this, false);
+             UpdateLocal(bv, false);
          } else {
              selection_start = selection_end = actpos;
          }
@@ -513,13 +498,13 @@ InsetText::LocalDispatch(BufferView * bv,
       case LFUN_DOWNSEL:
           moveDown(bv, false);
          selection_end = actpos;
-         bv->updateInset(this, false);
+         UpdateLocal(bv, false);
          break;
       case LFUN_DOWN:
           result= DISPATCH_RESULT(moveDown(bv));
          if (hasSelection()) {
              selection_start = selection_end = actpos;
-             bv->updateInset(this, false);
+             UpdateLocal(bv, false);
          } else {
              selection_start = selection_end = actpos;
          }
@@ -527,13 +512,13 @@ InsetText::LocalDispatch(BufferView * bv,
       case LFUN_UPSEL:
           moveUp(bv, false);
          selection_end = actpos;
-         bv->updateInset(this, false);
+         UpdateLocal(bv, false);
          break;
       case LFUN_UP:
           result= DISPATCH_RESULT(moveUp(bv));
          if (hasSelection()) {
              selection_start = selection_end = actpos;
-             bv->updateInset(this, false);
+             UpdateLocal(bv, false);
          } else {
              selection_start = selection_end = actpos;
          }
@@ -542,7 +527,7 @@ InsetText::LocalDispatch(BufferView * bv,
           if (!actpos || par->IsNewline(actpos-1)) {
              if (hasSelection()) {
                  selection_start = selection_end = actpos;
-                 bv->updateInset(this, false);
+                 UpdateLocal(bv, false);
              }
               break;
          }
@@ -550,11 +535,10 @@ InsetText::LocalDispatch(BufferView * bv,
       case LFUN_DELETE:
           if (Delete()) { // we need update
              selection_start = selection_end = actpos;
-             computeTextRows(bv->getPainter());
-             bv->updateInset(this, true);
+             UpdateLocal(bv, true);
           } else if (hasSelection()) {
              selection_start = selection_end = actpos;
-             bv->updateInset(this, false);
+             UpdateLocal(bv, false);
          }
           break;
       case LFUN_HOME:
@@ -563,7 +547,7 @@ InsetText::LocalDispatch(BufferView * bv,
          cx -= SingleWidth(bv->getPainter(), par, actpos);
          if (hasSelection()) {
              selection_start = selection_end = actpos;
-             bv->updateInset(this, false);
+             UpdateLocal(bv, false);
          } else {
              selection_start = selection_end = actpos;
          }
@@ -573,7 +557,7 @@ InsetText::LocalDispatch(BufferView * bv,
               cx += SingleWidth(bv->getPainter(), par, actpos);
          if (hasSelection()) {
              selection_start = selection_end = actpos;
-             bv->updateInset(this, false);
+             UpdateLocal(bv, false);
          } else {
              selection_start = selection_end = actpos;
          }
@@ -582,7 +566,7 @@ InsetText::LocalDispatch(BufferView * bv,
           InsertInset(bv, new InsetFormula);
          if (hasSelection()) {
              selection_start = selection_end = actpos;
-             bv->updateInset(this, false);
+             UpdateLocal(bv, false);
          } else {
              selection_start = selection_end = actpos;
          }
@@ -959,10 +943,13 @@ bool InsetText::Delete()
 
 bool InsetText::InsertInset(BufferView * bv, Inset * inset)
 {
+    if (inset->Editable() == Inset::IS_EDITABLE) {
+       UpdatableInset *i = (UpdatableInset *)inset;
+       i->setOwner((UpdatableInset *)this);
+    }
     par->InsertChar(actpos, LyXParagraph::META_INSET);
     par->InsertInset(actpos, inset);
-    computeTextRows(bv->getPainter());
-    bv->updateInset(this, true);
+    UpdateLocal(bv, true);
     the_locking_inset = static_cast<UpdatableInset*>(inset);
     inset_x = cx - top_x;
     inset_y = cy;
@@ -1015,8 +1002,7 @@ void InsetText::SetFont(BufferView * bv, LyXFont const & font, bool toggleall)
        SetCharFont(s_start, newfont);
        ++s_start;
     }
-    computeTextRows(bv->getPainter());
-    bv->updateInset(this, true);
+    UpdateLocal(bv, true);
 }
 
 
@@ -1051,28 +1037,6 @@ void InsetText::SetCharFont(int pos, LyXFont const & f)
 }
 
 
-// Ok, Jürgen. Here is my small secret message to you. As you can see I
-// played a bit witht he Textinset. (But only through the InsetERT so far).
-// As you can see below I have changed the code to use max/min instead of
-// the if < construct, imo this makes it faster and easier to read. I have
-// also changed rows[rows.size() - 1] to rows.back() makes it clearer that
-// we speak about the last element in the vector. I added a second arg to
-// to this func as well. This makes it possible to take the position of the
-// inset into account when drawing the inset, this is especially needed when
-// the ERT inset is first in a paragraph. I am not sure, but this might have
-// made short ERT (less than one line, just a couple of words) draw
-// incorrectly. You should perhaps have a look yourselves at this.
-// Also (phu...) I use pain to get at paperWidth().
-// This is beginning to look like a very nice Inset (speaking of the ERT
-// inset that is), but in afterthought, do we really need it? Wouldn't a
-// non dynamic inset working in the same way as the floats be more usefull
-// and easier to work with? Jean-Marc has already aired this thought.
-// I tested also a bit on the raw insettext, it seems that it can't break
-// over several lines properly. Other than that it seems to create the basis
-// for insetfloat, insetmarginal and insetfoot just fine. How about a
-// updatable inset that does not open, unless you click on it? uff... I just
-// ramble on. Feel free to remove my comments after you have read them.
-// Lgb
 void InsetText::computeTextRows(Painter & pain, float x) const
 {
     int p,
@@ -1088,7 +1052,6 @@ void InsetText::computeTextRows(Painter & pain, float x) const
 
     if (rows.size())
            rows.clear();
-           //rows.erase(rows.begin(),rows.end());
     int width = wordAscent = wordDescent = 0;
     insetWidth = maxAscent = maxDescent = 0;
     row.asc      = 0;
@@ -1101,11 +1064,7 @@ void InsetText::computeTextRows(Painter & pain, float x) const
            insetWidth += SingleWidth(pain, par, p);
            SingleHeight(pain, par, p, asc, desc);
            maxAscent = max(maxAscent, asc);
-           //if (asc > maxAscent)
-           //maxAscent = asc;
            maxDescent = max(maxDescent, desc);
-           //if (desc > maxDescent)
-           //maxDescent = desc;
        }
        rows[0].asc = maxAscent;
        rows[0].desc = maxDescent;
@@ -1119,25 +1078,20 @@ void InsetText::computeTextRows(Painter & pain, float x) const
 
     int cw, lastWordWidth = 0;
 
-    //maxWidth = buffer->getUser()->paperWidth();
-    maxWidth = pain.paperWidth();
+    maxWidth = UpdatableInset::getMaxWidth(pain) - widthOffset;
     for(p = 0; p < par->Last(); ++p) {
        cw = SingleWidth(pain, par, p);
        width += cw;
        lastWordWidth += cw;
        SingleHeight(pain, par, p, asc, desc);
        wordAscent = max(wordAscent, asc);
-       //if (asc > wordAscent)
-       //    wordAscent = asc;
        wordDescent = max(wordDescent, desc);
-       //if (desc > wordDescent)
-       //    wordDescent = desc;
        Inset const * inset = 0;
        if (((p + 1) < par->Last()) &&
            (par->GetChar(p + 1)==LyXParagraph::META_INSET))
            inset = par->GetInset(p + 1);
        if (inset && inset->display()) {
-           if (!is_first_word_in_row && (width >= maxWidth - x)) {
+           if (!is_first_word_in_row && (width >= (maxWidth - x))) {
                // we have to split also the row above
                rows.back().asc = oasc;
                rows.back().desc = odesc;
@@ -1146,17 +1100,11 @@ void InsetText::computeTextRows(Painter & pain, float x) const
                oasc = wordAscent;
                odesc = wordDescent;
                insetWidth = max(insetWidth, owidth);
-               //if (insetWidth < owidth)
-               //    insetWidth = owidth;
                width = lastWordWidth;
                lastWordWidth = 0;
            } else {
                    oasc = max(oasc, wordAscent);
-                   //if (oasc < wordAscent)
-                   //oasc = wordAscent;
                    odesc = max(odesc, wordDescent);
-                   //if (odesc < wordDescent)
-                   //odesc = wordDescent;
            }
            rows.back().asc = oasc;
            rows.back().desc = odesc;
@@ -1170,7 +1118,7 @@ void InsetText::computeTextRows(Painter & pain, float x) const
            oasc = odesc = width = lastWordWidth = 0;
            is_first_word_in_row = true;
            wordAscent = wordDescent = 0;
-           x = 0.0;
+//         x = 0.0;
            continue;
        } else if (par->IsSeparator(p)) {
            if (width >= maxWidth - x) {
@@ -1188,31 +1136,24 @@ void InsetText::computeTextRows(Painter & pain, float x) const
                    oasc = wordAscent;
                    odesc = wordDescent;
                    insetWidth = max(insetWidth, owidth);
-                   //if (insetWidth < owidth)
-                   //insetWidth = owidth;
                    width = lastWordWidth;
                }
                wordAscent = wordDescent = lastWordWidth = 0;
                nwp = p + 1;
-               x = 0.0;
+//             x = 0.0;
                continue;
            }
            owidth = width;
            oasc = max(oasc, wordAscent);
-           //if (oasc < wordAscent)
-           //oasc = wordAscent;
            odesc = max(odesc, wordDescent);
-           //if (odesc < wordDescent)
-           //odesc = wordDescent;
            wordAscent = wordDescent = lastWordWidth = 0;
            nwp = p + 1;
            is_first_word_in_row = false;
        }
-       x = 0.0;
     }
     // if we have some data in the paragraph we have ascent/descent
     if (p) {
-       if (width >= maxWidth) {
+       if (width >= (maxWidth - x)) {
            // assign upper row
            rows.back().asc = oasc;
            rows.back().desc = odesc;
@@ -1221,25 +1162,16 @@ void InsetText::computeTextRows(Painter & pain, float x) const
            rows.push_back(row);
            rows.back().asc = wordAscent;
            rows.back().desc = wordDescent;
-           insetWidth = max(insetWidth, owidth);
-           //if (insetWidth < owidth)
-           //insetWidth = owidth;
-           width -= owidth;
-           insetWidth = max(insetWidth, width);
-           //if (insetWidth < width)
-           //insetWidth = width;
+           width -= lastWordWidth;
        } else {
            // assign last row data
-               oasc = max(oasc, wordAscent);
-               //if (oasc < wordAscent)
-               //oasc = wordAscent;
-               odesc = min(odesc, wordDescent);
-               //if (odesc < wordDescent)
-               //odesc = wordDescent;
-           rows.back().asc = oasc;
-           rows.back().desc = odesc;
+//         width = lastWordWidth;
+//         lastWordWidth = 0;
+           rows.back().asc = max(oasc, wordAscent);
+           rows.back().desc = max(odesc, wordDescent);
        }
     }
+    insetWidth = max(insetWidth, width);
     // alocate a dummy row for the endpos
     row.pos = par->Last();
     rows.push_back(row);
@@ -1249,7 +1181,6 @@ void InsetText::computeTextRows(Painter & pain, float x) const
     for (RowList::size_type i = 1; i < rows.size() - 1; ++i) {
        maxDescent += rows[i].asc + rows[i].desc + interline_space;
     }
-    lyxerr << "Rows: " << rows.size() << endl;
 #if 0
     if (the_locking_inset) {
        computeBaselines(top_baseline);
@@ -1270,3 +1201,9 @@ void InsetText::computeBaselines(int baseline) const
            rows[i].asc + interline_space;
     }
 }
+
+void InsetText::UpdateLocal(BufferView *bv, bool flag)
+{
+    init_inset = flag;
+    bv->updateInset(this, flag);
+}
index 86965826cb4c9545de3011ec8b3219f6f292f98f..c616616d14666c84ea8915e61935563196b4c749 100644 (file)
 #include "lyxinset.h"
 #include "lyxparagraph.h"
 #include "LString.h"
-#include "buffer.h"
+//#include "buffer.h"
 
 class Painter;
 class BufferView;
+class Buffer;
 
 /** A text inset is like a TeX box
   
@@ -54,8 +55,6 @@ public:
     ///
     int width(Painter &, LyXFont const & f) const;
     ///
-    int getMaxWidth(UpdatableInset *) const;
-    ///
     void draw(Painter & pain, LyXFont const &, int , float &) const;
     ///
     char const * EditMessage() const;
@@ -66,8 +65,6 @@ public:
     ///
     bool UnlockInsetInInset(BufferView *, Inset *, bool lr = false);
     ///
-    //void UpdateLocal(bool flag=true);
-    ///
     bool UpdateInsetInInset(BufferView *, Inset *);
     ///
     void InsetButtonRelease(BufferView *, int, int, int);
@@ -114,6 +111,8 @@ public:
     LyXParagraph * par;
 
 protected:
+    ///
+    void UpdateLocal(BufferView *, bool);
     ///
     void WriteParagraphData(ostream &) const;
     ///
@@ -127,7 +126,7 @@ protected:
     int SingleWidth(Painter &, LyXParagraph * par, int pos) const;
     ///
     LyXFont GetFont(LyXParagraph * par, int pos) const;
-    ///
+
     Buffer * buffer;
     ///
     LyXFont current_font;
@@ -142,6 +141,8 @@ protected:
     ///
     mutable int insetWidth;
     ///
+    int widthOffset;
+    ///
     bool autoBreakRows;
 
 private:
@@ -202,6 +203,8 @@ private:
     ///
     bool no_selection;
     ///
+    mutable float xpos;
+    ///
     mutable bool init_inset;
     ///
     UpdatableInset * the_locking_inset;
index f6d08a5611e00da26d4bc1ee91175570df713053..d64cd9b2b9575f25236a1ea82cd7ccc1c738bb7e 100644 (file)
@@ -36,8 +36,8 @@ public:
        /// On edit, we open the TOC pop-up
        void Edit(BufferView * bv, int, int, unsigned int);
         ///
-       unsigned char Editable() const {
-               return 1;
+       EDITABLE Editable() const {
+               return IS_EDITABLE;
        }
        ///
        bool display() const { return true; }
index f0580239ff171b39e39e53c4c7410a95adcb4578..fc6835b81e47ba722124d353d1f1bbf6f8881073 100644 (file)
@@ -54,8 +54,8 @@ public:
        ///
        void Edit(BufferView *, int, int, unsigned int);
        ///
-       unsigned char Editable() const {
-               return 1;
+       EDITABLE Editable() const {
+               return IS_EDITABLE;
        }
        ///
        const char * EditMessage() const {return _("Opened Url");}
index 83365627869c36228ee6636520c26d726d984928..f018fdc84d206de1c216bf2508b654c476b8cc5b 100644 (file)
@@ -82,7 +82,17 @@ public:
                ///
                TEXT_CODE,
                ///
-               SPECIALCHAR_CODE
+               FOOT_CODE,
+               ///
+               MARGIN_CODE,
+               ///
+               SPECIALCHAR_CODE,
+       };
+
+       enum EDITABLE {
+           NOT_EDITABLE = 0,
+           IS_EDITABLE,
+           HIGHLY_EDITABLE
        };
 
        ///
@@ -103,7 +113,7 @@ public:
        ///
        virtual void Edit(BufferView *, int x, int y, unsigned int button);
        ///
-       virtual unsigned char Editable() const;
+       virtual EDITABLE Editable() const;
        ///
        virtual bool AutoDelete() const;
        ///
@@ -212,11 +222,14 @@ public:
        }
 
        ///
-       UpdatableInset() { scx = mx_scx = 0; }
+       UpdatableInset() {
+           scx = mx_scx = 0;
+           owner_ = 0;
+       }
        ///
        //virtual ~UpdatableInset() {}
        ///
-       virtual unsigned char Editable() const;
+       virtual EDITABLE Editable() const;
    
        /// may call ToggleLockedInsetCursor
        virtual void ToggleInsetCursor(BufferView *);
@@ -259,7 +272,12 @@ public:
        ///
        virtual bool isCursorVisible() const { return cursor_visible; }
        ///
-       virtual int getMaxWidth(UpdatableInset *) const { return -1; }
+       virtual int getMaxWidth(Painter & pain) const;
+       ///
+       virtual void setOwner(UpdatableInset * inset) { owner_ = inset; }
+       ///
+       virtual UpdatableInset * owner() { return owner_; }
+
 protected:
        ///
        // virtual void UpdateLocal(bool flag=true);
@@ -272,5 +290,8 @@ private:
        ///
        int mx_scx;
        mutable int scx;
+       ///
+       UpdatableInset * owner_;
+
 };
 #endif
index 0af4ce33cde93db8219615902e88df926041285c..e2db2999383b0730e929468f55436455fe20f7ac 100644 (file)
@@ -44,6 +44,7 @@
 #include "insets/insettext.h"
 #include "insets/insetert.h"
 #include "insets/insetgraphics.h"
+#include "insets/insetfoot.h"
 #include "mathed/formulamacro.h"
 #include "toolbar.h"
 #include "spellchecker.h" // RVDK_PATCH_5
@@ -1313,7 +1314,7 @@ string LyXFunc::Dispatch(int ac,
                    && tmptext->cursor.par->GetChar(tmptext->cursor.pos)
                    == LyXParagraph::META_INSET
                    && tmptext->cursor.par->GetInset(tmptext->cursor.pos)
-                   && tmptext->cursor.par->GetInset(tmptext->cursor.pos)->Editable() == 2){
+                   && tmptext->cursor.par->GetInset(tmptext->cursor.pos)->Editable() == Inset::HIGHLY_EDITABLE){
                        Inset * tmpinset = tmptext->cursor.par->GetInset(tmptext->cursor.pos);
                        setMessage(tmpinset->EditMessage());
                        tmpinset->Edit(owner->view(), 0, 0, 0);
@@ -1341,7 +1342,7 @@ string LyXFunc::Dispatch(int ac,
                    && txt->cursor.par->GetChar(txt->cursor.pos)
                    == LyXParagraph::META_INSET
                    && txt->cursor.par->GetInset(txt->cursor.pos)
-                   && txt->cursor.par->GetInset(txt->cursor.pos)->Editable() == 2) {
+                   && txt->cursor.par->GetInset(txt->cursor.pos)->Editable() == Inset::HIGHLY_EDITABLE) {
                        Inset * tmpinset = txt->cursor.par->GetInset(txt->cursor.pos);
                        setMessage(tmpinset->EditMessage());
                        tmpinset->Edit(owner->view(),
@@ -1929,6 +1930,12 @@ string LyXFunc::Dispatch(int ac,
                owner->view()->insertInset(new_inset);
                new_inset->Edit(owner->view(), 0, 0, 0);
        }
+       case LFUN_INSET_FOOTNOTE:
+       {
+               InsetFoot * new_inset = new InsetFoot(owner->buffer());
+               owner->view()->insertInset(new_inset);
+               new_inset->Edit(owner->view(), 0, 0, 0);
+       }
        break;
 
        // --- lyxserver commands ----------------------------
index d41597d9334f951201996856ea6b304a7fb5c636..f8979be1aa2fc5cae57dfad5590e79f1db7c75dd 100644 (file)
@@ -355,7 +355,7 @@ void LyXText::OpenStuff()
                 && cursor.par->GetInset(cursor.pos)->Editable()) {
                owner_->owner()->getMiniBuffer()
                        ->Set(cursor.par->GetInset(cursor.pos)->EditMessage());
-               if (cursor.par->GetInset(cursor.pos)->Editable() != 2)
+               if (cursor.par->GetInset(cursor.pos)->Editable() != Inset::HIGHLY_EDITABLE)
                        SetCursorParUndo();
                cursor.par->GetInset(cursor.pos)->Edit(owner_, 0, 0, 0);
        } else {