#include "InsetCollapsable.h"
#include "Buffer.h"
-#include "BufferParams.h"
#include "BufferView.h"
#include "Cursor.h"
#include "Dimension.h"
-#include "FloatList.h"
#include "FuncRequest.h"
#include "FuncStatus.h"
#include "InsetLayout.h"
#include "Lexer.h"
#include "MetricsInfo.h"
#include "OutputParams.h"
-#include "TextClass.h"
#include "frontends/FontMetrics.h"
#include "frontends/Painter.h"
InsetCollapsable::InsetCollapsable(Buffer * buf, InsetText::UsePlain ltype)
: InsetText(buf, ltype), status_(Open), openinlined_(false)
{
- setAutoBreakRows(true);
setDrawFrame(true);
setFrameColor(Color_collapsableframe);
}
Dimension InsetCollapsable::dimensionCollapsed(BufferView const & bv) const
{
Dimension dim;
- theFontMetrics(getLayout().labelfont()).buttonText(
+ FontInfo labelfont(getLabelfont());
+ labelfont.realize(sane_font);
+ theFontMetrics(labelfont).buttonText(
buttonLabel(bv), dim.wid, dim.asc, dim.des);
return dim;
}
auto_open_[mi.base.bv] = mi.base.bv->cursor().isInside(this);
FontInfo tmpfont = mi.base.font;
- mi.base.font = getLayout().font();
+ mi.base.font = getFont();
mi.base.font.realize(tmpfont);
BufferView const & bv = *mi.base.bv;
case SubLabel: {
InsetText::metrics(mi, dim);
// consider width of the inset label
- FontInfo font(getLayout().labelfont());
+ FontInfo font(getLabelfont());
font.realize(sane_font);
font.decSize();
font.decSize();
case TopButton:
case LeftButton:
case ButtonOnly:
+ if (hasFixedWidth()){
+ int const mindim = button_dim.x2 - button_dim.x1;
+ if (mi.base.textwidth < mindim)
+ mi.base.textwidth = mindim;
+ }
dim = dimensionCollapsed(bv);
if (geometry(bv) == TopButton
|| geometry(bv) == LeftButton) {
auto_open_[&bv] = bv.cursor().isInside(this);
FontInfo tmpfont = pi.base.font;
- pi.base.font = getLayout().font();
+ pi.base.font = getFont();
pi.base.font.realize(tmpfont);
// Draw button first -- top, left or only
button_dim.y1 = y - dimc.asc;
button_dim.y2 = y + dimc.des;
- FontInfo labelfont = getLayout().labelfont();
+ FontInfo labelfont = getLabelfont();
labelfont.setColor(labelColor());
pi.pain.buttonText(x, y, buttonLabel(bv), labelfont,
mouse_hover_[&bv]);
// the label below the text. Can be toggled.
if (geometry(bv) == SubLabel) {
- FontInfo font(getLayout().labelfont());
+ FontInfo font(getLabelfont());
font.realize(sane_font);
font.decSize();
font.decSize();
int const ww = max(textdim.wid, w);
pi.pain.rectText(x + (ww - w) / 2, y + desc + a,
buttonLabel(bv), font, Color_none, Color_none);
- desc += d;
}
// a visual cue when the cursor is inside the inset
}
-docstring InsetCollapsable::floatName(string const & type) const
-{
- BufferParams const & bp = buffer().params();
- FloatList const & floats = bp.documentClass().floats();
- FloatList::const_iterator it = floats[type];
- // FIXME UNICODE
- return (it == floats.end()) ? from_ascii(type) : bp.B_(it->second.name());
-}
-
-
InsetLayout::InsetDecoration InsetCollapsable::decoration() const
{
InsetLayout::InsetDecoration const dec = getLayout().decoration();