#include "InsetBox.h"
+#include "Buffer.h"
#include "BufferView.h"
#include "Cursor.h"
#include "DispatchResult.h"
#include "FuncRequest.h"
#include "gettext.h"
#include "LaTeXFeatures.h"
-#include "Color.h"
#include "Lexer.h"
#include "MetricsInfo.h"
-#include "Paragraph.h"
-#include "TextMetrics.h"
#include "support/Translator.h"
namespace lyx {
-using std::auto_ptr;
using std::string;
using std::istringstream;
using std::ostream;
}
-auto_ptr<Inset> InsetBox::doClone() const
+Inset * InsetBox::clone() const
{
- return auto_ptr<Inset>(new InsetBox(*this));
+ return new InsetBox(*this);
}
void InsetBox::setButtonLabel()
{
- Font font(Font::ALL_SANE);
- font.decSize();
- font.decSize();
-
BoxType btype = boxtranslator().find(params_.type);
docstring label;
label += ")";
setLabel(label);
-
- font.setColor(Color::foreground);
- setLabelFont(font);
}
}
-bool InsetBox::metrics(MetricsInfo & m, Dimension & dim) const
+void InsetBox::metrics(MetricsInfo & m, Dimension & dim) const
{
- MetricsInfo mi = m;
- // first round in order to know the minimum size.
- InsetCollapsable::metrics(mi, dim);
- TextMetrics & tm = mi.base.bv->textMetrics(&text_);
+ // back up textwidth.
+ int textwidth_backup = m.base.textwidth;
if (hasFixedWidth())
- mi.base.textwidth =
- std::max(tm.width() + 2 * border_ + (int) (2.5 * TEXT_TO_INSET_OFFSET),
- params_.width.inPixels(m.base.textwidth));
- InsetCollapsable::metrics(mi, dim);
- bool const changed = dim_ != dim;
- dim_ = dim;
- return changed;
+ m.base.textwidth = params_.width.inPixels(m.base.textwidth);
+ InsetCollapsable::metrics(m, dim);
+ // retore textwidth.
+ m.base.textwidth = textwidth_backup;
}
case LFUN_INSET_MODIFY: {
//lyxerr << "InsetBox::dispatch MODIFY" << endl;
InsetBoxMailer::string2params(to_utf8(cmd.argument()), params_);
- setButtonLabel();
+ setLayout(cur.buffer().params());
break;
}
os << "[" << params_.pos << "]";
if (params_.height_special == "none") {
// FIXME UNICODE
- os << '[' << from_ascii(params_.height.asLatexString())
- << ']';
+ os << "[" << from_ascii(params_.height.asLatexString()) << "]";
} else {
// Special heights
- // FIXME UNICODE
- os << "[" << params_.height.value()
- << '\\' << from_utf8(params_.height_special)
- << ']';
+ // set no optional argument when the value is the default "1\height"
+ // (special units like \height are handled as "in")
+ // but when the user has chosen a non-default inner_pos, the height
+ // must be given: \minipage[pos][height][inner-pos]{width}
+ if ((params_.height != Length("1in") ||
+ params_.height_special != "totalheight") ||
+ params_.inner_pos != params_.pos) {
+ // FIXME UNICODE
+ os << "[" << params_.height.value()
+ << "\\" << from_utf8(params_.height_special) << "]";
+ }
}
if (params_.inner_pos != params_.pos)
os << "[" << params_.inner_pos << "]";