]> git.lyx.org Git - lyx.git/commitdiff
playing around with insets
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Tue, 24 Jul 2001 10:13:19 +0000 (10:13 +0000)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Tue, 24 Jul 2001 10:13:19 +0000 (10:13 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2315 a592a061-630c-0410-9148-cb99ea01b6c8

19 files changed:
NEWS
lib/examples/fr_splash.lyx
src/ChangeLog
src/Painter.h
src/PainterBase.h
src/insets/ChangeLog
src/insets/inset.C
src/insets/inset.h
src/insets/insetcollapsable.C
src/insets/insetert.C
src/insets/insetert.h
src/insets/insetlatexaccent.C
src/insets/insetminipage.C
src/insets/insetnote.C
src/insets/insettabular.C
src/insets/insettext.C
src/insets/insettext.h
src/lyxtext.h
src/text.C

diff --git a/NEWS b/NEWS
index d5f065f6ebae2028917430604f765388f7c013a9..701326eb6657464a543a08a68441e74a0d9cbe5b 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -18,8 +18,8 @@ Switch to the so-called 'new' insets:
 - TeX mode has been superseded by the 666 (aka ERT) inset, which is
   foldable
 
-- new graphics inset superseding the older figure inset [will that be
-  OK in 1.2.0?]
+- new graphics inset with support for hassle-free inclusion of various
+  image formats (GIF, JPEG, PNG and EPS by default).
 
 - new minipage inset
 
index 8edd821d67cff68f3aea44e17f4216f4f7f49b6b..f8d19191358f3f75d42032d33273a5b1f5006dc3 100644 (file)
@@ -27,7 +27,7 @@
 Bienvenue dans l'univers de LyX !
 \begin_inset Info
 Informations de révision :
-Traduction : Mise à jour, Date: 2001/02/16
+Traduction : Mise à jour, Date: 2001/06/10
 Original : Révision: 1.5, Date: 2000/12/28
 \end_inset 
 
@@ -37,8 +37,8 @@ Original : R
 Le Top N des choses à connaître pour utiliser LyX
 \layout Enumerate
 
-LyX est fourni avec une excellente documentation -- servez-vous-en s'il
vous plaît ! Vous pouvez commencer par 
+LyX est fourni avec une excellente documentation -- servez-vous-en donc
+ ! Vous pouvez commencer par 
 \family sans 
 \bar under 
 A
@@ -58,10 +58,9 @@ A
 \bar default 
 ide\SpecialChar \menuseparator
 Manuel\SpecialChar ~
-d'Apprentissage.
+d'Apprentissage
 \family default 
-Seul le titre des autres documents est traduit en français pour le moment.
+.
 \layout Enumerate
 
 LyX est ce qu'on appelle un 
@@ -76,7 +75,7 @@ LyX est ce qu'on appelle un
  Par sa conception, il se distingue des traitements de texte ordinaires
  -- en ce sens qu'il facilite l'écriture des documents.
  Mais la distinction est minime, ne vous inquiétez pas.
- La documentation est là pour faire toute la lumière la-dessus
+ La documentation est là pour faire toute la lumière là-dessus
 \begin_float footnote 
 \layout Standard
 
@@ -85,8 +84,7 @@ Avons-nous d
 .
 \layout Enumerate
 
-Les résultats de mise en page de LyX sont très esthétiques ! Sélectionnez
+Les résultats de mise en page de LyX sont très esthétiques ! Faites 
 \family sans 
 \bar under 
 V
@@ -122,15 +120,15 @@ d'Apprentissage
 \layout Enumerate
 
 LyX possède de nombreuses fonctionnalités pour ceux qui lisent ou écrivent
- d'autres langages que l'anglais.
De plus, le clavier, la barre d'outils et beaucoup d'autres caractéristiques
+ dans d'autres langues que l'anglais.
En outre, le clavier, la barre d'outils et beaucoup d'autres caractéristiques
  sont pleinement configurables (pour la plupart en éditant votre fichier
  
 \family typewriter 
 lyxrc
 \family default 
 ).
- Voir le fichier 
+ Voir 
 \family sans 
 \bar under 
 A
index 12b51084e686286205e0a6247d92f53602fee2f2..047e57ebd0477aff38fcc6be4954458e84357deb 100644 (file)
@@ -1,3 +1,16 @@
+2001-07-24  Jean-Marc Lasgouttes  <lasgouttes@lyx.org>
+
+       * lyxtext.h: remove unused (and unimplemented) methods
+
+2001-07-23  Jean-Marc Lasgouttes  <lasgouttes@lyx.org>
+
+       * text.C (getVisibleRow): honor background color
+
+       * PainterBase.h:
+       * Painter.h: remove default color argument for fillRectangle
+
+       * text.C (backgroundColor): new method
+
 2001-07-24  Lars Gullik Bjønnes  <larsbj@birdstep.com>
 
        * text.C (getVisibleRow): adjust
index ba001988a45c41a2dcc74d00612b472225383276..f6dad96bbcc1d8c11cd95a3e1aaa1202c00db570 100644 (file)
@@ -74,7 +74,7 @@ public:
        
        /// Fill a rectangle
        PainterBase & fillRectangle(int x, int y, int w, int h,
-                                   LColor::color = LColor::background);
+                                   LColor::color);
        
        /// For the graphics inset.
        PainterBase & image(int x, int y, int w, int h, LyXImage const * image);
index 71a39f987f400533ace30993521019903ebdc510..237f7f13d1a9847e1c58877c0f1e851154fbd4ab 100644 (file)
@@ -137,7 +137,7 @@ public:
        /// Fill a rectangle
        virtual PainterBase & fillRectangle(
                int x, int y, int w, int h,
-               LColor::color = LColor::background) = 0;
+               LColor::color) = 0;
        
        /// A filled rectangle with the shape of a 3D button
        virtual PainterBase & button(int x, int y, int w, int h);
index 3ea458ea18aaec6353886f7279d42adc6291bd5b..c3750d95d56fd9504c9620d2bd4734ad91a4cfdf 100644 (file)
@@ -1,3 +1,34 @@
+2001-07-24  Jean-Marc Lasgouttes  <lasgouttes@lyx.org>
+
+       * insetminipage.C (InsetMinipage): set background color to red :)
+
+2001-07-23  Jean-Marc Lasgouttes  <lasgouttes@lyx.org>
+
+       * insettext.C (insetUnlock): only set update to CLEAR_FRAME if
+       draw frame mode is LOCKED.
+
+       * insetcollapsable.C (edit): 
+       (insetButtonRelease): set update status to full when
+       opening inset.
+
+       * insettext.C (clearInset): 
+       * insettabular.C (draw): 
+       * insetlatexaccent.C (draw): honor background color.
+
+       * inset.h: new member background_color_, initialized to
+       LColor::inherit.
+
+       * inset.C (backgroundColor): new method.
+       (setBackgroundColor): new method.
+
+       * insetert.C (init): new method, called by the ctors.
+       (InsetERT): when inserting contents, make sure the font is
+       ALL_INHERIT.
+
+       * insetnote.C (InsetNote): when inserting content, remove trailing
+       newline
+       (init): set background color to LColor::note
+
 2001-07-24  Lars Gullik Bjønnes  <larsbj@birdstep.com>
 
        * insetcollapsable.C: adjust
index 315cf2444cd3683e51f92d9b78cad6bd8f69d41e..581006f0cb0c98cd6da5787d61c8a158fea99dc2 100644 (file)
@@ -90,6 +90,24 @@ LyXText * Inset::getLyXText(BufferView const * bv, bool const) const
 }
 
 
+void Inset::setBackgroundColor(LColor::color color)
+{
+       background_color_ = color;
+}
+
+
+LColor::color Inset::backgroundColor() const
+{
+       if (background_color_ == LColor::inherit) {
+               if (owner())
+                       return owner()->backgroundColor();
+               else
+                       return LColor::background;
+       } else
+               return background_color_;
+}
+
+
 int Inset::id() const
 {
        return id_;
index c309e60a531920097aa39104cb3f69353b0d46c2..550c6cee318ded07621a8f2690be4c5a51092c0a 100644 (file)
@@ -19,6 +19,7 @@
 #include "LString.h"
 #include <X11/Xlib.h>
 #include "commandtags.h"
+#include "LColor.h"
 
 class LyXFont;
 class BufferView;
@@ -128,7 +129,7 @@ public:
        };
        
        ///
-       Inset() : top_x(0), top_baseline(0), scx(0), id_(inset_id++), owner_(0) {}
+       Inset() : top_x(0), top_baseline(0), scx(0), id_(inset_id++), owner_(0), background_color_(LColor::inherit) {}
        /// Virtual base destructor
        virtual ~Inset() {}
        ///
@@ -225,6 +226,10 @@ public:
        ///
        Inset * owner() const { return owner_; }
        ///
+       void setBackgroundColor(LColor::color);
+       ///
+       LColor::color backgroundColor() const;
+       ///
        int x() const { return top_x; }
        ///
        int y() const { return top_baseline; }
@@ -288,6 +293,8 @@ private:
        Inset * owner_;
        ///
        string name;
+       ///
+       LColor::color background_color_;
 };
 
 
index a5149e020f5cb6246ba846741ced5ea9e25df94a..5739b508013bebb7c68f7cb1891634d2834681d0 100644 (file)
@@ -289,6 +289,7 @@ void InsetCollapsable::edit(BufferView * bv, bool front)
                collapsed_ = false;
                if (!bv->lockInset(this))
                        return;
+               inset.setUpdateStatus(bv, InsetText::FULL);
                bv->updateInset(this, false);
                inset.edit(bv, front);
        } else {
@@ -347,6 +348,7 @@ void InsetCollapsable::insetButtonRelease(BufferView * bv,
                        draw_label = label;
                        collapsed_ = false;
                        inset.insetButtonRelease(bv, 0, 0, button);
+                       inset.setUpdateStatus(bv, InsetText::FULL);
                        bv->updateInset(this, false);
                } else {
                        if (change_label_with_text) {
@@ -620,8 +622,9 @@ void InsetCollapsable::setLabel(string const & l, bool flag)
 string InsetCollapsable::get_new_label() const
 {
        string la;
+       Paragraph::size_type const max_length = 10;
 
-       int n = std::min(10, inset.paragraph()->size());
+       int n = std::min(max_length, inset.paragraph()->size());
        int i,j;
        for(i=0,j=0; i < n && j < inset.paragraph()->size(); ++j) {
                if (inset.paragraph()->isInset(j))
index 4c76ca4c5f61ebb9ee0e81ab4b012dc7948ec299..acd54a065360a3733c7deebe5d589e9053252240 100644 (file)
 
 using std::ostream;
 
-InsetERT::InsetERT() : InsetCollapsable()
+void InsetERT::init()
 {
        setLabel(_("666"), true);
-       //LyXFont font(LyXFont::ALL_SANE);
-       //font.setLatex (LyXFont::ON);
        labelfont = LyXFont(LyXFont::ALL_SANE);
        labelfont.decSize();
        labelfont.decSize();
+#ifndef NO_LATEX
+       labelfont.setLatex(LyXFont::ON);
+#else
        labelfont.setColor(LColor::latex);
+#endif
        setAutoCollapse(false);
        setInsetName("ERT");
 }
 
+InsetERT::InsetERT() : InsetCollapsable()
+{
+       init();
+}
+
 
 InsetERT::InsetERT(string const & contents, bool collapsed)
        : InsetCollapsable(collapsed)
 {
-       setLabel(_("666"));
-       LyXFont font(LyXFont::ALL_SANE);
-#ifndef NO_LATEX
-       font.setLatex(LyXFont::ON);
-#else
-       font.setColor(LColor::latex);
-#endif
-       labelfont = LyXFont(LyXFont::ALL_SANE);
-       labelfont.decSize();
-       labelfont.decSize();
-       labelfont.setColor(LColor::latex);
-       setAutoCollapse(false);
-       setInsetName("ERT");
+       init();
 
+       LyXFont const font(LyXFont::ALL_INHERIT);
        string::const_iterator cit = contents.begin();
        string::const_iterator end = contents.end();
        Paragraph::size_type pos = 0;
index f6a0ebde9dddf787521fa951ac496cce7985b67a..116c2e9075db5364edaad8b16ed70353b9f7e51e 100644 (file)
@@ -58,6 +58,9 @@ public:
        virtual int linuxdoc(Buffer const *, std::ostream &) const;
        ///
        virtual int docBook(Buffer const *, std::ostream &) const;
+private:
+       ///
+       void init();
 };
 
 #endif
index ccd8401ebf742bf3a83ec07e1fae42676881fe40..3709a847bd30f61b482c8a6fee12e052d2165c45 100644 (file)
@@ -409,7 +409,7 @@ void InsetLatexAccent::draw(BufferView * bv, LyXFont const & font0,
                        pain.fillRectangle(int(x + tmpx), tmpvar, wid,
                                           lyxfont::ascent('i', font) -
                                           lyxfont::ascent('x', font) - 1,
-                                          LColor::background);
+                                          backgroundColor());
                        // the five lines below is a simple hack to
                        // make the display of accent 'i' and 'j'
                        // better. It makes the accent be written
@@ -602,7 +602,8 @@ void InsetLatexAccent::draw(BufferView * bv, LyXFont const & font0,
                                   baseline - ascent(bv, font) + 1,
                                   width(bv, font) - 2,
                                   ascent(bv, font)
-                                  + descent(bv, font) - 2);
+                                  + descent(bv, font) - 2,
+                                  backgroundColor());
                pain.rectangle(int(x + 1), baseline - ascent(bv, font) + 1,
                               width(bv, font) - 2,
                               ascent(bv, font) + descent(bv, font) - 2);
index 1f3ee2e0542aa009da7904f4a2884d25ac2c6383..3c357d1afefe61f270a411fd372599c33b043a32 100644 (file)
@@ -69,6 +69,8 @@ InsetMinipage::InsetMinipage()
        font.setColor(LColor::collapsable);
        setLabelFont(font);
        setAutoCollapse(false);
+       // just for experimentation :)
+       setBackgroundColor(LColor::red);
        setInsetName("Minipage");
        width_ = "100%"; // set default to 100% of column_width
 }
index 89ac827f58894c444184b46fff04918511356376..c8945ee3c8e53b9e92b1fbdc5c9806141026039f 100644 (file)
@@ -22,6 +22,7 @@
 #include "lyxtext.h"
 #include "insets/insettext.h"
 #include "support/LOstream.h"
+#include "support/lstrings.h"
 #include "debug.h"
 
 using std::ostream;
@@ -32,18 +33,22 @@ void InsetNote::init()
        font.decSize();
        font.setColor(LColor::note);
        setLabelFont(font);
+
        setAutoCollapse(false);
+       setBackgroundColor(LColor::note);
 
        setLabel(_("note"));
        setInsetName("Note");
 }
 
+
 InsetNote::InsetNote()
        : InsetCollapsable()
 {
        init();
 }
 
+
 InsetNote::InsetNote(Buffer const * buf, string const & contents, 
                     bool collapsed)
        : InsetCollapsable(collapsed)
@@ -52,9 +57,11 @@ InsetNote::InsetNote(Buffer const * buf, string const & contents,
 
        Paragraph * par = inset.paragraph();
        Paragraph::size_type pos = 0;
-       buf->insertStringAsLines(par, pos, labelfont, contents);
+       buf->insertStringAsLines(par, pos, LyXFont(LyXFont::ALL_INHERIT), 
+                                strip(contents, '\n'));
 }
 
+
 Inset * InsetNote::clone(Buffer const &, bool same_id) const
 {
        InsetNote * result = new InsetNote;
index ecd4b885de7067b78c6e60c4ef1ca63f80d5c6fc..26607fed2a69a40860f6e487555e543e9ab747e7 100644 (file)
@@ -259,7 +259,7 @@ void InsetTabular::draw(BufferView * bv, LyXFont const & font, int baseline,
                        h = pain.paperHeight();
                if ((top_x + w) > pain.paperWidth())
                        w = pain.paperWidth();
-               pain.fillRectangle(tx, ty, w, h);
+               pain.fillRectangle(tx, ty, w, h, backgroundColor());
                need_update = FULL;
                cleared = true;
        }
@@ -366,7 +366,8 @@ void InsetTabular::draw(BufferView * bv, LyXFont const & font, int baseline,
                                baseline - tabular->GetAscentOfRow(i) + 1,
                                int(cx - nx - 1),
                                tabular->GetAscentOfRow(i) +
-                               tabular->GetDescentOfRow(i) - 1);
+                               tabular->GetDescentOfRow(i) - 1,
+                               backgroundColor());
                        // clear behind the inset
                        pain.fillRectangle(
                                int(cx + the_locking_inset->width(bv,font) + 1),
@@ -376,7 +377,8 @@ void InsetTabular::draw(BufferView * bv, LyXFont const & font, int baseline,
                                the_locking_inset->width(bv,font) -
                                tabular->GetAdditionalWidth(cell) - 1,
                                tabular->GetAscentOfRow(i) +
-                               tabular->GetDescentOfRow(i) - 1);
+                               tabular->GetDescentOfRow(i) - 1,
+                               backgroundColor());
                }
        }
        x -= ADD_TO_TABULAR_WIDTH;
index 17f6610888718a878df1ac6efa069750733f932c..29c8cba48d37626d616503b1ce013574ceee49e3 100644 (file)
@@ -472,7 +472,7 @@ void InsetText::clearFrame(Painter & pain, bool cleared) const
                if (!cleared) {
                        pain.rectangle(top_x + 1, top_baseline - insetAscent + 1,
                                       insetWidth - 1, insetAscent + insetDescent - 1,
-                                      LColor::background);
+                                      backgroundColor());
                }
                frame_is_visible = false;
        }
@@ -667,7 +667,11 @@ void InsetText::insetUnlock(BufferView * bv)
        hideInsetCursor(bv);
        no_selection = false;
        locked = false;
-       int code = CURSOR|CLEAR_FRAME;
+       int code;
+       if (drawFrame_ == LOCKED)
+               code = CURSOR|CLEAR_FRAME;
+       else 
+               code = CURSOR;
        bool clear = false;
        if (!lt) {
                lt = getLyXText(bv);
@@ -1941,7 +1945,8 @@ void InsetText::clearInset(Painter & pain, int baseline, bool & cleared) const
                h = pain.paperHeight();
        if ((top_x + drawTextXOffset + w) > pain.paperWidth())
                w = pain.paperWidth();
-       pain.fillRectangle(top_x+drawTextXOffset, ty, w, h);
+       pain.fillRectangle(top_x+drawTextXOffset, ty, w, h, 
+                          backgroundColor());
        cleared = true;
        need_update = FULL;
 }
index 7bb3355b02f6993aa1b55b25328b05dca35db682..1b0388a3410f686149380e50aa563f90339aef53 100644 (file)
@@ -289,8 +289,11 @@ private:
        UpdatableInset::RESULT moveDown(BufferView *);
        ///
        void setCharFont(Buffer const *, int pos, LyXFont const & font);
+#if 0
+       ///What's that ??? Not used, not implemented!
        ///
        string const getText(int);
+#endif
        ///
        bool checkAndActivateInset(BufferView * bv, bool behind);
        ///
index 87d6b78c4b69127129341faf36ee4f9ce8bfca03..0cb33eac0d73f6a629fb9769fd45408ba5dc0fbb 100644 (file)
@@ -22,6 +22,7 @@
 #include "layout.h"
 #include "lyxrow.h"
 #include "vspace.h"
+#include "LColor.h"
 
 class Buffer;
 class BufferParams;
@@ -392,14 +393,6 @@ public:
        void copyEnvironmentType();
        ///
        void pasteEnvironmentType(BufferView *);
-       ///
-       void insertFootnote();
-       ///
-       void insertMarginpar();
-       ///
-       void insertFigure();
-       ///
-       void insertTabular();
 
        /** the DTP switches for paragraphs. LyX will store the top settings
         always in the first physical paragraph, the bottom settings in the
@@ -606,6 +599,8 @@ private:
          */
        bool hfillExpansion(Buffer const *, Row const * row_ptr,
                            Paragraph::size_type pos) const;
+       /// 
+       LColor::color backgroundColor();
 
 
        ///
index 8d499450130ce4290454865a3885718f0a4855a1..c6b00c4e65df2b6b455a3ef65f8d1c09ba093a93 100644 (file)
@@ -1159,6 +1159,14 @@ bool LyXText::hfillExpansion(Buffer const * buf, Row const * row_ptr,
 }
 
 
+LColor::color LyXText::backgroundColor()
+{
+       if (inset_owner)
+               return inset_owner->backgroundColor();
+       else
+               return LColor::background;
+}
+
 void LyXText::setHeightOfRow(BufferView * bview, Row * row_ptr) const
 {
     /* get the maximum ascent and the maximum descent */
@@ -2938,25 +2946,29 @@ void LyXText::getVisibleRow(BufferView * bview, int y_offset, int x_offset,
                int const w = inset_owner ?
                        inset_owner->width(bview, font) - 2 : ww;
                int const x = x_offset;
-               pain.fillRectangle(x, y, w, h);
+               pain.fillRectangle(x, y, w, h, backgroundColor());
        } else if (inset != 0) {
                int h = row_ptr->baseline() - inset->ascent(bview, font);
                if (h > 0) {
                        int const w = (inset_owner ?
                                 inset_owner->width(bview, font) : ww);
-                       pain.fillRectangle(x_offset, y_offset, w, h);
+                       pain.fillRectangle(x_offset, y_offset, w, h,
+                                          backgroundColor());
                }
                h += inset->ascent(bview, font) + inset->descent(bview, font);
                if ((row_ptr->height() - h) > 0) {
                        int const w = (inset_owner ?
                                 inset_owner->width(bview, font) : ww);
                        pain.fillRectangle(x_offset, y_offset + h,
-                                          w, row_ptr->height() - h);
+                                          w, row_ptr->height() - h,
+                                          backgroundColor());
                }
                if (!inset_owner && !inset->display() && !inset->needFullRow())
                {
                        int const w = inset->width(bview, font) + int(x);
-                       pain.fillRectangle(w, y_offset, ww - w, row_ptr->height());
+                       pain.fillRectangle(w, y_offset, 
+                                          ww - w, row_ptr->height(),
+                                          backgroundColor());
                }
        }
 
@@ -3158,8 +3170,8 @@ void LyXText::getVisibleRow(BufferView * bview, int y_offset, int x_offset,
                                          0,
                                          _("Page Break (top)"),
                                          pb_font,
-                                         LColor::background,
-                                         LColor::background, false, w, a, d);
+                                         backgroundColor(),
+                                         backgroundColor(), false, w, a, d);
 #else
                        ;
                        lyxfont::rectText(_("Page Break (top)"), pb_font,
@@ -3169,8 +3181,8 @@ void LyXText::getVisibleRow(BufferView * bview, int y_offset, int x_offset,
                                      y_offset + y_top + 2 * defaultHeight() + d,
                                      _("Page Break (top)"),
                                      pb_font,
-                                     LColor::background,
-                                     LColor::background);
+                                     backgroundColor(),
+                                     backgroundColor());
                        y_top += 3 * defaultHeight();
                }
                
@@ -3354,8 +3366,8 @@ void LyXText::getVisibleRow(BufferView * bview, int y_offset, int x_offset,
                                .rectText(0, 0,
                                          _("Page Break (bottom)"),
                                          pb_font,
-                                         LColor::background,
-                                         LColor::background, false, w, a, d);
+                                         backgroundColor(),
+                                         backgroundColor(), false, w, a, d);
 #else
                        ;
                        lyxfont::rectText(_("Page Break (bottom)"), pb_font,
@@ -3364,8 +3376,8 @@ void LyXText::getVisibleRow(BufferView * bview, int y_offset, int x_offset,
                        pain.rectText((ww - w) / 2, y_place + d,
                                      _("Page Break (bottom)"),
                                      pb_font,
-                                     LColor::background,
-                                     LColor::background);
+                                     backgroundColor(),
+                                     backgroundColor());
                        y_bottom -= 3 * defaultHeight();
                }