Place inset content on the button when collapsed

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8169 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Martin Vermeer 2003-12-01 14:51:52 +00:00
parent b06de5044f
commit d6c55f8b50
6 changed files with 38 additions and 29 deletions

View File

@ -1,3 +1,11 @@
2003-12-01 Martin Vermeer <martin.vermeer@hut.fi>
* insetcollapsable.[Ch]:
* insetert.[Ch]:
* insetcharstyle.C: place inset content on the button when
collapsed.
2003-12-01 Michael Schmitt <michael.schmitt@teststep.org> 2003-12-01 Michael Schmitt <michael.schmitt@teststep.org>
* insetvspace.C: remove VSpace::NONE; increase inset width * insetvspace.C: remove VSpace::NONE; increase inset width

View File

@ -92,8 +92,8 @@ void InsetCharStyle::setButtonLabel()
{ {
LyXFont font(params_.labelfont); LyXFont font(params_.labelfont);
font.realize(LyXFont(LyXFont::ALL_SANE)); font.realize(LyXFont(LyXFont::ALL_SANE));
font.decSize(); string const s = "Style: " + params_.type;
setLabel("Style: " + params_.type); setLabel(isOpen() ? s : getNewLabel(s) );
setLabelFont(font); setLabelFont(font);
} }

View File

@ -35,6 +35,7 @@ using lyx::graphics::PreviewLoader;
using std::endl; using std::endl;
using std::string; using std::string;
using std::max; using std::max;
using std::min;
using std::ostream; using std::ostream;
@ -260,6 +261,30 @@ bool InsetCollapsable::hitButton(FuncRequest const & cmd) const
} }
string const InsetCollapsable::getNewLabel(string const & l) const
{
string la;
pos_type const max_length = 15;
pos_type const p_siz = inset.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 (inset.paragraphs().begin()->isInset(j))
continue;
la += inset.paragraphs().begin()->getChar(j);
++i;
}
if (inset.paragraphs().size() > 1 || (i > 0 && j < p_siz)) {
la += "...";
}
if (la.empty()) {
la = l;
}
return la;
}
void InsetCollapsable::edit(BufferView * bv, bool left) void InsetCollapsable::edit(BufferView * bv, bool left)
{ {
lyxerr << "InsetCollapsable: edit left/right" << endl; lyxerr << "InsetCollapsable: edit left/right" << endl;

View File

@ -51,6 +51,8 @@ public:
/// ///
bool hitButton(FuncRequest const &) const; bool hitButton(FuncRequest const &) const;
/// ///
std::string const getNewLabel(std::string const & l) const;
///
EDITABLE editable() const; EDITABLE editable() const;
/// can we go further down on mouse click? /// can we go further down on mouse click?
bool descendable() const { return isOpen(); } bool descendable() const { return isOpen(); }

View File

@ -451,33 +451,9 @@ InsetERT::priv_dispatch(FuncRequest const & cmd, idx_type & idx, pos_type & pos)
} }
string const InsetERT::getNewLabel() const
{
string la;
pos_type const max_length = 15;
pos_type const p_siz = inset.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 (inset.paragraphs().begin()->isInset(j))
continue;
la += inset.paragraphs().begin()->getChar(j);
++i;
}
if (inset.paragraphs().size() > 1 || (i > 0 && j < p_siz)) {
la += "...";
}
if (la.empty()) {
la = _("ERT");
}
return la;
}
void InsetERT::setButtonLabel() const void InsetERT::setButtonLabel() const
{ {
setLabel(status_ == Collapsed ? getNewLabel() : _("ERT")); setLabel(status_ == Collapsed ? getNewLabel(_("ERT")) : _("ERT"));
} }

View File

@ -119,8 +119,6 @@ private:
/// ///
void init(); void init();
/// ///
std::string const getNewLabel() const;
///
void setButtonLabel() const; void setButtonLabel() const;
/// ///
void setLatexFont(BufferView *); void setLatexFont(BufferView *);