From d6c55f8b5089977a332c30db85f4305aaf2dc743 Mon Sep 17 00:00:00 2001 From: Martin Vermeer Date: Mon, 1 Dec 2003 14:51:52 +0000 Subject: [PATCH] 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 --- src/insets/ChangeLog | 8 ++++++++ src/insets/insetcharstyle.C | 4 ++-- src/insets/insetcollapsable.C | 25 +++++++++++++++++++++++++ src/insets/insetcollapsable.h | 2 ++ src/insets/insetert.C | 26 +------------------------- src/insets/insetert.h | 2 -- 6 files changed, 38 insertions(+), 29 deletions(-) diff --git a/src/insets/ChangeLog b/src/insets/ChangeLog index 7e2de7d13c..baeee6150d 100644 --- a/src/insets/ChangeLog +++ b/src/insets/ChangeLog @@ -1,3 +1,11 @@ + +2003-12-01 Martin Vermeer + + * insetcollapsable.[Ch]: + * insetert.[Ch]: + * insetcharstyle.C: place inset content on the button when + collapsed. + 2003-12-01 Michael Schmitt * insetvspace.C: remove VSpace::NONE; increase inset width diff --git a/src/insets/insetcharstyle.C b/src/insets/insetcharstyle.C index e80300ab9c..709694bbe7 100644 --- a/src/insets/insetcharstyle.C +++ b/src/insets/insetcharstyle.C @@ -92,8 +92,8 @@ void InsetCharStyle::setButtonLabel() { LyXFont font(params_.labelfont); font.realize(LyXFont(LyXFont::ALL_SANE)); - font.decSize(); - setLabel("Style: " + params_.type); + string const s = "Style: " + params_.type; + setLabel(isOpen() ? s : getNewLabel(s) ); setLabelFont(font); } diff --git a/src/insets/insetcollapsable.C b/src/insets/insetcollapsable.C index 4f5662ba9e..b0b43b0d33 100644 --- a/src/insets/insetcollapsable.C +++ b/src/insets/insetcollapsable.C @@ -35,6 +35,7 @@ using lyx::graphics::PreviewLoader; using std::endl; using std::string; using std::max; +using std::min; 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) { lyxerr << "InsetCollapsable: edit left/right" << endl; diff --git a/src/insets/insetcollapsable.h b/src/insets/insetcollapsable.h index dbffd9c662..c0eed4a195 100644 --- a/src/insets/insetcollapsable.h +++ b/src/insets/insetcollapsable.h @@ -51,6 +51,8 @@ public: /// bool hitButton(FuncRequest const &) const; /// + std::string const getNewLabel(std::string const & l) const; + /// EDITABLE editable() const; /// can we go further down on mouse click? bool descendable() const { return isOpen(); } diff --git a/src/insets/insetert.C b/src/insets/insetert.C index a23fc5be78..4451a3cc06 100644 --- a/src/insets/insetert.C +++ b/src/insets/insetert.C @@ -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 { - setLabel(status_ == Collapsed ? getNewLabel() : _("ERT")); + setLabel(status_ == Collapsed ? getNewLabel(_("ERT")) : _("ERT")); } diff --git a/src/insets/insetert.h b/src/insets/insetert.h index cce282325e..98c102ba57 100644 --- a/src/insets/insetert.h +++ b/src/insets/insetert.h @@ -119,8 +119,6 @@ private: /// void init(); /// - std::string const getNewLabel() const; - /// void setButtonLabel() const; /// void setLatexFont(BufferView *); -- 2.39.2