]> git.lyx.org Git - features.git/commitdiff
Conglomerate-style CharStyles
authorMartin Vermeer <martin.vermeer@hut.fi>
Sat, 6 Dec 2003 09:31:30 +0000 (09:31 +0000)
committerMartin Vermeer <martin.vermeer@hut.fi>
Sat, 6 Dec 2003 09:31:30 +0000 (09:31 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8210 a592a061-630c-0410-9148-cb99ea01b6c8

lib/ChangeLog
lib/layouts/agu_stdclass.inc
lib/layouts/db_stdclass.inc
src/insets/ChangeLog
src/insets/insetcharstyle.C
src/insets/insetcharstyle.h

index 99d8a77a3d00b86a81d7b4ad15ad535f7a90a393..56ceb59f1bc80f326f45b7ab944b3efdb49ee159 100644 (file)
@@ -1,3 +1,8 @@
+2003-12-06  Martin Vermeer  <martin.vermeer@hut.fi>
+
+       * db_stdclass.inc:
+       * agu_stdclass.inc: Conglomerate-style CharStyles
+
 2003-12-03  José Matos  <jamatos@lyx.org>
 
        * examples/docbook_article.lyx: update to latest file format.
index 425cd8c5bd9aec8828653acaea7d995775be377d..5a73fcfc83a9250a222bf10ebd842b246e57aada 100644 (file)
@@ -38,11 +38,12 @@ CharStyle Firstname
          Shape               SmallCaps
        EndFont
        LabelFont
-         Shape               Italic
-         Color               red
+         Shape               Up
+         Color               blue
        EndFont
 End
 
+
 CharStyle Surname
        LatexType             Command
        LatexName             firstname
@@ -50,11 +51,12 @@ CharStyle Surname
          Shape               SmallCaps
        EndFont
        LabelFont
-         Shape               Italic
-         Color               red
+         Shape               Up
+         Color               blue
        EndFont
 End
 
+
 CharStyle Filename
        LatexType             Command
        LatexName             firstname
@@ -62,11 +64,12 @@ CharStyle Filename
          Family              Typewriter
        EndFont
        LabelFont
-         Shape               Italic
-         Color               red
+         Family              Roman
+         Color               blue
        EndFont
 End
 
+
 CharStyle Literal
        LatexType             Command
        LatexName             firstname
@@ -74,8 +77,22 @@ CharStyle Literal
          Family              Typewriter
        EndFont
        LabelFont
+         Family              Roman
+         Color               blue
+       EndFont
+End
+
+
+CharStyle Emph
+       LatexType             Command
+       LatexName             emph
+       LatexParam            "type=&quot;italic&quot;"
+       Font
          Shape               Italic
-         Color               red
+       EndFont
+       LabelFont
+         Shape               Up
+         Color               blue
        EndFont
 End
 
index bb62a2fc06eba19c88448f35221da8048f169fa9..5a48b5984c57da5c3fcd568446023eba0e1031e8 100644 (file)
@@ -36,8 +36,8 @@ CharStyle Filename
          Family              Typewriter
        EndFont
        LabelFont
-         Shape               Italic
-         Color               red
+         Family              Roman
+         Color               blue
        EndFont
 End
 
@@ -48,8 +48,8 @@ CharStyle Firstname
          Shape               SmallCaps 
        EndFont
        LabelFont
-         Shape               Italic
-         Color               red
+         Shape               Up
+         Color               blue
        EndFont
 End
 
@@ -60,8 +60,8 @@ CharStyle Surname
          Shape               SmallCaps 
        EndFont
        LabelFont
-         Shape               Italic
-         Color               red
+         Shape               Up
+         Color               blue
        EndFont
 End
 
@@ -72,8 +72,8 @@ CharStyle Literal
          Family              Typewriter
        EndFont
        LabelFont
-         Shape               Italic
-         Color               red
+         Family              Roman
+         Color               blue
        EndFont
 End
 
index ca399e2b90b31815a0cf9f5139b0de04c06e31eb..f1cf93657f54136fc5502640e29132d0abfd1dda 100644 (file)
@@ -1,3 +1,7 @@
+2003-12-04  Martin Vermeer  <martin.vermee@hut.fi>
+
+       * insetcharstyle.[Ch]: Conglomerate-style CharStyles
+
 2003-12-04  Angus Leeming  <leeming@lyx.org>
 
        * insetexternal.C (draw): update the xo_, yo_ cache.
index 3a24c12cda2167070f4da930adfa3638dd6f438c..afea5713240b900977092ea2aa318b71344a5610 100644 (file)
@@ -25,6 +25,8 @@
 #include "metricsinfo.h"
 #include "paragraph.h"
 
+#include "frontends/font_metrics.h"
+#include "frontends/Painter.h"
 #include "support/std_sstream.h"
 
 
@@ -38,13 +40,13 @@ using std::ostringstream;
 void InsetCharStyle::init()
 {
        setInsetName("CharStyle");
-       setButtonLabel();
+       setStatus(Inlined);
 }
 
 
 InsetCharStyle::InsetCharStyle(BufferParams const & bp,
                                CharStyles::iterator cs)
-       : InsetCollapsable(bp)
+       : InsetCollapsable(bp), has_label_(true)
 {
        params_.type = cs->name;
        params_.latextype = cs->latextype;
@@ -57,7 +59,7 @@ InsetCharStyle::InsetCharStyle(BufferParams const & bp,
 
 
 InsetCharStyle::InsetCharStyle(InsetCharStyle const & in)
-       : InsetCollapsable(in), params_(in.params_)
+       : InsetCollapsable(in), params_(in.params_), has_label_(true)
 {
        init();
 }
@@ -85,24 +87,51 @@ void InsetCharStyle::write(Buffer const & buf, ostream & os) const
 void InsetCharStyle::read(Buffer const & buf, LyXLex & lex)
 {
        InsetCollapsable::read(buf, lex);
-       setButtonLabel();
+       setStatus(Inlined);
 }
 
 
-void InsetCharStyle::setButtonLabel()
+void InsetCharStyle::metrics(MetricsInfo & mi, Dimension & dim) const
 {
-       LyXFont font(params_.labelfont);
-       font.realize(LyXFont(LyXFont::ALL_SANE));
-       string const s = "Style: " + params_.type;
-       setLabel(isOpen() ? s : getNewLabel(s) );
-       setLabelFont(font);
+       InsetCollapsable::metrics(mi, dim);
+       dim_ = dim;
+       if (has_label_)
+               dim_.des += ascent();
 }
 
 
-void InsetCharStyle::metrics(MetricsInfo & mi, Dimension & dim) const
+void InsetCharStyle::draw(PainterInfo & pi, int x, int y) const
 {
-       InsetCollapsable::metrics(mi, dim);
-       dim_ = dim;
+       xo_ = x;
+       yo_ = y;
+
+       status_ = Inlined;
+       inset.setDrawFrame(InsetText::NEVER);
+       inset.draw(pi, x, y);
+
+       pi.pain.line(x + 2, y + inset.descent() - 4, x + 2,
+               y + inset.descent(), params_.labelfont.color());
+       pi.pain.line(x + 2, y + inset.descent(), x + dim_.wid - 2,
+               y + inset.descent(), params_.labelfont.color());
+       pi.pain.line(x + dim_.wid - 2, y + inset.descent(), x + dim_.wid - 2,
+               y + inset.descent() - 4, params_.labelfont.color());
+
+       if (has_label_) {
+               if (!owner())
+                       x += scroll();
+
+       LyXFont font(params_.labelfont);
+       font.realize(LyXFont(LyXFont::ALL_SANE));
+       font.decSize();
+       font.decSize();
+       int w = 0;
+       int a = 0;
+       int d = 0;
+       font_metrics::rectText(params_.type, font, w, a, d);
+       pi.pain.rectText(x + 0.5 * (dim_.wid - w), 
+               y + inset.descent() + a,
+               params_.type, font, LColor::none, LColor::none);
+       }
 }
 
 
@@ -116,9 +145,19 @@ DispatchResult
 InsetCharStyle::priv_dispatch(FuncRequest const & cmd,
                        idx_type & idx, pos_type & pos)
 {
-       DispatchResult dr = InsetCollapsable::priv_dispatch(cmd, idx, pos);
-       setButtonLabel();
-       return dr;
+       setStatus(Inlined);
+       switch (cmd.action) {
+               case LFUN_MOUSE_PRESS:
+                       if (cmd.button() == mouse_button::button3) {
+                               has_label_ = !has_label_;
+                               return DispatchResult(true);
+                       }
+                       inset.dispatch(cmd);
+                       return DispatchResult(true, true);
+                       break;
+               default:
+                       return InsetCollapsable::priv_dispatch(cmd, idx, pos);
+       }
 }
 
 
index c4fcad97083f64dccaceef6c2f973b0c62e7a961..d7c3f4cd80d58ba5988b805dce79f59924ece675 100644 (file)
@@ -60,10 +60,10 @@ public:
        ///
        void read(Buffer const & buf, LyXLex & lex);
        ///
-       void setButtonLabel();
-       ///
        void metrics(MetricsInfo &, Dimension &) const;
        ///
+       void draw(PainterInfo &, int, int) const;
+       ///
        void getDrawFont(LyXFont &) const;
        ///
        int latex(Buffer const &, std::ostream &,
@@ -96,6 +96,8 @@ private:
        void init();
        ///
        InsetCharStyleParams params_;
+       ///
+       bool has_label_;
 };
 
 #endif