]> git.lyx.org Git - lyx.git/commitdiff
Collapsable -> Collapsible (part 2)
authorJuergen Spitzmueller <spitz@lyx.org>
Mon, 16 Oct 2017 08:12:21 +0000 (10:12 +0200)
committerJuergen Spitzmueller <spitz@lyx.org>
Mon, 16 Oct 2017 08:12:21 +0000 (10:12 +0200)
The current spelling is not strictly wrong, but flagged as unusual or
historical by some authorities. It is also found fault with many
spell checkers. Thus we decided to move to the more standard "-ible"
form once and for all.

See #10678 for discussion

This part covers the most tricky part: the internal naming.
Translations and layouts will follow.

This will all also all be backported to 2.3.x, for the sake of backwards
compatibility (cherry-picking).

53 files changed:
lib/doc/Customization.lyx
lib/doc/de/Customization.lyx
lib/doc/es/Customization.lyx
lib/doc/fr/Customization.lyx
lib/doc/ja/Customization.lyx
lib/scripts/layout2layout.py
lib/ui/stdcontext.inc
src/Color.cpp
src/ColorCode.h
src/CutAndPaste.cpp
src/Makefile.am
src/Text2.cpp
src/Text3.cpp
src/TextClass.cpp
src/factory.cpp
src/frontends/qt4/GuiERT.cpp
src/insets/Inset.cpp
src/insets/Inset.h
src/insets/InsetArgument.cpp
src/insets/InsetArgument.h
src/insets/InsetBox.cpp
src/insets/InsetBox.h
src/insets/InsetBranch.cpp
src/insets/InsetBranch.h
src/insets/InsetCaption.cpp
src/insets/InsetCaptionable.cpp
src/insets/InsetCaptionable.h
src/insets/InsetCode.h
src/insets/InsetCollapsable.cpp [deleted file]
src/insets/InsetCollapsable.h [deleted file]
src/insets/InsetCollapsible.cpp [new file with mode: 0644]
src/insets/InsetCollapsible.h [new file with mode: 0644]
src/insets/InsetCommand.cpp
src/insets/InsetERT.cpp
src/insets/InsetERT.h
src/insets/InsetFlex.cpp
src/insets/InsetFlex.h
src/insets/InsetFoot.cpp
src/insets/InsetFootlike.cpp
src/insets/InsetFootlike.h
src/insets/InsetIPAMacro.cpp
src/insets/InsetIPAMacro.h
src/insets/InsetIndex.cpp
src/insets/InsetIndex.h
src/insets/InsetInfo.cpp
src/insets/InsetInfo.h
src/insets/InsetListingsParams.cpp
src/insets/InsetListingsParams.h
src/insets/InsetNote.cpp
src/insets/InsetNote.h
src/insets/InsetPhantom.cpp
src/insets/InsetPhantom.h
src/insets/InsetScript.cpp

index ed456e0619b6be7a89fe59aca1cffa3377a9a3a1..23d0ed9d04ec2518516d9b93acbc9e0aec277d13 100644 (file)
@@ -27778,11 +27778,11 @@ changedtextauthor5 Changed text color author 5
 \end_layout
 
 \begin_layout Description
-collapsable Collapsable insets text color
+collapsible Collapsible insets text color
 \end_layout
 
 \begin_layout Description
-collapsableframe Collapsable insets framecolor
+collapsibleframe Collapsible insets framecolor
 \end_layout
 
 \begin_layout Description
index e1dac3cb65f0ff36933ba9290fdb71d2ff8847d6..a32430b7423231c9998ce75e2049828a83e6cfbb 100644 (file)
@@ -27279,7 +27279,7 @@ Autors
 \begin_layout Description
 
 \lang english
-collapsable
+collapsible
 \lang ngerman
  Textfarbe in einklappbaren Einfügungen
 \end_layout
@@ -27287,7 +27287,7 @@ collapsable
 \begin_layout Description
 
 \lang english
-collapsableframe
+collapsibleframe
 \lang ngerman
  Rahmenfarbe in einklappbaren Einfügungen
 \end_layout
index d9c2eda96bf4bf5e59a5f1e8f01d0eca1e99c7e4..d18c53f40e83fd292b94d609b3cdb13d789abb02 100644 (file)
@@ -28035,11 +28035,11 @@ changedtextauthor5 Color autor 5 de texto cambiado
 \end_layout
 
 \begin_layout Description
-collapsabletext Color texto de recuadro plegable 
+collapsibletext Color texto de recuadro plegable 
 \end_layout
 
 \begin_layout Description
-collapsableframe Color marco de recuadro plegable
+collapsibleframe Color marco de recuadro plegable
 \end_layout
 
 \begin_layout Description
index e68c89f536ff6226f53dc57d0cc16d77607a67ab..6db72fb27ac091918846c40e7ddc753176f062ab 100644 (file)
@@ -31166,7 +31166,7 @@ changedtextauthor5
 \begin_layout Description
 
 \lang english
-collapsabletext
+collapsibletext
 \lang french
  texte d'insert repliable
 \end_layout
@@ -31174,7 +31174,7 @@ collapsabletext
 \begin_layout Description
 
 \lang english
-collapsableframe
+collapsibleframe
 \lang french
  cadre d'insert repliable
 \end_layout
index baf0823daa6cf88c7629139aaebf115de373c158..2faeb0733b01a8472414cdbee94d7893fe5af907 100644 (file)
@@ -24744,11 +24744,11 @@ changedtextauthor5 変更された文章:第5著者の色
 \end_layout
 
 \begin_layout Description
-collapsabletext 畳み込み可能枠の文字色
+collapsibletext 畳み込み可能枠の文字色
 \end_layout
 
 \begin_layout Description
-collapsableframe 畳み込み可能枠の縁色
+collapsibleframe 畳み込み可能枠の縁色
 \end_layout
 
 \begin_layout Description
index 77cafa048ae50413e12364ea1d995885e7b0ece3..2cf54c5e1490b2736570cdb723e80a708478f034 100644 (file)
@@ -11,7 +11,7 @@
 # This script will update a .layout file to current format
 
 # The latest layout format is also defined in src/TextClass.cpp
-currentFormat = 64
+currentFormat = 65
 
 
 # Incremented to format 4, 6 April 2007, lasgouttes
@@ -217,6 +217,9 @@ currentFormat = 64
 # LabelStringAppendix, and EndLabelString, and LabelCounter,
 # to conform to what we used to do.
 
+# Incremented to format 65, 16 October 2017 by spitz
+# Color collapsable -> collapsible
+
 # Do not forget to document format change in Customization
 # Manual (section "Declaring a new text class").
 
@@ -466,6 +469,17 @@ def convert(lines, end_format):
                 i += 1
             continue
 
+        if format == 64:
+            match = re.compile(b'(\\s*Color\\s+)(\\w+)', re.IGNORECASE).match(lines[i])
+            if not match:
+                i += 1
+                continue
+            col  = match.group(2)
+            if col == "collapsable":
+                lines[i] = match.group(1) + "collapsible"
+            i += 1
+            continue
+
         if format == 63:
             for r in (re_trimLabelString, re_trimLabelStringAppendix,\
               re_trimEndLabelString, re_trimLabelCounter):
index 9e68cc14e873a5498d34eda75ce1325d4bbe27a9..ccfd20065e068fdf02940be20a0df3dcce45712a 100644 (file)
@@ -139,9 +139,9 @@ Menuset
        End
 
 #
-# InsetCollapsable context menu
+# InsetCollapsible context menu
 #
-       Menu "context-collapsable"
+       Menu "context-collapsible"
                OptItem "Open Inset|O" "inset-toggle open"
                OptItem "Close Inset|C" "inset-toggle close"
                Separator
index 6d5b73883eba312fbdb65a6c1628962d52431a42..d9933ce34e342e0611bb6a8b3974c5e875ec7401 100644 (file)
@@ -269,8 +269,8 @@ ColorSet::ColorSet()
        { Color_mathmacroblend, N_("math macro blended out"), "mathmacroblend", "black", "mathmacroblend" },
        { Color_mathmacrooldarg, N_("math macro old parameter"), "mathmacrooldarg", grey80, "mathmacrooldarg" },
        { Color_mathmacronewarg, N_("math macro new parameter"), "mathmacronewarg", "black", "mathmacronewarg" },
-       { Color_collapsable, N_("collapsable inset text"), "collapsable", "DarkRed", "collapsable" },
-       { Color_collapsableframe, N_("collapsable inset frame"), "collapsableframe", "IndianRed", "collapsableframe" },
+       { Color_collapsible, N_("collapsible inset text"), "collapsible", "DarkRed", "collapsible" },
+       { Color_collapsibleframe, N_("collapsible inset frame"), "collapsibleframe", "IndianRed", "collapsibleframe" },
        { Color_insetbg, N_("inset background"), "insetbg", grey80, "insetbg" },
        { Color_insetframe, N_("inset frame"), "insetframe", "IndianRed", "insetframe" },
        { Color_error, N_("LaTeX error"), "error", "Red", "error" },
index f98ecf8008757c4f62070025096b7e213193c462..d0973852f8694275aad0adf044e35ce37cd22441 100644 (file)
@@ -155,10 +155,10 @@ enum ColorCode {
        /// Math line color
        Color_mathline,
 
-       /// Collapsable insets text
-       Color_collapsable,
-       /// Collapsable insets frame
-       Color_collapsableframe,
+       /// Collapsible insets text
+       Color_collapsible,
+       /// Collapsible insets frame
+       Color_collapsibleframe,
 
        /// Inset marker background color
        Color_insetbg,
index 05f9b90bca42f3430bed0512f019c195ddbf18ff..d79ef5a655defd744cc98ac6adf26c561194d143 100644 (file)
@@ -773,7 +773,7 @@ void switchBetweenClasses(DocumentClassConstPtr oldone,
        for (InsetIterator it = inset_iterator_begin(in); it != i_end; ++it) {
                InsetCode const code = it->lyxCode();
                if (code == FLEX_CODE) {
-                       // FIXME: Should we verify all InsetCollapsable?
+                       // FIXME: Should we verify all InsetCollapsible?
                        docstring const layoutName = it->layoutName();
                        docstring const & n = newone->insetLayout(layoutName).name();
                        bool const is_undefined = n.empty() ||
index 905617b4030cb26fa759cd652266ac2bf624b647..28592fb0a2651057745c3d78dc5f13de2c3b20d4 100644 (file)
@@ -578,7 +578,7 @@ SOURCEFILESINSETS = \
        insets/InsetCaption.cpp \
        insets/InsetCaptionable.cpp \
        insets/InsetCitation.cpp \
-       insets/InsetCollapsable.cpp \
+       insets/InsetCollapsible.cpp \
        insets/InsetCommand.cpp \
        insets/InsetCommandParams.cpp \
        insets/InsetERT.cpp \
@@ -638,7 +638,7 @@ HEADERFILESINSETS = \
        insets/InsetCaptionable.h \
        insets/InsetCitation.h \
        insets/InsetCode.h \
-       insets/InsetCollapsable.h \
+       insets/InsetCollapsible.h \
        insets/InsetCommand.h \
        insets/InsetCommandParams.h \
        insets/InsetERT.h \
index c223ce06e6aa8de612fa802460a795041d8a5473..8eb70f8e328c5e455c27935774f62788d135dce8 100644 (file)
@@ -42,7 +42,7 @@
 #include "TextClass.h"
 #include "TextMetrics.h"
 
-#include "insets/InsetCollapsable.h"
+#include "insets/InsetCollapsible.h"
 
 #include "mathed/InsetMathHull.h"
 
index 930b5347c2d79fc48504a8513588ffe6419f9848..4b2f90af4b230d98d5f66a161f6abe3a6dae1f4c 100644 (file)
@@ -53,7 +53,7 @@
 #include "frontends/Selection.h"
 
 #include "insets/InsetArgument.h"
-#include "insets/InsetCollapsable.h"
+#include "insets/InsetCollapsible.h"
 #include "insets/InsetCommand.h"
 #include "insets/InsetExternal.h"
 #include "insets/InsetFloat.h"
@@ -245,7 +245,7 @@ static bool doInsertInset(Cursor & cur, Text * text,
        if (!inset)
                return false;
 
-       if (InsetCollapsable * ci = inset->asInsetCollapsable())
+       if (InsetCollapsible * ci = inset->asInsetCollapsible())
                ci->setButtonLabel();
 
        cur.recordUndo();
index 8b6b5a7f84004b2900752bf79b71667ac6e34393..f63632471c87be80a433f49adae7c9dc9c84d14a 100644 (file)
@@ -62,7 +62,7 @@ namespace lyx {
 // You should also run the development/tools/updatelayouts.py script,
 // to update the format of all of our layout files.
 //
-int const LAYOUT_FORMAT = 64; //lasgouttes/rgheck: do not trim LabeString and friends.
+int const LAYOUT_FORMAT = 65; //spitz: Color collapsable -> collapsible.
 
 
 // Layout format for the current lyx file format. Controls which format is
index 3937a9e7f882b8c6f27069fceda8d29880063d1d..c69d37c205ec20c171d3909aa5d57b319a0f2eba 100644 (file)
@@ -679,7 +679,7 @@ Inset * readInset(Lexer & lex, Buffer * buf)
                }
 
                // Set the buffer reference for proper parsing of some insets
-               // (InsetCollapsable for example)
+               // (InsetCollapsible for example)
                inset->setBuffer(*buf);
                inset->read(lex);
                // Set again the buffer for insets that are created inside this inset
index 8fc92e22505ccbf4db88df349cb7fe8e3eca0846..fece83ea766d73907ccb34416a6b6d6e16aa14cd 100644 (file)
@@ -40,8 +40,8 @@ GuiERT::GuiERT(QWidget * parent) : InsetParamsWidget(parent)
 
 docstring GuiERT::dialogToParams() const
 {
-       InsetCollapsable::CollapseStatus const status = openRB->isChecked()
-               ? InsetCollapsable::Open : InsetCollapsable::Collapsed;
+       InsetCollapsible::CollapseStatus const status = openRB->isChecked()
+               ? InsetCollapsible::Open : InsetCollapsible::Collapsed;
        return from_ascii(InsetERT::params2string(status));
 }
 
@@ -51,10 +51,10 @@ void GuiERT::paramsToDialog(Inset const * inset)
        InsetERT const * ert = static_cast<InsetERT const *>(inset);
        // FIXME: This dialog has absolutely no value...
        BufferView const * bv = guiApp->currentView()->currentBufferView();
-       InsetCollapsable::CollapseStatus status = ert->status(*bv);
+       InsetCollapsible::CollapseStatus status = ert->status(*bv);
        switch (status) {
-               case InsetCollapsable::Open: openRB->setChecked(true); break;
-               case InsetCollapsable::Collapsed: collapsedRB->setChecked(true); break;
+               case InsetCollapsible::Open: openRB->setChecked(true); break;
+               case InsetCollapsible::Collapsed: collapsedRB->setChecked(true); break;
        }
 }
 
index b458c8181bfe74f50c049c6e3017c6f12f96f33b..f2e2d4bcb88e5d197730d29f39f08cfdd5ea3fb2 100644 (file)
@@ -117,7 +117,7 @@ static void build_translator()
        insetnames[MATH_MACROARG_CODE] = InsetName("mathmacroarg");
        insetnames[LISTINGS_CODE] = InsetName("listings");
        insetnames[INFO_CODE] = InsetName("info", _("Info"));
-       insetnames[COLLAPSABLE_CODE] = InsetName("collapsable");
+       insetnames[COLLAPSIBLE_CODE] = InsetName("collapsible");
        insetnames[NEWPAGE_CODE] = InsetName("newpage");
        insetnames[SCRIPT_CODE] = InsetName("script");
        insetnames[CELL_CODE] = InsetName("tablecell");
index 6ce428f96a042a1190b6599db9a9a40614136bd7..578a7f4d5a1a9541a37a2c40e8b928fd2f6861a7 100644 (file)
@@ -41,7 +41,7 @@ class DocIterator;
 class FuncRequest;
 class FuncStatus;
 class InsetArgument;
-class InsetCollapsable;
+class InsetCollapsible;
 class InsetCommand;
 class InsetIterator;
 class InsetLayout;
@@ -143,10 +143,10 @@ public:
        virtual InsetText * asInsetText() { return 0; }
        /// is this inset based on the InsetText class?
        virtual InsetText const * asInsetText() 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; }
+       /// is this inset based on the InsetCollapsible class?
+       virtual InsetCollapsible * asInsetCollapsible() { return 0; }
+       /// is this inset based on the InsetCollapsible class?
+       virtual InsetCollapsible const * asInsetCollapsible() const { return 0; }
        /// is this inset based on the InsetTabular class?
        virtual InsetTabular * asInsetTabular() { return 0; }
        /// is this inset based on the InsetTabular class?
@@ -347,12 +347,12 @@ public:
        /// InsetMathCommand and InsetInfo.
        virtual bool isActive() const { return nargs() > 0; }
        /// can the contents of the inset be edited on screen ?
-       // equivalent to isActive except for closed InsetCollapsable
+       // equivalent to isActive except for closed InsetCollapsible
        virtual bool editable() const;
        /// has the Inset settings that can be modified in a dialog ?
        virtual bool hasSettings() const;
        /// can we go further down on mouse click?
-       /// true for InsetCaption, InsetCollapsables (not ButtonOnly), InsetTabular
+       /// true for InsetCaption, InsetCollapsibles (not ButtonOnly), InsetTabular
        virtual bool descendable(BufferView const &) const { return false; }
        /// can we click at the specified position ?
        virtual bool clickable(BufferView const &, int, int) const { return false; }
index 88e733613ad3d13fbb9d56ffbba381a6c742a9cd..a3cf1c5202971fd76cb2529dcf67cb5fb93028be 100644 (file)
@@ -40,7 +40,7 @@ namespace lyx {
 
 
 InsetArgument::InsetArgument(Buffer * buf, string const & name)
-    : InsetCollapsable(buf), name_(name), labelstring_(docstring()),
+    : InsetCollapsible(buf), name_(name), labelstring_(docstring()),
       font_(inherit_font), labelfont_(inherit_font), decoration_(string()),
       pass_thru_context_(false), pass_thru_local_(false), pass_thru_(false),
       pass_thru_chars_(docstring())
@@ -50,14 +50,14 @@ InsetArgument::InsetArgument(Buffer * buf, string const & name)
 void InsetArgument::write(ostream & os) const
 {
        os << "Argument " << name_ << "\n";
-       InsetCollapsable::write(os);
+       InsetCollapsible::write(os);
 }
 
 
 void InsetArgument::read(Lexer & lex)
 {
        lex >> name_;
-       InsetCollapsable::read(lex);
+       InsetCollapsible::read(lex);
 }
 
 
@@ -152,7 +152,7 @@ void InsetArgument::updateBuffer(ParIterator const & it, UpdateType utype)
        }
 
        setButtonLabel();
-       InsetCollapsable::updateBuffer(it, utype);
+       InsetCollapsible::updateBuffer(it, utype);
 }
 
 
@@ -207,11 +207,11 @@ void InsetArgument::doDispatch(Cursor & cur, FuncRequest & cmd)
                                fixParagraphLanguage(buffer().params().language);
                }
                else
-                       InsetCollapsable::doDispatch(cur, cmd);
+                       InsetCollapsible::doDispatch(cur, cmd);
                break;
 
        default:
-               InsetCollapsable::doDispatch(cur, cmd);
+               InsetCollapsible::doDispatch(cur, cmd);
                break;
        }
 }
@@ -251,11 +251,11 @@ bool InsetArgument::getStatus(Cursor & cur, FuncRequest const & cmd,
                                flag.setEnabled(false);
                        return true;
                }
-               return InsetCollapsable::getStatus(cur, cmd, flag);
+               return InsetCollapsible::getStatus(cur, cmd, flag);
        }
 
        default:
-               return InsetCollapsable::getStatus(cur, cmd, flag);
+               return InsetCollapsible::getStatus(cur, cmd, flag);
        }
 }
 
@@ -273,7 +273,7 @@ FontInfo InsetArgument::getFont() const
 {
        if (font_ != inherit_font)
                return font_;
-       return InsetCollapsable::getFont();
+       return InsetCollapsible::getFont();
 }
 
 
@@ -281,14 +281,14 @@ FontInfo InsetArgument::getLabelfont() const
 {
        if (labelfont_ != inherit_font)
                return labelfont_;
-       return InsetCollapsable::getLabelfont();
+       return InsetCollapsible::getLabelfont();
 }
 
 
 ColorCode InsetArgument::labelColor() const {
        if (labelfont_.color() != Color_inherit)
                return labelfont_.color();
-       return InsetCollapsable::labelColor();
+       return InsetCollapsible::labelColor();
 }
 
 
index 86de5b1ca115ca5173fcc5e331920d1bfe4792b2..9fff93b4e12034199eb56c73f7287406956ace00 100644 (file)
@@ -13,7 +13,7 @@
 #define INSETARGUMENT_H
 
 
-#include "InsetCollapsable.h"
+#include "InsetCollapsible.h"
 
 
 namespace lyx {
@@ -23,7 +23,7 @@ namespace lyx {
  * InsetArgument. Used to insert a short version of sectioning header etc.
  * automatically, or other optional LaTeX arguments
  */
-class InsetArgument : public InsetCollapsable
+class InsetArgument : public InsetCollapsible
 {
 public:
        ///
@@ -71,7 +71,7 @@ public:
        ///
        bool resetFontEdit() const { return false; }
        //@}
-       /// \name Public functions inherited from InsetCollapsable class
+       /// \name Public functions inherited from InsetCollapsible class
        //@{
        ///
        InsetLayout::InsetDecoration decoration() const;
index 90523c5c08953db7d0fd950f8b4822653e8c5ca4..c593c4c759b6ed311ad584b05c47bbd8d1bc6896 100644 (file)
@@ -102,7 +102,7 @@ BoxTranslatorLoc const & boxtranslator_loc()
 /////////////////////////////////////////////////////////////////////////
 
 InsetBox::InsetBox(Buffer * buffer, string const & label)
-       : InsetCollapsable(buffer), params_(label)
+       : InsetCollapsible(buffer), params_(label)
 {}
 
 
@@ -116,14 +116,14 @@ docstring InsetBox::layoutName() const
 void InsetBox::write(ostream & os) const
 {
        params_.write(os);
-       InsetCollapsable::write(os);
+       InsetCollapsible::write(os);
 }
 
 
 void InsetBox::read(Lexer & lex)
 {
        params_.read(lex);
-       InsetCollapsable::read(lex);
+       InsetCollapsible::read(lex);
 }
 
 
@@ -165,7 +165,7 @@ void InsetBox::setButtonLabel()
        if (btype == Boxed)
                setFrameColor(lcolor.getFromLaTeXName(params_.framecolor));
        else
-               setFrameColor(Color_collapsableframe);
+               setFrameColor(Color_collapsibleframe);
 }
 
 
@@ -188,7 +188,7 @@ void InsetBox::metrics(MetricsInfo & m, Dimension & dim) const
        int textwidth_backup = m.base.textwidth;
        if (hasFixedWidth())
                m.base.textwidth = params_.width.inPixels(m.base);
-       InsetCollapsable::metrics(m, dim);
+       InsetCollapsible::metrics(m, dim);
        // retore textwidth.
        m.base.textwidth = textwidth_backup;
 }
@@ -287,7 +287,7 @@ void InsetBox::doDispatch(Cursor & cur, FuncRequest & cmd)
        }
 
        default:
-               InsetCollapsable::doDispatch(cur, cmd);
+               InsetCollapsible::doDispatch(cur, cmd);
                break;
        }
 }
@@ -310,7 +310,7 @@ bool InsetBox::getStatus(Cursor & cur, FuncRequest const & cmd,
                        flag.setEnabled(true);
                        return true;
                }
-               return InsetCollapsable::getStatus(cur, cmd, flag);
+               return InsetCollapsible::getStatus(cur, cmd, flag);
        }
 
        case LFUN_INSET_DIALOG_UPDATE:
@@ -318,7 +318,7 @@ bool InsetBox::getStatus(Cursor & cur, FuncRequest const & cmd,
                return true;
 
        default:
-               return InsetCollapsable::getStatus(cur, cmd, flag);
+               return InsetCollapsible::getStatus(cur, cmd, flag);
        }
 }
 
@@ -730,7 +730,7 @@ void InsetBox::validate(LaTeXFeatures & features) const
                features.require("framed");
                break;
        }
-       InsetCollapsable::validate(features);
+       InsetCollapsible::validate(features);
 }
 
 
index 151d622fcb7b73b87fd86f1561941b15e5b72e71..d5610b746a0344a18d1cf551d5c72e91a3988e8f 100644 (file)
@@ -14,7 +14,7 @@
 #ifndef INSETBOX_H
 #define INSETBOX_H
 
-#include "InsetCollapsable.h"
+#include "InsetCollapsible.h"
 #include "Length.h"
 
 
@@ -74,7 +74,7 @@ public:
 ///////////////////////////////////////////////////////////////////////
 
 
-class InsetBox : public InsetCollapsable
+class InsetBox : public InsetCollapsible
 {
 public:
        ///
@@ -143,7 +143,7 @@ public:
        std::string contextMenuName() const;
        //@}
 
-       /// \name Public functions inherited from InsetCollapsable class
+       /// \name Public functions inherited from InsetCollapsible class
        //@{
        ///
        void setButtonLabel();
index 3d1a147a8626ae50ca38f768194af3ff3cde780a..77af2829e1a70421e319ea01bcbc03068aad03d5 100644 (file)
@@ -44,7 +44,7 @@ using namespace std;
 namespace lyx {
 
 InsetBranch::InsetBranch(Buffer * buf, InsetBranchParams const & params)
-       : InsetCollapsable(buf, InsetText::DefaultLayout), params_(params)
+       : InsetCollapsible(buf, InsetText::DefaultLayout), params_(params)
 {}
 
 
@@ -53,14 +53,14 @@ void InsetBranch::write(ostream & os) const
        os << "Branch ";
        params_.write(os);
        os << '\n';
-       InsetCollapsable::write(os);
+       InsetCollapsible::write(os);
 }
 
 
 void InsetBranch::read(Lexer & lex)
 {
        params_.read(lex);
-       InsetCollapsable::read(lex);
+       InsetCollapsible::read(lex);
 }
 
 
@@ -207,11 +207,11 @@ void InsetBranch::doDispatch(Cursor & cur, FuncRequest & cmd)
                if (cmd.argument() == "assign")
                        setStatus(cur, isBranchSelected() ? Open : Collapsed);
                else
-                       InsetCollapsable::doDispatch(cur, cmd);
+                       InsetCollapsible::doDispatch(cur, cmd);
                break;
 
        default:
-               InsetCollapsable::doDispatch(cur, cmd);
+               InsetCollapsible::doDispatch(cur, cmd);
                break;
        }
 }
@@ -259,11 +259,11 @@ bool InsetBranch::getStatus(Cursor & cur, FuncRequest const & cmd,
                if (cmd.argument() == "assign")
                        flag.setEnabled(true);
                else
-                       return InsetCollapsable::getStatus(cur, cmd, flag);
+                       return InsetCollapsible::getStatus(cur, cmd, flag);
                break;
 
        default:
-               return InsetCollapsable::getStatus(cur, cmd, flag);
+               return InsetCollapsible::getStatus(cur, cmd, flag);
        }
        return true;
 }
@@ -331,7 +331,7 @@ docstring InsetBranch::xhtml(XHTMLStream & xs, OutputParams const & rp) const
 void InsetBranch::toString(odocstream & os) const
 {
        if (producesOutput())
-               InsetCollapsable::toString(os);
+               InsetCollapsible::toString(os);
 }
 
 
@@ -339,14 +339,14 @@ void InsetBranch::forOutliner(docstring & os, size_t const maxlen,
                                                          bool const shorten) const
 {
        if (producesOutput())
-               InsetCollapsable::forOutliner(os, maxlen, shorten);
+               InsetCollapsible::forOutliner(os, maxlen, shorten);
 }
 
 
 void InsetBranch::validate(LaTeXFeatures & features) const
 {
        if (producesOutput())
-               InsetCollapsable::validate(features);
+               InsetCollapsible::validate(features);
 }
 
 
@@ -388,7 +388,7 @@ void InsetBranch::string2params(string const & in, InsetBranchParams & params)
 void InsetBranch::updateBuffer(ParIterator const & it, UpdateType utype)
 {
        setLabel(params_.branch + (params_.inverted ? " (-)" : ""));
-       InsetCollapsable::updateBuffer(it, utype);
+       InsetCollapsible::updateBuffer(it, utype);
 }
 
 
index bcb2cd8fd90e21217b0cb265eed89021dbccf725..391f2475f06765971a9d4d69afb324b5bef05943 100644 (file)
@@ -12,7 +12,7 @@
 #ifndef INSETBRANCH_H
 #define INSETBRANCH_H
 
-#include "InsetCollapsable.h"
+#include "InsetCollapsible.h"
 
 namespace lyx {
 
@@ -42,7 +42,7 @@ public:
 
 /// The Branch inset for alternative, conditional output.
 
-class InsetBranch : public InsetCollapsable
+class InsetBranch : public InsetCollapsible
 {
 public:
        ///
index 36ebfa0a95324c4362f300ad06c7aec25f5365ba..0850363bc43f98d40f8004b7227a3572411855ec 100644 (file)
@@ -57,7 +57,7 @@ InsetCaption::InsetCaption(Buffer * buf, string const & type)
       labelwidth_(0), is_subfloat_(false), type_(type)
 {
        setDrawFrame(true);
-       setFrameColor(Color_collapsableframe);
+       setFrameColor(Color_collapsibleframe);
 }
 
 
index 0683aa69485b86d0cd2fe8e8fd9087125f6af943..467106fa43e3e10888b7d68e633a4ca03aa5e96a 100644 (file)
@@ -110,7 +110,7 @@ void InsetCaptionable::addToToc(DocIterator const & cpit, bool output_active,
        TocBuilder & b = backend.builder(caption_type_);
        b.pushItem(pit, str, output_active);
        // Proceed with the rest of the inset.
-       InsetCollapsable::addToToc(cpit, output_active, utype, backend);
+       InsetCollapsible::addToToc(cpit, output_active, utype, backend);
        b.pop();
 }
 
@@ -131,7 +131,7 @@ void InsetCaptionable::updateBuffer(ParIterator const & it, UpdateType utype)
        // Tell captions what the current float is
        cnts.current_float(caption_type_);
        cnts.isSubfloat(subflt);
-       InsetCollapsable::updateBuffer(it, utype);
+       InsetCollapsible::updateBuffer(it, utype);
        // Restore counters
        cnts.current_float(saveflt);
        if (utype == OutputUpdate)
@@ -142,7 +142,7 @@ void InsetCaptionable::updateBuffer(ParIterator const & it, UpdateType utype)
 
 bool InsetCaptionable::insetAllowed(InsetCode c) const
 {
-       return (c == CAPTION_CODE) || InsetCollapsable::insetAllowed(c);
+       return (c == CAPTION_CODE) || InsetCollapsible::insetAllowed(c);
 }
 
 
index 005c371ea2b99448cad45ee437b636ff0f3a3260..8d0b486bcff7b3ccdb569f6cc9eea58eaba5d0b2 100644 (file)
 #ifndef INSET_CAPTIONABLE_H
 #define INSET_CAPTIONABLE_H
 
-#include "InsetCollapsable.h"
+#include "InsetCollapsible.h"
 
 
 namespace lyx {
 
-class InsetCaptionable : public InsetCollapsable
+class InsetCaptionable : public InsetCollapsible
 {
 public:
        InsetCaptionable(Buffer * buffer, std::string const & type = "senseless")
-               : InsetCollapsable(buffer), caption_type_(type) {}
+               : InsetCollapsible(buffer), caption_type_(type) {}
        ///
        std::string const & captionType() const { return caption_type_; }
        ///
index e580472ec37b6af9dbb341745410835c1a9e5a6a..3633da727ae45e684ebe54abed293d33ff0962d8 100644 (file)
@@ -111,7 +111,7 @@ enum InsetCode {
        ///
        INFO_CODE, // 45
        ///
-       COLLAPSABLE_CODE,
+       COLLAPSIBLE_CODE,
        ///
        PHANTOM_CODE,
        ///
diff --git a/src/insets/InsetCollapsable.cpp b/src/insets/InsetCollapsable.cpp
deleted file mode 100644 (file)
index ab84cc9..0000000
+++ /dev/null
@@ -1,694 +0,0 @@
-/**
- * \file InsetCollapsable.cpp
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author Alejandro Aguilar Sierra
- * \author Jürgen Vigna
- * \author Lars Gullik Bjønnes
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#include <config.h>
-
-#include "InsetCollapsable.h"
-
-#include "Buffer.h"
-#include "BufferView.h"
-#include "Cursor.h"
-#include "Dimension.h"
-#include "FuncRequest.h"
-#include "FuncStatus.h"
-#include "InsetLayout.h"
-#include "Lexer.h"
-#include "MetricsInfo.h"
-#include "OutputParams.h"
-#include "TocBackend.h"
-
-#include "frontends/FontMetrics.h"
-#include "frontends/Painter.h"
-
-#include "support/debug.h"
-#include "support/docstream.h"
-#include "support/gettext.h"
-#include "support/lassert.h"
-#include "support/lstrings.h"
-#include "support/RefChanger.h"
-
-using namespace std;
-
-
-namespace lyx {
-
-InsetCollapsable::InsetCollapsable(Buffer * buf, InsetText::UsePlain ltype)
-       : InsetText(buf, ltype), status_(Open)
-{
-       setDrawFrame(true);
-       setFrameColor(Color_collapsableframe);
-}
-
-
-// The sole purpose of this copy constructor is to make sure
-// that the view_ map is not copied and remains empty.
-InsetCollapsable::InsetCollapsable(InsetCollapsable const & rhs)
-       : InsetText(rhs),
-         status_(rhs.status_),
-         labelstring_(rhs.labelstring_)
-{}
-
-
-InsetCollapsable::~InsetCollapsable()
-{
-       map<BufferView const *, View>::iterator it = view_.begin();
-       map<BufferView const *, View>::iterator end = view_.end();
-       for (; it != end; ++it)
-               if (it->second.mouse_hover_)
-                       it->first->clearLastInset(this);
-}
-
-
-InsetCollapsable::CollapseStatus InsetCollapsable::status(BufferView const & bv) const
-{
-       if (decoration() == InsetLayout::CONGLOMERATE)
-               return status_;
-       return view_[&bv].auto_open_ ? Open : status_;
-}
-
-
-InsetCollapsable::Geometry InsetCollapsable::geometry(BufferView const & bv) const
-{
-       switch (decoration()) {
-       case InsetLayout::CLASSIC:
-               if (status(bv) == Open)
-                       return view_[&bv].openinlined_ ? LeftButton : TopButton;
-               return ButtonOnly;
-
-       case InsetLayout::MINIMALISTIC:
-               return status(bv) == Open ? NoButton : ButtonOnly ;
-
-       case InsetLayout::CONGLOMERATE:
-               return status(bv) == Open ? SubLabel : Corners ;
-
-       case InsetLayout::DEFAULT:
-               break; // this shouldn't happen
-       }
-
-       // dummy return value to shut down a warning,
-       // this is dead code.
-       return NoButton;
-}
-
-
-docstring InsetCollapsable::toolTip(BufferView const & bv, int x, int y) const
-{
-       Dimension const dim = dimensionCollapsed(bv);
-       if (geometry(bv) == NoButton)
-               return translateIfPossible(getLayout().labelstring());
-       if (x > xo(bv) + dim.wid || y > yo(bv) + dim.des || isOpen(bv))
-               return docstring();
-
-       return toolTipText();
-}
-
-
-void InsetCollapsable::write(ostream & os) const
-{
-       os << "status ";
-       switch (status_) {
-       case Open:
-               os << "open";
-               break;
-       case Collapsed:
-               os << "collapsed";
-               break;
-       }
-       os << "\n";
-       text().write(os);
-}
-
-
-void InsetCollapsable::read(Lexer & lex)
-{
-       lex.setContext("InsetCollapsable::read");
-       string tmp_token;
-       status_ = Collapsed;
-       lex >> "status" >> tmp_token;
-       if (tmp_token == "open")
-               status_ = Open;
-
-       InsetText::read(lex);
-       setButtonLabel();
-}
-
-
-Dimension InsetCollapsable::dimensionCollapsed(BufferView const & bv) const
-{
-       Dimension dim;
-       FontInfo labelfont(getLabelfont());
-       labelfont.realize(sane_font);
-       theFontMetrics(labelfont).buttonText(
-               buttonLabel(bv), TEXT_TO_INSET_OFFSET, dim.wid, dim.asc, dim.des);
-       return dim;
-}
-
-
-void InsetCollapsable::metrics(MetricsInfo & mi, Dimension & dim) const
-{
-       view_[mi.base.bv].auto_open_ = mi.base.bv->cursor().isInside(this);
-
-       FontInfo tmpfont = mi.base.font;
-       mi.base.font = getFont();
-       mi.base.font.realize(tmpfont);
-
-       BufferView const & bv = *mi.base.bv;
-
-       switch (geometry(bv)) {
-       case NoButton:
-               InsetText::metrics(mi, dim);
-               break;
-       case Corners:
-               InsetText::metrics(mi, dim);
-               dim.des -= 3;
-               dim.asc -= 1;
-               break;
-       case SubLabel: {
-               InsetText::metrics(mi, dim);
-               // consider width of the inset label
-               FontInfo font(getLabelfont());
-               font.realize(sane_font);
-               font.decSize();
-               font.decSize();
-               int w = 0;
-               int a = 0;
-               int d = 0;
-               theFontMetrics(font).rectText(buttonLabel(bv), w, a, d);
-               dim.des += a + d;
-               break;
-               }
-       case TopButton:
-       case LeftButton:
-       case ButtonOnly:
-               if (hasFixedWidth()){
-                       int const mindim = view_[&bv].button_dim_.x2 - view_[&bv].button_dim_.x1;
-                       if (mi.base.textwidth < mindim)
-                               mi.base.textwidth = mindim;
-               }
-               dim = dimensionCollapsed(bv);
-               if (geometry(bv) == TopButton || geometry(bv) == LeftButton) {
-                       Dimension textdim;
-                       InsetText::metrics(mi, textdim);
-                       view_[&bv].openinlined_ = (textdim.wid + dim.wid) < mi.base.textwidth;
-                       if (view_[&bv].openinlined_) {
-                               // Correct for button width.
-                               dim.wid += textdim.wid;
-                               dim.des = max(dim.des - textdim.asc + dim.asc, textdim.des);
-                               dim.asc = textdim.asc;
-                       } else {
-                               dim.des += textdim.height() + TEXT_TO_INSET_OFFSET;
-                               dim.wid = max(dim.wid, textdim.wid);
-                       }
-               }
-               break;
-       }
-
-       mi.base.font = tmpfont;
-}
-
-
-bool InsetCollapsable::setMouseHover(BufferView const * bv, bool mouse_hover)
-       const
-{
-       view_[bv].mouse_hover_ = mouse_hover;
-       return true;
-}
-
-
-void InsetCollapsable::draw(PainterInfo & pi, int x, int y) const
-{
-       BufferView const & bv = *pi.base.bv;
-
-       view_[&bv].auto_open_ = bv.cursor().isInside(this);
-
-       Changer dummy = pi.base.font.change(getFont(), true);
-
-       // Draw button first -- top, left or only
-       Dimension dimc = dimensionCollapsed(bv);
-
-       if (geometry(bv) == TopButton ||
-           geometry(bv) == LeftButton ||
-           geometry(bv) == ButtonOnly) {
-               view_[&bv].button_dim_.x1 = x + 0;
-               view_[&bv].button_dim_.x2 = x + dimc.width();
-               view_[&bv].button_dim_.y1 = y - dimc.asc;
-               view_[&bv].button_dim_.y2 = y + dimc.des;
-
-               FontInfo labelfont = getLabelfont();
-               labelfont.setColor(labelColor());
-               labelfont.realize(pi.base.font);
-               pi.pain.buttonText(x, y, buttonLabel(bv), labelfont,
-                                  view_[&bv].mouse_hover_ ? Color_buttonhoverbg : Color_buttonbg,
-                                  Color_buttonframe, TEXT_TO_INSET_OFFSET);
-               // Draw the change tracking cue on the label, unless RowPainter already
-               // takes care of it.
-               if (canPaintChange(bv))
-                       pi.change_.paintCue(pi, x, y, x + dimc.width(), labelfont);
-       } else {
-               view_[&bv].button_dim_.x1 = 0;
-               view_[&bv].button_dim_.y1 = 0;
-               view_[&bv].button_dim_.x2 = 0;
-               view_[&bv].button_dim_.y2 = 0;
-       }
-
-       Dimension const textdim = dimensionHelper(bv);
-       int const baseline = y;
-       int textx, texty;
-       Geometry g = geometry(bv);
-       switch (g) {
-       case LeftButton:
-       case TopButton: {
-               if (g == LeftButton) {
-                       textx = x + dimc.width();
-                       texty = baseline;
-               } else {
-                       textx = x;
-                       texty = baseline + dimc.des + textdim.asc;
-               }
-               // Do not draw the cue for INSERTED -- it is already in the button and
-               // that's enough.
-               Changer dummy = (pi.change_.type == Change::INSERTED)
-                       ? make_change(pi.change_, Change())
-                       : Changer();
-               InsetText::draw(pi, textx, texty);
-               break;
-       }
-       case ButtonOnly:
-               break;
-       case NoButton:
-               textx = x;
-               texty = baseline;
-               InsetText::draw(pi, textx, texty);
-               break;
-       case SubLabel:
-       case Corners:
-               textx = x;
-               texty = baseline;
-               {       // We will take care of the frame and the change tracking cue
-                       // ourselves, below.
-                       Changer dummy = make_change(pi.change_, Change());
-                       const_cast<InsetCollapsable *>(this)->setDrawFrame(false);
-                       InsetText::draw(pi, textx, texty);
-                       const_cast<InsetCollapsable *>(this)->setDrawFrame(true);
-               }
-
-               int desc = textdim.descent();
-               if (g == Corners)
-                       desc -= 3;
-
-               // Colour the frame according to the change type. (Like for tables.)
-               Color colour = pi.change_.changed() ? pi.change_.color()
-                                                   : Color_foreground;
-               const int xx1 = x + TEXT_TO_INSET_OFFSET - 1;
-               const int xx2 = x + textdim.wid - TEXT_TO_INSET_OFFSET + 1;
-               pi.pain.line(xx1, y + desc - 4,
-                            xx1, y + desc, colour);
-               if (status_ == Open)
-                       pi.pain.line(xx1, y + desc,
-                                    xx2, y + desc, colour);
-               else {
-                       // Make status_ value visible:
-                       pi.pain.line(xx1, y + desc,
-                                    xx1 + 4, y + desc, colour);
-                       pi.pain.line(xx2 - 4, y + desc,
-                                    xx2, y + desc, colour);
-               }
-               pi.pain.line(x + textdim.wid - 3, y + desc, x + textdim.wid - 3,
-                            y + desc - 4, colour);
-
-               // the label below the text. Can be toggled.
-               if (g == SubLabel) {
-                       FontInfo font(getLabelfont());
-                       if (pi.change_.changed())
-                               font.setPaintColor(colour);
-                       font.realize(sane_font);
-                       font.decSize();
-                       font.decSize();
-                       int w = 0;
-                       int a = 0;
-                       int d = 0;
-                       Color const col = pi.full_repaint ? Color_none : pi.backgroundColor(this);
-                       theFontMetrics(font).rectText(buttonLabel(bv), w, a, d);
-                       int const ww = max(textdim.wid, w);
-                       pi.pain.rectText(x + (ww - w) / 2, y + desc + a,
-                                        buttonLabel(bv), font, col, Color_none);
-               }
-
-               int const y1 = y - textdim.asc + 3;
-               // a visual cue when the cursor is inside the inset
-               Cursor const & cur = bv.cursor();
-               if (cur.isInside(this)) {
-                       pi.pain.line(xx1, y1 + 4, xx1, y1, colour);
-                       pi.pain.line(xx1 + 4, y1, xx1, y1, colour);
-                       pi.pain.line(xx2, y1 + 4, xx2, y1, colour);
-                       pi.pain.line(xx2 - 4, y1, xx2, y1, colour);
-               }
-               // Strike through the inset if deleted and not already handled by
-               // RowPainter.
-               if (pi.change_.deleted() && canPaintChange(bv))
-                       pi.change_.paintCue(pi, xx1, y1, xx2, y + desc);
-               break;
-       }
-}
-
-
-void InsetCollapsable::cursorPos(BufferView const & bv,
-               CursorSlice const & sl, bool boundary, int & x, int & y) const
-{
-       if (geometry(bv) == ButtonOnly)
-               status_ = Open;
-
-       InsetText::cursorPos(bv, sl, boundary, x, y);
-       Dimension const textdim = dimensionHelper(bv);
-
-       switch (geometry(bv)) {
-       case LeftButton:
-               x += dimensionCollapsed(bv).wid;
-               break;
-       case TopButton: {
-               y += dimensionCollapsed(bv).des + textdim.asc;
-               break;
-       }
-       case NoButton:
-       case SubLabel:
-       case Corners:
-               // Do nothing
-               break;
-       case ButtonOnly:
-               // Cannot get here
-               break;
-       }
-}
-
-
-bool InsetCollapsable::editable() const
-{
-       switch (decoration()) {
-       case InsetLayout::CLASSIC:
-       case InsetLayout::MINIMALISTIC:
-               return status_ == Open;
-       default:
-               return true;
-       }
-}
-
-
-bool InsetCollapsable::descendable(BufferView const & bv) const
-{
-       return geometry(bv) != ButtonOnly;
-}
-
-
-bool InsetCollapsable::clickable(BufferView const & bv, int x, int y) const
-{
-       return view_[&bv].button_dim_.contains(x, y);
-}
-
-
-docstring const InsetCollapsable::getNewLabel(docstring const & l) const
-{
-       odocstringstream label;
-       pos_type const max_length = 15;
-       pos_type const p_siz = paragraphs().begin()->size();
-       pos_type const n = min(max_length, p_siz);
-       pos_type i = 0;
-       pos_type j = 0;
-       for (; i < n && j < p_siz; ++j) {
-               if (paragraphs().begin()->isInset(j)) {
-                       if (!paragraphs().begin()->getInset(j)->isChar())
-                               continue;
-                       paragraphs().begin()->getInset(j)->toString(label);
-               } else
-                       label.put(paragraphs().begin()->getChar(j));
-               ++i;
-       }
-       if (paragraphs().size() > 1 || (i > 0 && j < p_siz)) {
-               label << "...";
-       }
-       docstring const lbl = label.str();
-       return lbl.empty() ? l : lbl;
-}
-
-
-void InsetCollapsable::edit(Cursor & cur, bool front, EntryDirection entry_from)
-{
-       //lyxerr << "InsetCollapsable: edit left/right" << endl;
-       cur.push(*this);
-       InsetText::edit(cur, front, entry_from);
-}
-
-
-Inset * InsetCollapsable::editXY(Cursor & cur, int x, int y)
-{
-       //lyxerr << "InsetCollapsable: edit xy" << endl;
-       if (geometry(cur.bv()) == ButtonOnly
-           || (view_[&cur.bv()].button_dim_.contains(x, y)
-               && geometry(cur.bv()) != NoButton))
-               return this;
-       cur.push(*this);
-       return InsetText::editXY(cur, x, y);
-}
-
-
-void InsetCollapsable::doDispatch(Cursor & cur, FuncRequest & cmd)
-{
-       //lyxerr << "InsetCollapsable::doDispatch (begin): cmd: " << cmd
-       //      << " cur: " << cur << " bvcur: " << cur.bv().cursor() << endl;
-
-       bool const hitButton = clickable(cur.bv(), cmd.x(), cmd.y());
-
-       switch (cmd.action()) {
-       case LFUN_MOUSE_PRESS:
-               if (hitButton) {
-                       switch (cmd.button()) {
-                       case mouse_button::button1:
-                       case mouse_button::button3:
-                               // Pass the command to the enclosing InsetText,
-                               // so that the cursor gets set.
-                               cur.undispatched();
-                               break;
-                       case mouse_button::none:
-                       case mouse_button::button2:
-                       case mouse_button::button4:
-                       case mouse_button::button5:
-                               // Nothing to do.
-                               cur.noScreenUpdate();
-                               break;
-                       }
-               } else if (geometry(cur.bv()) != ButtonOnly)
-                       InsetText::doDispatch(cur, cmd);
-               else
-                       cur.undispatched();
-               break;
-
-       case LFUN_MOUSE_DOUBLE:
-       case LFUN_MOUSE_TRIPLE:
-               if (hitButton)
-                       cur.noScreenUpdate();
-               else if (geometry(cur.bv()) != ButtonOnly)
-                       InsetText::doDispatch(cur, cmd);
-               else
-                       cur.undispatched();
-               break;
-
-       case LFUN_MOUSE_RELEASE:
-               if (!hitButton) {
-                       // The mouse click has to be within the inset!
-                       if (geometry(cur.bv()) != ButtonOnly)
-                               InsetText::doDispatch(cur, cmd);
-                       else
-                               cur.undispatched();
-                       break;
-               }
-               if (cmd.button() != mouse_button::button1) {
-                       // Nothing to do.
-                       cur.noScreenUpdate();
-                       break;
-               }
-               // if we are selecting, we do not want to
-               // toggle the inset.
-               if (cur.selection())
-                       break;
-               // Left button is clicked, the user asks to
-               // toggle the inset visual state.
-               cur.dispatched();
-               cur.screenUpdateFlags(Update::Force | Update::FitCursor);
-               if (geometry(cur.bv()) == ButtonOnly) {
-                       setStatus(cur, Open);
-                       edit(cur, true);
-               }
-               else
-                       setStatus(cur, Collapsed);
-               cur.bv().cursor() = cur;
-               break;
-
-       case LFUN_INSET_TOGGLE:
-               if (cmd.argument() == "open")
-                       setStatus(cur, Open);
-               else if (cmd.argument() == "close")
-                       setStatus(cur, Collapsed);
-               else if (cmd.argument() == "toggle" || cmd.argument().empty())
-                       if (status_ == Open)
-                               setStatus(cur, Collapsed);
-                       else
-                               setStatus(cur, Open);
-               else // if assign or anything else
-                       cur.undispatched();
-               cur.dispatched();
-               break;
-
-       default:
-               InsetText::doDispatch(cur, cmd);
-               break;
-       }
-}
-
-
-bool InsetCollapsable::getStatus(Cursor & cur, FuncRequest const & cmd,
-               FuncStatus & flag) const
-{
-       switch (cmd.action()) {
-       case LFUN_INSET_TOGGLE:
-               if (cmd.argument() == "open")
-                       flag.setEnabled(status_ != Open);
-               else if (cmd.argument() == "close")
-                       flag.setEnabled(status_ == Open);
-               else if (cmd.argument() == "toggle" || cmd.argument().empty()) {
-                       flag.setEnabled(true);
-                       flag.setOnOff(status_ == Open);
-               } else
-                       flag.setEnabled(false);
-               return true;
-
-       default:
-               return InsetText::getStatus(cur, cmd, flag);
-       }
-}
-
-
-void InsetCollapsable::setLabel(docstring const & l)
-{
-       labelstring_ = l;
-}
-
-
-docstring InsetCollapsable::getLabel() const
-{
-       InsetLayout const & il = getLayout();
-       return labelstring_.empty() ?
-               translateIfPossible(il.labelstring()) : labelstring_;
-}
-
-
-docstring const InsetCollapsable::buttonLabel(BufferView const & bv) const
-{
-       InsetLayout const & il = getLayout();
-       docstring const label = getLabel();
-       if (!il.contentaslabel() || geometry(bv) != ButtonOnly)
-               return label;
-       return getNewLabel(label);
-}
-
-
-void InsetCollapsable::setStatus(Cursor & cur, CollapseStatus status)
-{
-       status_ = status;
-       setButtonLabel();
-       if (status_ == Collapsed)
-               cur.leaveInset(*this);
-}
-
-
-InsetLayout::InsetDecoration InsetCollapsable::decoration() const
-{
-       InsetLayout::InsetDecoration const dec = getLayout().decoration();
-       return dec == InsetLayout::DEFAULT ? InsetLayout::CLASSIC : dec;
-}
-
-
-string InsetCollapsable::contextMenu(BufferView const & bv, int x,
-       int y) const
-{
-       string context_menu = contextMenuName();
-       string const it_context_menu = InsetText::contextMenuName();
-       if (decoration() == InsetLayout::CONGLOMERATE)
-               return context_menu + ";" + it_context_menu;
-
-       string const ic_context_menu = InsetCollapsable::contextMenuName();
-       if (ic_context_menu != context_menu)
-               context_menu += ";" + ic_context_menu;
-
-       if (geometry(bv) == NoButton)
-               return context_menu + ";" + it_context_menu;
-
-       Dimension dim = dimensionCollapsed(bv);
-       if (x < xo(bv) + dim.wid && y < yo(bv) + dim.des)
-               return context_menu;
-
-       return it_context_menu;
-}
-
-
-string InsetCollapsable::contextMenuName() const
-{
-       if (decoration() == InsetLayout::CONGLOMERATE)
-               return "context-conglomerate";
-       else
-               return "context-collapsable";
-}
-
-
-bool InsetCollapsable::canPaintChange(BufferView const & bv) const
-{
-       // return false to let RowPainter draw the change tracking cue consistently
-       // with the surrounding text, when the inset is inline: for buttons, for
-       // non-allowMultiPar insets.
-       switch (geometry(bv)) {
-       case Corners:
-       case SubLabel:
-               return allowMultiPar();
-       case ButtonOnly:
-               return false;
-       default:
-               break;
-       }
-       return true;
-}
-
-
-void InsetCollapsable::addToToc(DocIterator const & cpit, bool output_active,
-                                UpdateType utype, TocBackend & backend) const
-{
-       bool doing_output = output_active && producesOutput();
-       InsetLayout const & layout = getLayout();
-       if (layout.addToToc()) {
-               TocBuilder & b = backend.builder(layout.tocType());
-               // Cursor inside the inset
-               DocIterator pit = cpit;
-               pit.push_back(CursorSlice(const_cast<InsetCollapsable &>(*this)));
-               docstring const label = getLabel();
-               b.pushItem(pit, label + (label.empty() ? "" : ": "), output_active);
-               // Proceed with the rest of the inset.
-               InsetText::addToToc(cpit, doing_output, utype, backend);
-               if (layout.isTocCaption()) {
-                       docstring str;
-                       text().forOutliner(str, TOC_ENTRY_LENGTH);
-                       b.argumentItem(str);
-               }
-               b.pop();
-       } else
-               InsetText::addToToc(cpit, doing_output, utype, backend);
-}
-
-
-
-} // namespace lyx
diff --git a/src/insets/InsetCollapsable.h b/src/insets/InsetCollapsable.h
deleted file mode 100644 (file)
index bb4f234..0000000
+++ /dev/null
@@ -1,193 +0,0 @@
-// -*- C++ -*-
-/**
- * \file InsetCollapsable.h
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author Alejandro Aguilar Sierra
- * \author Jürgen Vigna
- * \author Lars Gullik Bjønnes
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#ifndef INSETCOLLAPSABLE_H
-#define INSETCOLLAPSABLE_H
-
-#include "InsetText.h"
-
-#include "Box.h"
-
-#include <map>
-
-namespace lyx {
-
-class CursorSlice;
-class InsetLayout;
-
-namespace frontend { class Painter; }
-
-/** A collapsable text inset
-
-*/
-class InsetCollapsable : public InsetText {
-public:
-       ///
-       InsetCollapsable(Buffer *, InsetText::UsePlain = InsetText::PlainLayout);
-       ///
-       InsetCollapsable(InsetCollapsable const & rhs);
-       ///
-       virtual ~InsetCollapsable();
-       ///
-       InsetCollapsable * asInsetCollapsable() { return this; }
-       ///
-       InsetCollapsable const * asInsetCollapsable() const { return this; }
-       ///
-       docstring toolTip(BufferView const & bv, int x, int y) const;
-       ///
-       docstring layoutName() const { return from_ascii("Collapsable"); }
-       ///
-       void read(Lexer &);
-       ///
-       void write(std::ostream &) const;
-       ///
-       void metrics(MetricsInfo &, Dimension &) const;
-       ///
-       void draw(PainterInfo & pi, int x, int y) const;
-       ///
-       virtual void drawBackground(PainterInfo &, int, int) const {}
-
-       /// return x,y of given position relative to the inset's baseline
-       void cursorPos(BufferView const & bv, CursorSlice const & sl,
-               bool boundary, int & x, int & y) const;
-       ///
-       docstring const getNewLabel(docstring const & l) const;
-       ///
-       bool editable() const;
-       ///
-       bool hasSettings() const { return true; }
-       /// Returns true if coordinates are over the inset's button.
-       /// Always returns false when the inset does not have a
-       /// button.
-       bool clickable(BufferView const & bv, int x, int y) const;
-       /// can we go further down on mouse click?
-       bool descendable(BufferView const & bv) const;
-       ///
-       void setLabel(docstring const & l);
-       ///
-       docstring getLabel() const;
-       ///
-       virtual void setButtonLabel() {}
-       ///
-       virtual docstring const buttonLabel(BufferView const &) const;
-       ///
-       bool isOpen(BufferView const & bv) const
-               { return geometry(bv) != ButtonOnly; }
-       ///
-       enum CollapseStatus {
-               Collapsed,
-               Open
-       };
-       ///
-       virtual void setStatus(Cursor & cur, CollapseStatus st);
-       ///
-       CollapseStatus status(BufferView const & bv) const;
-       /** Of the old CollapseStatus we only keep the values
-        *  Open and Collapsed.
-        * We define a list of possible inset decoration
-        * styles, and a list of possible (concrete, visual)
-        * inset geometries. Relationships between them
-        * (geometries in body of table):
-        *
-        *               \       CollapseStatus:
-        *   Decoration:  \ Open                Collapsed
-        *   -------------+-------------------------------
-        *   Classic      | *) TopButton, <--x) ButtonOnly
-        *                | LeftButton
-        *   Minimalistic | NoButton            ButtonOnly
-        *   Conglomerate | SubLabel            Corners
-        *   ---------------------------------------------
-        *   *) toggled by openinlined_
-        *   x) toggled by auto_open_
-        */
-
-       /// Default looks
-       virtual InsetLayout::InsetDecoration decoration() const;
-       /// Inset font
-       virtual FontInfo getFont() const { return getLayout().font(); }
-       /// Label font
-       virtual FontInfo getLabelfont() const { return getLayout().labelfont(); }
-       ///
-       enum Geometry {
-               TopButton,
-               ButtonOnly,
-               NoButton,
-               LeftButton,
-               SubLabel,
-               Corners
-       };
-       /// Returns the geometry based on CollapseStatus
-       /// (status_), auto_open_[BufferView] and openinlined_,
-       /// and of course decoration().
-       Geometry geometry(BufferView const & bv) const;
-       ///
-       bool canPaintChange(BufferView const & bv) const;
-       ///
-       bool getStatus(Cursor &, FuncRequest const &, FuncStatus &) const;
-       ///
-       bool setMouseHover(BufferView const * bv, bool mouse_hover) const;
-       ///
-       ColorCode backgroundColor(PainterInfo const &) const
-               { return getLayout().bgcolor(); }
-       ///
-       ColorCode labelColor() const { return getLayout().labelfont().color(); }
-       ///
-       InsetCode lyxCode() const { return COLLAPSABLE_CODE; }
-
-       ///
-       virtual bool usePlainLayout() const { return true; }
-       ///
-       std::string contextMenu(BufferView const & bv, int x, int y) const;
-       ///
-       std::string contextMenuName() const;
-       ///
-       void addToToc(DocIterator const & dit, bool output_active,
-                     UpdateType utype, TocBackend & backend) const; //override
-
-protected:
-       ///
-       void doDispatch(Cursor & cur, FuncRequest & cmd);
-       ///
-       void edit(Cursor & cur, bool front,
-               EntryDirection entry_from = ENTRY_DIRECTION_IGNORE);
-       ///
-       Inset * editXY(Cursor & cur, int x, int y);
-       ///
-       mutable CollapseStatus status_;
-private:
-       ///
-       Dimension dimensionCollapsed(BufferView const & bv) const;
-       ///
-       docstring labelstring_;
-
-       // These variables depend of the view in which the inset is displayed
-       struct View
-       {
-               /// The dimension of the inset button
-               Box button_dim_;
-               /// a substatus of the Open status, determined automatically in metrics
-               bool openinlined_;
-               /// the inset will automatically open when the cursor is inside. This is
-               /// dependent on the bufferview, compare with InsetMathMacro::editing_.
-               bool auto_open_;
-               /// changes color when mouse enters/leaves this inset
-               bool mouse_hover_;
-       };
-
-       ///
-       mutable std::map<BufferView const *, View> view_;
-};
-
-} // namespace lyx
-
-#endif
diff --git a/src/insets/InsetCollapsible.cpp b/src/insets/InsetCollapsible.cpp
new file mode 100644 (file)
index 0000000..11c9e2a
--- /dev/null
@@ -0,0 +1,694 @@
+/**
+ * \file InsetCollapsible.cpp
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Alejandro Aguilar Sierra
+ * \author Jürgen Vigna
+ * \author Lars Gullik Bjønnes
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#include <config.h>
+
+#include "InsetCollapsible.h"
+
+#include "Buffer.h"
+#include "BufferView.h"
+#include "Cursor.h"
+#include "Dimension.h"
+#include "FuncRequest.h"
+#include "FuncStatus.h"
+#include "InsetLayout.h"
+#include "Lexer.h"
+#include "MetricsInfo.h"
+#include "OutputParams.h"
+#include "TocBackend.h"
+
+#include "frontends/FontMetrics.h"
+#include "frontends/Painter.h"
+
+#include "support/debug.h"
+#include "support/docstream.h"
+#include "support/gettext.h"
+#include "support/lassert.h"
+#include "support/lstrings.h"
+#include "support/RefChanger.h"
+
+using namespace std;
+
+
+namespace lyx {
+
+InsetCollapsible::InsetCollapsible(Buffer * buf, InsetText::UsePlain ltype)
+       : InsetText(buf, ltype), status_(Open)
+{
+       setDrawFrame(true);
+       setFrameColor(Color_collapsibleframe);
+}
+
+
+// The sole purpose of this copy constructor is to make sure
+// that the view_ map is not copied and remains empty.
+InsetCollapsible::InsetCollapsible(InsetCollapsible const & rhs)
+       : InsetText(rhs),
+         status_(rhs.status_),
+         labelstring_(rhs.labelstring_)
+{}
+
+
+InsetCollapsible::~InsetCollapsible()
+{
+       map<BufferView const *, View>::iterator it = view_.begin();
+       map<BufferView const *, View>::iterator end = view_.end();
+       for (; it != end; ++it)
+               if (it->second.mouse_hover_)
+                       it->first->clearLastInset(this);
+}
+
+
+InsetCollapsible::CollapseStatus InsetCollapsible::status(BufferView const & bv) const
+{
+       if (decoration() == InsetLayout::CONGLOMERATE)
+               return status_;
+       return view_[&bv].auto_open_ ? Open : status_;
+}
+
+
+InsetCollapsible::Geometry InsetCollapsible::geometry(BufferView const & bv) const
+{
+       switch (decoration()) {
+       case InsetLayout::CLASSIC:
+               if (status(bv) == Open)
+                       return view_[&bv].openinlined_ ? LeftButton : TopButton;
+               return ButtonOnly;
+
+       case InsetLayout::MINIMALISTIC:
+               return status(bv) == Open ? NoButton : ButtonOnly ;
+
+       case InsetLayout::CONGLOMERATE:
+               return status(bv) == Open ? SubLabel : Corners ;
+
+       case InsetLayout::DEFAULT:
+               break; // this shouldn't happen
+       }
+
+       // dummy return value to shut down a warning,
+       // this is dead code.
+       return NoButton;
+}
+
+
+docstring InsetCollapsible::toolTip(BufferView const & bv, int x, int y) const
+{
+       Dimension const dim = dimensionCollapsed(bv);
+       if (geometry(bv) == NoButton)
+               return translateIfPossible(getLayout().labelstring());
+       if (x > xo(bv) + dim.wid || y > yo(bv) + dim.des || isOpen(bv))
+               return docstring();
+
+       return toolTipText();
+}
+
+
+void InsetCollapsible::write(ostream & os) const
+{
+       os << "status ";
+       switch (status_) {
+       case Open:
+               os << "open";
+               break;
+       case Collapsed:
+               os << "collapsed";
+               break;
+       }
+       os << "\n";
+       text().write(os);
+}
+
+
+void InsetCollapsible::read(Lexer & lex)
+{
+       lex.setContext("InsetCollapsible::read");
+       string tmp_token;
+       status_ = Collapsed;
+       lex >> "status" >> tmp_token;
+       if (tmp_token == "open")
+               status_ = Open;
+
+       InsetText::read(lex);
+       setButtonLabel();
+}
+
+
+Dimension InsetCollapsible::dimensionCollapsed(BufferView const & bv) const
+{
+       Dimension dim;
+       FontInfo labelfont(getLabelfont());
+       labelfont.realize(sane_font);
+       theFontMetrics(labelfont).buttonText(
+               buttonLabel(bv), TEXT_TO_INSET_OFFSET, dim.wid, dim.asc, dim.des);
+       return dim;
+}
+
+
+void InsetCollapsible::metrics(MetricsInfo & mi, Dimension & dim) const
+{
+       view_[mi.base.bv].auto_open_ = mi.base.bv->cursor().isInside(this);
+
+       FontInfo tmpfont = mi.base.font;
+       mi.base.font = getFont();
+       mi.base.font.realize(tmpfont);
+
+       BufferView const & bv = *mi.base.bv;
+
+       switch (geometry(bv)) {
+       case NoButton:
+               InsetText::metrics(mi, dim);
+               break;
+       case Corners:
+               InsetText::metrics(mi, dim);
+               dim.des -= 3;
+               dim.asc -= 1;
+               break;
+       case SubLabel: {
+               InsetText::metrics(mi, dim);
+               // consider width of the inset label
+               FontInfo font(getLabelfont());
+               font.realize(sane_font);
+               font.decSize();
+               font.decSize();
+               int w = 0;
+               int a = 0;
+               int d = 0;
+               theFontMetrics(font).rectText(buttonLabel(bv), w, a, d);
+               dim.des += a + d;
+               break;
+               }
+       case TopButton:
+       case LeftButton:
+       case ButtonOnly:
+               if (hasFixedWidth()){
+                       int const mindim = view_[&bv].button_dim_.x2 - view_[&bv].button_dim_.x1;
+                       if (mi.base.textwidth < mindim)
+                               mi.base.textwidth = mindim;
+               }
+               dim = dimensionCollapsed(bv);
+               if (geometry(bv) == TopButton || geometry(bv) == LeftButton) {
+                       Dimension textdim;
+                       InsetText::metrics(mi, textdim);
+                       view_[&bv].openinlined_ = (textdim.wid + dim.wid) < mi.base.textwidth;
+                       if (view_[&bv].openinlined_) {
+                               // Correct for button width.
+                               dim.wid += textdim.wid;
+                               dim.des = max(dim.des - textdim.asc + dim.asc, textdim.des);
+                               dim.asc = textdim.asc;
+                       } else {
+                               dim.des += textdim.height() + TEXT_TO_INSET_OFFSET;
+                               dim.wid = max(dim.wid, textdim.wid);
+                       }
+               }
+               break;
+       }
+
+       mi.base.font = tmpfont;
+}
+
+
+bool InsetCollapsible::setMouseHover(BufferView const * bv, bool mouse_hover)
+       const
+{
+       view_[bv].mouse_hover_ = mouse_hover;
+       return true;
+}
+
+
+void InsetCollapsible::draw(PainterInfo & pi, int x, int y) const
+{
+       BufferView const & bv = *pi.base.bv;
+
+       view_[&bv].auto_open_ = bv.cursor().isInside(this);
+
+       Changer dummy = pi.base.font.change(getFont(), true);
+
+       // Draw button first -- top, left or only
+       Dimension dimc = dimensionCollapsed(bv);
+
+       if (geometry(bv) == TopButton ||
+           geometry(bv) == LeftButton ||
+           geometry(bv) == ButtonOnly) {
+               view_[&bv].button_dim_.x1 = x + 0;
+               view_[&bv].button_dim_.x2 = x + dimc.width();
+               view_[&bv].button_dim_.y1 = y - dimc.asc;
+               view_[&bv].button_dim_.y2 = y + dimc.des;
+
+               FontInfo labelfont = getLabelfont();
+               labelfont.setColor(labelColor());
+               labelfont.realize(pi.base.font);
+               pi.pain.buttonText(x, y, buttonLabel(bv), labelfont,
+                                  view_[&bv].mouse_hover_ ? Color_buttonhoverbg : Color_buttonbg,
+                                  Color_buttonframe, TEXT_TO_INSET_OFFSET);
+               // Draw the change tracking cue on the label, unless RowPainter already
+               // takes care of it.
+               if (canPaintChange(bv))
+                       pi.change_.paintCue(pi, x, y, x + dimc.width(), labelfont);
+       } else {
+               view_[&bv].button_dim_.x1 = 0;
+               view_[&bv].button_dim_.y1 = 0;
+               view_[&bv].button_dim_.x2 = 0;
+               view_[&bv].button_dim_.y2 = 0;
+       }
+
+       Dimension const textdim = dimensionHelper(bv);
+       int const baseline = y;
+       int textx, texty;
+       Geometry g = geometry(bv);
+       switch (g) {
+       case LeftButton:
+       case TopButton: {
+               if (g == LeftButton) {
+                       textx = x + dimc.width();
+                       texty = baseline;
+               } else {
+                       textx = x;
+                       texty = baseline + dimc.des + textdim.asc;
+               }
+               // Do not draw the cue for INSERTED -- it is already in the button and
+               // that's enough.
+               Changer dummy = (pi.change_.type == Change::INSERTED)
+                       ? make_change(pi.change_, Change())
+                       : Changer();
+               InsetText::draw(pi, textx, texty);
+               break;
+       }
+       case ButtonOnly:
+               break;
+       case NoButton:
+               textx = x;
+               texty = baseline;
+               InsetText::draw(pi, textx, texty);
+               break;
+       case SubLabel:
+       case Corners:
+               textx = x;
+               texty = baseline;
+               {       // We will take care of the frame and the change tracking cue
+                       // ourselves, below.
+                       Changer dummy = make_change(pi.change_, Change());
+                       const_cast<InsetCollapsible *>(this)->setDrawFrame(false);
+                       InsetText::draw(pi, textx, texty);
+                       const_cast<InsetCollapsible *>(this)->setDrawFrame(true);
+               }
+
+               int desc = textdim.descent();
+               if (g == Corners)
+                       desc -= 3;
+
+               // Colour the frame according to the change type. (Like for tables.)
+               Color colour = pi.change_.changed() ? pi.change_.color()
+                                                   : Color_foreground;
+               const int xx1 = x + TEXT_TO_INSET_OFFSET - 1;
+               const int xx2 = x + textdim.wid - TEXT_TO_INSET_OFFSET + 1;
+               pi.pain.line(xx1, y + desc - 4,
+                            xx1, y + desc, colour);
+               if (status_ == Open)
+                       pi.pain.line(xx1, y + desc,
+                                    xx2, y + desc, colour);
+               else {
+                       // Make status_ value visible:
+                       pi.pain.line(xx1, y + desc,
+                                    xx1 + 4, y + desc, colour);
+                       pi.pain.line(xx2 - 4, y + desc,
+                                    xx2, y + desc, colour);
+               }
+               pi.pain.line(x + textdim.wid - 3, y + desc, x + textdim.wid - 3,
+                            y + desc - 4, colour);
+
+               // the label below the text. Can be toggled.
+               if (g == SubLabel) {
+                       FontInfo font(getLabelfont());
+                       if (pi.change_.changed())
+                               font.setPaintColor(colour);
+                       font.realize(sane_font);
+                       font.decSize();
+                       font.decSize();
+                       int w = 0;
+                       int a = 0;
+                       int d = 0;
+                       Color const col = pi.full_repaint ? Color_none : pi.backgroundColor(this);
+                       theFontMetrics(font).rectText(buttonLabel(bv), w, a, d);
+                       int const ww = max(textdim.wid, w);
+                       pi.pain.rectText(x + (ww - w) / 2, y + desc + a,
+                                        buttonLabel(bv), font, col, Color_none);
+               }
+
+               int const y1 = y - textdim.asc + 3;
+               // a visual cue when the cursor is inside the inset
+               Cursor const & cur = bv.cursor();
+               if (cur.isInside(this)) {
+                       pi.pain.line(xx1, y1 + 4, xx1, y1, colour);
+                       pi.pain.line(xx1 + 4, y1, xx1, y1, colour);
+                       pi.pain.line(xx2, y1 + 4, xx2, y1, colour);
+                       pi.pain.line(xx2 - 4, y1, xx2, y1, colour);
+               }
+               // Strike through the inset if deleted and not already handled by
+               // RowPainter.
+               if (pi.change_.deleted() && canPaintChange(bv))
+                       pi.change_.paintCue(pi, xx1, y1, xx2, y + desc);
+               break;
+       }
+}
+
+
+void InsetCollapsible::cursorPos(BufferView const & bv,
+               CursorSlice const & sl, bool boundary, int & x, int & y) const
+{
+       if (geometry(bv) == ButtonOnly)
+               status_ = Open;
+
+       InsetText::cursorPos(bv, sl, boundary, x, y);
+       Dimension const textdim = dimensionHelper(bv);
+
+       switch (geometry(bv)) {
+       case LeftButton:
+               x += dimensionCollapsed(bv).wid;
+               break;
+       case TopButton: {
+               y += dimensionCollapsed(bv).des + textdim.asc;
+               break;
+       }
+       case NoButton:
+       case SubLabel:
+       case Corners:
+               // Do nothing
+               break;
+       case ButtonOnly:
+               // Cannot get here
+               break;
+       }
+}
+
+
+bool InsetCollapsible::editable() const
+{
+       switch (decoration()) {
+       case InsetLayout::CLASSIC:
+       case InsetLayout::MINIMALISTIC:
+               return status_ == Open;
+       default:
+               return true;
+       }
+}
+
+
+bool InsetCollapsible::descendable(BufferView const & bv) const
+{
+       return geometry(bv) != ButtonOnly;
+}
+
+
+bool InsetCollapsible::clickable(BufferView const & bv, int x, int y) const
+{
+       return view_[&bv].button_dim_.contains(x, y);
+}
+
+
+docstring const InsetCollapsible::getNewLabel(docstring const & l) const
+{
+       odocstringstream label;
+       pos_type const max_length = 15;
+       pos_type const p_siz = paragraphs().begin()->size();
+       pos_type const n = min(max_length, p_siz);
+       pos_type i = 0;
+       pos_type j = 0;
+       for (; i < n && j < p_siz; ++j) {
+               if (paragraphs().begin()->isInset(j)) {
+                       if (!paragraphs().begin()->getInset(j)->isChar())
+                               continue;
+                       paragraphs().begin()->getInset(j)->toString(label);
+               } else
+                       label.put(paragraphs().begin()->getChar(j));
+               ++i;
+       }
+       if (paragraphs().size() > 1 || (i > 0 && j < p_siz)) {
+               label << "...";
+       }
+       docstring const lbl = label.str();
+       return lbl.empty() ? l : lbl;
+}
+
+
+void InsetCollapsible::edit(Cursor & cur, bool front, EntryDirection entry_from)
+{
+       //lyxerr << "InsetCollapsible: edit left/right" << endl;
+       cur.push(*this);
+       InsetText::edit(cur, front, entry_from);
+}
+
+
+Inset * InsetCollapsible::editXY(Cursor & cur, int x, int y)
+{
+       //lyxerr << "InsetCollapsible: edit xy" << endl;
+       if (geometry(cur.bv()) == ButtonOnly
+           || (view_[&cur.bv()].button_dim_.contains(x, y)
+               && geometry(cur.bv()) != NoButton))
+               return this;
+       cur.push(*this);
+       return InsetText::editXY(cur, x, y);
+}
+
+
+void InsetCollapsible::doDispatch(Cursor & cur, FuncRequest & cmd)
+{
+       //lyxerr << "InsetCollapsible::doDispatch (begin): cmd: " << cmd
+       //      << " cur: " << cur << " bvcur: " << cur.bv().cursor() << endl;
+
+       bool const hitButton = clickable(cur.bv(), cmd.x(), cmd.y());
+
+       switch (cmd.action()) {
+       case LFUN_MOUSE_PRESS:
+               if (hitButton) {
+                       switch (cmd.button()) {
+                       case mouse_button::button1:
+                       case mouse_button::button3:
+                               // Pass the command to the enclosing InsetText,
+                               // so that the cursor gets set.
+                               cur.undispatched();
+                               break;
+                       case mouse_button::none:
+                       case mouse_button::button2:
+                       case mouse_button::button4:
+                       case mouse_button::button5:
+                               // Nothing to do.
+                               cur.noScreenUpdate();
+                               break;
+                       }
+               } else if (geometry(cur.bv()) != ButtonOnly)
+                       InsetText::doDispatch(cur, cmd);
+               else
+                       cur.undispatched();
+               break;
+
+       case LFUN_MOUSE_DOUBLE:
+       case LFUN_MOUSE_TRIPLE:
+               if (hitButton)
+                       cur.noScreenUpdate();
+               else if (geometry(cur.bv()) != ButtonOnly)
+                       InsetText::doDispatch(cur, cmd);
+               else
+                       cur.undispatched();
+               break;
+
+       case LFUN_MOUSE_RELEASE:
+               if (!hitButton) {
+                       // The mouse click has to be within the inset!
+                       if (geometry(cur.bv()) != ButtonOnly)
+                               InsetText::doDispatch(cur, cmd);
+                       else
+                               cur.undispatched();
+                       break;
+               }
+               if (cmd.button() != mouse_button::button1) {
+                       // Nothing to do.
+                       cur.noScreenUpdate();
+                       break;
+               }
+               // if we are selecting, we do not want to
+               // toggle the inset.
+               if (cur.selection())
+                       break;
+               // Left button is clicked, the user asks to
+               // toggle the inset visual state.
+               cur.dispatched();
+               cur.screenUpdateFlags(Update::Force | Update::FitCursor);
+               if (geometry(cur.bv()) == ButtonOnly) {
+                       setStatus(cur, Open);
+                       edit(cur, true);
+               }
+               else
+                       setStatus(cur, Collapsed);
+               cur.bv().cursor() = cur;
+               break;
+
+       case LFUN_INSET_TOGGLE:
+               if (cmd.argument() == "open")
+                       setStatus(cur, Open);
+               else if (cmd.argument() == "close")
+                       setStatus(cur, Collapsed);
+               else if (cmd.argument() == "toggle" || cmd.argument().empty())
+                       if (status_ == Open)
+                               setStatus(cur, Collapsed);
+                       else
+                               setStatus(cur, Open);
+               else // if assign or anything else
+                       cur.undispatched();
+               cur.dispatched();
+               break;
+
+       default:
+               InsetText::doDispatch(cur, cmd);
+               break;
+       }
+}
+
+
+bool InsetCollapsible::getStatus(Cursor & cur, FuncRequest const & cmd,
+               FuncStatus & flag) const
+{
+       switch (cmd.action()) {
+       case LFUN_INSET_TOGGLE:
+               if (cmd.argument() == "open")
+                       flag.setEnabled(status_ != Open);
+               else if (cmd.argument() == "close")
+                       flag.setEnabled(status_ == Open);
+               else if (cmd.argument() == "toggle" || cmd.argument().empty()) {
+                       flag.setEnabled(true);
+                       flag.setOnOff(status_ == Open);
+               } else
+                       flag.setEnabled(false);
+               return true;
+
+       default:
+               return InsetText::getStatus(cur, cmd, flag);
+       }
+}
+
+
+void InsetCollapsible::setLabel(docstring const & l)
+{
+       labelstring_ = l;
+}
+
+
+docstring InsetCollapsible::getLabel() const
+{
+       InsetLayout const & il = getLayout();
+       return labelstring_.empty() ?
+               translateIfPossible(il.labelstring()) : labelstring_;
+}
+
+
+docstring const InsetCollapsible::buttonLabel(BufferView const & bv) const
+{
+       InsetLayout const & il = getLayout();
+       docstring const label = getLabel();
+       if (!il.contentaslabel() || geometry(bv) != ButtonOnly)
+               return label;
+       return getNewLabel(label);
+}
+
+
+void InsetCollapsible::setStatus(Cursor & cur, CollapseStatus status)
+{
+       status_ = status;
+       setButtonLabel();
+       if (status_ == Collapsed)
+               cur.leaveInset(*this);
+}
+
+
+InsetLayout::InsetDecoration InsetCollapsible::decoration() const
+{
+       InsetLayout::InsetDecoration const dec = getLayout().decoration();
+       return dec == InsetLayout::DEFAULT ? InsetLayout::CLASSIC : dec;
+}
+
+
+string InsetCollapsible::contextMenu(BufferView const & bv, int x,
+       int y) const
+{
+       string context_menu = contextMenuName();
+       string const it_context_menu = InsetText::contextMenuName();
+       if (decoration() == InsetLayout::CONGLOMERATE)
+               return context_menu + ";" + it_context_menu;
+
+       string const ic_context_menu = InsetCollapsible::contextMenuName();
+       if (ic_context_menu != context_menu)
+               context_menu += ";" + ic_context_menu;
+
+       if (geometry(bv) == NoButton)
+               return context_menu + ";" + it_context_menu;
+
+       Dimension dim = dimensionCollapsed(bv);
+       if (x < xo(bv) + dim.wid && y < yo(bv) + dim.des)
+               return context_menu;
+
+       return it_context_menu;
+}
+
+
+string InsetCollapsible::contextMenuName() const
+{
+       if (decoration() == InsetLayout::CONGLOMERATE)
+               return "context-conglomerate";
+       else
+               return "context-collapsible";
+}
+
+
+bool InsetCollapsible::canPaintChange(BufferView const & bv) const
+{
+       // return false to let RowPainter draw the change tracking cue consistently
+       // with the surrounding text, when the inset is inline: for buttons, for
+       // non-allowMultiPar insets.
+       switch (geometry(bv)) {
+       case Corners:
+       case SubLabel:
+               return allowMultiPar();
+       case ButtonOnly:
+               return false;
+       default:
+               break;
+       }
+       return true;
+}
+
+
+void InsetCollapsible::addToToc(DocIterator const & cpit, bool output_active,
+                                UpdateType utype, TocBackend & backend) const
+{
+       bool doing_output = output_active && producesOutput();
+       InsetLayout const & layout = getLayout();
+       if (layout.addToToc()) {
+               TocBuilder & b = backend.builder(layout.tocType());
+               // Cursor inside the inset
+               DocIterator pit = cpit;
+               pit.push_back(CursorSlice(const_cast<InsetCollapsible &>(*this)));
+               docstring const label = getLabel();
+               b.pushItem(pit, label + (label.empty() ? "" : ": "), output_active);
+               // Proceed with the rest of the inset.
+               InsetText::addToToc(cpit, doing_output, utype, backend);
+               if (layout.isTocCaption()) {
+                       docstring str;
+                       text().forOutliner(str, TOC_ENTRY_LENGTH);
+                       b.argumentItem(str);
+               }
+               b.pop();
+       } else
+               InsetText::addToToc(cpit, doing_output, utype, backend);
+}
+
+
+
+} // namespace lyx
diff --git a/src/insets/InsetCollapsible.h b/src/insets/InsetCollapsible.h
new file mode 100644 (file)
index 0000000..380d9ae
--- /dev/null
@@ -0,0 +1,193 @@
+// -*- C++ -*-
+/**
+ * \file InsetCollapsible.h
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Alejandro Aguilar Sierra
+ * \author Jürgen Vigna
+ * \author Lars Gullik Bjønnes
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#ifndef INSETCOLLAPSIBLE_H
+#define INSETCOLLAPSIBLE_H
+
+#include "InsetText.h"
+
+#include "Box.h"
+
+#include <map>
+
+namespace lyx {
+
+class CursorSlice;
+class InsetLayout;
+
+namespace frontend { class Painter; }
+
+/** A collapsible text inset
+
+*/
+class InsetCollapsible : public InsetText {
+public:
+       ///
+       InsetCollapsible(Buffer *, InsetText::UsePlain = InsetText::PlainLayout);
+       ///
+       InsetCollapsible(InsetCollapsible const & rhs);
+       ///
+       virtual ~InsetCollapsible();
+       ///
+       InsetCollapsible * asInsetCollapsible() { return this; }
+       ///
+       InsetCollapsible const * asInsetCollapsible() const { return this; }
+       ///
+       docstring toolTip(BufferView const & bv, int x, int y) const;
+       ///
+       docstring layoutName() const { return from_ascii("Collapsible"); }
+       ///
+       void read(Lexer &);
+       ///
+       void write(std::ostream &) const;
+       ///
+       void metrics(MetricsInfo &, Dimension &) const;
+       ///
+       void draw(PainterInfo & pi, int x, int y) const;
+       ///
+       virtual void drawBackground(PainterInfo &, int, int) const {}
+
+       /// return x,y of given position relative to the inset's baseline
+       void cursorPos(BufferView const & bv, CursorSlice const & sl,
+               bool boundary, int & x, int & y) const;
+       ///
+       docstring const getNewLabel(docstring const & l) const;
+       ///
+       bool editable() const;
+       ///
+       bool hasSettings() const { return true; }
+       /// Returns true if coordinates are over the inset's button.
+       /// Always returns false when the inset does not have a
+       /// button.
+       bool clickable(BufferView const & bv, int x, int y) const;
+       /// can we go further down on mouse click?
+       bool descendable(BufferView const & bv) const;
+       ///
+       void setLabel(docstring const & l);
+       ///
+       docstring getLabel() const;
+       ///
+       virtual void setButtonLabel() {}
+       ///
+       virtual docstring const buttonLabel(BufferView const &) const;
+       ///
+       bool isOpen(BufferView const & bv) const
+               { return geometry(bv) != ButtonOnly; }
+       ///
+       enum CollapseStatus {
+               Collapsed,
+               Open
+       };
+       ///
+       virtual void setStatus(Cursor & cur, CollapseStatus st);
+       ///
+       CollapseStatus status(BufferView const & bv) const;
+       /** Of the old CollapseStatus we only keep the values
+        *  Open and Collapsed.
+        * We define a list of possible inset decoration
+        * styles, and a list of possible (concrete, visual)
+        * inset geometries. Relationships between them
+        * (geometries in body of table):
+        *
+        *               \       CollapseStatus:
+        *   Decoration:  \ Open                Collapsed
+        *   -------------+-------------------------------
+        *   Classic      | *) TopButton, <--x) ButtonOnly
+        *                | LeftButton
+        *   Minimalistic | NoButton            ButtonOnly
+        *   Conglomerate | SubLabel            Corners
+        *   ---------------------------------------------
+        *   *) toggled by openinlined_
+        *   x) toggled by auto_open_
+        */
+
+       /// Default looks
+       virtual InsetLayout::InsetDecoration decoration() const;
+       /// Inset font
+       virtual FontInfo getFont() const { return getLayout().font(); }
+       /// Label font
+       virtual FontInfo getLabelfont() const { return getLayout().labelfont(); }
+       ///
+       enum Geometry {
+               TopButton,
+               ButtonOnly,
+               NoButton,
+               LeftButton,
+               SubLabel,
+               Corners
+       };
+       /// Returns the geometry based on CollapseStatus
+       /// (status_), auto_open_[BufferView] and openinlined_,
+       /// and of course decoration().
+       Geometry geometry(BufferView const & bv) const;
+       ///
+       bool canPaintChange(BufferView const & bv) const;
+       ///
+       bool getStatus(Cursor &, FuncRequest const &, FuncStatus &) const;
+       ///
+       bool setMouseHover(BufferView const * bv, bool mouse_hover) const;
+       ///
+       ColorCode backgroundColor(PainterInfo const &) const
+               { return getLayout().bgcolor(); }
+       ///
+       ColorCode labelColor() const { return getLayout().labelfont().color(); }
+       ///
+       InsetCode lyxCode() const { return COLLAPSIBLE_CODE; }
+
+       ///
+       virtual bool usePlainLayout() const { return true; }
+       ///
+       std::string contextMenu(BufferView const & bv, int x, int y) const;
+       ///
+       std::string contextMenuName() const;
+       ///
+       void addToToc(DocIterator const & dit, bool output_active,
+                     UpdateType utype, TocBackend & backend) const; //override
+
+protected:
+       ///
+       void doDispatch(Cursor & cur, FuncRequest & cmd);
+       ///
+       void edit(Cursor & cur, bool front,
+               EntryDirection entry_from = ENTRY_DIRECTION_IGNORE);
+       ///
+       Inset * editXY(Cursor & cur, int x, int y);
+       ///
+       mutable CollapseStatus status_;
+private:
+       ///
+       Dimension dimensionCollapsed(BufferView const & bv) const;
+       ///
+       docstring labelstring_;
+
+       // These variables depend of the view in which the inset is displayed
+       struct View
+       {
+               /// The dimension of the inset button
+               Box button_dim_;
+               /// a substatus of the Open status, determined automatically in metrics
+               bool openinlined_;
+               /// the inset will automatically open when the cursor is inside. This is
+               /// dependent on the bufferview, compare with InsetMathMacro::editing_.
+               bool auto_open_;
+               /// changes color when mouse enters/leaves this inset
+               bool mouse_hover_;
+       };
+
+       ///
+       mutable std::map<BufferView const *, View> view_;
+};
+
+} // namespace lyx
+
+#endif
index 504338616533ed8b1fc38ae12601b3183de570f2..7693d08fd7c70010f323eddd24956697932d09fd 100644 (file)
@@ -349,7 +349,7 @@ bool decodeInsetParam(string const & name, string & data,
                break;
        }
        case ERT_CODE: {
-               data = InsetERT::params2string(InsetCollapsable::Open);
+               data = InsetERT::params2string(InsetCollapsible::Open);
                break;
        }
        case EXTERNAL_CODE: {
index ce9d3834d2b74d3e5c20394ccdfcac7ecad721de..2d96f952f636c919df1bce41594089f77231df4f 100644 (file)
@@ -40,7 +40,7 @@ using namespace lyx::support;
 namespace lyx {
 
 InsetERT::InsetERT(Buffer * buf, CollapseStatus status)
-       : InsetCollapsable(buf)
+       : InsetCollapsible(buf)
 {
        status_ = status;
 }
@@ -49,7 +49,7 @@ InsetERT::InsetERT(Buffer * buf, CollapseStatus status)
 void InsetERT::write(ostream & os) const
 {
        os << "ERT" << "\n";
-       InsetCollapsable::write(os);
+       InsetCollapsible::write(os);
 }
 
 
@@ -117,7 +117,7 @@ void InsetERT::doDispatch(Cursor & cur, FuncRequest & cmd)
                }
                //fall-through
        default:
-               InsetCollapsable::doDispatch(cur, cmd);
+               InsetCollapsible::doDispatch(cur, cmd);
                break;
        }
 
@@ -136,7 +136,7 @@ bool InsetERT::getStatus(Cursor & cur, FuncRequest const & cmd,
                //fall through
 
        default:
-               return InsetCollapsable::getStatus(cur, cmd, status);
+               return InsetCollapsible::getStatus(cur, cmd, status);
        }
 }
 
@@ -150,7 +150,7 @@ docstring const InsetERT::buttonLabel(BufferView const & bv) const
 }
 
 
-InsetCollapsable::CollapseStatus InsetERT::string2params(string const & in)
+InsetCollapsible::CollapseStatus InsetERT::string2params(string const & in)
 {
        if (in.empty())
                return Collapsed;
index eb6ab9178d01a5af3daa852a531918a379daebb2..87ed11616a302e8be87e7d399a4ced83d024c205 100644 (file)
@@ -13,7 +13,7 @@
 #ifndef INSETERT_H
 #define INSETERT_H
 
-#include "InsetCollapsable.h"
+#include "InsetCollapsible.h"
 
 
 namespace lyx {
@@ -29,7 +29,7 @@ namespace lyx {
 
 class Language;
 
-class InsetERT : public InsetCollapsable {
+class InsetERT : public InsetCollapsible {
 public:
        ///
        InsetERT(Buffer *, CollapseStatus status = Open);
index 6c91b4c10ac92239f7096be37a31bfe299291681..61e47d4c367f1737a4e69e821937b4abf09040a9 100644 (file)
@@ -35,12 +35,12 @@ namespace lyx {
 
 
 InsetFlex::InsetFlex(Buffer * buf, string const & layoutName)
-       : InsetCollapsable(buf), name_(layoutName)
+       : InsetCollapsible(buf), name_(layoutName)
 {}
 
 
 InsetFlex::InsetFlex(InsetFlex const & in)
-       : InsetCollapsable(in), name_(in.name_)
+       : InsetCollapsible(in), name_(in.name_)
 {}
 
 
@@ -86,7 +86,7 @@ void InsetFlex::write(ostream & os) const
                }
        }
        os << name << "\n";
-       InsetCollapsable::write(os);
+       InsetCollapsible::write(os);
 }
 
 
@@ -101,13 +101,13 @@ bool InsetFlex::getStatus(Cursor & cur, FuncRequest const & cmd,
                                translateLyXType(to_utf8(cmd.argument()));
                        if (il.lyxtype() == type) {
                                FuncRequest temp_cmd(LFUN_INSET_DISSOLVE);
-                               return InsetCollapsable::getStatus(cur, temp_cmd, flag);
+                               return InsetCollapsible::getStatus(cur, temp_cmd, flag);
                        } else
                                return false;
                }
                // fall-through
        default:
-               return InsetCollapsable::getStatus(cur, cmd, flag);
+               return InsetCollapsible::getStatus(cur, cmd, flag);
        }
 }
 
@@ -123,14 +123,14 @@ void InsetFlex::doDispatch(Cursor & cur, FuncRequest & cmd)
 
                        if (il.lyxtype() == type) {
                                FuncRequest temp_cmd(LFUN_INSET_DISSOLVE);
-                               InsetCollapsable::doDispatch(cur, temp_cmd);
+                               InsetCollapsible::doDispatch(cur, temp_cmd);
                        } else
                                cur.undispatched();
                        break;
                }
                // fall-through
        default:
-               InsetCollapsable::doDispatch(cur, cmd);
+               InsetCollapsible::doDispatch(cur, cmd);
                break;
        }
 }
@@ -159,7 +159,7 @@ void InsetFlex::updateBuffer(ParIterator const & it, UpdateType utype)
                // need a layout flag
                cnts.saveLastCounter();
        }
-       InsetCollapsable::updateBuffer(it, utype);
+       InsetCollapsible::updateBuffer(it, utype);
        if (save_counter)
                cnts.restoreLastCounter();
 }
index ced22c8746b2e6f1a126b1d3063f324b38a7d0ce..0844246769e7b76a344a855fa4fae68d4b942427 100644 (file)
 #ifndef INSETFLEX_H
 #define INSETFLEX_H
 
-#include "InsetCollapsable.h"
+#include "InsetCollapsible.h"
 
 namespace lyx {
 
 /** The Flex inset, e.g., CharStyle, Custom inset or XML short element
 
 */
-class InsetFlex : public InsetCollapsable {
+class InsetFlex : public InsetCollapsible {
 public:
        ///
        InsetFlex(Buffer *, std::string const & layoutName);
index cb7462d503702c0f993f9492e4640bb47a4f9af7..86c719ae65fc81ca0ed3e2554c7cf91b3db40dab 100644 (file)
@@ -69,7 +69,7 @@ void InsetFoot::updateBuffer(ParIterator const & it, UpdateType utype)
        custom_label_ += ' ' + cnts.theCounter(count, lang->code());
        setLabel(custom_label_);
 
-       InsetCollapsable::updateBuffer(it, utype);
+       InsetCollapsible::updateBuffer(it, utype);
        if (utype == OutputUpdate)
                cnts.restoreLastCounter();
 }
@@ -79,7 +79,7 @@ docstring InsetFoot::toolTip(BufferView const & bv, int x, int y) const
 {
        if (isOpen(bv))
                // this will give us something useful if there is no button
-               return InsetCollapsable::toolTip(bv, x, y);
+               return InsetCollapsible::toolTip(bv, x, y);
        return toolTipText(custom_label_+ ": ");
 }
 
index 5685e865bfa8407ed6b6eec42966e3b9b0924127..739d89745e6673a5d52ee82f33b49a28ff994ab2 100644 (file)
@@ -29,7 +29,7 @@ namespace lyx {
 using support::token;
 
 InsetFootlike::InsetFootlike(Buffer * buf)
-       : InsetCollapsable(buf)
+       : InsetCollapsible(buf)
 {}
 
 
@@ -37,7 +37,7 @@ void InsetFootlike::metrics(MetricsInfo & mi, Dimension & dim) const
 {
        FontInfo tmpfont = mi.base.font;
        mi.base.font = mi.base.bv->buffer().params().getFont().fontInfo();
-       InsetCollapsable::metrics(mi, dim);
+       InsetCollapsible::metrics(mi, dim);
        mi.base.font = tmpfont;
 }
 
@@ -46,7 +46,7 @@ void InsetFootlike::draw(PainterInfo & pi, int x, int y) const
 {
        FontInfo tmpfont = pi.base.font;
        pi.base.font = pi.base.bv->buffer().params().getFont().fontInfo();
-       InsetCollapsable::draw(pi, x, y);
+       InsetCollapsible::draw(pi, x, y);
        pi.base.font = tmpfont;
 }
 
@@ -55,7 +55,7 @@ void InsetFootlike::write(ostream & os) const
 {
        // The layoutName may contain a "InTitle" qualifier
        os << to_utf8(token(layoutName(), char_type(':'), 0)) << "\n";
-       InsetCollapsable::write(os);
+       InsetCollapsible::write(os);
 }
 
 
@@ -63,7 +63,7 @@ bool InsetFootlike::insetAllowed(InsetCode code) const
 {
        if (code == FOOT_CODE || code == MARGIN_CODE || code == FLOAT_CODE)
                return false;
-       return InsetCollapsable::insetAllowed(code);
+       return InsetCollapsible::insetAllowed(code);
 }
 
 
index f16f355a963b09d44adee31689717c95065892c3..f4bcbdef19445eef05d42ee074a8dbb211cc4410 100644 (file)
@@ -12,7 +12,7 @@
 #ifndef INSETFOOTLIKE_H
 #define INSETFOOTLIKE_H
 
-#include "InsetCollapsable.h"
+#include "InsetCollapsible.h"
 
 
 namespace lyx {
@@ -20,7 +20,7 @@ namespace lyx {
 // To have this class is probably a bit overkill... (Lgb)
 
 // The footnote inset
-class InsetFootlike : public InsetCollapsable {
+class InsetFootlike : public InsetCollapsible {
 public:
        ///
        InsetFootlike(Buffer *);
index cbc3abf525bb491d0b2b8e0d573c521895fa49d3..4b2369b3796741fb6177bd1f876da9313146f893 100644 (file)
@@ -125,7 +125,7 @@ void InsetIPADecoParams::read(Lexer & lex)
 /////////////////////////////////////////////////////////////////////
 
 InsetIPADeco::InsetIPADeco(Buffer * buf, string const & label)
-       : InsetCollapsable(buf)
+       : InsetCollapsible(buf)
 {
        setDrawFrame(true);
        setFrameColor(Color_insetframe);
@@ -179,7 +179,7 @@ void InsetIPADeco::metrics(MetricsInfo & mi, Dimension & dim) const
 void InsetIPADeco::draw(PainterInfo & pi, int x, int y) const
 {
        // draw the text
-       InsetCollapsable::draw(pi, x, y);
+       InsetCollapsible::draw(pi, x, y);
 
        // draw the inset marker
        drawMarkers(pi, x, y);
@@ -223,14 +223,14 @@ void InsetIPADeco::draw(PainterInfo & pi, int x, int y) const
 void InsetIPADeco::write(ostream & os) const
 {
        params_.write(os);
-       InsetCollapsable::write(os);
+       InsetCollapsible::write(os);
 }
 
 
 void InsetIPADeco::read(Lexer & lex)
 {
        params_.read(lex);
-       InsetCollapsable::read(lex);
+       InsetCollapsible::read(lex);
 }
 
 
@@ -277,7 +277,7 @@ void InsetIPADeco::latex(otexstream & os, OutputParams const & runparams) const
                os << "\\texttoptiebar{";
        else if (params_.type == InsetIPADecoParams::Bottomtiebar)
                os << "\\textbottomtiebar{";
-       InsetCollapsable::latex(os, runparams);
+       InsetCollapsible::latex(os, runparams);
        os << "}";
 }
 
@@ -286,7 +286,7 @@ int InsetIPADeco::plaintext(odocstringstream & os,
                            OutputParams const & runparams, size_t max_length) const
 {
        odocstringstream ods;
-       int h = (int)(InsetCollapsable::plaintext(ods, runparams, max_length) / 2);
+       int h = (int)(InsetCollapsible::plaintext(ods, runparams, max_length) / 2);
        docstring result = ods.str();
        docstring const before = result.substr(0, h);
        docstring const after = result.substr(h, result.size());
@@ -308,7 +308,7 @@ int InsetIPADeco::plaintext(odocstringstream & os,
 int InsetIPADeco::docbook(odocstream & os, OutputParams const & runparams) const
 {
        // FIXME: Any docbook option here?
-       return InsetCollapsable::docbook(os, runparams);
+       return InsetCollapsible::docbook(os, runparams);
 }
 
 
@@ -317,7 +317,7 @@ docstring InsetIPADeco::xhtml(XHTMLStream & xs, OutputParams const & runparams)
        // FIXME: Like in plaintext, the combining characters "&#x361;" (toptiebar)
        // or "&#x35c;" (bottomtiebar) would need to be inserted just in the mid
        // of the text string. (How) can this be done with the xhtml stream?
-       return InsetCollapsable::xhtml(xs, runparams);
+       return InsetCollapsible::xhtml(xs, runparams);
 }
 
 
index c29fc49c91e06b8eb560a8fd844a27516cdf0361..fb35adb763f213ffb079e29cf89880cea0e26c21 100644 (file)
@@ -14,7 +14,7 @@
 
 
 #include "Inset.h"
-#include "InsetCollapsable.h"
+#include "InsetCollapsible.h"
 
 
 namespace lyx {
@@ -45,7 +45,7 @@ public:
 /////////////////////////////////////////////////////////////////////////
 
 /// Used to insert IPA decorations
-class InsetIPADeco : public InsetCollapsable
+class InsetIPADeco : public InsetCollapsible
 {
 public:
        ///
index 219954d4e320d86562276601813f90cdfa18f1d6..584fb280c78d74396d77839092167861bc14f52f 100644 (file)
@@ -55,7 +55,7 @@ namespace lyx {
 
 
 InsetIndex::InsetIndex(Buffer * buf, InsetIndexParams const & params)
-       : InsetCollapsable(buf), params_(params)
+       : InsetCollapsible(buf), params_(params)
 {}
 
 
@@ -221,7 +221,7 @@ void InsetIndex::doDispatch(Cursor & cur, FuncRequest & cmd)
                break;
 
        default:
-               InsetCollapsable::doDispatch(cur, cmd);
+               InsetCollapsible::doDispatch(cur, cmd);
                break;
        }
 }
@@ -243,7 +243,7 @@ bool InsetIndex::getStatus(Cursor & cur, FuncRequest const & cmd,
                                from_utf8(cmd.getArg(1)) == params_.index);
                        return true;
                }
-               return InsetCollapsable::getStatus(cur, cmd, flag);
+               return InsetCollapsible::getStatus(cur, cmd, flag);
 
        case LFUN_INSET_DIALOG_UPDATE: {
                Buffer const & realbuffer = *buffer().masterBuffer();
@@ -252,7 +252,7 @@ bool InsetIndex::getStatus(Cursor & cur, FuncRequest const & cmd,
        }
 
        default:
-               return InsetCollapsable::getStatus(cur, cmd, flag);
+               return InsetCollapsible::getStatus(cur, cmd, flag);
        }
 }
 
@@ -260,11 +260,11 @@ bool InsetIndex::getStatus(Cursor & cur, FuncRequest const & cmd,
 ColorCode InsetIndex::labelColor() const
 {
        if (params_.index.empty() || params_.index == from_ascii("idx"))
-               return InsetCollapsable::labelColor();
+               return InsetCollapsible::labelColor();
        // FIXME UNICODE
        ColorCode c = lcolor.getFromLyXName(to_utf8(params_.index));
        if (c == Color_none)
-               c = InsetCollapsable::labelColor();
+               c = InsetCollapsible::labelColor();
        return c;
 }
 
@@ -315,14 +315,14 @@ void InsetIndex::write(ostream & os) const
 {
        os << to_utf8(layoutName());
        params_.write(os);
-       InsetCollapsable::write(os);
+       InsetCollapsible::write(os);
 }
 
 
 void InsetIndex::read(Lexer & lex)
 {
        params_.read(lex);
-       InsetCollapsable::read(lex);
+       InsetCollapsible::read(lex);
 }
 
 
@@ -364,7 +364,7 @@ void InsetIndex::addToToc(DocIterator const & cpit, bool output_active,
        TocBuilder & b = backend.builder(type);
        b.pushItem(pit, str, output_active);
        // Proceed with the rest of the inset.
-       InsetCollapsable::addToToc(cpit, output_active, utype, backend);
+       InsetCollapsible::addToToc(cpit, output_active, utype, backend);
        b.pop();
 }
 
@@ -375,7 +375,7 @@ void InsetIndex::validate(LaTeXFeatures & features) const
            && !params_.index.empty()
            && params_.index != "idx")
                features.require("splitidx");
-       InsetCollapsable::validate(features);
+       InsetCollapsible::validate(features);
 }
 
 
index 3ee17509dcf45e4fd5fcc22733617479191ad861..01bf7096b08b5d0b8f074b92103df8f2d2eb53e2 100644 (file)
@@ -13,7 +13,7 @@
 #define INSET_INDEX_H
 
 
-#include "InsetCollapsable.h"
+#include "InsetCollapsible.h"
 #include "InsetCommand.h"
 
 
@@ -35,7 +35,7 @@ public:
 
 /** Used to insert index labels
   */
-class InsetIndex : public InsetCollapsable {
+class InsetIndex : public InsetCollapsible {
 public:
        ///
        InsetIndex(Buffer *, InsetIndexParams const &);
index d52f88703106588cd0ebbd4cce8a7a131fcc33c2..700049d6ee8e8540cba83e2f25cf4f5d6b898729 100644 (file)
@@ -92,7 +92,7 @@ NameTranslator const & nameTranslator()
 
 
 InsetInfo::InsetInfo(Buffer * buf, string const & name)
-       : InsetCollapsable(buf), initialized_(false), 
+       : InsetCollapsible(buf), initialized_(false), 
          type_(UNKNOWN_INFO), name_()
 {
        setInfo(name);
@@ -221,7 +221,7 @@ bool InsetInfo::getStatus(Cursor & cur, FuncRequest const & cmd,
 {
        switch (cmd.action()) {
        case LFUN_INSET_SETTINGS:
-               return InsetCollapsable::getStatus(cur, cmd, flag);
+               return InsetCollapsible::getStatus(cur, cmd, flag);
 
        case LFUN_INSET_DIALOG_UPDATE:
        case LFUN_INSET_COPY_AS:
@@ -265,7 +265,7 @@ void InsetInfo::doDispatch(Cursor & cur, FuncRequest & cmd)
        }
 
        default:
-               InsetCollapsable::doDispatch(cur, cmd);
+               InsetCollapsible::doDispatch(cur, cmd);
                break;
        }
 }
@@ -529,14 +529,14 @@ void InsetInfo::updateBuffer(ParIterator const & it, UpdateType utype) {
                initialized_ = true;
                break;
        }
-       InsetCollapsable::updateBuffer(it, utype);
+       InsetCollapsible::updateBuffer(it, utype);
 }
 
 
 string InsetInfo::contextMenu(BufferView const &, int, int) const
 {
-       //FIXME: We override the implementation of InsetCollapsable,
-       //because this inset is not a collapsable inset.
+       //FIXME: We override the implementation of InsetCollapsible,
+       //because this inset is not a collapsible inset.
        return contextMenuName();
 }
 
index 8ab6f826ca96d125d2b0a262bf6055ee71a4861e..86f957aac1c067496f967261ce9c3f1bce825f4b 100644 (file)
@@ -12,7 +12,7 @@
 #ifndef INSET_INFO_H
 #define INSET_INFO_H
 
-#include "InsetCollapsable.h"
+#include "InsetCollapsible.h"
 
 namespace lyx {
 
@@ -77,7 +77,7 @@ the command buffer (view->Toolbar->Command Buffer).
 
 */
 
-class InsetInfo : public InsetCollapsable {
+class InsetInfo : public InsetCollapsible {
 public:
        enum info_type {
                UNKNOWN_INFO,   // Invalid type
@@ -146,7 +146,7 @@ private:
        ///
        void setText(docstring const & str);
        // make sure that the other version of setText is still available.
-       using InsetCollapsable::setText;
+       using InsetCollapsible::setText;
        ///
        bool initialized_;
        ///
index ea7eeb699f6e5cddfb742d78cbff4a8299549c2c..998554c395c7f3f6e33c4798c2fb469b3b6e0c36 100644 (file)
@@ -969,13 +969,13 @@ ParValidator * par_validator = 0;
 int InsetListingsParams::package_ = 0;
 
 InsetListingsParams::InsetListingsParams()
-       : inline_(false), params_(), status_(InsetCollapsable::Open)
+       : inline_(false), params_(), status_(InsetCollapsible::Open)
 {
 }
 
 
 InsetListingsParams::InsetListingsParams(string const & par, bool in,
-               InsetCollapsable::CollapseStatus s)
+               InsetCollapsible::CollapseStatus s)
        : inline_(in), params_(), status_(s)
 {
        // this will activate parameter validation.
@@ -996,9 +996,9 @@ void InsetListingsParams::write(ostream & os) const
 void InsetListingsParams::read(Lexer & lex)
 {
        lex >> inline_;
-       int s = InsetCollapsable::Collapsed;
+       int s = InsetCollapsible::Collapsed;
        lex >> s;
-       status_ = static_cast<InsetCollapsable::CollapseStatus>(s);
+       status_ = static_cast<InsetCollapsible::CollapseStatus>(s);
        string par;
        lex >> par;
        fromEncodedString(par);
index ce50de669d706862d3e8016c49967035de977900..ddcca62f23a2b9d32439fa05b2b68199950a7a80 100644 (file)
@@ -25,7 +25,7 @@ public:
 
        ///
        InsetListingsParams(std::string const &, bool in=false,
-               InsetCollapsable::CollapseStatus s = InsetCollapsable::Open);
+               InsetCollapsible::CollapseStatus s = InsetCollapsible::Open);
 
        /// write parameters to an ostream
        void write(std::ostream &) const;
@@ -65,7 +65,7 @@ public:
        bool isFloat() const;
 
        ///
-       InsetCollapsable::CollapseStatus status() const { return status_; }
+       InsetCollapsible::CollapseStatus status() const { return status_; }
 
        ///
        void setInline(bool i) { inline_ = i; }
@@ -105,8 +105,8 @@ private:
        typedef std::vector<std::pair<std::string, std::string> > keyValuePair;
        keyValuePair params_;
 
-       /// collapsable status
-       InsetCollapsable::CollapseStatus status_;
+       /// collapsible status
+       InsetCollapsible::CollapseStatus status_;
 };
 
 
index 1ee573c9e6352d9a11c6ef9886ebf278c50881d8..ef946db3388e3dcb326f4529bb1b8dba4caa50e6 100644 (file)
@@ -100,7 +100,7 @@ void InsetNoteParams::read(Lexer & lex)
 /////////////////////////////////////////////////////////////////////
 
 InsetNote::InsetNote(Buffer * buf, string const & label)
-       : InsetCollapsable(buf)
+       : InsetCollapsible(buf)
 {
        params_.type = notetranslator().find(label);
 }
@@ -127,14 +127,14 @@ Inset::DisplayType InsetNote::display() const
 void InsetNote::write(ostream & os) const
 {
        params_.write(os);
-       InsetCollapsable::write(os);
+       InsetCollapsible::write(os);
 }
 
 
 void InsetNote::read(Lexer & lex)
 {
        params_.read(lex);
-       InsetCollapsable::read(lex);
+       InsetCollapsible::read(lex);
 }
 
 
@@ -176,7 +176,7 @@ void InsetNote::doDispatch(Cursor & cur, FuncRequest & cmd)
                break;
 
        default:
-               InsetCollapsable::doDispatch(cur, cmd);
+               InsetCollapsible::doDispatch(cur, cmd);
                break;
        }
 }
@@ -203,7 +203,7 @@ bool InsetNote::getStatus(Cursor & cur, FuncRequest const & cmd,
                return true;
 
        default:
-               return InsetCollapsable::getStatus(cur, cmd, flag);
+               return InsetCollapsible::getStatus(cur, cmd, flag);
        }
 }
 
@@ -214,7 +214,7 @@ bool InsetNote::isMacroScope() const
        if (params_.type == InsetNoteParams::Note)
                return true;
 
-       return InsetCollapsable::isMacroScope();
+       return InsetCollapsible::isMacroScope();
 }
 
 
@@ -245,7 +245,7 @@ void InsetNote::latex(otexstream & os, OutputParams const & runparams_in) const
        // insets whose InsetLayout Display tag is false. This is achieved
        // by telling otexstream to protect an immediately following space
        // and is done for both comment and greyedout insets.
-       InsetCollapsable::latex(os, runparams);
+       InsetCollapsible::latex(os, runparams);
 
        runparams_in.encoding = runparams.encoding;
 }
@@ -300,7 +300,7 @@ docstring InsetNote::xhtml(XHTMLStream & xs, OutputParams const & rp) const
        if (params_.type == InsetNoteParams::Note)
                return docstring();
 
-       return InsetCollapsable::xhtml(xs, rp);
+       return InsetCollapsible::xhtml(xs, rp);
 }
 
 
@@ -311,13 +311,13 @@ void InsetNote::validate(LaTeXFeatures & features) const
                if (features.runparams().flavor == OutputParams::HTML)
                        // we do output this but set display to "none" by default,
                        // but people might want to use it.
-                       InsetCollapsable::validate(features);
+                       InsetCollapsible::validate(features);
                else
                        // Only do the requires
                        features.useInsetLayout(getLayout());
                break;
        case InsetNoteParams::Greyedout:
-               InsetCollapsable::validate(features);
+               InsetCollapsible::validate(features);
                break;
        case InsetNoteParams::Note:
                break;
index d6cc0a6510ec623e4903732b00ade77a1eaa1b64..9df1a501a29c75ba12c7ebc3c8f13517f7f4d3c4 100644 (file)
@@ -12,7 +12,7 @@
 #ifndef INSET_NOTE_H
 #define INSET_NOTE_H
 
-#include "InsetCollapsable.h"
+#include "InsetCollapsible.h"
 
 
 namespace lyx {
@@ -43,7 +43,7 @@ public:
 /////////////////////////////////////////////////////////////////////////
 
 /// The PostIt note inset, and other annotations
-class InsetNote : public InsetCollapsable
+class InsetNote : public InsetCollapsible
 {
 public:
        ///
index 2a004fa6f887c0a90ab32c6f33acc18140b92969..19e05700230583c00abc817865004914091da473 100644 (file)
@@ -116,7 +116,7 @@ void InsetPhantomParams::read(Lexer & lex)
 /////////////////////////////////////////////////////////////////////
 
 InsetPhantom::InsetPhantom(Buffer * buf, string const & label)
-       : InsetCollapsable(buf)
+       : InsetCollapsible(buf)
 {
        setDrawFrame(false);
        params_.type = phantomtranslator().find(label);
@@ -138,7 +138,7 @@ docstring InsetPhantom::layoutName() const
 void InsetPhantom::draw(PainterInfo & pi, int x, int y) const
 {
        // draw the text
-       InsetCollapsable::draw(pi, x, y);
+       InsetCollapsible::draw(pi, x, y);
 
        // draw the inset marker
        drawMarkers(pi, x, y);
@@ -222,14 +222,14 @@ void InsetPhantom::draw(PainterInfo & pi, int x, int y) const
 void InsetPhantom::write(ostream & os) const
 {
        params_.write(os);
-       InsetCollapsable::write(os);
+       InsetCollapsible::write(os);
 }
 
 
 void InsetPhantom::read(Lexer & lex)
 {
        params_.read(lex);
-       InsetCollapsable::read(lex);
+       InsetCollapsible::read(lex);
 }
 
 
@@ -264,7 +264,7 @@ void InsetPhantom::doDispatch(Cursor & cur, FuncRequest & cmd)
                break;
 
        default:
-               InsetCollapsable::doDispatch(cur, cmd);
+               InsetCollapsible::doDispatch(cur, cmd);
                break;
        }
 }
@@ -289,7 +289,7 @@ bool InsetPhantom::getStatus(Cursor & cur, FuncRequest const & cmd,
                return true;
 
        default:
-               return InsetCollapsable::getStatus(cur, cmd, flag);
+               return InsetCollapsible::getStatus(cur, cmd, flag);
        }
 }
 
@@ -320,7 +320,7 @@ void InsetPhantom::latex(otexstream & os, OutputParams const & runparams) const
                os << "\\phantom{";
                break;
        }
-       InsetCollapsable::latex(os, runparams);
+       InsetCollapsible::latex(os, runparams);
        os << "}";
 }
 
@@ -342,7 +342,7 @@ int InsetPhantom::plaintext(odocstringstream & os,
                os << '[' << buffer().B_("phantom") << ":";
                break;
        }
-       InsetCollapsable::plaintext(os, runparams, max_length);
+       InsetCollapsible::plaintext(os, runparams, max_length);
        os << "]";
 
        return PLAINTEXT_NEWLINE;
@@ -361,7 +361,7 @@ int InsetPhantom::docbook(odocstream & os, OutputParams const & runparams) const
                break;
        }
        os << "<" + cmdname + ">";
-       int const i = InsetCollapsable::docbook(os, runparams);
+       int const i = InsetCollapsible::docbook(os, runparams);
        os << "</" + cmdname + ">";
 
        return i;
index 42c3da1f26cebc94216ca86d857ceae44e9b4c7d..46e8576678f5a1567ccefde72fcf441ecafeda21 100644 (file)
@@ -12,7 +12,7 @@
 #ifndef INSET_PHANTOM_H
 #define INSET_PHANTOM_H
 
-#include "InsetCollapsable.h"
+#include "InsetCollapsible.h"
 
 
 namespace lyx {
@@ -43,7 +43,7 @@ public:
 /////////////////////////////////////////////////////////////////////////
 
 /// The phantom inset
-class InsetPhantom : public InsetCollapsable
+class InsetPhantom : public InsetCollapsible
 {
 public:
        ///
index 44665a439b022d698280d98a386da92be7ebb905..918492fb55493041b31edd34a5b00e0f5b092fd4 100644 (file)
@@ -235,7 +235,7 @@ bool InsetScript::insetAllowed(InsetCode code) const
        case BOX_CODE:
        case BRANCH_CODE:
        case CAPTION_CODE:
-       case COLLAPSABLE_CODE:
+       case COLLAPSIBLE_CODE:
        case FLOAT_CODE:
        case FLOAT_LIST_CODE:
        case FOOT_CODE: