Conglomerate-style CharStyles

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8210 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Martin Vermeer 2003-12-06 09:31:30 +00:00
parent 62715f910e
commit ee31454d59
6 changed files with 101 additions and 34 deletions

View 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.

View 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

View 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

View 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.

View 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,17 +87,7 @@ void InsetCharStyle::write(Buffer const & buf, ostream & os) const
void InsetCharStyle::read(Buffer const & buf, LyXLex & lex)
{
InsetCollapsable::read(buf, lex);
setButtonLabel();
}
void InsetCharStyle::setButtonLabel()
{
LyXFont font(params_.labelfont);
font.realize(LyXFont(LyXFont::ALL_SANE));
string const s = "Style: " + params_.type;
setLabel(isOpen() ? s : getNewLabel(s) );
setLabelFont(font);
setStatus(Inlined);
}
@ -103,6 +95,43 @@ void InsetCharStyle::metrics(MetricsInfo & mi, Dimension & dim) const
{
InsetCollapsable::metrics(mi, dim);
dim_ = dim;
if (has_label_)
dim_.des += ascent();
}
void InsetCharStyle::draw(PainterInfo & pi, int x, int y) const
{
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);
}
}

View 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