From: Jürgen Vigna Date: Mon, 23 Jul 2001 12:47:25 +0000 (+0000) Subject: Added support for changing label on collapsed InsetERT. X-Git-Tag: 1.6.10~21033 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=3ea708f4b65214175852871236509fa86e1fb68b;p=lyx.git Added support for changing label on collapsed InsetERT. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2305 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/po/POTFILES.in b/po/POTFILES.in index cb3dd3f697..1542be87a7 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -10,8 +10,8 @@ src/CutAndPaste.C src/debug.C src/exporter.C src/ext_l10n.h -src/figureForm.C src/figure_form.C +src/figureForm.C src/FontLoader.C src/frontends/controllers/biblio.C src/frontends/controllers/ButtonController.h @@ -90,67 +90,67 @@ src/frontends/qt2/paragraphdlgimpl.C src/frontends/qt2/tabularcreatedlgimpl.C src/frontends/xforms/combox.C src/frontends/xforms/FileDialog.C -src/frontends/xforms/FormAboutlyx.C src/frontends/xforms/form_aboutlyx.C -src/frontends/xforms/FormBibitem.C +src/frontends/xforms/FormAboutlyx.C src/frontends/xforms/form_bibitem.C -src/frontends/xforms/FormBibtex.C +src/frontends/xforms/FormBibitem.C src/frontends/xforms/form_bibtex.C +src/frontends/xforms/FormBibtex.C src/frontends/xforms/form_browser.C -src/frontends/xforms/FormCharacter.C src/frontends/xforms/form_character.C -src/frontends/xforms/FormCitation.C +src/frontends/xforms/FormCharacter.C src/frontends/xforms/form_citation.C -src/frontends/xforms/FormDocument.C +src/frontends/xforms/FormCitation.C src/frontends/xforms/form_document.C -src/frontends/xforms/FormError.C +src/frontends/xforms/FormDocument.C src/frontends/xforms/form_error.C -src/frontends/xforms/FormExternal.C +src/frontends/xforms/FormError.C src/frontends/xforms/form_external.C -src/frontends/xforms/FormFiledialog.C +src/frontends/xforms/FormExternal.C src/frontends/xforms/form_filedialog.C -src/frontends/xforms/FormGraphics.C +src/frontends/xforms/FormFiledialog.C src/frontends/xforms/form_graphics.C -src/frontends/xforms/FormInclude.C +src/frontends/xforms/FormGraphics.C src/frontends/xforms/form_include.C -src/frontends/xforms/FormIndex.C +src/frontends/xforms/FormInclude.C src/frontends/xforms/form_index.C +src/frontends/xforms/FormIndex.C src/frontends/xforms/FormLog.C src/frontends/xforms/FormMathsBitmap.C -src/frontends/xforms/FormMathsDeco.C src/frontends/xforms/form_maths_deco.C -src/frontends/xforms/FormMathsDelim.C +src/frontends/xforms/FormMathsDeco.C src/frontends/xforms/form_maths_delim.C -src/frontends/xforms/FormMathsMatrix.C +src/frontends/xforms/FormMathsDelim.C src/frontends/xforms/form_maths_matrix.C -src/frontends/xforms/FormMathsPanel.C +src/frontends/xforms/FormMathsMatrix.C src/frontends/xforms/form_maths_panel.C -src/frontends/xforms/FormMathsSpace.C +src/frontends/xforms/FormMathsPanel.C src/frontends/xforms/form_maths_space.C -src/frontends/xforms/FormMinipage.C +src/frontends/xforms/FormMathsSpace.C src/frontends/xforms/form_minipage.C -src/frontends/xforms/FormParagraph.C +src/frontends/xforms/FormMinipage.C src/frontends/xforms/form_paragraph.C -src/frontends/xforms/FormPreamble.C +src/frontends/xforms/FormParagraph.C src/frontends/xforms/form_preamble.C -src/frontends/xforms/FormPreferences.C +src/frontends/xforms/FormPreamble.C src/frontends/xforms/form_preferences.C -src/frontends/xforms/FormPrint.C +src/frontends/xforms/FormPreferences.C src/frontends/xforms/form_print.C -src/frontends/xforms/FormRef.C +src/frontends/xforms/FormPrint.C src/frontends/xforms/form_ref.C -src/frontends/xforms/FormSearch.C +src/frontends/xforms/FormRef.C src/frontends/xforms/form_search.C -src/frontends/xforms/FormSpellchecker.C +src/frontends/xforms/FormSearch.C src/frontends/xforms/form_spellchecker.C -src/frontends/xforms/FormTabular.C +src/frontends/xforms/FormSpellchecker.C src/frontends/xforms/form_tabular.C -src/frontends/xforms/FormTabularCreate.C +src/frontends/xforms/FormTabular.C src/frontends/xforms/form_tabular_create.C -src/frontends/xforms/FormToc.C +src/frontends/xforms/FormTabularCreate.C src/frontends/xforms/form_toc.C -src/frontends/xforms/FormUrl.C +src/frontends/xforms/FormToc.C src/frontends/xforms/form_url.C +src/frontends/xforms/FormUrl.C src/frontends/xforms/FormVCLog.C src/frontends/xforms/input_validators.C src/frontends/xforms/Menubar_pimpl.C @@ -171,6 +171,7 @@ src/insets/insetfoot.C src/insets/insetgraphics.C src/insets/insetinclude.C src/insets/insetindex.C +src/insets/insetinfo.C src/insets/insetlabel.C src/insets/insetlist.C src/insets/insetmarginal.C @@ -206,7 +207,6 @@ src/MenuBackend.C src/minibuffer.C src/paragraph.C src/print_form.C -src/sp_form.C src/support/filetools.C src/support/getUserName.C src/support/path.C diff --git a/src/insets/ChangeLog b/src/insets/ChangeLog index 7a9ce5ee07..bee44e9cd4 100644 --- a/src/insets/ChangeLog +++ b/src/insets/ChangeLog @@ -1,3 +1,22 @@ +2001-07-23 Juergen Vigna + + * insetert.C (InsetERT): use setLabel with "true" flag. + + * insetcollapsable.C: modified various functions to set the draw_label + string right in any condition. + (setLabel): added a bool parameter to set change_label_with_text. + + * insetcollapsable.h: added draw_label string which is set to the + actual drawn label-string, while label is the original static label + of this collapsable inset. Added bool change_label_with_text to set + if we want that the label changes to the start of the InsetText's + text when collabpsed. You can set this flag with the setLabel funciton. + Added bool inlined for inlined collapsable insets, but not handled + yet. + + * insetcollapsable.C (get_new_label): added should get a new label + from the InsetText beginning (for now 10 chars). + 2001-07-21 Yves Bastide * insetquotes.C (latex): fix the handling of french double quotes diff --git a/src/insets/insetcollapsable.C b/src/insets/insetcollapsable.C index 5d6739fbcf..9e573c273a 100644 --- a/src/insets/insetcollapsable.C +++ b/src/insets/insetcollapsable.C @@ -34,9 +34,11 @@ using std::max; InsetCollapsable::InsetCollapsable(bool collapsed) : UpdatableInset(), collapsed_(collapsed), - button_length(0), button_top_y(0), button_bottom_y(0), - label("Label"), autocollapse(true), - widthCollapsed(0), oldWidth(0), need_update(FULL) + button_length(0), button_top_y(0), button_bottom_y(0), + label("Label"), draw_label(label), autocollapse(true), + widthCollapsed(0), oldWidth(0), need_update(FULL), + inlined(false), change_label_with_text(false) + { inset.setOwner(this); @@ -80,6 +82,11 @@ void InsetCollapsable::read(Buffer const * buf, LyXLex & lex) } } inset.read(buf, lex); + if (collapsed_ && change_label_with_text) { + draw_label = get_new_label(); + } else { + draw_label = label; + } } @@ -88,7 +95,7 @@ int InsetCollapsable::ascent_collapsed(Painter & pain, LyXFont const &) const int width = 0; int ascent = 0; int descent = 0; - pain.buttonText(0, 0, label, labelfont, false, + pain.buttonText(0, 0, draw_label, labelfont, false, width, ascent, descent); return ascent; } @@ -99,7 +106,7 @@ int InsetCollapsable::descent_collapsed(Painter & pain, LyXFont const &) const int width = 0; int ascent = 0; int descent = 0; - pain.buttonText(0, 0, label, labelfont, false, + pain.buttonText(0, 0, draw_label, labelfont, false, width, ascent, descent); return descent; } @@ -110,7 +117,7 @@ int InsetCollapsable::width_collapsed(Painter & pain, LyXFont const &) const int width; int ascent; int descent; - pain.buttonText(TEXT_TO_INSET_OFFSET, 0, label, labelfont, false, + pain.buttonText(TEXT_TO_INSET_OFFSET, 0, draw_label, labelfont, false, width, ascent, descent); return width + (2*TEXT_TO_INSET_OFFSET); } @@ -136,8 +143,7 @@ int InsetCollapsable::descent(BufferView * bv, LyXFont const & font) const int InsetCollapsable::width(BufferView * bv, LyXFont const & font) const { - if (!widthCollapsed) - widthCollapsed = width_collapsed(bv->painter(), font); + widthCollapsed = width_collapsed(bv->painter(), font); if (collapsed_) return widthCollapsed; @@ -148,17 +154,17 @@ int InsetCollapsable::width(BufferView * bv, LyXFont const & font) const void InsetCollapsable::draw_collapsed(Painter & pain, LyXFont const &, - int baseline, float & x) const + int baseline, float & x) const { int width = 0; pain.buttonText(int(x) + TEXT_TO_INSET_OFFSET, - baseline, label, labelfont, true, width); + baseline, draw_label, labelfont, true, width); x += width + TEXT_TO_INSET_OFFSET; } void InsetCollapsable::draw(BufferView * bv, LyXFont const & f, - int baseline, float & x, bool cleared) const + int baseline, float & x, bool cleared) const { if (nodraw()) return; @@ -234,6 +240,7 @@ void InsetCollapsable::edit(BufferView * bv, int xp, int yp, UpdatableInset::edit(bv, xp, yp, button); if (collapsed_) { + draw_label = label; collapsed_ = false; if (!bv->lockInset(this)) return; @@ -257,6 +264,7 @@ void InsetCollapsable::edit(BufferView * bv, bool front) UpdatableInset::edit(bv, front); if (collapsed_) { + draw_label = label; collapsed_ = false; if (!bv->lockInset(this)) return; @@ -281,6 +289,11 @@ Inset::EDITABLE InsetCollapsable::editable() const void InsetCollapsable::insetUnlock(BufferView * bv) { if (autocollapse) { + if (change_label_with_text) { + draw_label = get_new_label(); + } else { + draw_label = label; + } collapsed_ = true; } inset.insetUnlock(bv); @@ -310,10 +323,16 @@ void InsetCollapsable::insetButtonRelease(BufferView * bv, if ((x >= 0) && (x < button_length) && (y >= button_top_y) && (y <= button_bottom_y)) { if (collapsed_) { + draw_label = label; collapsed_ = false; inset.insetButtonRelease(bv, 0, 0, button); bv->updateInset(this, false); } else { + if (change_label_with_text) { + draw_label = get_new_label(); + } else { + draw_label = label; + } collapsed_ = true; bv->unlockInset(this); bv->updateInset(this, false); @@ -585,5 +604,42 @@ void InsetCollapsable::open(BufferView * bv, bool flag) if (flag == !collapsed_) return; collapsed_ = !flag; + if (collapsed_ && change_label_with_text) { + draw_label = get_new_label(); + } else { + draw_label = label; + } bv->updateInset(this, false); } + + +void InsetCollapsable::setLabel(string const & l, bool flag) +{ + label = l; + change_label_with_text = flag; + if (collapsed_ && change_label_with_text) { + draw_label = get_new_label(); + } else { + draw_label = label; + } +} + + +string InsetCollapsable::get_new_label() const +{ + string la; + + int n = std::min(10, inset.paragraph()->size()); + int i,j; + for(i=0,j=0; i < n && j < inset.paragraph()->size(); ++j) { + if (inset.paragraph()->isInset(j)) + continue; + la += inset.paragraph()->getChar(j); + ++i; + } + if ((i > 0) && (j < inset.paragraph()->size())) + la += "..."; + if (la.empty()) + la = label; + return la; +} diff --git a/src/insets/insetcollapsable.h b/src/insets/insetcollapsable.h index 05dfb96f48..66db8f4a84 100644 --- a/src/insets/insetcollapsable.h +++ b/src/insets/insetcollapsable.h @@ -127,7 +127,7 @@ public: void setFont(BufferView *, LyXFont const &, bool toggleall = false, bool selectall = false); /// - void setLabel(string const & l) { label = l; } + void setLabel(string const & l, bool flag = false); /// void setLabelFont(LyXFont & f) { labelfont = f; } /// @@ -207,6 +207,9 @@ public: /// InsetText inset; protected: + /// + string get_new_label() const; + /// mutable int button_length; /// @@ -217,6 +220,8 @@ private: /// string label; /// + mutable string draw_label; + /// bool autocollapse; /// mutable int widthCollapsed; @@ -226,6 +231,10 @@ private: mutable int topx; mutable int topbaseline; mutable UpdateCodes need_update; + /// + bool inlined; + /// + bool change_label_with_text; }; #endif diff --git a/src/insets/insetert.C b/src/insets/insetert.C index 14bdf5e3f7..4c76ca4c5f 100644 --- a/src/insets/insetert.C +++ b/src/insets/insetert.C @@ -25,7 +25,7 @@ using std::ostream; InsetERT::InsetERT() : InsetCollapsable() { - setLabel(_("666")); + setLabel(_("666"), true); //LyXFont font(LyXFont::ALL_SANE); //font.setLatex (LyXFont::ON); labelfont = LyXFont(LyXFont::ALL_SANE);