]> git.lyx.org Git - features.git/commitdiff
Further cleanup of collapsable insets. The layouts are now properly read and applied.
authorAbdelrazak Younes <younes@lyx.org>
Fri, 2 Nov 2007 21:27:41 +0000 (21:27 +0000)
committerAbdelrazak Younes <younes@lyx.org>
Fri, 2 Nov 2007 21:27:41 +0000 (21:27 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@21392 a592a061-630c-0410-9148-cb99ea01b6c8

src/Text3.cpp
src/insets/Inset.h
src/insets/InsetBox.cpp
src/insets/InsetCollapsable.cpp
src/insets/InsetCollapsable.h

index 3d77ab78f0bfa595fd26254639a8b110d4c2122b..f51106448ff90dddbffb98f5ab579ef3e12e89ef 100644 (file)
@@ -190,6 +190,9 @@ static bool doInsertInset(Cursor & cur, Text * text,
        if (!inset)
                return false;
 
+       if (InsetCollapsable * ci = inset->asInsetCollapsable())
+               ci->setLayout(cur.bv().buffer().params());
+
        cur.recordUndo();
        if (cmd.action == LFUN_INDEX_INSERT) {
                docstring ds = support::subst(text->getStringToIndex(cur), '\n', ' ');
index aae34f86954639f6d16b09f38cfe2162f5696897..c38e44e67ddb88d39a532d8b3324cdde18652bc1 100644 (file)
@@ -35,6 +35,7 @@ class Dimension;
 class FuncRequest;
 class FuncStatus;
 class InsetIterator;
+class InsetCollapsable;
 class InsetLayout;
 class InsetList;
 class InsetMath;
@@ -88,6 +89,10 @@ public:
        virtual InsetText * asTextInset() { return 0; }
        /// is this inset based on the TextInset class?
        virtual InsetText const * asTextInset() const { return 0; }
+       /// is this inset based on the InsetCollapsable class?
+       virtual InsetCollapsable * asInsetCollapsable() { return 0; }
+       /// is this inset based on the InsetCollapsable class?
+       virtual InsetCollapsable const * asInsetCollapsable() const { return 0; }
        
        /// the real dispatcher
        void dispatch(Cursor & cur, FuncRequest & cmd);
index ed131d50934a1f0a86dcbf0dc5b9ce7650442241..b86d6f485288ac43f26c1bea7d2bb612d5e65ce1 100644 (file)
@@ -199,7 +199,6 @@ void InsetBox::doDispatch(Cursor & cur, FuncRequest & cmd)
                //lyxerr << "InsetBox::dispatch MODIFY" << endl;
                InsetBoxMailer::string2params(to_utf8(cmd.argument()), params_);
                setLayout(cur.buffer().params());
-               setButtonLabel();
                break;
        }
 
index 70e21e6e94bb20001aae8071dbdde989797bc297..98e4a96ac47856f9422bb87514c02a8dc7c72ca4 100644 (file)
@@ -81,8 +81,6 @@ InsetCollapsable::InsetCollapsable
        setAutoBreakRows(true);
        setDrawFrame(true);
        setFrameColor(Color_collapsableframe);
-       setButtonLabel();
-       setLayout(bp);
 }
 
 
@@ -108,15 +106,11 @@ void  InsetCollapsable::setLayout(BufferParams const & bp)
        layout_.bgcolor = Color_background;
 
        layout_ = getLayout(bp);
-       if (layout_.labelfont != inherit_font)
-               return;
 
        // FIXME: put this in the InsetLayout parsing?
-       // Fallback for lacking inset layout labelfont.
-       layout_.labelfont = sane_font;
-       layout_.labelfont.decSize();
-       layout_.labelfont.decSize();
-       layout_.labelfont.setColor(Color_collapsable);
+       layout_.labelfont.realize(sane_font);
+
+       setButtonLabel();
 }
 
 
@@ -170,7 +164,6 @@ void InsetCollapsable::read(Buffer const & buf, Lexer & lex)
        if (!token_found)
                status_ = isOpen() ? Open : Collapsed;
 
-       setButtonLabel();
        setLayout(buf.params());
 
        // Force default font, if so requested
index df406e26ef0a1527639cad917e369da0477b28a3..7803e860391757cbfe964ff3bcfcdce26b24c6a3 100644 (file)
@@ -41,7 +41,9 @@ public:
        InsetCollapsable(BufferParams const &, CollapseStatus status = Inset::Open);
        ///
        InsetCollapsable(InsetCollapsable const & rhs);
-       ///
+       
+       InsetCollapsable * asInsetCollapsable() { return this; }
+       InsetCollapsable const * asInsetCollapsable() const { return this; }
        docstring name() const { return from_ascii("Collapsable"); }
        ///
        void setLayout(BufferParams const &);