]> git.lyx.org Git - features.git/commitdiff
Enhance LyX by fixing bug 5587. We add a new ContentAsLabel tag to
authorRichard Heck <rgheck@comcast.net>
Fri, 18 Dec 2009 00:29:22 +0000 (00:29 +0000)
committerRichard Heck <rgheck@comcast.net>
Fri, 18 Dec 2009 00:29:22 +0000 (00:29 +0000)
InsetLayout, per Jurgen's suggestion, so that insets can be told to
display an abbreviated form of their content when closed.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@32575 a592a061-630c-0410-9148-cb99ea01b6c8

lib/doc/Customization.lyx
lib/layouts/stdinsets.inc
lib/scripts/layout2layout.py
src/TextClass.cpp
src/insets/InsetCollapsable.cpp
src/insets/InsetLayout.cpp
src/insets/InsetLayout.h

index 35bd469e572c081af77dac1808d75db31a9d1db0..50e56bd7d3d70ef976930c83be431cd9dba08d2b 100644 (file)
@@ -1,5 +1,5 @@
 #LyX 2.0.0svn created this file. For more info see http://www.lyx.org/
-\lyxformat 372
+\lyxformat 373
 \begin_document
 \begin_header
 \textclass scrbook
@@ -12868,6 +12868,43 @@ src/ColorCode.h
 \begin_inset Flex CharStyle:Code
 status collapsed
 
+\begin_layout Plain Layout
+ContentAsLabel
+\end_layout
+
+\end_inset
+
+ [
+\begin_inset Flex CharStyle:Code
+status collapsed
+
+\begin_layout Plain Layout
+
+\emph on
+0
+\end_layout
+
+\end_inset
+
+,
+\begin_inset Flex CharStyle:Code
+status collapsed
+
+\begin_layout Plain Layout
+1
+\end_layout
+
+\end_inset
+
+] Whether to use the content of the inset as the label, when the inset is
+ closed.
+ Default is false.
+\end_layout
+
+\begin_layout Description
+\begin_inset Flex CharStyle:Code
+status collapsed
+
 \begin_layout Plain Layout
 CopyStyle
 \end_layout
@@ -13121,6 +13158,7 @@ status collapsed
 
 ] Indicates whether the PlainLayout should be used or, instead, the user
  can change the paragraph style used in the inset.
+ Default is false.
 \end_layout
 
 \begin_layout Description
@@ -13141,6 +13179,7 @@ reference "des:FreeSpacing"
 \end_inset
 
 ).
+ Default is false.
 \end_layout
 
 \begin_layout Description
@@ -13201,6 +13240,7 @@ reference "des:KeepEmpty"
 \end_inset
 
 ).
+ Default is false.
 \end_layout
 
 \begin_layout Description
@@ -13409,13 +13449,43 @@ status collapsed
 \end_inset
 
 ] Whether multiple paragraphs are permitted in this inset.
- This will also set CustomPars to the same value and ForcePlain to the opposite
- value.
+ This will also set 
+\begin_inset Flex CharStyle:Code
+status collapsed
+
+\begin_layout Plain Layout
+CustomPars
+\end_layout
+
+\end_inset
+
+ to the same value and 
+\begin_inset Flex CharStyle:Code
+status collapsed
+
+\begin_layout Plain Layout
+ForcePlain
+\end_layout
+
+\end_inset
+
+ to the opposite value.
  These can be reset to other values, if they are used 
 \emph on
 after
 \emph default
- MultiPar.
+\begin_inset Flex CharStyle:Code
+status collapsed
+
+\begin_layout Plain Layout
+MultiPar
+\end_layout
+
+\end_inset
+
+.
+ Default is true.
 \end_layout
 
 \begin_layout Description
@@ -13467,7 +13537,7 @@ protect
 \emph on
 not
 \emph default
- whether the command should itself be protected.)
+ whether the command should itself be protected.) Default is false.
 \end_layout
 
 \begin_layout Description
@@ -13504,12 +13574,13 @@ status collapsed
 
 ] As with paragraph styles (see page 
 \begin_inset CommandInset ref
-LatexCommand ref
+LatexCommand pageref
 reference "des:PathThru"
 
 \end_inset
 
 ).
+ Default is false.
 \end_layout
 
 \begin_layout Description
index cf371940b6b34c1ee354d85d7c7e5da541aeb13d..526432ebe835c976c77780db122b6ef8236745c3 100644 (file)
@@ -305,6 +305,7 @@ InsetLayout URL
        LyXType               standard
        Decoration            classic
        LabelString           URL
+       ContentAsLabel        true
        LatexName             url
        LatexType             command
        Requires              url
index 44af31d709a8330fb021c87a47cb18ade9cd5f1d..616e458d4af1a8c805e0feeb94e09694ba5a9ef5 100644 (file)
@@ -73,10 +73,13 @@ import os, re, string, sys
 # Incremented to format 19, 17 November 2009 by rgh
 # Added InPreamble tag.
 
+# Incremented to format 20, 17 December 2009 by rgh
+# Added ContentAsLabel tag.
+
 # Do not forget to document format change in Customization
 # Manual (section "Declaring a new text class").
 
-currentFormat = 19
+currentFormat = 20
 
 
 def usage(prog_name):
@@ -245,7 +248,7 @@ def convert(lines):
             continue
 
         # This just involved new features, not any changes to old ones
-        if format == 14 or format == 15 or format == 16 or format == 17 or format == 18:
+        if format >= 14 and format <= 19:
           i += 1
           continue
 
index e19b0ec2003d72e068b2387fca7a842a3d681e30..52f5c3034079ebcf84ea2c4478b8ffff944b6388 100644 (file)
@@ -66,7 +66,7 @@ private:
 };
 
 // Keep the changes documented in the Customization manual. 
-int const FORMAT = 19;
+int const FORMAT = 20;
 
 
 bool layout2layout(FileName const & filename, FileName const & tempfile)
index 4497e937d33990477bec993d8ee4561ee2d5977c..dc9939e5acfe1e63223cdf10574726acca0a79bd 100644 (file)
@@ -573,10 +573,14 @@ void InsetCollapsable::setLabel(docstring const & l)
 }
 
 
-docstring const InsetCollapsable::buttonLabel(BufferView const &) const
+docstring const InsetCollapsable::buttonLabel(BufferView const & bv) const
 {
-       return labelstring_.empty() ? 
+       docstring const label = labelstring_.empty() ? 
                translateIfPossible(getLayout().labelstring()) : labelstring_;
+       InsetLayout const & il = getLayout();
+       if (!il.contentaslabel() || geometry(bv) != ButtonOnly)
+               return label;
+       return getNewLabel(label);
 }
 
 
index f2b701dfb8057f81bb21b03d0242a519b9cc0ec4..0b9963a0ee479ca9cfa26ac18c0f25af682c58ec 100644 (file)
@@ -31,8 +31,8 @@ namespace lyx {
 
 InsetLayout::InsetLayout() :
        name_(from_ascii("undefined")), lyxtype_(STANDARD),
-       labelstring_(from_ascii("UNDEFINED")), decoration_(DEFAULT),
-       latextype_(NOLATEXTYPE), font_(sane_font), 
+       labelstring_(from_ascii("UNDEFINED")), contentaslabel_(false),
+       decoration_(DEFAULT), latextype_(NOLATEXTYPE), font_(sane_font), 
        labelfont_(sane_font), bgcolor_(Color_error), 
        htmlforcecss_ (false), htmlisblock_(true),
        multipar_(true), custompars_(true), forceplain_(false), 
@@ -74,6 +74,7 @@ bool InsetLayout::read(Lexer & lex, TextClass const & tclass)
 {
        enum {
                IL_BGCOLOR,
+               IL_CONTENTASLABEL,
                IL_COPYSTYLE,
                IL_COUNTER,
                IL_CUSTOMPARS,
@@ -110,6 +111,7 @@ bool InsetLayout::read(Lexer & lex, TextClass const & tclass)
 
        LexerKeyword elementTags[] = {
                { "bgcolor", IL_BGCOLOR },
+               { "contentaslabel", IL_CONTENTASLABEL },
                { "copystyle", IL_COPYSTYLE }, 
                { "counter", IL_COUNTER},
                { "custompars", IL_CUSTOMPARS },
@@ -240,6 +242,9 @@ bool InsetLayout::read(Lexer & lex, TextClass const & tclass)
                case IL_NEEDPROTECT:
                        lex >> needprotect_;
                        break;
+               case IL_CONTENTASLABEL:
+                       lex >> contentaslabel_;
+                       break;
                case IL_COPYSTYLE: {     // initialize with a known style
                        docstring style;
                        lex >> style;
index 8237cd4029ecf4cee6666e819fd4329ec96dbc86..533b62d0e8202452a644db9b97239bdbbdbab675 100644 (file)
@@ -66,6 +66,8 @@ public:
        ///
        docstring labelstring() const { return labelstring_; }
        ///
+       bool contentaslabel() const { return contentaslabel_; }
+       ///
        InsetDecoration decoration() const { return decoration_; }
        ///
        InsetLaTeXType latextype() const { return latextype_; }
@@ -143,6 +145,8 @@ private:
        ///
        docstring labelstring_;
        ///
+       bool contentaslabel_;
+       ///
        InsetDecoration decoration_;
        ///
        InsetLaTeXType latextype_;