From: Juergen Spitzmueller Date: Mon, 16 Oct 2017 08:12:21 +0000 (+0200) Subject: Collapsable -> Collapsible (part 2) X-Git-Tag: 2.3.0rc1~40 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=a59301eaff51c63db706e17bd5496b8e02928f14;p=features.git Collapsable -> Collapsible (part 2) 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). (cherry picked from commit c466baaa5b99e44ea25616556bd0918197f4b54c) --- diff --git a/lib/doc/Customization.lyx b/lib/doc/Customization.lyx index ed456e0619..23d0ed9d04 100644 --- a/lib/doc/Customization.lyx +++ b/lib/doc/Customization.lyx @@ -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 diff --git a/lib/doc/de/Customization.lyx b/lib/doc/de/Customization.lyx index e1dac3cb65..a32430b742 100644 --- a/lib/doc/de/Customization.lyx +++ b/lib/doc/de/Customization.lyx @@ -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 diff --git a/lib/doc/es/Customization.lyx b/lib/doc/es/Customization.lyx index d9c2eda96b..d18c53f40e 100644 --- a/lib/doc/es/Customization.lyx +++ b/lib/doc/es/Customization.lyx @@ -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 diff --git a/lib/doc/fr/Customization.lyx b/lib/doc/fr/Customization.lyx index e68c89f536..6db72fb27a 100644 --- a/lib/doc/fr/Customization.lyx +++ b/lib/doc/fr/Customization.lyx @@ -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 diff --git a/lib/doc/ja/Customization.lyx b/lib/doc/ja/Customization.lyx index baf0823daa..2faeb0733b 100644 --- a/lib/doc/ja/Customization.lyx +++ b/lib/doc/ja/Customization.lyx @@ -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 diff --git a/lib/scripts/layout2layout.py b/lib/scripts/layout2layout.py index 77cafa048a..2cf54c5e14 100644 --- a/lib/scripts/layout2layout.py +++ b/lib/scripts/layout2layout.py @@ -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): diff --git a/lib/ui/stdcontext.inc b/lib/ui/stdcontext.inc index 9e68cc14e8..ccfd20065e 100644 --- a/lib/ui/stdcontext.inc +++ b/lib/ui/stdcontext.inc @@ -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 diff --git a/src/Color.cpp b/src/Color.cpp index 6d5b73883e..d9933ce34e 100644 --- a/src/Color.cpp +++ b/src/Color.cpp @@ -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" }, diff --git a/src/ColorCode.h b/src/ColorCode.h index f98ecf8008..d0973852f8 100644 --- a/src/ColorCode.h +++ b/src/ColorCode.h @@ -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, diff --git a/src/CutAndPaste.cpp b/src/CutAndPaste.cpp index 05f9b90bca..d79ef5a655 100644 --- a/src/CutAndPaste.cpp +++ b/src/CutAndPaste.cpp @@ -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() || diff --git a/src/Makefile.am b/src/Makefile.am index 905617b403..28592fb0a2 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -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 \ diff --git a/src/Text2.cpp b/src/Text2.cpp index c223ce06e6..8eb70f8e32 100644 --- a/src/Text2.cpp +++ b/src/Text2.cpp @@ -42,7 +42,7 @@ #include "TextClass.h" #include "TextMetrics.h" -#include "insets/InsetCollapsable.h" +#include "insets/InsetCollapsible.h" #include "mathed/InsetMathHull.h" diff --git a/src/Text3.cpp b/src/Text3.cpp index 930b5347c2..4b2f90af4b 100644 --- a/src/Text3.cpp +++ b/src/Text3.cpp @@ -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(); diff --git a/src/TextClass.cpp b/src/TextClass.cpp index 8b6b5a7f84..f63632471c 100644 --- a/src/TextClass.cpp +++ b/src/TextClass.cpp @@ -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 diff --git a/src/factory.cpp b/src/factory.cpp index 72019cd6f7..765daceba8 100644 --- a/src/factory.cpp +++ b/src/factory.cpp @@ -680,7 +680,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 diff --git a/src/frontends/qt4/GuiERT.cpp b/src/frontends/qt4/GuiERT.cpp index 8fc92e2250..fece83ea76 100644 --- a/src/frontends/qt4/GuiERT.cpp +++ b/src/frontends/qt4/GuiERT.cpp @@ -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(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; } } diff --git a/src/insets/Inset.cpp b/src/insets/Inset.cpp index b458c8181b..f2e2d4bcb8 100644 --- a/src/insets/Inset.cpp +++ b/src/insets/Inset.cpp @@ -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"); diff --git a/src/insets/Inset.h b/src/insets/Inset.h index 6ce428f96a..578a7f4d5a 100644 --- a/src/insets/Inset.h +++ b/src/insets/Inset.h @@ -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; } diff --git a/src/insets/InsetArgument.cpp b/src/insets/InsetArgument.cpp index 88e733613a..a3cf1c5202 100644 --- a/src/insets/InsetArgument.cpp +++ b/src/insets/InsetArgument.cpp @@ -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(); } diff --git a/src/insets/InsetArgument.h b/src/insets/InsetArgument.h index 86de5b1ca1..9fff93b4e1 100644 --- a/src/insets/InsetArgument.h +++ b/src/insets/InsetArgument.h @@ -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; diff --git a/src/insets/InsetBox.cpp b/src/insets/InsetBox.cpp index 90523c5c08..c593c4c759 100644 --- a/src/insets/InsetBox.cpp +++ b/src/insets/InsetBox.cpp @@ -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); } diff --git a/src/insets/InsetBox.h b/src/insets/InsetBox.h index 151d622fcb..d5610b746a 100644 --- a/src/insets/InsetBox.h +++ b/src/insets/InsetBox.h @@ -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(); diff --git a/src/insets/InsetBranch.cpp b/src/insets/InsetBranch.cpp index 3d1a147a86..77af2829e1 100644 --- a/src/insets/InsetBranch.cpp +++ b/src/insets/InsetBranch.cpp @@ -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); } diff --git a/src/insets/InsetBranch.h b/src/insets/InsetBranch.h index bcb2cd8fd9..391f2475f0 100644 --- a/src/insets/InsetBranch.h +++ b/src/insets/InsetBranch.h @@ -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: /// diff --git a/src/insets/InsetCaption.cpp b/src/insets/InsetCaption.cpp index 36ebfa0a95..0850363bc4 100644 --- a/src/insets/InsetCaption.cpp +++ b/src/insets/InsetCaption.cpp @@ -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); } diff --git a/src/insets/InsetCaptionable.cpp b/src/insets/InsetCaptionable.cpp index 0683aa6948..467106fa43 100644 --- a/src/insets/InsetCaptionable.cpp +++ b/src/insets/InsetCaptionable.cpp @@ -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); } diff --git a/src/insets/InsetCaptionable.h b/src/insets/InsetCaptionable.h index 005c371ea2..8d0b486bcf 100644 --- a/src/insets/InsetCaptionable.h +++ b/src/insets/InsetCaptionable.h @@ -15,16 +15,16 @@ #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_; } /// diff --git a/src/insets/InsetCode.h b/src/insets/InsetCode.h index e580472ec3..3633da727a 100644 --- a/src/insets/InsetCode.h +++ b/src/insets/InsetCode.h @@ -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 index ab84cc9c7d..0000000000 --- a/src/insets/InsetCollapsable.cpp +++ /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 - -#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::iterator it = view_.begin(); - map::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(this)->setDrawFrame(false); - InsetText::draw(pi, textx, texty); - const_cast(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(*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 index bb4f234b9d..0000000000 --- a/src/insets/InsetCollapsable.h +++ /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 - -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 view_; -}; - -} // namespace lyx - -#endif diff --git a/src/insets/InsetCollapsible.cpp b/src/insets/InsetCollapsible.cpp new file mode 100644 index 0000000000..11c9e2a43d --- /dev/null +++ b/src/insets/InsetCollapsible.cpp @@ -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 + +#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::iterator it = view_.begin(); + map::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(this)->setDrawFrame(false); + InsetText::draw(pi, textx, texty); + const_cast(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(*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 index 0000000000..380d9aef6a --- /dev/null +++ b/src/insets/InsetCollapsible.h @@ -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 + +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 view_; +}; + +} // namespace lyx + +#endif diff --git a/src/insets/InsetCommand.cpp b/src/insets/InsetCommand.cpp index 5043386165..7693d08fd7 100644 --- a/src/insets/InsetCommand.cpp +++ b/src/insets/InsetCommand.cpp @@ -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: { diff --git a/src/insets/InsetERT.cpp b/src/insets/InsetERT.cpp index ce9d3834d2..2d96f952f6 100644 --- a/src/insets/InsetERT.cpp +++ b/src/insets/InsetERT.cpp @@ -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; diff --git a/src/insets/InsetERT.h b/src/insets/InsetERT.h index eb6ab9178d..87ed11616a 100644 --- a/src/insets/InsetERT.h +++ b/src/insets/InsetERT.h @@ -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); diff --git a/src/insets/InsetFlex.cpp b/src/insets/InsetFlex.cpp index 6c91b4c10a..61e47d4c36 100644 --- a/src/insets/InsetFlex.cpp +++ b/src/insets/InsetFlex.cpp @@ -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(); } diff --git a/src/insets/InsetFlex.h b/src/insets/InsetFlex.h index ced22c8746..0844246769 100644 --- a/src/insets/InsetFlex.h +++ b/src/insets/InsetFlex.h @@ -13,14 +13,14 @@ #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); diff --git a/src/insets/InsetFoot.cpp b/src/insets/InsetFoot.cpp index cb7462d503..86c719ae65 100644 --- a/src/insets/InsetFoot.cpp +++ b/src/insets/InsetFoot.cpp @@ -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_+ ": "); } diff --git a/src/insets/InsetFootlike.cpp b/src/insets/InsetFootlike.cpp index 5685e865bf..739d89745e 100644 --- a/src/insets/InsetFootlike.cpp +++ b/src/insets/InsetFootlike.cpp @@ -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); } diff --git a/src/insets/InsetFootlike.h b/src/insets/InsetFootlike.h index f16f355a96..f4bcbdef19 100644 --- a/src/insets/InsetFootlike.h +++ b/src/insets/InsetFootlike.h @@ -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 *); diff --git a/src/insets/InsetIPAMacro.cpp b/src/insets/InsetIPAMacro.cpp index cbc3abf525..4b2369b379 100644 --- a/src/insets/InsetIPAMacro.cpp +++ b/src/insets/InsetIPAMacro.cpp @@ -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 "͡" (toptiebar) // or "͜" (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); } diff --git a/src/insets/InsetIPAMacro.h b/src/insets/InsetIPAMacro.h index c29fc49c91..fb35adb763 100644 --- a/src/insets/InsetIPAMacro.h +++ b/src/insets/InsetIPAMacro.h @@ -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: /// diff --git a/src/insets/InsetIndex.cpp b/src/insets/InsetIndex.cpp index 219954d4e3..584fb280c7 100644 --- a/src/insets/InsetIndex.cpp +++ b/src/insets/InsetIndex.cpp @@ -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); } diff --git a/src/insets/InsetIndex.h b/src/insets/InsetIndex.h index 3ee17509dc..01bf7096b0 100644 --- a/src/insets/InsetIndex.h +++ b/src/insets/InsetIndex.h @@ -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 &); diff --git a/src/insets/InsetInfo.cpp b/src/insets/InsetInfo.cpp index 42e0f6cda2..a54be67fcf 100644 --- a/src/insets/InsetInfo.cpp +++ b/src/insets/InsetInfo.cpp @@ -92,7 +92,7 @@ NameTranslator const & nameTranslator() InsetInfo::InsetInfo(Buffer * buf, string const & name) - : InsetCollapsable(buf), type_(UNKNOWN_INFO), name_() + : InsetCollapsible(buf), type_(UNKNOWN_INFO), name_() { setInfo(name); status_ = Collapsed; @@ -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: @@ -264,7 +264,7 @@ void InsetInfo::doDispatch(Cursor & cur, FuncRequest & cmd) } default: - InsetCollapsable::doDispatch(cur, cmd); + InsetCollapsible::doDispatch(cur, cmd); break; } } @@ -498,8 +498,8 @@ void InsetInfo::updateInfo() 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(); } diff --git a/src/insets/InsetInfo.h b/src/insets/InsetInfo.h index 96ba22cf12..8cb7f45adb 100644 --- a/src/insets/InsetInfo.h +++ b/src/insets/InsetInfo.h @@ -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; /// info_type type_; /// diff --git a/src/insets/InsetListingsParams.cpp b/src/insets/InsetListingsParams.cpp index ea7eeb699f..998554c395 100644 --- a/src/insets/InsetListingsParams.cpp +++ b/src/insets/InsetListingsParams.cpp @@ -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(s); + status_ = static_cast(s); string par; lex >> par; fromEncodedString(par); diff --git a/src/insets/InsetListingsParams.h b/src/insets/InsetListingsParams.h index ce50de669d..ddcca62f23 100644 --- a/src/insets/InsetListingsParams.h +++ b/src/insets/InsetListingsParams.h @@ -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 > keyValuePair; keyValuePair params_; - /// collapsable status - InsetCollapsable::CollapseStatus status_; + /// collapsible status + InsetCollapsible::CollapseStatus status_; }; diff --git a/src/insets/InsetNote.cpp b/src/insets/InsetNote.cpp index 1ee573c9e6..ef946db338 100644 --- a/src/insets/InsetNote.cpp +++ b/src/insets/InsetNote.cpp @@ -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; diff --git a/src/insets/InsetNote.h b/src/insets/InsetNote.h index d6cc0a6510..9df1a501a2 100644 --- a/src/insets/InsetNote.h +++ b/src/insets/InsetNote.h @@ -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: /// diff --git a/src/insets/InsetPhantom.cpp b/src/insets/InsetPhantom.cpp index 2a004fa6f8..19e0570023 100644 --- a/src/insets/InsetPhantom.cpp +++ b/src/insets/InsetPhantom.cpp @@ -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 << ""; return i; diff --git a/src/insets/InsetPhantom.h b/src/insets/InsetPhantom.h index 42c3da1f26..46e8576678 100644 --- a/src/insets/InsetPhantom.h +++ b/src/insets/InsetPhantom.h @@ -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: /// diff --git a/src/insets/InsetScript.cpp b/src/insets/InsetScript.cpp index 44665a439b..918492fb55 100644 --- a/src/insets/InsetScript.cpp +++ b/src/insets/InsetScript.cpp @@ -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: