\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
\begin_layout Description
\lang english
-collapsable
+collapsible
\lang ngerman
Textfarbe in einklappbaren Einfügungen
\end_layout
\begin_layout Description
\lang english
-collapsableframe
+collapsibleframe
\lang ngerman
Rahmenfarbe in einklappbaren Einfügungen
\end_layout
\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
\begin_layout Description
\lang english
-collapsabletext
+collapsibletext
\lang french
texte d'insert repliable
\end_layout
\begin_layout Description
\lang english
-collapsableframe
+collapsibleframe
\lang french
cadre d'insert repliable
\end_layout
\end_layout
\begin_layout Description
-collapsabletext 畳み込み可能枠の文字色
+collapsibletext 畳み込み可能枠の文字色
\end_layout
\begin_layout Description
-collapsableframe 畳み込み可能枠の縁色
+collapsibleframe 畳み込み可能枠の縁色
\end_layout
\begin_layout Description
# 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
# 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").
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):
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
{ 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" },
/// 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,
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() ||
insets/InsetCaption.cpp \
insets/InsetCaptionable.cpp \
insets/InsetCitation.cpp \
- insets/InsetCollapsable.cpp \
+ insets/InsetCollapsible.cpp \
insets/InsetCommand.cpp \
insets/InsetCommandParams.cpp \
insets/InsetERT.cpp \
insets/InsetCaptionable.h \
insets/InsetCitation.h \
insets/InsetCode.h \
- insets/InsetCollapsable.h \
+ insets/InsetCollapsible.h \
insets/InsetCommand.h \
insets/InsetCommandParams.h \
insets/InsetERT.h \
#include "TextClass.h"
#include "TextMetrics.h"
-#include "insets/InsetCollapsable.h"
+#include "insets/InsetCollapsible.h"
#include "mathed/InsetMathHull.h"
#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"
if (!inset)
return false;
- if (InsetCollapsable * ci = inset->asInsetCollapsable())
+ if (InsetCollapsible * ci = inset->asInsetCollapsible())
ci->setButtonLabel();
cur.recordUndo();
// 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
}
// 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
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));
}
InsetERT const * ert = static_cast<InsetERT const *>(inset);
// FIXME: This dialog has absolutely no value...
BufferView const * bv = guiApp->currentView()->currentBufferView();
- InsetCollapsable::CollapseStatus status = ert->status(*bv);
+ InsetCollapsible::CollapseStatus status = ert->status(*bv);
switch (status) {
- case InsetCollapsable::Open: openRB->setChecked(true); break;
- case InsetCollapsable::Collapsed: collapsedRB->setChecked(true); break;
+ case InsetCollapsible::Open: openRB->setChecked(true); break;
+ case InsetCollapsible::Collapsed: collapsedRB->setChecked(true); break;
}
}
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");
class FuncRequest;
class FuncStatus;
class InsetArgument;
-class InsetCollapsable;
+class InsetCollapsible;
class InsetCommand;
class InsetIterator;
class InsetLayout;
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?
/// 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; }
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())
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);
}
}
setButtonLabel();
- InsetCollapsable::updateBuffer(it, utype);
+ InsetCollapsible::updateBuffer(it, utype);
}
fixParagraphLanguage(buffer().params().language);
}
else
- InsetCollapsable::doDispatch(cur, cmd);
+ InsetCollapsible::doDispatch(cur, cmd);
break;
default:
- InsetCollapsable::doDispatch(cur, cmd);
+ InsetCollapsible::doDispatch(cur, cmd);
break;
}
}
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);
}
}
{
if (font_ != inherit_font)
return font_;
- return InsetCollapsable::getFont();
+ return InsetCollapsible::getFont();
}
{
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();
}
#define INSETARGUMENT_H
-#include "InsetCollapsable.h"
+#include "InsetCollapsible.h"
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:
///
///
bool resetFontEdit() const { return false; }
//@}
- /// \name Public functions inherited from InsetCollapsable class
+ /// \name Public functions inherited from InsetCollapsible class
//@{
///
InsetLayout::InsetDecoration decoration() const;
/////////////////////////////////////////////////////////////////////////
InsetBox::InsetBox(Buffer * buffer, string const & label)
- : InsetCollapsable(buffer), params_(label)
+ : InsetCollapsible(buffer), params_(label)
{}
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);
}
if (btype == Boxed)
setFrameColor(lcolor.getFromLaTeXName(params_.framecolor));
else
- setFrameColor(Color_collapsableframe);
+ setFrameColor(Color_collapsibleframe);
}
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;
}
}
default:
- InsetCollapsable::doDispatch(cur, cmd);
+ InsetCollapsible::doDispatch(cur, cmd);
break;
}
}
flag.setEnabled(true);
return true;
}
- return InsetCollapsable::getStatus(cur, cmd, flag);
+ return InsetCollapsible::getStatus(cur, cmd, flag);
}
case LFUN_INSET_DIALOG_UPDATE:
return true;
default:
- return InsetCollapsable::getStatus(cur, cmd, flag);
+ return InsetCollapsible::getStatus(cur, cmd, flag);
}
}
features.require("framed");
break;
}
- InsetCollapsable::validate(features);
+ InsetCollapsible::validate(features);
}
#ifndef INSETBOX_H
#define INSETBOX_H
-#include "InsetCollapsable.h"
+#include "InsetCollapsible.h"
#include "Length.h"
///////////////////////////////////////////////////////////////////////
-class InsetBox : public InsetCollapsable
+class InsetBox : public InsetCollapsible
{
public:
///
std::string contextMenuName() const;
//@}
- /// \name Public functions inherited from InsetCollapsable class
+ /// \name Public functions inherited from InsetCollapsible class
//@{
///
void setButtonLabel();
namespace lyx {
InsetBranch::InsetBranch(Buffer * buf, InsetBranchParams const & params)
- : InsetCollapsable(buf, InsetText::DefaultLayout), params_(params)
+ : InsetCollapsible(buf, InsetText::DefaultLayout), params_(params)
{}
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);
}
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;
}
}
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;
}
void InsetBranch::toString(odocstream & os) const
{
if (producesOutput())
- InsetCollapsable::toString(os);
+ InsetCollapsible::toString(os);
}
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);
}
void InsetBranch::updateBuffer(ParIterator const & it, UpdateType utype)
{
setLabel(params_.branch + (params_.inverted ? " (-)" : ""));
- InsetCollapsable::updateBuffer(it, utype);
+ InsetCollapsible::updateBuffer(it, utype);
}
#ifndef INSETBRANCH_H
#define INSETBRANCH_H
-#include "InsetCollapsable.h"
+#include "InsetCollapsible.h"
namespace lyx {
/// The Branch inset for alternative, conditional output.
-class InsetBranch : public InsetCollapsable
+class InsetBranch : public InsetCollapsible
{
public:
///
labelwidth_(0), is_subfloat_(false), type_(type)
{
setDrawFrame(true);
- setFrameColor(Color_collapsableframe);
+ setFrameColor(Color_collapsibleframe);
}
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();
}
// 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)
bool InsetCaptionable::insetAllowed(InsetCode c) const
{
- return (c == CAPTION_CODE) || InsetCollapsable::insetAllowed(c);
+ return (c == CAPTION_CODE) || InsetCollapsible::insetAllowed(c);
}
#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_; }
///
///
INFO_CODE, // 45
///
- COLLAPSABLE_CODE,
+ COLLAPSIBLE_CODE,
///
PHANTOM_CODE,
///
+++ /dev/null
-/**
- * \file InsetCollapsable.cpp
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author Alejandro Aguilar Sierra
- * \author Jürgen Vigna
- * \author Lars Gullik Bjønnes
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#include <config.h>
-
-#include "InsetCollapsable.h"
-
-#include "Buffer.h"
-#include "BufferView.h"
-#include "Cursor.h"
-#include "Dimension.h"
-#include "FuncRequest.h"
-#include "FuncStatus.h"
-#include "InsetLayout.h"
-#include "Lexer.h"
-#include "MetricsInfo.h"
-#include "OutputParams.h"
-#include "TocBackend.h"
-
-#include "frontends/FontMetrics.h"
-#include "frontends/Painter.h"
-
-#include "support/debug.h"
-#include "support/docstream.h"
-#include "support/gettext.h"
-#include "support/lassert.h"
-#include "support/lstrings.h"
-#include "support/RefChanger.h"
-
-using namespace std;
-
-
-namespace lyx {
-
-InsetCollapsable::InsetCollapsable(Buffer * buf, InsetText::UsePlain ltype)
- : InsetText(buf, ltype), status_(Open)
-{
- setDrawFrame(true);
- setFrameColor(Color_collapsableframe);
-}
-
-
-// The sole purpose of this copy constructor is to make sure
-// that the view_ map is not copied and remains empty.
-InsetCollapsable::InsetCollapsable(InsetCollapsable const & rhs)
- : InsetText(rhs),
- status_(rhs.status_),
- labelstring_(rhs.labelstring_)
-{}
-
-
-InsetCollapsable::~InsetCollapsable()
-{
- map<BufferView const *, View>::iterator it = view_.begin();
- map<BufferView const *, View>::iterator end = view_.end();
- for (; it != end; ++it)
- if (it->second.mouse_hover_)
- it->first->clearLastInset(this);
-}
-
-
-InsetCollapsable::CollapseStatus InsetCollapsable::status(BufferView const & bv) const
-{
- if (decoration() == InsetLayout::CONGLOMERATE)
- return status_;
- return view_[&bv].auto_open_ ? Open : status_;
-}
-
-
-InsetCollapsable::Geometry InsetCollapsable::geometry(BufferView const & bv) const
-{
- switch (decoration()) {
- case InsetLayout::CLASSIC:
- if (status(bv) == Open)
- return view_[&bv].openinlined_ ? LeftButton : TopButton;
- return ButtonOnly;
-
- case InsetLayout::MINIMALISTIC:
- return status(bv) == Open ? NoButton : ButtonOnly ;
-
- case InsetLayout::CONGLOMERATE:
- return status(bv) == Open ? SubLabel : Corners ;
-
- case InsetLayout::DEFAULT:
- break; // this shouldn't happen
- }
-
- // dummy return value to shut down a warning,
- // this is dead code.
- return NoButton;
-}
-
-
-docstring InsetCollapsable::toolTip(BufferView const & bv, int x, int y) const
-{
- Dimension const dim = dimensionCollapsed(bv);
- if (geometry(bv) == NoButton)
- return translateIfPossible(getLayout().labelstring());
- if (x > xo(bv) + dim.wid || y > yo(bv) + dim.des || isOpen(bv))
- return docstring();
-
- return toolTipText();
-}
-
-
-void InsetCollapsable::write(ostream & os) const
-{
- os << "status ";
- switch (status_) {
- case Open:
- os << "open";
- break;
- case Collapsed:
- os << "collapsed";
- break;
- }
- os << "\n";
- text().write(os);
-}
-
-
-void InsetCollapsable::read(Lexer & lex)
-{
- lex.setContext("InsetCollapsable::read");
- string tmp_token;
- status_ = Collapsed;
- lex >> "status" >> tmp_token;
- if (tmp_token == "open")
- status_ = Open;
-
- InsetText::read(lex);
- setButtonLabel();
-}
-
-
-Dimension InsetCollapsable::dimensionCollapsed(BufferView const & bv) const
-{
- Dimension dim;
- FontInfo labelfont(getLabelfont());
- labelfont.realize(sane_font);
- theFontMetrics(labelfont).buttonText(
- buttonLabel(bv), TEXT_TO_INSET_OFFSET, dim.wid, dim.asc, dim.des);
- return dim;
-}
-
-
-void InsetCollapsable::metrics(MetricsInfo & mi, Dimension & dim) const
-{
- view_[mi.base.bv].auto_open_ = mi.base.bv->cursor().isInside(this);
-
- FontInfo tmpfont = mi.base.font;
- mi.base.font = getFont();
- mi.base.font.realize(tmpfont);
-
- BufferView const & bv = *mi.base.bv;
-
- switch (geometry(bv)) {
- case NoButton:
- InsetText::metrics(mi, dim);
- break;
- case Corners:
- InsetText::metrics(mi, dim);
- dim.des -= 3;
- dim.asc -= 1;
- break;
- case SubLabel: {
- InsetText::metrics(mi, dim);
- // consider width of the inset label
- FontInfo font(getLabelfont());
- font.realize(sane_font);
- font.decSize();
- font.decSize();
- int w = 0;
- int a = 0;
- int d = 0;
- theFontMetrics(font).rectText(buttonLabel(bv), w, a, d);
- dim.des += a + d;
- break;
- }
- case TopButton:
- case LeftButton:
- case ButtonOnly:
- if (hasFixedWidth()){
- int const mindim = view_[&bv].button_dim_.x2 - view_[&bv].button_dim_.x1;
- if (mi.base.textwidth < mindim)
- mi.base.textwidth = mindim;
- }
- dim = dimensionCollapsed(bv);
- if (geometry(bv) == TopButton || geometry(bv) == LeftButton) {
- Dimension textdim;
- InsetText::metrics(mi, textdim);
- view_[&bv].openinlined_ = (textdim.wid + dim.wid) < mi.base.textwidth;
- if (view_[&bv].openinlined_) {
- // Correct for button width.
- dim.wid += textdim.wid;
- dim.des = max(dim.des - textdim.asc + dim.asc, textdim.des);
- dim.asc = textdim.asc;
- } else {
- dim.des += textdim.height() + TEXT_TO_INSET_OFFSET;
- dim.wid = max(dim.wid, textdim.wid);
- }
- }
- break;
- }
-
- mi.base.font = tmpfont;
-}
-
-
-bool InsetCollapsable::setMouseHover(BufferView const * bv, bool mouse_hover)
- const
-{
- view_[bv].mouse_hover_ = mouse_hover;
- return true;
-}
-
-
-void InsetCollapsable::draw(PainterInfo & pi, int x, int y) const
-{
- BufferView const & bv = *pi.base.bv;
-
- view_[&bv].auto_open_ = bv.cursor().isInside(this);
-
- Changer dummy = pi.base.font.change(getFont(), true);
-
- // Draw button first -- top, left or only
- Dimension dimc = dimensionCollapsed(bv);
-
- if (geometry(bv) == TopButton ||
- geometry(bv) == LeftButton ||
- geometry(bv) == ButtonOnly) {
- view_[&bv].button_dim_.x1 = x + 0;
- view_[&bv].button_dim_.x2 = x + dimc.width();
- view_[&bv].button_dim_.y1 = y - dimc.asc;
- view_[&bv].button_dim_.y2 = y + dimc.des;
-
- FontInfo labelfont = getLabelfont();
- labelfont.setColor(labelColor());
- labelfont.realize(pi.base.font);
- pi.pain.buttonText(x, y, buttonLabel(bv), labelfont,
- view_[&bv].mouse_hover_ ? Color_buttonhoverbg : Color_buttonbg,
- Color_buttonframe, TEXT_TO_INSET_OFFSET);
- // Draw the change tracking cue on the label, unless RowPainter already
- // takes care of it.
- if (canPaintChange(bv))
- pi.change_.paintCue(pi, x, y, x + dimc.width(), labelfont);
- } else {
- view_[&bv].button_dim_.x1 = 0;
- view_[&bv].button_dim_.y1 = 0;
- view_[&bv].button_dim_.x2 = 0;
- view_[&bv].button_dim_.y2 = 0;
- }
-
- Dimension const textdim = dimensionHelper(bv);
- int const baseline = y;
- int textx, texty;
- Geometry g = geometry(bv);
- switch (g) {
- case LeftButton:
- case TopButton: {
- if (g == LeftButton) {
- textx = x + dimc.width();
- texty = baseline;
- } else {
- textx = x;
- texty = baseline + dimc.des + textdim.asc;
- }
- // Do not draw the cue for INSERTED -- it is already in the button and
- // that's enough.
- Changer dummy = (pi.change_.type == Change::INSERTED)
- ? make_change(pi.change_, Change())
- : Changer();
- InsetText::draw(pi, textx, texty);
- break;
- }
- case ButtonOnly:
- break;
- case NoButton:
- textx = x;
- texty = baseline;
- InsetText::draw(pi, textx, texty);
- break;
- case SubLabel:
- case Corners:
- textx = x;
- texty = baseline;
- { // We will take care of the frame and the change tracking cue
- // ourselves, below.
- Changer dummy = make_change(pi.change_, Change());
- const_cast<InsetCollapsable *>(this)->setDrawFrame(false);
- InsetText::draw(pi, textx, texty);
- const_cast<InsetCollapsable *>(this)->setDrawFrame(true);
- }
-
- int desc = textdim.descent();
- if (g == Corners)
- desc -= 3;
-
- // Colour the frame according to the change type. (Like for tables.)
- Color colour = pi.change_.changed() ? pi.change_.color()
- : Color_foreground;
- const int xx1 = x + TEXT_TO_INSET_OFFSET - 1;
- const int xx2 = x + textdim.wid - TEXT_TO_INSET_OFFSET + 1;
- pi.pain.line(xx1, y + desc - 4,
- xx1, y + desc, colour);
- if (status_ == Open)
- pi.pain.line(xx1, y + desc,
- xx2, y + desc, colour);
- else {
- // Make status_ value visible:
- pi.pain.line(xx1, y + desc,
- xx1 + 4, y + desc, colour);
- pi.pain.line(xx2 - 4, y + desc,
- xx2, y + desc, colour);
- }
- pi.pain.line(x + textdim.wid - 3, y + desc, x + textdim.wid - 3,
- y + desc - 4, colour);
-
- // the label below the text. Can be toggled.
- if (g == SubLabel) {
- FontInfo font(getLabelfont());
- if (pi.change_.changed())
- font.setPaintColor(colour);
- font.realize(sane_font);
- font.decSize();
- font.decSize();
- int w = 0;
- int a = 0;
- int d = 0;
- Color const col = pi.full_repaint ? Color_none : pi.backgroundColor(this);
- theFontMetrics(font).rectText(buttonLabel(bv), w, a, d);
- int const ww = max(textdim.wid, w);
- pi.pain.rectText(x + (ww - w) / 2, y + desc + a,
- buttonLabel(bv), font, col, Color_none);
- }
-
- int const y1 = y - textdim.asc + 3;
- // a visual cue when the cursor is inside the inset
- Cursor const & cur = bv.cursor();
- if (cur.isInside(this)) {
- pi.pain.line(xx1, y1 + 4, xx1, y1, colour);
- pi.pain.line(xx1 + 4, y1, xx1, y1, colour);
- pi.pain.line(xx2, y1 + 4, xx2, y1, colour);
- pi.pain.line(xx2 - 4, y1, xx2, y1, colour);
- }
- // Strike through the inset if deleted and not already handled by
- // RowPainter.
- if (pi.change_.deleted() && canPaintChange(bv))
- pi.change_.paintCue(pi, xx1, y1, xx2, y + desc);
- break;
- }
-}
-
-
-void InsetCollapsable::cursorPos(BufferView const & bv,
- CursorSlice const & sl, bool boundary, int & x, int & y) const
-{
- if (geometry(bv) == ButtonOnly)
- status_ = Open;
-
- InsetText::cursorPos(bv, sl, boundary, x, y);
- Dimension const textdim = dimensionHelper(bv);
-
- switch (geometry(bv)) {
- case LeftButton:
- x += dimensionCollapsed(bv).wid;
- break;
- case TopButton: {
- y += dimensionCollapsed(bv).des + textdim.asc;
- break;
- }
- case NoButton:
- case SubLabel:
- case Corners:
- // Do nothing
- break;
- case ButtonOnly:
- // Cannot get here
- break;
- }
-}
-
-
-bool InsetCollapsable::editable() const
-{
- switch (decoration()) {
- case InsetLayout::CLASSIC:
- case InsetLayout::MINIMALISTIC:
- return status_ == Open;
- default:
- return true;
- }
-}
-
-
-bool InsetCollapsable::descendable(BufferView const & bv) const
-{
- return geometry(bv) != ButtonOnly;
-}
-
-
-bool InsetCollapsable::clickable(BufferView const & bv, int x, int y) const
-{
- return view_[&bv].button_dim_.contains(x, y);
-}
-
-
-docstring const InsetCollapsable::getNewLabel(docstring const & l) const
-{
- odocstringstream label;
- pos_type const max_length = 15;
- pos_type const p_siz = paragraphs().begin()->size();
- pos_type const n = min(max_length, p_siz);
- pos_type i = 0;
- pos_type j = 0;
- for (; i < n && j < p_siz; ++j) {
- if (paragraphs().begin()->isInset(j)) {
- if (!paragraphs().begin()->getInset(j)->isChar())
- continue;
- paragraphs().begin()->getInset(j)->toString(label);
- } else
- label.put(paragraphs().begin()->getChar(j));
- ++i;
- }
- if (paragraphs().size() > 1 || (i > 0 && j < p_siz)) {
- label << "...";
- }
- docstring const lbl = label.str();
- return lbl.empty() ? l : lbl;
-}
-
-
-void InsetCollapsable::edit(Cursor & cur, bool front, EntryDirection entry_from)
-{
- //lyxerr << "InsetCollapsable: edit left/right" << endl;
- cur.push(*this);
- InsetText::edit(cur, front, entry_from);
-}
-
-
-Inset * InsetCollapsable::editXY(Cursor & cur, int x, int y)
-{
- //lyxerr << "InsetCollapsable: edit xy" << endl;
- if (geometry(cur.bv()) == ButtonOnly
- || (view_[&cur.bv()].button_dim_.contains(x, y)
- && geometry(cur.bv()) != NoButton))
- return this;
- cur.push(*this);
- return InsetText::editXY(cur, x, y);
-}
-
-
-void InsetCollapsable::doDispatch(Cursor & cur, FuncRequest & cmd)
-{
- //lyxerr << "InsetCollapsable::doDispatch (begin): cmd: " << cmd
- // << " cur: " << cur << " bvcur: " << cur.bv().cursor() << endl;
-
- bool const hitButton = clickable(cur.bv(), cmd.x(), cmd.y());
-
- switch (cmd.action()) {
- case LFUN_MOUSE_PRESS:
- if (hitButton) {
- switch (cmd.button()) {
- case mouse_button::button1:
- case mouse_button::button3:
- // Pass the command to the enclosing InsetText,
- // so that the cursor gets set.
- cur.undispatched();
- break;
- case mouse_button::none:
- case mouse_button::button2:
- case mouse_button::button4:
- case mouse_button::button5:
- // Nothing to do.
- cur.noScreenUpdate();
- break;
- }
- } else if (geometry(cur.bv()) != ButtonOnly)
- InsetText::doDispatch(cur, cmd);
- else
- cur.undispatched();
- break;
-
- case LFUN_MOUSE_DOUBLE:
- case LFUN_MOUSE_TRIPLE:
- if (hitButton)
- cur.noScreenUpdate();
- else if (geometry(cur.bv()) != ButtonOnly)
- InsetText::doDispatch(cur, cmd);
- else
- cur.undispatched();
- break;
-
- case LFUN_MOUSE_RELEASE:
- if (!hitButton) {
- // The mouse click has to be within the inset!
- if (geometry(cur.bv()) != ButtonOnly)
- InsetText::doDispatch(cur, cmd);
- else
- cur.undispatched();
- break;
- }
- if (cmd.button() != mouse_button::button1) {
- // Nothing to do.
- cur.noScreenUpdate();
- break;
- }
- // if we are selecting, we do not want to
- // toggle the inset.
- if (cur.selection())
- break;
- // Left button is clicked, the user asks to
- // toggle the inset visual state.
- cur.dispatched();
- cur.screenUpdateFlags(Update::Force | Update::FitCursor);
- if (geometry(cur.bv()) == ButtonOnly) {
- setStatus(cur, Open);
- edit(cur, true);
- }
- else
- setStatus(cur, Collapsed);
- cur.bv().cursor() = cur;
- break;
-
- case LFUN_INSET_TOGGLE:
- if (cmd.argument() == "open")
- setStatus(cur, Open);
- else if (cmd.argument() == "close")
- setStatus(cur, Collapsed);
- else if (cmd.argument() == "toggle" || cmd.argument().empty())
- if (status_ == Open)
- setStatus(cur, Collapsed);
- else
- setStatus(cur, Open);
- else // if assign or anything else
- cur.undispatched();
- cur.dispatched();
- break;
-
- default:
- InsetText::doDispatch(cur, cmd);
- break;
- }
-}
-
-
-bool InsetCollapsable::getStatus(Cursor & cur, FuncRequest const & cmd,
- FuncStatus & flag) const
-{
- switch (cmd.action()) {
- case LFUN_INSET_TOGGLE:
- if (cmd.argument() == "open")
- flag.setEnabled(status_ != Open);
- else if (cmd.argument() == "close")
- flag.setEnabled(status_ == Open);
- else if (cmd.argument() == "toggle" || cmd.argument().empty()) {
- flag.setEnabled(true);
- flag.setOnOff(status_ == Open);
- } else
- flag.setEnabled(false);
- return true;
-
- default:
- return InsetText::getStatus(cur, cmd, flag);
- }
-}
-
-
-void InsetCollapsable::setLabel(docstring const & l)
-{
- labelstring_ = l;
-}
-
-
-docstring InsetCollapsable::getLabel() const
-{
- InsetLayout const & il = getLayout();
- return labelstring_.empty() ?
- translateIfPossible(il.labelstring()) : labelstring_;
-}
-
-
-docstring const InsetCollapsable::buttonLabel(BufferView const & bv) const
-{
- InsetLayout const & il = getLayout();
- docstring const label = getLabel();
- if (!il.contentaslabel() || geometry(bv) != ButtonOnly)
- return label;
- return getNewLabel(label);
-}
-
-
-void InsetCollapsable::setStatus(Cursor & cur, CollapseStatus status)
-{
- status_ = status;
- setButtonLabel();
- if (status_ == Collapsed)
- cur.leaveInset(*this);
-}
-
-
-InsetLayout::InsetDecoration InsetCollapsable::decoration() const
-{
- InsetLayout::InsetDecoration const dec = getLayout().decoration();
- return dec == InsetLayout::DEFAULT ? InsetLayout::CLASSIC : dec;
-}
-
-
-string InsetCollapsable::contextMenu(BufferView const & bv, int x,
- int y) const
-{
- string context_menu = contextMenuName();
- string const it_context_menu = InsetText::contextMenuName();
- if (decoration() == InsetLayout::CONGLOMERATE)
- return context_menu + ";" + it_context_menu;
-
- string const ic_context_menu = InsetCollapsable::contextMenuName();
- if (ic_context_menu != context_menu)
- context_menu += ";" + ic_context_menu;
-
- if (geometry(bv) == NoButton)
- return context_menu + ";" + it_context_menu;
-
- Dimension dim = dimensionCollapsed(bv);
- if (x < xo(bv) + dim.wid && y < yo(bv) + dim.des)
- return context_menu;
-
- return it_context_menu;
-}
-
-
-string InsetCollapsable::contextMenuName() const
-{
- if (decoration() == InsetLayout::CONGLOMERATE)
- return "context-conglomerate";
- else
- return "context-collapsable";
-}
-
-
-bool InsetCollapsable::canPaintChange(BufferView const & bv) const
-{
- // return false to let RowPainter draw the change tracking cue consistently
- // with the surrounding text, when the inset is inline: for buttons, for
- // non-allowMultiPar insets.
- switch (geometry(bv)) {
- case Corners:
- case SubLabel:
- return allowMultiPar();
- case ButtonOnly:
- return false;
- default:
- break;
- }
- return true;
-}
-
-
-void InsetCollapsable::addToToc(DocIterator const & cpit, bool output_active,
- UpdateType utype, TocBackend & backend) const
-{
- bool doing_output = output_active && producesOutput();
- InsetLayout const & layout = getLayout();
- if (layout.addToToc()) {
- TocBuilder & b = backend.builder(layout.tocType());
- // Cursor inside the inset
- DocIterator pit = cpit;
- pit.push_back(CursorSlice(const_cast<InsetCollapsable &>(*this)));
- docstring const label = getLabel();
- b.pushItem(pit, label + (label.empty() ? "" : ": "), output_active);
- // Proceed with the rest of the inset.
- InsetText::addToToc(cpit, doing_output, utype, backend);
- if (layout.isTocCaption()) {
- docstring str;
- text().forOutliner(str, TOC_ENTRY_LENGTH);
- b.argumentItem(str);
- }
- b.pop();
- } else
- InsetText::addToToc(cpit, doing_output, utype, backend);
-}
-
-
-
-} // namespace lyx
+++ /dev/null
-// -*- C++ -*-
-/**
- * \file InsetCollapsable.h
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author Alejandro Aguilar Sierra
- * \author Jürgen Vigna
- * \author Lars Gullik Bjønnes
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#ifndef INSETCOLLAPSABLE_H
-#define INSETCOLLAPSABLE_H
-
-#include "InsetText.h"
-
-#include "Box.h"
-
-#include <map>
-
-namespace lyx {
-
-class CursorSlice;
-class InsetLayout;
-
-namespace frontend { class Painter; }
-
-/** A collapsable text inset
-
-*/
-class InsetCollapsable : public InsetText {
-public:
- ///
- InsetCollapsable(Buffer *, InsetText::UsePlain = InsetText::PlainLayout);
- ///
- InsetCollapsable(InsetCollapsable const & rhs);
- ///
- virtual ~InsetCollapsable();
- ///
- InsetCollapsable * asInsetCollapsable() { return this; }
- ///
- InsetCollapsable const * asInsetCollapsable() const { return this; }
- ///
- docstring toolTip(BufferView const & bv, int x, int y) const;
- ///
- docstring layoutName() const { return from_ascii("Collapsable"); }
- ///
- void read(Lexer &);
- ///
- void write(std::ostream &) const;
- ///
- void metrics(MetricsInfo &, Dimension &) const;
- ///
- void draw(PainterInfo & pi, int x, int y) const;
- ///
- virtual void drawBackground(PainterInfo &, int, int) const {}
-
- /// return x,y of given position relative to the inset's baseline
- void cursorPos(BufferView const & bv, CursorSlice const & sl,
- bool boundary, int & x, int & y) const;
- ///
- docstring const getNewLabel(docstring const & l) const;
- ///
- bool editable() const;
- ///
- bool hasSettings() const { return true; }
- /// Returns true if coordinates are over the inset's button.
- /// Always returns false when the inset does not have a
- /// button.
- bool clickable(BufferView const & bv, int x, int y) const;
- /// can we go further down on mouse click?
- bool descendable(BufferView const & bv) const;
- ///
- void setLabel(docstring const & l);
- ///
- docstring getLabel() const;
- ///
- virtual void setButtonLabel() {}
- ///
- virtual docstring const buttonLabel(BufferView const &) const;
- ///
- bool isOpen(BufferView const & bv) const
- { return geometry(bv) != ButtonOnly; }
- ///
- enum CollapseStatus {
- Collapsed,
- Open
- };
- ///
- virtual void setStatus(Cursor & cur, CollapseStatus st);
- ///
- CollapseStatus status(BufferView const & bv) const;
- /** Of the old CollapseStatus we only keep the values
- * Open and Collapsed.
- * We define a list of possible inset decoration
- * styles, and a list of possible (concrete, visual)
- * inset geometries. Relationships between them
- * (geometries in body of table):
- *
- * \ CollapseStatus:
- * Decoration: \ Open Collapsed
- * -------------+-------------------------------
- * Classic | *) TopButton, <--x) ButtonOnly
- * | LeftButton
- * Minimalistic | NoButton ButtonOnly
- * Conglomerate | SubLabel Corners
- * ---------------------------------------------
- * *) toggled by openinlined_
- * x) toggled by auto_open_
- */
-
- /// Default looks
- virtual InsetLayout::InsetDecoration decoration() const;
- /// Inset font
- virtual FontInfo getFont() const { return getLayout().font(); }
- /// Label font
- virtual FontInfo getLabelfont() const { return getLayout().labelfont(); }
- ///
- enum Geometry {
- TopButton,
- ButtonOnly,
- NoButton,
- LeftButton,
- SubLabel,
- Corners
- };
- /// Returns the geometry based on CollapseStatus
- /// (status_), auto_open_[BufferView] and openinlined_,
- /// and of course decoration().
- Geometry geometry(BufferView const & bv) const;
- ///
- bool canPaintChange(BufferView const & bv) const;
- ///
- bool getStatus(Cursor &, FuncRequest const &, FuncStatus &) const;
- ///
- bool setMouseHover(BufferView const * bv, bool mouse_hover) const;
- ///
- ColorCode backgroundColor(PainterInfo const &) const
- { return getLayout().bgcolor(); }
- ///
- ColorCode labelColor() const { return getLayout().labelfont().color(); }
- ///
- InsetCode lyxCode() const { return COLLAPSABLE_CODE; }
-
- ///
- virtual bool usePlainLayout() const { return true; }
- ///
- std::string contextMenu(BufferView const & bv, int x, int y) const;
- ///
- std::string contextMenuName() const;
- ///
- void addToToc(DocIterator const & dit, bool output_active,
- UpdateType utype, TocBackend & backend) const; //override
-
-protected:
- ///
- void doDispatch(Cursor & cur, FuncRequest & cmd);
- ///
- void edit(Cursor & cur, bool front,
- EntryDirection entry_from = ENTRY_DIRECTION_IGNORE);
- ///
- Inset * editXY(Cursor & cur, int x, int y);
- ///
- mutable CollapseStatus status_;
-private:
- ///
- Dimension dimensionCollapsed(BufferView const & bv) const;
- ///
- docstring labelstring_;
-
- // These variables depend of the view in which the inset is displayed
- struct View
- {
- /// The dimension of the inset button
- Box button_dim_;
- /// a substatus of the Open status, determined automatically in metrics
- bool openinlined_;
- /// the inset will automatically open when the cursor is inside. This is
- /// dependent on the bufferview, compare with InsetMathMacro::editing_.
- bool auto_open_;
- /// changes color when mouse enters/leaves this inset
- bool mouse_hover_;
- };
-
- ///
- mutable std::map<BufferView const *, View> view_;
-};
-
-} // namespace lyx
-
-#endif
--- /dev/null
+/**
+ * \file InsetCollapsible.cpp
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Alejandro Aguilar Sierra
+ * \author Jürgen Vigna
+ * \author Lars Gullik Bjønnes
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#include <config.h>
+
+#include "InsetCollapsible.h"
+
+#include "Buffer.h"
+#include "BufferView.h"
+#include "Cursor.h"
+#include "Dimension.h"
+#include "FuncRequest.h"
+#include "FuncStatus.h"
+#include "InsetLayout.h"
+#include "Lexer.h"
+#include "MetricsInfo.h"
+#include "OutputParams.h"
+#include "TocBackend.h"
+
+#include "frontends/FontMetrics.h"
+#include "frontends/Painter.h"
+
+#include "support/debug.h"
+#include "support/docstream.h"
+#include "support/gettext.h"
+#include "support/lassert.h"
+#include "support/lstrings.h"
+#include "support/RefChanger.h"
+
+using namespace std;
+
+
+namespace lyx {
+
+InsetCollapsible::InsetCollapsible(Buffer * buf, InsetText::UsePlain ltype)
+ : InsetText(buf, ltype), status_(Open)
+{
+ setDrawFrame(true);
+ setFrameColor(Color_collapsibleframe);
+}
+
+
+// The sole purpose of this copy constructor is to make sure
+// that the view_ map is not copied and remains empty.
+InsetCollapsible::InsetCollapsible(InsetCollapsible const & rhs)
+ : InsetText(rhs),
+ status_(rhs.status_),
+ labelstring_(rhs.labelstring_)
+{}
+
+
+InsetCollapsible::~InsetCollapsible()
+{
+ map<BufferView const *, View>::iterator it = view_.begin();
+ map<BufferView const *, View>::iterator end = view_.end();
+ for (; it != end; ++it)
+ if (it->second.mouse_hover_)
+ it->first->clearLastInset(this);
+}
+
+
+InsetCollapsible::CollapseStatus InsetCollapsible::status(BufferView const & bv) const
+{
+ if (decoration() == InsetLayout::CONGLOMERATE)
+ return status_;
+ return view_[&bv].auto_open_ ? Open : status_;
+}
+
+
+InsetCollapsible::Geometry InsetCollapsible::geometry(BufferView const & bv) const
+{
+ switch (decoration()) {
+ case InsetLayout::CLASSIC:
+ if (status(bv) == Open)
+ return view_[&bv].openinlined_ ? LeftButton : TopButton;
+ return ButtonOnly;
+
+ case InsetLayout::MINIMALISTIC:
+ return status(bv) == Open ? NoButton : ButtonOnly ;
+
+ case InsetLayout::CONGLOMERATE:
+ return status(bv) == Open ? SubLabel : Corners ;
+
+ case InsetLayout::DEFAULT:
+ break; // this shouldn't happen
+ }
+
+ // dummy return value to shut down a warning,
+ // this is dead code.
+ return NoButton;
+}
+
+
+docstring InsetCollapsible::toolTip(BufferView const & bv, int x, int y) const
+{
+ Dimension const dim = dimensionCollapsed(bv);
+ if (geometry(bv) == NoButton)
+ return translateIfPossible(getLayout().labelstring());
+ if (x > xo(bv) + dim.wid || y > yo(bv) + dim.des || isOpen(bv))
+ return docstring();
+
+ return toolTipText();
+}
+
+
+void InsetCollapsible::write(ostream & os) const
+{
+ os << "status ";
+ switch (status_) {
+ case Open:
+ os << "open";
+ break;
+ case Collapsed:
+ os << "collapsed";
+ break;
+ }
+ os << "\n";
+ text().write(os);
+}
+
+
+void InsetCollapsible::read(Lexer & lex)
+{
+ lex.setContext("InsetCollapsible::read");
+ string tmp_token;
+ status_ = Collapsed;
+ lex >> "status" >> tmp_token;
+ if (tmp_token == "open")
+ status_ = Open;
+
+ InsetText::read(lex);
+ setButtonLabel();
+}
+
+
+Dimension InsetCollapsible::dimensionCollapsed(BufferView const & bv) const
+{
+ Dimension dim;
+ FontInfo labelfont(getLabelfont());
+ labelfont.realize(sane_font);
+ theFontMetrics(labelfont).buttonText(
+ buttonLabel(bv), TEXT_TO_INSET_OFFSET, dim.wid, dim.asc, dim.des);
+ return dim;
+}
+
+
+void InsetCollapsible::metrics(MetricsInfo & mi, Dimension & dim) const
+{
+ view_[mi.base.bv].auto_open_ = mi.base.bv->cursor().isInside(this);
+
+ FontInfo tmpfont = mi.base.font;
+ mi.base.font = getFont();
+ mi.base.font.realize(tmpfont);
+
+ BufferView const & bv = *mi.base.bv;
+
+ switch (geometry(bv)) {
+ case NoButton:
+ InsetText::metrics(mi, dim);
+ break;
+ case Corners:
+ InsetText::metrics(mi, dim);
+ dim.des -= 3;
+ dim.asc -= 1;
+ break;
+ case SubLabel: {
+ InsetText::metrics(mi, dim);
+ // consider width of the inset label
+ FontInfo font(getLabelfont());
+ font.realize(sane_font);
+ font.decSize();
+ font.decSize();
+ int w = 0;
+ int a = 0;
+ int d = 0;
+ theFontMetrics(font).rectText(buttonLabel(bv), w, a, d);
+ dim.des += a + d;
+ break;
+ }
+ case TopButton:
+ case LeftButton:
+ case ButtonOnly:
+ if (hasFixedWidth()){
+ int const mindim = view_[&bv].button_dim_.x2 - view_[&bv].button_dim_.x1;
+ if (mi.base.textwidth < mindim)
+ mi.base.textwidth = mindim;
+ }
+ dim = dimensionCollapsed(bv);
+ if (geometry(bv) == TopButton || geometry(bv) == LeftButton) {
+ Dimension textdim;
+ InsetText::metrics(mi, textdim);
+ view_[&bv].openinlined_ = (textdim.wid + dim.wid) < mi.base.textwidth;
+ if (view_[&bv].openinlined_) {
+ // Correct for button width.
+ dim.wid += textdim.wid;
+ dim.des = max(dim.des - textdim.asc + dim.asc, textdim.des);
+ dim.asc = textdim.asc;
+ } else {
+ dim.des += textdim.height() + TEXT_TO_INSET_OFFSET;
+ dim.wid = max(dim.wid, textdim.wid);
+ }
+ }
+ break;
+ }
+
+ mi.base.font = tmpfont;
+}
+
+
+bool InsetCollapsible::setMouseHover(BufferView const * bv, bool mouse_hover)
+ const
+{
+ view_[bv].mouse_hover_ = mouse_hover;
+ return true;
+}
+
+
+void InsetCollapsible::draw(PainterInfo & pi, int x, int y) const
+{
+ BufferView const & bv = *pi.base.bv;
+
+ view_[&bv].auto_open_ = bv.cursor().isInside(this);
+
+ Changer dummy = pi.base.font.change(getFont(), true);
+
+ // Draw button first -- top, left or only
+ Dimension dimc = dimensionCollapsed(bv);
+
+ if (geometry(bv) == TopButton ||
+ geometry(bv) == LeftButton ||
+ geometry(bv) == ButtonOnly) {
+ view_[&bv].button_dim_.x1 = x + 0;
+ view_[&bv].button_dim_.x2 = x + dimc.width();
+ view_[&bv].button_dim_.y1 = y - dimc.asc;
+ view_[&bv].button_dim_.y2 = y + dimc.des;
+
+ FontInfo labelfont = getLabelfont();
+ labelfont.setColor(labelColor());
+ labelfont.realize(pi.base.font);
+ pi.pain.buttonText(x, y, buttonLabel(bv), labelfont,
+ view_[&bv].mouse_hover_ ? Color_buttonhoverbg : Color_buttonbg,
+ Color_buttonframe, TEXT_TO_INSET_OFFSET);
+ // Draw the change tracking cue on the label, unless RowPainter already
+ // takes care of it.
+ if (canPaintChange(bv))
+ pi.change_.paintCue(pi, x, y, x + dimc.width(), labelfont);
+ } else {
+ view_[&bv].button_dim_.x1 = 0;
+ view_[&bv].button_dim_.y1 = 0;
+ view_[&bv].button_dim_.x2 = 0;
+ view_[&bv].button_dim_.y2 = 0;
+ }
+
+ Dimension const textdim = dimensionHelper(bv);
+ int const baseline = y;
+ int textx, texty;
+ Geometry g = geometry(bv);
+ switch (g) {
+ case LeftButton:
+ case TopButton: {
+ if (g == LeftButton) {
+ textx = x + dimc.width();
+ texty = baseline;
+ } else {
+ textx = x;
+ texty = baseline + dimc.des + textdim.asc;
+ }
+ // Do not draw the cue for INSERTED -- it is already in the button and
+ // that's enough.
+ Changer dummy = (pi.change_.type == Change::INSERTED)
+ ? make_change(pi.change_, Change())
+ : Changer();
+ InsetText::draw(pi, textx, texty);
+ break;
+ }
+ case ButtonOnly:
+ break;
+ case NoButton:
+ textx = x;
+ texty = baseline;
+ InsetText::draw(pi, textx, texty);
+ break;
+ case SubLabel:
+ case Corners:
+ textx = x;
+ texty = baseline;
+ { // We will take care of the frame and the change tracking cue
+ // ourselves, below.
+ Changer dummy = make_change(pi.change_, Change());
+ const_cast<InsetCollapsible *>(this)->setDrawFrame(false);
+ InsetText::draw(pi, textx, texty);
+ const_cast<InsetCollapsible *>(this)->setDrawFrame(true);
+ }
+
+ int desc = textdim.descent();
+ if (g == Corners)
+ desc -= 3;
+
+ // Colour the frame according to the change type. (Like for tables.)
+ Color colour = pi.change_.changed() ? pi.change_.color()
+ : Color_foreground;
+ const int xx1 = x + TEXT_TO_INSET_OFFSET - 1;
+ const int xx2 = x + textdim.wid - TEXT_TO_INSET_OFFSET + 1;
+ pi.pain.line(xx1, y + desc - 4,
+ xx1, y + desc, colour);
+ if (status_ == Open)
+ pi.pain.line(xx1, y + desc,
+ xx2, y + desc, colour);
+ else {
+ // Make status_ value visible:
+ pi.pain.line(xx1, y + desc,
+ xx1 + 4, y + desc, colour);
+ pi.pain.line(xx2 - 4, y + desc,
+ xx2, y + desc, colour);
+ }
+ pi.pain.line(x + textdim.wid - 3, y + desc, x + textdim.wid - 3,
+ y + desc - 4, colour);
+
+ // the label below the text. Can be toggled.
+ if (g == SubLabel) {
+ FontInfo font(getLabelfont());
+ if (pi.change_.changed())
+ font.setPaintColor(colour);
+ font.realize(sane_font);
+ font.decSize();
+ font.decSize();
+ int w = 0;
+ int a = 0;
+ int d = 0;
+ Color const col = pi.full_repaint ? Color_none : pi.backgroundColor(this);
+ theFontMetrics(font).rectText(buttonLabel(bv), w, a, d);
+ int const ww = max(textdim.wid, w);
+ pi.pain.rectText(x + (ww - w) / 2, y + desc + a,
+ buttonLabel(bv), font, col, Color_none);
+ }
+
+ int const y1 = y - textdim.asc + 3;
+ // a visual cue when the cursor is inside the inset
+ Cursor const & cur = bv.cursor();
+ if (cur.isInside(this)) {
+ pi.pain.line(xx1, y1 + 4, xx1, y1, colour);
+ pi.pain.line(xx1 + 4, y1, xx1, y1, colour);
+ pi.pain.line(xx2, y1 + 4, xx2, y1, colour);
+ pi.pain.line(xx2 - 4, y1, xx2, y1, colour);
+ }
+ // Strike through the inset if deleted and not already handled by
+ // RowPainter.
+ if (pi.change_.deleted() && canPaintChange(bv))
+ pi.change_.paintCue(pi, xx1, y1, xx2, y + desc);
+ break;
+ }
+}
+
+
+void InsetCollapsible::cursorPos(BufferView const & bv,
+ CursorSlice const & sl, bool boundary, int & x, int & y) const
+{
+ if (geometry(bv) == ButtonOnly)
+ status_ = Open;
+
+ InsetText::cursorPos(bv, sl, boundary, x, y);
+ Dimension const textdim = dimensionHelper(bv);
+
+ switch (geometry(bv)) {
+ case LeftButton:
+ x += dimensionCollapsed(bv).wid;
+ break;
+ case TopButton: {
+ y += dimensionCollapsed(bv).des + textdim.asc;
+ break;
+ }
+ case NoButton:
+ case SubLabel:
+ case Corners:
+ // Do nothing
+ break;
+ case ButtonOnly:
+ // Cannot get here
+ break;
+ }
+}
+
+
+bool InsetCollapsible::editable() const
+{
+ switch (decoration()) {
+ case InsetLayout::CLASSIC:
+ case InsetLayout::MINIMALISTIC:
+ return status_ == Open;
+ default:
+ return true;
+ }
+}
+
+
+bool InsetCollapsible::descendable(BufferView const & bv) const
+{
+ return geometry(bv) != ButtonOnly;
+}
+
+
+bool InsetCollapsible::clickable(BufferView const & bv, int x, int y) const
+{
+ return view_[&bv].button_dim_.contains(x, y);
+}
+
+
+docstring const InsetCollapsible::getNewLabel(docstring const & l) const
+{
+ odocstringstream label;
+ pos_type const max_length = 15;
+ pos_type const p_siz = paragraphs().begin()->size();
+ pos_type const n = min(max_length, p_siz);
+ pos_type i = 0;
+ pos_type j = 0;
+ for (; i < n && j < p_siz; ++j) {
+ if (paragraphs().begin()->isInset(j)) {
+ if (!paragraphs().begin()->getInset(j)->isChar())
+ continue;
+ paragraphs().begin()->getInset(j)->toString(label);
+ } else
+ label.put(paragraphs().begin()->getChar(j));
+ ++i;
+ }
+ if (paragraphs().size() > 1 || (i > 0 && j < p_siz)) {
+ label << "...";
+ }
+ docstring const lbl = label.str();
+ return lbl.empty() ? l : lbl;
+}
+
+
+void InsetCollapsible::edit(Cursor & cur, bool front, EntryDirection entry_from)
+{
+ //lyxerr << "InsetCollapsible: edit left/right" << endl;
+ cur.push(*this);
+ InsetText::edit(cur, front, entry_from);
+}
+
+
+Inset * InsetCollapsible::editXY(Cursor & cur, int x, int y)
+{
+ //lyxerr << "InsetCollapsible: edit xy" << endl;
+ if (geometry(cur.bv()) == ButtonOnly
+ || (view_[&cur.bv()].button_dim_.contains(x, y)
+ && geometry(cur.bv()) != NoButton))
+ return this;
+ cur.push(*this);
+ return InsetText::editXY(cur, x, y);
+}
+
+
+void InsetCollapsible::doDispatch(Cursor & cur, FuncRequest & cmd)
+{
+ //lyxerr << "InsetCollapsible::doDispatch (begin): cmd: " << cmd
+ // << " cur: " << cur << " bvcur: " << cur.bv().cursor() << endl;
+
+ bool const hitButton = clickable(cur.bv(), cmd.x(), cmd.y());
+
+ switch (cmd.action()) {
+ case LFUN_MOUSE_PRESS:
+ if (hitButton) {
+ switch (cmd.button()) {
+ case mouse_button::button1:
+ case mouse_button::button3:
+ // Pass the command to the enclosing InsetText,
+ // so that the cursor gets set.
+ cur.undispatched();
+ break;
+ case mouse_button::none:
+ case mouse_button::button2:
+ case mouse_button::button4:
+ case mouse_button::button5:
+ // Nothing to do.
+ cur.noScreenUpdate();
+ break;
+ }
+ } else if (geometry(cur.bv()) != ButtonOnly)
+ InsetText::doDispatch(cur, cmd);
+ else
+ cur.undispatched();
+ break;
+
+ case LFUN_MOUSE_DOUBLE:
+ case LFUN_MOUSE_TRIPLE:
+ if (hitButton)
+ cur.noScreenUpdate();
+ else if (geometry(cur.bv()) != ButtonOnly)
+ InsetText::doDispatch(cur, cmd);
+ else
+ cur.undispatched();
+ break;
+
+ case LFUN_MOUSE_RELEASE:
+ if (!hitButton) {
+ // The mouse click has to be within the inset!
+ if (geometry(cur.bv()) != ButtonOnly)
+ InsetText::doDispatch(cur, cmd);
+ else
+ cur.undispatched();
+ break;
+ }
+ if (cmd.button() != mouse_button::button1) {
+ // Nothing to do.
+ cur.noScreenUpdate();
+ break;
+ }
+ // if we are selecting, we do not want to
+ // toggle the inset.
+ if (cur.selection())
+ break;
+ // Left button is clicked, the user asks to
+ // toggle the inset visual state.
+ cur.dispatched();
+ cur.screenUpdateFlags(Update::Force | Update::FitCursor);
+ if (geometry(cur.bv()) == ButtonOnly) {
+ setStatus(cur, Open);
+ edit(cur, true);
+ }
+ else
+ setStatus(cur, Collapsed);
+ cur.bv().cursor() = cur;
+ break;
+
+ case LFUN_INSET_TOGGLE:
+ if (cmd.argument() == "open")
+ setStatus(cur, Open);
+ else if (cmd.argument() == "close")
+ setStatus(cur, Collapsed);
+ else if (cmd.argument() == "toggle" || cmd.argument().empty())
+ if (status_ == Open)
+ setStatus(cur, Collapsed);
+ else
+ setStatus(cur, Open);
+ else // if assign or anything else
+ cur.undispatched();
+ cur.dispatched();
+ break;
+
+ default:
+ InsetText::doDispatch(cur, cmd);
+ break;
+ }
+}
+
+
+bool InsetCollapsible::getStatus(Cursor & cur, FuncRequest const & cmd,
+ FuncStatus & flag) const
+{
+ switch (cmd.action()) {
+ case LFUN_INSET_TOGGLE:
+ if (cmd.argument() == "open")
+ flag.setEnabled(status_ != Open);
+ else if (cmd.argument() == "close")
+ flag.setEnabled(status_ == Open);
+ else if (cmd.argument() == "toggle" || cmd.argument().empty()) {
+ flag.setEnabled(true);
+ flag.setOnOff(status_ == Open);
+ } else
+ flag.setEnabled(false);
+ return true;
+
+ default:
+ return InsetText::getStatus(cur, cmd, flag);
+ }
+}
+
+
+void InsetCollapsible::setLabel(docstring const & l)
+{
+ labelstring_ = l;
+}
+
+
+docstring InsetCollapsible::getLabel() const
+{
+ InsetLayout const & il = getLayout();
+ return labelstring_.empty() ?
+ translateIfPossible(il.labelstring()) : labelstring_;
+}
+
+
+docstring const InsetCollapsible::buttonLabel(BufferView const & bv) const
+{
+ InsetLayout const & il = getLayout();
+ docstring const label = getLabel();
+ if (!il.contentaslabel() || geometry(bv) != ButtonOnly)
+ return label;
+ return getNewLabel(label);
+}
+
+
+void InsetCollapsible::setStatus(Cursor & cur, CollapseStatus status)
+{
+ status_ = status;
+ setButtonLabel();
+ if (status_ == Collapsed)
+ cur.leaveInset(*this);
+}
+
+
+InsetLayout::InsetDecoration InsetCollapsible::decoration() const
+{
+ InsetLayout::InsetDecoration const dec = getLayout().decoration();
+ return dec == InsetLayout::DEFAULT ? InsetLayout::CLASSIC : dec;
+}
+
+
+string InsetCollapsible::contextMenu(BufferView const & bv, int x,
+ int y) const
+{
+ string context_menu = contextMenuName();
+ string const it_context_menu = InsetText::contextMenuName();
+ if (decoration() == InsetLayout::CONGLOMERATE)
+ return context_menu + ";" + it_context_menu;
+
+ string const ic_context_menu = InsetCollapsible::contextMenuName();
+ if (ic_context_menu != context_menu)
+ context_menu += ";" + ic_context_menu;
+
+ if (geometry(bv) == NoButton)
+ return context_menu + ";" + it_context_menu;
+
+ Dimension dim = dimensionCollapsed(bv);
+ if (x < xo(bv) + dim.wid && y < yo(bv) + dim.des)
+ return context_menu;
+
+ return it_context_menu;
+}
+
+
+string InsetCollapsible::contextMenuName() const
+{
+ if (decoration() == InsetLayout::CONGLOMERATE)
+ return "context-conglomerate";
+ else
+ return "context-collapsible";
+}
+
+
+bool InsetCollapsible::canPaintChange(BufferView const & bv) const
+{
+ // return false to let RowPainter draw the change tracking cue consistently
+ // with the surrounding text, when the inset is inline: for buttons, for
+ // non-allowMultiPar insets.
+ switch (geometry(bv)) {
+ case Corners:
+ case SubLabel:
+ return allowMultiPar();
+ case ButtonOnly:
+ return false;
+ default:
+ break;
+ }
+ return true;
+}
+
+
+void InsetCollapsible::addToToc(DocIterator const & cpit, bool output_active,
+ UpdateType utype, TocBackend & backend) const
+{
+ bool doing_output = output_active && producesOutput();
+ InsetLayout const & layout = getLayout();
+ if (layout.addToToc()) {
+ TocBuilder & b = backend.builder(layout.tocType());
+ // Cursor inside the inset
+ DocIterator pit = cpit;
+ pit.push_back(CursorSlice(const_cast<InsetCollapsible &>(*this)));
+ docstring const label = getLabel();
+ b.pushItem(pit, label + (label.empty() ? "" : ": "), output_active);
+ // Proceed with the rest of the inset.
+ InsetText::addToToc(cpit, doing_output, utype, backend);
+ if (layout.isTocCaption()) {
+ docstring str;
+ text().forOutliner(str, TOC_ENTRY_LENGTH);
+ b.argumentItem(str);
+ }
+ b.pop();
+ } else
+ InsetText::addToToc(cpit, doing_output, utype, backend);
+}
+
+
+
+} // namespace lyx
--- /dev/null
+// -*- C++ -*-
+/**
+ * \file InsetCollapsible.h
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Alejandro Aguilar Sierra
+ * \author Jürgen Vigna
+ * \author Lars Gullik Bjønnes
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#ifndef INSETCOLLAPSIBLE_H
+#define INSETCOLLAPSIBLE_H
+
+#include "InsetText.h"
+
+#include "Box.h"
+
+#include <map>
+
+namespace lyx {
+
+class CursorSlice;
+class InsetLayout;
+
+namespace frontend { class Painter; }
+
+/** A collapsible text inset
+
+*/
+class InsetCollapsible : public InsetText {
+public:
+ ///
+ InsetCollapsible(Buffer *, InsetText::UsePlain = InsetText::PlainLayout);
+ ///
+ InsetCollapsible(InsetCollapsible const & rhs);
+ ///
+ virtual ~InsetCollapsible();
+ ///
+ InsetCollapsible * asInsetCollapsible() { return this; }
+ ///
+ InsetCollapsible const * asInsetCollapsible() const { return this; }
+ ///
+ docstring toolTip(BufferView const & bv, int x, int y) const;
+ ///
+ docstring layoutName() const { return from_ascii("Collapsible"); }
+ ///
+ void read(Lexer &);
+ ///
+ void write(std::ostream &) const;
+ ///
+ void metrics(MetricsInfo &, Dimension &) const;
+ ///
+ void draw(PainterInfo & pi, int x, int y) const;
+ ///
+ virtual void drawBackground(PainterInfo &, int, int) const {}
+
+ /// return x,y of given position relative to the inset's baseline
+ void cursorPos(BufferView const & bv, CursorSlice const & sl,
+ bool boundary, int & x, int & y) const;
+ ///
+ docstring const getNewLabel(docstring const & l) const;
+ ///
+ bool editable() const;
+ ///
+ bool hasSettings() const { return true; }
+ /// Returns true if coordinates are over the inset's button.
+ /// Always returns false when the inset does not have a
+ /// button.
+ bool clickable(BufferView const & bv, int x, int y) const;
+ /// can we go further down on mouse click?
+ bool descendable(BufferView const & bv) const;
+ ///
+ void setLabel(docstring const & l);
+ ///
+ docstring getLabel() const;
+ ///
+ virtual void setButtonLabel() {}
+ ///
+ virtual docstring const buttonLabel(BufferView const &) const;
+ ///
+ bool isOpen(BufferView const & bv) const
+ { return geometry(bv) != ButtonOnly; }
+ ///
+ enum CollapseStatus {
+ Collapsed,
+ Open
+ };
+ ///
+ virtual void setStatus(Cursor & cur, CollapseStatus st);
+ ///
+ CollapseStatus status(BufferView const & bv) const;
+ /** Of the old CollapseStatus we only keep the values
+ * Open and Collapsed.
+ * We define a list of possible inset decoration
+ * styles, and a list of possible (concrete, visual)
+ * inset geometries. Relationships between them
+ * (geometries in body of table):
+ *
+ * \ CollapseStatus:
+ * Decoration: \ Open Collapsed
+ * -------------+-------------------------------
+ * Classic | *) TopButton, <--x) ButtonOnly
+ * | LeftButton
+ * Minimalistic | NoButton ButtonOnly
+ * Conglomerate | SubLabel Corners
+ * ---------------------------------------------
+ * *) toggled by openinlined_
+ * x) toggled by auto_open_
+ */
+
+ /// Default looks
+ virtual InsetLayout::InsetDecoration decoration() const;
+ /// Inset font
+ virtual FontInfo getFont() const { return getLayout().font(); }
+ /// Label font
+ virtual FontInfo getLabelfont() const { return getLayout().labelfont(); }
+ ///
+ enum Geometry {
+ TopButton,
+ ButtonOnly,
+ NoButton,
+ LeftButton,
+ SubLabel,
+ Corners
+ };
+ /// Returns the geometry based on CollapseStatus
+ /// (status_), auto_open_[BufferView] and openinlined_,
+ /// and of course decoration().
+ Geometry geometry(BufferView const & bv) const;
+ ///
+ bool canPaintChange(BufferView const & bv) const;
+ ///
+ bool getStatus(Cursor &, FuncRequest const &, FuncStatus &) const;
+ ///
+ bool setMouseHover(BufferView const * bv, bool mouse_hover) const;
+ ///
+ ColorCode backgroundColor(PainterInfo const &) const
+ { return getLayout().bgcolor(); }
+ ///
+ ColorCode labelColor() const { return getLayout().labelfont().color(); }
+ ///
+ InsetCode lyxCode() const { return COLLAPSIBLE_CODE; }
+
+ ///
+ virtual bool usePlainLayout() const { return true; }
+ ///
+ std::string contextMenu(BufferView const & bv, int x, int y) const;
+ ///
+ std::string contextMenuName() const;
+ ///
+ void addToToc(DocIterator const & dit, bool output_active,
+ UpdateType utype, TocBackend & backend) const; //override
+
+protected:
+ ///
+ void doDispatch(Cursor & cur, FuncRequest & cmd);
+ ///
+ void edit(Cursor & cur, bool front,
+ EntryDirection entry_from = ENTRY_DIRECTION_IGNORE);
+ ///
+ Inset * editXY(Cursor & cur, int x, int y);
+ ///
+ mutable CollapseStatus status_;
+private:
+ ///
+ Dimension dimensionCollapsed(BufferView const & bv) const;
+ ///
+ docstring labelstring_;
+
+ // These variables depend of the view in which the inset is displayed
+ struct View
+ {
+ /// The dimension of the inset button
+ Box button_dim_;
+ /// a substatus of the Open status, determined automatically in metrics
+ bool openinlined_;
+ /// the inset will automatically open when the cursor is inside. This is
+ /// dependent on the bufferview, compare with InsetMathMacro::editing_.
+ bool auto_open_;
+ /// changes color when mouse enters/leaves this inset
+ bool mouse_hover_;
+ };
+
+ ///
+ mutable std::map<BufferView const *, View> view_;
+};
+
+} // namespace lyx
+
+#endif
break;
}
case ERT_CODE: {
- data = InsetERT::params2string(InsetCollapsable::Open);
+ data = InsetERT::params2string(InsetCollapsible::Open);
break;
}
case EXTERNAL_CODE: {
namespace lyx {
InsetERT::InsetERT(Buffer * buf, CollapseStatus status)
- : InsetCollapsable(buf)
+ : InsetCollapsible(buf)
{
status_ = status;
}
void InsetERT::write(ostream & os) const
{
os << "ERT" << "\n";
- InsetCollapsable::write(os);
+ InsetCollapsible::write(os);
}
}
//fall-through
default:
- InsetCollapsable::doDispatch(cur, cmd);
+ InsetCollapsible::doDispatch(cur, cmd);
break;
}
//fall through
default:
- return InsetCollapsable::getStatus(cur, cmd, status);
+ return InsetCollapsible::getStatus(cur, cmd, status);
}
}
}
-InsetCollapsable::CollapseStatus InsetERT::string2params(string const & in)
+InsetCollapsible::CollapseStatus InsetERT::string2params(string const & in)
{
if (in.empty())
return Collapsed;
#ifndef INSETERT_H
#define INSETERT_H
-#include "InsetCollapsable.h"
+#include "InsetCollapsible.h"
namespace lyx {
class Language;
-class InsetERT : public InsetCollapsable {
+class InsetERT : public InsetCollapsible {
public:
///
InsetERT(Buffer *, CollapseStatus status = Open);
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_)
{}
}
}
os << name << "\n";
- InsetCollapsable::write(os);
+ InsetCollapsible::write(os);
}
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);
}
}
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;
}
}
// need a layout flag
cnts.saveLastCounter();
}
- InsetCollapsable::updateBuffer(it, utype);
+ InsetCollapsible::updateBuffer(it, utype);
if (save_counter)
cnts.restoreLastCounter();
}
#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);
custom_label_ += ' ' + cnts.theCounter(count, lang->code());
setLabel(custom_label_);
- InsetCollapsable::updateBuffer(it, utype);
+ InsetCollapsible::updateBuffer(it, utype);
if (utype == OutputUpdate)
cnts.restoreLastCounter();
}
{
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_+ ": ");
}
using support::token;
InsetFootlike::InsetFootlike(Buffer * buf)
- : InsetCollapsable(buf)
+ : InsetCollapsible(buf)
{}
{
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;
}
{
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;
}
{
// The layoutName may contain a "InTitle" qualifier
os << to_utf8(token(layoutName(), char_type(':'), 0)) << "\n";
- InsetCollapsable::write(os);
+ InsetCollapsible::write(os);
}
{
if (code == FOOT_CODE || code == MARGIN_CODE || code == FLOAT_CODE)
return false;
- return InsetCollapsable::insetAllowed(code);
+ return InsetCollapsible::insetAllowed(code);
}
#ifndef INSETFOOTLIKE_H
#define INSETFOOTLIKE_H
-#include "InsetCollapsable.h"
+#include "InsetCollapsible.h"
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 *);
/////////////////////////////////////////////////////////////////////
InsetIPADeco::InsetIPADeco(Buffer * buf, string const & label)
- : InsetCollapsable(buf)
+ : InsetCollapsible(buf)
{
setDrawFrame(true);
setFrameColor(Color_insetframe);
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);
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);
}
os << "\\texttoptiebar{";
else if (params_.type == InsetIPADecoParams::Bottomtiebar)
os << "\\textbottomtiebar{";
- InsetCollapsable::latex(os, runparams);
+ InsetCollapsible::latex(os, runparams);
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());
int InsetIPADeco::docbook(odocstream & os, OutputParams const & runparams) const
{
// FIXME: Any docbook option here?
- return InsetCollapsable::docbook(os, runparams);
+ return InsetCollapsible::docbook(os, 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);
}
#include "Inset.h"
-#include "InsetCollapsable.h"
+#include "InsetCollapsible.h"
namespace lyx {
/////////////////////////////////////////////////////////////////////////
/// Used to insert IPA decorations
-class InsetIPADeco : public InsetCollapsable
+class InsetIPADeco : public InsetCollapsible
{
public:
///
InsetIndex::InsetIndex(Buffer * buf, InsetIndexParams const & params)
- : InsetCollapsable(buf), params_(params)
+ : InsetCollapsible(buf), params_(params)
{}
break;
default:
- InsetCollapsable::doDispatch(cur, cmd);
+ InsetCollapsible::doDispatch(cur, cmd);
break;
}
}
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();
}
default:
- return InsetCollapsable::getStatus(cur, cmd, flag);
+ return InsetCollapsible::getStatus(cur, cmd, flag);
}
}
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;
}
{
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);
}
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();
}
&& !params_.index.empty()
&& params_.index != "idx")
features.require("splitidx");
- InsetCollapsable::validate(features);
+ InsetCollapsible::validate(features);
}
#define INSET_INDEX_H
-#include "InsetCollapsable.h"
+#include "InsetCollapsible.h"
#include "InsetCommand.h"
/** Used to insert index labels
*/
-class InsetIndex : public InsetCollapsable {
+class InsetIndex : public InsetCollapsible {
public:
///
InsetIndex(Buffer *, InsetIndexParams const &);
InsetInfo::InsetInfo(Buffer * buf, string const & name)
- : InsetCollapsable(buf), type_(UNKNOWN_INFO), name_()
+ : InsetCollapsible(buf), type_(UNKNOWN_INFO), name_()
{
setInfo(name);
status_ = Collapsed;
{
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:
}
default:
- InsetCollapsable::doDispatch(cur, cmd);
+ InsetCollapsible::doDispatch(cur, cmd);
break;
}
}
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();
}
#ifndef INSET_INFO_H
#define INSET_INFO_H
-#include "InsetCollapsable.h"
+#include "InsetCollapsible.h"
namespace lyx {
*/
-class InsetInfo : public InsetCollapsable {
+class InsetInfo : public InsetCollapsible {
public:
enum info_type {
UNKNOWN_INFO, // Invalid type
///
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_;
///
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.
void InsetListingsParams::read(Lexer & lex)
{
lex >> inline_;
- int s = InsetCollapsable::Collapsed;
+ int s = InsetCollapsible::Collapsed;
lex >> s;
- status_ = static_cast<InsetCollapsable::CollapseStatus>(s);
+ status_ = static_cast<InsetCollapsible::CollapseStatus>(s);
string par;
lex >> par;
fromEncodedString(par);
///
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;
bool isFloat() const;
///
- InsetCollapsable::CollapseStatus status() const { return status_; }
+ InsetCollapsible::CollapseStatus status() const { return status_; }
///
void setInline(bool i) { inline_ = i; }
typedef std::vector<std::pair<std::string, std::string> > keyValuePair;
keyValuePair params_;
- /// collapsable status
- InsetCollapsable::CollapseStatus status_;
+ /// collapsible status
+ InsetCollapsible::CollapseStatus status_;
};
/////////////////////////////////////////////////////////////////////
InsetNote::InsetNote(Buffer * buf, string const & label)
- : InsetCollapsable(buf)
+ : InsetCollapsible(buf)
{
params_.type = notetranslator().find(label);
}
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);
}
break;
default:
- InsetCollapsable::doDispatch(cur, cmd);
+ InsetCollapsible::doDispatch(cur, cmd);
break;
}
}
return true;
default:
- return InsetCollapsable::getStatus(cur, cmd, flag);
+ return InsetCollapsible::getStatus(cur, cmd, flag);
}
}
if (params_.type == InsetNoteParams::Note)
return true;
- return InsetCollapsable::isMacroScope();
+ return InsetCollapsible::isMacroScope();
}
// 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;
}
if (params_.type == InsetNoteParams::Note)
return docstring();
- return InsetCollapsable::xhtml(xs, rp);
+ return InsetCollapsible::xhtml(xs, rp);
}
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;
#ifndef INSET_NOTE_H
#define INSET_NOTE_H
-#include "InsetCollapsable.h"
+#include "InsetCollapsible.h"
namespace lyx {
/////////////////////////////////////////////////////////////////////////
/// The PostIt note inset, and other annotations
-class InsetNote : public InsetCollapsable
+class InsetNote : public InsetCollapsible
{
public:
///
/////////////////////////////////////////////////////////////////////
InsetPhantom::InsetPhantom(Buffer * buf, string const & label)
- : InsetCollapsable(buf)
+ : InsetCollapsible(buf)
{
setDrawFrame(false);
params_.type = phantomtranslator().find(label);
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);
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);
}
break;
default:
- InsetCollapsable::doDispatch(cur, cmd);
+ InsetCollapsible::doDispatch(cur, cmd);
break;
}
}
return true;
default:
- return InsetCollapsable::getStatus(cur, cmd, flag);
+ return InsetCollapsible::getStatus(cur, cmd, flag);
}
}
os << "\\phantom{";
break;
}
- InsetCollapsable::latex(os, runparams);
+ InsetCollapsible::latex(os, runparams);
os << "}";
}
os << '[' << buffer().B_("phantom") << ":";
break;
}
- InsetCollapsable::plaintext(os, runparams, max_length);
+ InsetCollapsible::plaintext(os, runparams, max_length);
os << "]";
return PLAINTEXT_NEWLINE;
break;
}
os << "<" + cmdname + ">";
- int const i = InsetCollapsable::docbook(os, runparams);
+ int const i = InsetCollapsible::docbook(os, runparams);
os << "</" + cmdname + ">";
return i;
#ifndef INSET_PHANTOM_H
#define INSET_PHANTOM_H
-#include "InsetCollapsable.h"
+#include "InsetCollapsible.h"
namespace lyx {
/////////////////////////////////////////////////////////////////////////
/// The phantom inset
-class InsetPhantom : public InsetCollapsable
+class InsetPhantom : public InsetCollapsible
{
public:
///
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: