From ee31454d597dce8f67e4828b03eb3e7cc6125551 Mon Sep 17 00:00:00 2001 From: Martin Vermeer Date: Sat, 6 Dec 2003 09:31:30 +0000 Subject: [PATCH] Conglomerate-style CharStyles git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8210 a592a061-630c-0410-9148-cb99ea01b6c8 --- lib/ChangeLog | 5 +++ lib/layouts/agu_stdclass.inc | 31 ++++++++++++---- lib/layouts/db_stdclass.inc | 16 ++++---- src/insets/ChangeLog | 4 ++ src/insets/insetcharstyle.C | 71 ++++++++++++++++++++++++++++-------- src/insets/insetcharstyle.h | 6 ++- 6 files changed, 100 insertions(+), 33 deletions(-) diff --git a/lib/ChangeLog b/lib/ChangeLog index 99d8a77a3d..56ceb59f1b 100644 --- a/lib/ChangeLog +++ b/lib/ChangeLog @@ -1,3 +1,8 @@ +2003-12-06 Martin Vermeer + + * db_stdclass.inc: + * agu_stdclass.inc: Conglomerate-style CharStyles + 2003-12-03 José Matos * examples/docbook_article.lyx: update to latest file format. diff --git a/lib/layouts/agu_stdclass.inc b/lib/layouts/agu_stdclass.inc index 425cd8c5bd..5a73fcfc83 100644 --- a/lib/layouts/agu_stdclass.inc +++ b/lib/layouts/agu_stdclass.inc @@ -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="italic"" + Font Shape Italic - Color red + EndFont + LabelFont + Shape Up + Color blue EndFont End diff --git a/lib/layouts/db_stdclass.inc b/lib/layouts/db_stdclass.inc index bb62a2fc06..5a48b5984c 100644 --- a/lib/layouts/db_stdclass.inc +++ b/lib/layouts/db_stdclass.inc @@ -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 diff --git a/src/insets/ChangeLog b/src/insets/ChangeLog index ca399e2b90..f1cf93657f 100644 --- a/src/insets/ChangeLog +++ b/src/insets/ChangeLog @@ -1,3 +1,7 @@ +2003-12-04 Martin Vermeer + + * insetcharstyle.[Ch]: Conglomerate-style CharStyles + 2003-12-04 Angus Leeming * insetexternal.C (draw): update the xo_, yo_ cache. diff --git a/src/insets/insetcharstyle.C b/src/insets/insetcharstyle.C index 3a24c12cda..afea571324 100644 --- a/src/insets/insetcharstyle.C +++ b/src/insets/insetcharstyle.C @@ -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); + } } diff --git a/src/insets/insetcharstyle.h b/src/insets/insetcharstyle.h index c4fcad9708..d7c3f4cd80 100644 --- a/src/insets/insetcharstyle.h +++ b/src/insets/insetcharstyle.h @@ -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 -- 2.39.2