mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-29 05:01:49 +00:00
IU for second phase of two-phase drawing
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7067 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
246d6a9587
commit
d60684fd07
@ -1,3 +1,7 @@
|
|||||||
|
2003-05-30 André Pönitz <poenitz@gmx.net>
|
||||||
|
|
||||||
|
* rowpainter.C: unify second drawing phase
|
||||||
|
|
||||||
2003-05-29 Lars Gullik Bjønnes <larsbj@gullik.net>
|
2003-05-29 Lars Gullik Bjønnes <larsbj@gullik.net>
|
||||||
|
|
||||||
* trans_mgr.C: remove one case of current_view
|
* trans_mgr.C: remove one case of current_view
|
||||||
|
@ -1,3 +1,24 @@
|
|||||||
|
|
||||||
|
2003-05-30 André Pönitz <poenitz@gmx.net>
|
||||||
|
|
||||||
|
* inset.h:
|
||||||
|
* insetbase.h:
|
||||||
|
* insetbutton.[Ch]:
|
||||||
|
* insetcaption.[Ch]:
|
||||||
|
* insetcollapsable.[Ch]:
|
||||||
|
* inseterror.[Ch]:
|
||||||
|
* insetert.[Ch]:
|
||||||
|
* insetgraphics.[Ch]:
|
||||||
|
* insetinclude.[Ch]:
|
||||||
|
* insetlatexaccent.[Ch]:
|
||||||
|
* insetnewline.[Ch]:
|
||||||
|
* insetquotes.[Ch]:
|
||||||
|
* insetspace.[Ch]:
|
||||||
|
* insetspecialchar.[Ch]:
|
||||||
|
* insettabular.[Ch]:
|
||||||
|
* insettext.[Ch]:
|
||||||
|
* updatableinset.[Ch]: unify second drawing phase
|
||||||
|
|
||||||
2003-05-30 John Levon <levon@movementarian.org>
|
2003-05-30 John Levon <levon@movementarian.org>
|
||||||
|
|
||||||
* insetgraphics.C: fix a bformat
|
* insetgraphics.C: fix a bformat
|
||||||
|
@ -167,8 +167,6 @@ public:
|
|||||||
int descent(BufferView *, LyXFont const &) const;
|
int descent(BufferView *, LyXFont const &) const;
|
||||||
///
|
///
|
||||||
int width(BufferView *, LyXFont const &) const;
|
int width(BufferView *, LyXFont const &) const;
|
||||||
///
|
|
||||||
virtual void draw(BufferView *, LyXFont const &, int baseline, float & x) const = 0;
|
|
||||||
/// update the inset representation
|
/// update the inset representation
|
||||||
virtual void update(BufferView *, bool = false)
|
virtual void update(BufferView *, bool = false)
|
||||||
{}
|
{}
|
||||||
|
@ -16,6 +16,8 @@
|
|||||||
|
|
||||||
class BufferView;
|
class BufferView;
|
||||||
class FuncRequest;
|
class FuncRequest;
|
||||||
|
class MetricsInfo;
|
||||||
|
class PainterInfo;
|
||||||
|
|
||||||
/** Dispatch result codes
|
/** Dispatch result codes
|
||||||
DISPATCHED = the inset catched the action
|
DISPATCHED = the inset catched the action
|
||||||
@ -62,6 +64,8 @@ public:
|
|||||||
|
|
||||||
/// small wrapper for the time being
|
/// small wrapper for the time being
|
||||||
virtual dispatch_result localDispatch(FuncRequest const & cmd);
|
virtual dispatch_result localDispatch(FuncRequest const & cmd);
|
||||||
|
///
|
||||||
|
virtual void draw(PainterInfo & pi, int x, int y) const = 0;
|
||||||
|
|
||||||
///
|
///
|
||||||
virtual ~InsetBase() {}
|
virtual ~InsetBase() {}
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
#include "frontends/Painter.h"
|
#include "frontends/Painter.h"
|
||||||
#include "support/LAssert.h"
|
#include "support/LAssert.h"
|
||||||
#include "lyxfont.h"
|
#include "lyxfont.h"
|
||||||
|
#include "metricsinfo.h"
|
||||||
#include "frontends/font_metrics.h"
|
#include "frontends/font_metrics.h"
|
||||||
|
|
||||||
using std::ostream;
|
using std::ostream;
|
||||||
@ -46,27 +47,23 @@ void InsetButton::dimension(BufferView * bv, LyXFont const &,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void InsetButton::draw(BufferView * bv, LyXFont const &,
|
void InsetButton::draw(PainterInfo & pi, int x, int y) const
|
||||||
int baseline, float & x) const
|
|
||||||
{
|
{
|
||||||
lyx::Assert(bv);
|
lyx::Assert(pi.base.bv);
|
||||||
cache(bv);
|
cache(pi.base.bv);
|
||||||
|
|
||||||
Painter & pain = bv->painter();
|
|
||||||
// Draw it as a box with the LaTeX text
|
// Draw it as a box with the LaTeX text
|
||||||
LyXFont font(LyXFont::ALL_SANE);
|
LyXFont font(LyXFont::ALL_SANE);
|
||||||
font.setColor(LColor::command).decSize();
|
font.setColor(LColor::command).decSize();
|
||||||
|
|
||||||
string const s = getScreenLabel(bv->buffer());
|
string const s = getScreenLabel(pi.base.bv->buffer());
|
||||||
|
|
||||||
if (editable()) {
|
if (editable()) {
|
||||||
pain.buttonText(int(x) + 2, baseline, s, font);
|
pi.pain.buttonText(x + 2, y, s, font);
|
||||||
} else {
|
} else {
|
||||||
pain.rectText(int(x) + 2, baseline, s, font,
|
pi.pain.rectText(x + 2, y, s, font,
|
||||||
LColor::commandbg, LColor::commandframe);
|
LColor::commandbg, LColor::commandframe);
|
||||||
}
|
}
|
||||||
|
|
||||||
x += width(bv, font);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ public:
|
|||||||
///
|
///
|
||||||
void dimension(BufferView *, LyXFont const &, Dimension &) const;
|
void dimension(BufferView *, LyXFont const &, Dimension &) const;
|
||||||
///
|
///
|
||||||
void draw(BufferView *, LyXFont const &, int, float &) const;
|
void draw(PainterInfo & pi, int x, int y) const;
|
||||||
///
|
///
|
||||||
dispatch_result localDispatch(FuncRequest const & cmd);
|
dispatch_result localDispatch(FuncRequest const & cmd);
|
||||||
|
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
#include "gettext.h"
|
#include "gettext.h"
|
||||||
#include "Lsstream.h"
|
#include "Lsstream.h"
|
||||||
|
#include "metricsinfo.h"
|
||||||
#include "support/lstrings.h"
|
#include "support/lstrings.h"
|
||||||
#include "support/LAssert.h"
|
#include "support/LAssert.h"
|
||||||
#include "support/BoostFormat.h"
|
#include "support/BoostFormat.h"
|
||||||
@ -66,8 +67,7 @@ string const InsetCaption::editMessage() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void InsetCaption::draw(BufferView * bv, LyXFont const & f,
|
void InsetCaption::draw(PainterInfo & pi, int x, int y) const
|
||||||
int baseline, float & x) const
|
|
||||||
{
|
{
|
||||||
// We must draw the label, we should get the label string
|
// We must draw the label, we should get the label string
|
||||||
// from the enclosing float inset.
|
// from the enclosing float inset.
|
||||||
@ -88,7 +88,7 @@ void InsetCaption::draw(BufferView * bv, LyXFont const & f,
|
|||||||
lyx::Assert(0);
|
lyx::Assert(0);
|
||||||
|
|
||||||
FloatList const & floats =
|
FloatList const & floats =
|
||||||
bv->buffer()->params.getLyXTextClass().floats();
|
pi.base.bv->buffer()->params.getLyXTextClass().floats();
|
||||||
string const fl = i2 ? floats.getType(type).name() : N_("Float");
|
string const fl = i2 ? floats.getType(type).name() : N_("Float");
|
||||||
|
|
||||||
// Discover the number...
|
// Discover the number...
|
||||||
@ -96,12 +96,9 @@ void InsetCaption::draw(BufferView * bv, LyXFont const & f,
|
|||||||
|
|
||||||
// Generate the label
|
// Generate the label
|
||||||
string const label = bformat("%1$s %2$s:", _(fl), num);
|
string const label = bformat("%1$s %2$s:", _(fl), num);
|
||||||
Painter & pain = bv->painter();
|
int const w = font_metrics::width(label, pi.base.font);
|
||||||
int const w = font_metrics::width(label, f);
|
pi.pain.text(x, y, label, pi.base.font);
|
||||||
pain.text(int(x), baseline, label, f);
|
InsetText::draw(pi, x + w, y);
|
||||||
x += w;
|
|
||||||
|
|
||||||
InsetText::draw(bv, f, baseline, x);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -34,8 +34,7 @@ public:
|
|||||||
///
|
///
|
||||||
virtual string const editMessage() const;
|
virtual string const editMessage() const;
|
||||||
///
|
///
|
||||||
virtual void draw(BufferView * bv, LyXFont const & f,
|
virtual void draw(PainterInfo & pi, int x, int y) const;
|
||||||
int baseline, float & x) const;
|
|
||||||
///
|
///
|
||||||
virtual int latex(Buffer const * buf, std::ostream & os,
|
virtual int latex(Buffer const * buf, std::ostream & os,
|
||||||
LatexRunParams const &) const;
|
LatexRunParams const &) const;
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
#include "WordLangTuple.h"
|
#include "WordLangTuple.h"
|
||||||
#include "funcrequest.h"
|
#include "funcrequest.h"
|
||||||
#include "buffer.h"
|
#include "buffer.h"
|
||||||
|
#include "metricsinfo.h"
|
||||||
|
|
||||||
#include "frontends/font_metrics.h"
|
#include "frontends/font_metrics.h"
|
||||||
#include "frontends/Painter.h"
|
#include "frontends/Painter.h"
|
||||||
@ -136,22 +137,16 @@ void InsetCollapsable::dimension(BufferView * bv, LyXFont const & font,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void InsetCollapsable::draw_collapsed(Painter & pain,
|
void InsetCollapsable::draw_collapsed(PainterInfo & pi, int x, int y) const
|
||||||
int baseline, float & x) const
|
|
||||||
{
|
{
|
||||||
pain.buttonText(int(x) + TEXT_TO_INSET_OFFSET,
|
pi.pain.buttonText(x + TEXT_TO_INSET_OFFSET, y, label, labelfont);
|
||||||
baseline, label, labelfont);
|
|
||||||
Dimension dim;
|
|
||||||
dimension_collapsed(dim);
|
|
||||||
x += dim.wid;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void InsetCollapsable::draw(BufferView * bv, LyXFont const & f,
|
void InsetCollapsable::draw(PainterInfo & pi, int x, int y, bool inlined) const
|
||||||
int baseline, float & x, bool inlined) const
|
|
||||||
{
|
{
|
||||||
lyx::Assert(bv);
|
lyx::Assert(pi.base.bv);
|
||||||
cache(bv);
|
cache(pi.base.bv);
|
||||||
|
|
||||||
if (nodraw())
|
if (nodraw())
|
||||||
return;
|
return;
|
||||||
@ -159,45 +154,41 @@ void InsetCollapsable::draw(BufferView * bv, LyXFont const & f,
|
|||||||
Dimension dim_collapsed;
|
Dimension dim_collapsed;
|
||||||
dimension_collapsed(dim_collapsed);
|
dimension_collapsed(dim_collapsed);
|
||||||
|
|
||||||
Painter & pain = bv->painter();
|
int const aa = ascent(pi.base.bv, pi.base.font);
|
||||||
|
|
||||||
button_length = dim_collapsed.width();
|
button_length = dim_collapsed.width();
|
||||||
button_top_y = -ascent(bv, f);
|
button_top_y = -aa;
|
||||||
button_bottom_y = -ascent(bv, f) + dim_collapsed.height();
|
button_bottom_y = -aa + dim_collapsed.height();
|
||||||
|
|
||||||
if (!isOpen()) {
|
if (!isOpen()) {
|
||||||
draw_collapsed(pain, baseline, x);
|
draw_collapsed(pi, x, y);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
float old_x = x;
|
int old_x = x;
|
||||||
|
|
||||||
if (!owner())
|
if (!owner())
|
||||||
x += scroll();
|
x += scroll();
|
||||||
|
|
||||||
top_x = int(x);
|
top_x = x;
|
||||||
top_baseline = baseline;
|
top_baseline = y;
|
||||||
|
|
||||||
int const bl = baseline - ascent(bv, f) + dim_collapsed.ascent();
|
int const bl = y - aa + dim_collapsed.ascent();
|
||||||
|
|
||||||
if (inlined) {
|
if (inlined) {
|
||||||
inset.draw(bv, f, baseline, x);
|
inset.draw(pi, x, y);
|
||||||
} else {
|
} else {
|
||||||
draw_collapsed(pain, bl, old_x);
|
draw_collapsed(pi, old_x, bl);
|
||||||
int const yy = bl + dim_collapsed.descent() + inset.ascent(bv, f);
|
int const yy = bl + dim_collapsed.descent()
|
||||||
inset.draw(bv, f, yy, x);
|
+ inset.ascent(pi.base.bv, pi.base.font);
|
||||||
// contained inset may be shorter than the button
|
inset.draw(pi, x, yy);
|
||||||
if (x < top_x + button_length + TEXT_TO_INSET_OFFSET)
|
|
||||||
x = top_x + button_length + TEXT_TO_INSET_OFFSET;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void InsetCollapsable::draw(BufferView * bv, LyXFont const & f,
|
void InsetCollapsable::draw(PainterInfo & pi, int x, int y) const
|
||||||
int baseline, float & x) const
|
|
||||||
{
|
{
|
||||||
// by default, we are not inlined-drawing
|
// by default, we are not inlined-drawing
|
||||||
draw(bv, f, baseline, x, false);
|
draw(pi, x, y, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -47,10 +47,9 @@ public:
|
|||||||
///
|
///
|
||||||
void dimension(BufferView *, LyXFont const &, Dimension &) const;
|
void dimension(BufferView *, LyXFont const &, Dimension &) const;
|
||||||
///
|
///
|
||||||
void draw(BufferView *, const LyXFont &, int, float &) const;
|
void draw(PainterInfo & pi, int x, int y) const;
|
||||||
/// draw, either inlined (no button) or collapsed/open
|
/// draw, either inlined (no button) or collapsed/open
|
||||||
void draw(BufferView * bv, LyXFont const & f,
|
void draw(PainterInfo & pi, int x, int y, bool inlined) const;
|
||||||
int baseline, float & x, bool inlined) const;
|
|
||||||
///
|
///
|
||||||
void update(BufferView *, bool = false);
|
void update(BufferView *, bool = false);
|
||||||
///
|
///
|
||||||
@ -181,7 +180,7 @@ protected:
|
|||||||
///
|
///
|
||||||
int height_collapsed() const;
|
int height_collapsed() const;
|
||||||
///
|
///
|
||||||
void draw_collapsed(Painter & pain, int, float &) const;
|
void draw_collapsed(PainterInfo & pi, int x, int y) const;
|
||||||
///
|
///
|
||||||
int getMaxTextWidth(Painter & pain, UpdatableInset const *) const;
|
int getMaxTextWidth(Painter & pain, UpdatableInset const *) const;
|
||||||
|
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
#include "funcrequest.h"
|
#include "funcrequest.h"
|
||||||
#include "gettext.h"
|
#include "gettext.h"
|
||||||
#include "lyxfont.h"
|
#include "lyxfont.h"
|
||||||
|
#include "metricsinfo.h"
|
||||||
|
|
||||||
#include "frontends/Dialogs.h"
|
#include "frontends/Dialogs.h"
|
||||||
#include "frontends/font_metrics.h"
|
#include "frontends/font_metrics.h"
|
||||||
@ -71,30 +72,24 @@ void InsetError::dimension(BufferView *, LyXFont const & font,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void InsetError::draw(BufferView * bv, LyXFont const & font,
|
void InsetError::draw(PainterInfo & pi, int x, int y) const
|
||||||
int baseline, float & x) const
|
|
||||||
{
|
{
|
||||||
lyx::Assert(bv);
|
lyx::Assert(pi.base.bv);
|
||||||
cache(bv);
|
cache(pi.base.bv);
|
||||||
|
|
||||||
Painter & pain = bv->painter();
|
|
||||||
LyXFont efont;
|
LyXFont efont;
|
||||||
efont.setSize(font.size()).decSize();
|
efont.setSize(pi.base.font.size()).decSize();
|
||||||
efont.setColor(LColor::error);
|
efont.setColor(LColor::error);
|
||||||
|
|
||||||
// Draw as "Error" in a framed box
|
// Draw as "Error" in a framed box
|
||||||
x += 1;
|
x += 1;
|
||||||
pain.fillRectangle(int(x), baseline - ascent(bv, font) + 1,
|
Dimension dim;
|
||||||
width(bv, font) - 2,
|
dimension(pi.base.bv, pi.base.font, dim);
|
||||||
ascent(bv, font) + descent(bv, font) - 2,
|
pi.pain.fillRectangle(x, y - dim.asc + 1,
|
||||||
LColor::insetbg);
|
dim.wid - 2, dim.asc + dim.des - 2, LColor::insetbg);
|
||||||
pain.rectangle(int(x), baseline - ascent(bv, font) + 1,
|
pi.pain.rectangle(x, y - dim.asc + 1,
|
||||||
width(bv, font) - 2,
|
dim.wid - 2, dim.asc + dim.des - 2, LColor::error);
|
||||||
ascent(bv, font) + descent(bv, font) - 2,
|
pi.pain.text(x + 2, y, _("Error"), efont);
|
||||||
LColor::error);
|
|
||||||
pain.text(int(x + 2), baseline, _("Error"), efont);
|
|
||||||
|
|
||||||
x += width(bv, font) - 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ public:
|
|||||||
///
|
///
|
||||||
void dimension(BufferView *, LyXFont const &, Dimension &) const;
|
void dimension(BufferView *, LyXFont const &, Dimension &) const;
|
||||||
///
|
///
|
||||||
void draw(BufferView *, LyXFont const &, int, float &) const;
|
void draw(PainterInfo & pi, int x, int y) const;
|
||||||
///
|
///
|
||||||
void write(Buffer const *, std::ostream &) const {}
|
void write(Buffer const *, std::ostream &) const {}
|
||||||
///
|
///
|
||||||
|
@ -562,10 +562,9 @@ void InsetERT::dimension(BufferView * bv, LyXFont const & font,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void InsetERT::draw(BufferView * bv, LyXFont const & f,
|
void InsetERT::draw(PainterInfo & pi, int x, int y) const
|
||||||
int baseline, float & x) const
|
|
||||||
{
|
{
|
||||||
InsetCollapsable::draw(bv, f, baseline, x, inlined());
|
InsetCollapsable::draw(pi, x, y, inlined());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -101,7 +101,7 @@ public:
|
|||||||
///
|
///
|
||||||
void dimension(BufferView *, LyXFont const &, Dimension &) const;
|
void dimension(BufferView *, LyXFont const &, Dimension &) const;
|
||||||
///
|
///
|
||||||
void draw(BufferView *, const LyXFont &, int , float &) const;
|
void draw(PainterInfo & pi, int x, int y) const;
|
||||||
/// set the status of the inset
|
/// set the status of the inset
|
||||||
void status(BufferView *, ERTStatus const st) const;
|
void status(BufferView *, ERTStatus const st) const;
|
||||||
///
|
///
|
||||||
|
@ -73,7 +73,7 @@ TODO
|
|||||||
#include "Lsstream.h"
|
#include "Lsstream.h"
|
||||||
#include "lyxlex.h"
|
#include "lyxlex.h"
|
||||||
#include "lyxrc.h"
|
#include "lyxrc.h"
|
||||||
#include "Lsstream.h"
|
#include "metricsinfo.h"
|
||||||
|
|
||||||
#include "frontends/lyx_gui.h"
|
#include "frontends/lyx_gui.h"
|
||||||
#include "frontends/Alert.h"
|
#include "frontends/Alert.h"
|
||||||
@ -324,9 +324,9 @@ BufferView * InsetGraphics::view() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void InsetGraphics::draw(BufferView * bv, LyXFont const & font,
|
void InsetGraphics::draw(PainterInfo & pi, int x, int y) const
|
||||||
int baseline, float & x) const
|
|
||||||
{
|
{
|
||||||
|
BufferView * bv = pi.base.bv;
|
||||||
// MakeAbsPath returns params().filename unchanged if it absolute
|
// MakeAbsPath returns params().filename unchanged if it absolute
|
||||||
// already.
|
// already.
|
||||||
string const file_with_path =
|
string const file_with_path =
|
||||||
@ -342,22 +342,18 @@ void InsetGraphics::draw(BufferView * bv, LyXFont const & font,
|
|||||||
cache_->view = bv->owner()->view();
|
cache_->view = bv->owner()->view();
|
||||||
int oasc = cache_->old_ascent;
|
int oasc = cache_->old_ascent;
|
||||||
|
|
||||||
int ldescent = descent(bv, font);
|
Dimension dim;
|
||||||
int lascent = ascent(bv, font);
|
dimension(bv, pi.base.font, dim);
|
||||||
int lwidth = width(bv, font);
|
|
||||||
|
|
||||||
// we may have changed while someone other was drawing us so better
|
// we may have changed while someone other was drawing us so better
|
||||||
// to not draw anything as we surely call to redraw ourself soon.
|
// to not draw anything as we surely call to redraw ourself soon.
|
||||||
// This is not a nice thing to do and should be fixed properly somehow.
|
// This is not a nice thing to do and should be fixed properly somehow.
|
||||||
// But I still don't know the best way to go. So let's do this like this
|
// But I still don't know the best way to go. So let's do this like this
|
||||||
// for now (Jug 20020311)
|
// for now (Jug 20020311)
|
||||||
if (lascent != oasc)
|
if (dim.asc != oasc)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Make sure now that x is updated upon exit from this routine
|
// Make sure now that x is updated upon exit from this routine
|
||||||
int old_x = int(x);
|
|
||||||
x += lwidth;
|
|
||||||
|
|
||||||
grfx::Params const & gparams = params().as_grfxParams();
|
grfx::Params const & gparams = params().as_grfxParams();
|
||||||
|
|
||||||
if (gparams.display != grfx::NoDisplay &&
|
if (gparams.display != grfx::NoDisplay &&
|
||||||
@ -369,26 +365,25 @@ void InsetGraphics::draw(BufferView * bv, LyXFont const & font,
|
|||||||
|
|
||||||
// This will draw the graphics. If the graphics has not been loaded yet,
|
// This will draw the graphics. If the graphics has not been loaded yet,
|
||||||
// we draw just a rectangle.
|
// we draw just a rectangle.
|
||||||
Painter & paint = bv->painter();
|
|
||||||
|
|
||||||
if (imageIsDrawable()) {
|
if (imageIsDrawable()) {
|
||||||
paint.image(old_x + TEXT_TO_INSET_OFFSET, baseline - lascent,
|
pi.pain.image(x + TEXT_TO_INSET_OFFSET, y - dim.asc,
|
||||||
lwidth - 2 * TEXT_TO_INSET_OFFSET, lascent + ldescent,
|
dim.wid - 2 * TEXT_TO_INSET_OFFSET, dim.asc + dim.des,
|
||||||
*cache_->loader.image());
|
*cache_->loader.image());
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
paint.rectangle(old_x + TEXT_TO_INSET_OFFSET, baseline - lascent,
|
pi.pain.rectangle(x + TEXT_TO_INSET_OFFSET, y - dim.asc,
|
||||||
lwidth - 2 * TEXT_TO_INSET_OFFSET, lascent + ldescent);
|
dim.wid - 2 * TEXT_TO_INSET_OFFSET, dim.asc + dim.des);
|
||||||
|
|
||||||
// Print the file name.
|
// Print the file name.
|
||||||
LyXFont msgFont(font);
|
LyXFont msgFont = pi.base.font;
|
||||||
msgFont.setFamily(LyXFont::SANS_FAMILY);
|
msgFont.setFamily(LyXFont::SANS_FAMILY);
|
||||||
string const justname = OnlyFilename (params().filename);
|
string const justname = OnlyFilename (params().filename);
|
||||||
if (!justname.empty()) {
|
if (!justname.empty()) {
|
||||||
msgFont.setSize(LyXFont::SIZE_FOOTNOTE);
|
msgFont.setSize(LyXFont::SIZE_FOOTNOTE);
|
||||||
paint.text(old_x + TEXT_TO_INSET_OFFSET + 6,
|
pi.pain.text(x + TEXT_TO_INSET_OFFSET + 6,
|
||||||
baseline - font_metrics::maxAscent(msgFont) - 4,
|
y - font_metrics::maxAscent(msgFont) - 4,
|
||||||
justname, msgFont);
|
justname, msgFont);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -396,7 +391,7 @@ void InsetGraphics::draw(BufferView * bv, LyXFont const & font,
|
|||||||
string const msg = statusMessage();
|
string const msg = statusMessage();
|
||||||
if (!msg.empty()) {
|
if (!msg.empty()) {
|
||||||
msgFont.setSize(LyXFont::SIZE_TINY);
|
msgFont.setSize(LyXFont::SIZE_TINY);
|
||||||
paint.text(old_x + TEXT_TO_INSET_OFFSET + 6, baseline - 4, msg, msgFont);
|
pi.pain.text(x + TEXT_TO_INSET_OFFSET + 6, y - 4, msg, msgFont);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -36,7 +36,7 @@ public:
|
|||||||
///
|
///
|
||||||
void dimension(BufferView *, LyXFont const &, Dimension &) const;
|
void dimension(BufferView *, LyXFont const &, Dimension &) const;
|
||||||
///
|
///
|
||||||
void draw(BufferView *, LyXFont const &, int, float &) const;
|
void draw(PainterInfo & pi, int x, int y) const;
|
||||||
///
|
///
|
||||||
EDITABLE editable() const;
|
EDITABLE editable() const;
|
||||||
///
|
///
|
||||||
|
@ -22,7 +22,8 @@
|
|||||||
#include "Lsstream.h"
|
#include "Lsstream.h"
|
||||||
#include "lyxlex.h"
|
#include "lyxlex.h"
|
||||||
#include "lyxrc.h"
|
#include "lyxrc.h"
|
||||||
#include "Lsstream.h"
|
#include "metricsinfo.h"
|
||||||
|
#include "dimension.h"
|
||||||
|
|
||||||
#include "frontends/Dialogs.h"
|
#include "frontends/Dialogs.h"
|
||||||
#include "frontends/LyXView.h"
|
#include "frontends/LyXView.h"
|
||||||
@ -532,28 +533,22 @@ int InsetInclude::width(BufferView * bv, LyXFont const & font) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void InsetInclude::draw(BufferView * bv, LyXFont const & font, int y,
|
void InsetInclude::draw(PainterInfo & pi, int x, int y) const
|
||||||
float & xx) const
|
|
||||||
{
|
{
|
||||||
cache(bv);
|
cache(pi.base.bv);
|
||||||
if (!preview_->previewReady()) {
|
if (!preview_->previewReady()) {
|
||||||
InsetButton::draw(bv, font, y, xx);
|
InsetButton::draw(pi, x, y);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!preview_->monitoring())
|
if (!preview_->monitoring())
|
||||||
preview_->startMonitoring();
|
preview_->startMonitoring();
|
||||||
|
|
||||||
int const x = int(xx);
|
Dimension dim;
|
||||||
int const w = width(bv, font);
|
dimension(pi.base.bv, pi.base.font, dim);
|
||||||
int const d = descent(bv, font);
|
|
||||||
int const a = ascent(bv, font);
|
|
||||||
int const h = a + d;
|
|
||||||
|
|
||||||
bv->painter().image(x, y - a, w, h,
|
pi.pain.image(x, y - dim.asc, dim.wid, dim.height(),
|
||||||
*(preview_->pimage()->image()));
|
*(preview_->pimage()->image()));
|
||||||
|
|
||||||
xx += w;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -66,7 +66,7 @@ public:
|
|||||||
///
|
///
|
||||||
int width(BufferView *, LyXFont const &) const;
|
int width(BufferView *, LyXFont const &) const;
|
||||||
///
|
///
|
||||||
void draw(BufferView *, LyXFont const &, int, float &) const;
|
void draw(PainterInfo & pi, int x, int y) const;
|
||||||
|
|
||||||
/// get the parameters
|
/// get the parameters
|
||||||
Params const & params(void) const;
|
Params const & params(void) const;
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
#include "frontends/font_metrics.h"
|
#include "frontends/font_metrics.h"
|
||||||
#include "language.h"
|
#include "language.h"
|
||||||
#include "lyxlex.h"
|
#include "lyxlex.h"
|
||||||
|
#include "metricsinfo.h"
|
||||||
|
|
||||||
using std::ostream;
|
using std::ostream;
|
||||||
using std::endl;
|
using std::endl;
|
||||||
@ -306,9 +307,7 @@ int InsetLatexAccent::rbearing(LyXFont const & font) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool InsetLatexAccent::displayISO8859_9(BufferView * bv, LyXFont const & font,
|
bool InsetLatexAccent::displayISO8859_9(PainterInfo & pi, int x, int y) const
|
||||||
int baseline,
|
|
||||||
float & x) const
|
|
||||||
{
|
{
|
||||||
unsigned char tmpic = ic;
|
unsigned char tmpic = ic;
|
||||||
|
|
||||||
@ -339,9 +338,7 @@ bool InsetLatexAccent::displayISO8859_9(BufferView * bv, LyXFont const & font,
|
|||||||
default: return false;
|
default: return false;
|
||||||
}
|
}
|
||||||
if (tmpic != ic) {
|
if (tmpic != ic) {
|
||||||
char ch = char(tmpic);
|
pi.pain.text(x, y, char(tmpic), pi.base.font);
|
||||||
bv->painter().text(int(x), baseline, ch, font);
|
|
||||||
x += width(bv, font);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -349,13 +346,10 @@ bool InsetLatexAccent::displayISO8859_9(BufferView * bv, LyXFont const & font,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void InsetLatexAccent::draw(BufferView * bv, LyXFont const & font0,
|
void InsetLatexAccent::draw(PainterInfo & pi, int x, int baseline) const
|
||||||
int baseline, float & x) const
|
|
||||||
{
|
{
|
||||||
Painter & pain = bv->painter();
|
|
||||||
|
|
||||||
if (lyxrc.font_norm_type == LyXRC::ISO_8859_9)
|
if (lyxrc.font_norm_type == LyXRC::ISO_8859_9)
|
||||||
if (displayISO8859_9(bv, font0, baseline, x))
|
if (displayISO8859_9(pi, x, baseline))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* draw it! */
|
/* draw it! */
|
||||||
@ -363,27 +357,28 @@ void InsetLatexAccent::draw(BufferView * bv, LyXFont const & font0,
|
|||||||
// overhaul. Different ways of drawing (what metrics to use)
|
// overhaul. Different ways of drawing (what metrics to use)
|
||||||
// should also be considered.
|
// should also be considered.
|
||||||
|
|
||||||
LyXFont font(font0);
|
BufferView * bv = pi.base.bv;
|
||||||
|
LyXFont font = pi.base.font;
|
||||||
if (lyxrc.font_norm_type == LyXRC::ISO_10646_1)
|
if (lyxrc.font_norm_type == LyXRC::ISO_10646_1)
|
||||||
font.setLanguage(english_language);
|
font.setLanguage(english_language);
|
||||||
|
|
||||||
|
Dimension dim;
|
||||||
|
dimension(bv, font, dim);
|
||||||
|
|
||||||
if (candisp) {
|
if (candisp) {
|
||||||
int asc = ascent(bv, font);
|
|
||||||
int desc = descent(bv, font);
|
|
||||||
int wid = width(bv, font);
|
|
||||||
float x2 = x + (rbearing(font) - lbearing(font)) / 2.0;
|
float x2 = x + (rbearing(font) - lbearing(font)) / 2.0;
|
||||||
float hg;
|
float hg;
|
||||||
int y;
|
int y;
|
||||||
if (plusasc) {
|
if (plusasc) {
|
||||||
// mark at the top
|
// mark at the top
|
||||||
hg = font_metrics::maxDescent(font);
|
hg = font_metrics::maxDescent(font);
|
||||||
y = baseline - asc;
|
y = baseline - dim.asc;
|
||||||
|
|
||||||
if (font.shape() == LyXFont::ITALIC_SHAPE)
|
if (font.shape() == LyXFont::ITALIC_SHAPE)
|
||||||
x2 += (4.0 * hg) / 5.0; // italic
|
x2 += (4.0 * hg) / 5.0; // italic
|
||||||
} else {
|
} else {
|
||||||
// at the bottom
|
// at the bottom
|
||||||
hg = desc;
|
hg = dim.des;
|
||||||
y = baseline;
|
y = baseline;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -391,18 +386,18 @@ void InsetLatexAccent::draw(BufferView * bv, LyXFont const & font0,
|
|||||||
|
|
||||||
// display with proper accent mark
|
// display with proper accent mark
|
||||||
// first the letter
|
// first the letter
|
||||||
pain.text(int(x), baseline, ic, font);
|
pi.pain.text(x, baseline, ic, font);
|
||||||
|
|
||||||
if (remdot) {
|
if (remdot) {
|
||||||
int tmpvar = baseline - font_metrics::ascent('i', font);
|
int tmpvar = baseline - font_metrics::ascent('i', font);
|
||||||
float tmpx = 0;
|
int tmpx = 0;
|
||||||
if (font.shape() == LyXFont::ITALIC_SHAPE)
|
if (font.shape() == LyXFont::ITALIC_SHAPE)
|
||||||
tmpx += (8.0 * hg) / 10.0; // italic
|
tmpx += int(0.8 * hg); // italic
|
||||||
lyxerr[Debug::KEY] << "Removing dot." << endl;
|
lyxerr[Debug::KEY] << "Removing dot." << endl;
|
||||||
// remove the dot first
|
// remove the dot first
|
||||||
pain.fillRectangle(int(x + tmpx), tmpvar, wid,
|
pi.pain.fillRectangle(x + tmpx, tmpvar, dim.wid,
|
||||||
font_metrics::ascent('i', font) -
|
font_metrics::ascent('i', pi.base.font) -
|
||||||
font_metrics::ascent('x', font) - 1,
|
font_metrics::ascent('x', pi.base.font) - 1,
|
||||||
backgroundColor());
|
backgroundColor());
|
||||||
// the five lines below is a simple hack to
|
// the five lines below is a simple hack to
|
||||||
// make the display of accent 'i' and 'j'
|
// make the display of accent 'i' and 'j'
|
||||||
@ -410,7 +405,7 @@ void InsetLatexAccent::draw(BufferView * bv, LyXFont const & font0,
|
|||||||
// closer to the top of the dot-less 'i' or 'j'.
|
// closer to the top of the dot-less 'i' or 'j'.
|
||||||
char tmpic = ic; // store the ic when we
|
char tmpic = ic; // store the ic when we
|
||||||
ic = 'x'; // calculates the ascent of
|
ic = 'x'; // calculates the ascent of
|
||||||
asc = ascent(bv, font); // the dot-less version (here: 'x')
|
int asc = ascent(bv, font); // the dot-less version (here: 'x')
|
||||||
ic = tmpic; // set the orig ic back
|
ic = tmpic; // set the orig ic back
|
||||||
y = baseline - asc; // update to new y coord.
|
y = baseline - asc; // update to new y coord.
|
||||||
}
|
}
|
||||||
@ -418,48 +413,52 @@ void InsetLatexAccent::draw(BufferView * bv, LyXFont const & font0,
|
|||||||
switch (modtype) {
|
switch (modtype) {
|
||||||
case ACUTE: // acute 0xB4
|
case ACUTE: // acute 0xB4
|
||||||
{
|
{
|
||||||
pain.text(int(x2 - (font_metrics::rbearing(0xB4, font) - font_metrics::lbearing(0xB4, font)) / 2),
|
pi.pain.text(int(x2 - (font_metrics::rbearing(0xB4, font)
|
||||||
baseline - font_metrics::ascent(ic, font) - font_metrics::descent(0xB4, font) - (font_metrics::ascent(0xB4, font) + font_metrics::descent(0xB4, font)) / 2,
|
- font_metrics::lbearing(0xB4, font)) / 2),
|
||||||
|
baseline - font_metrics::ascent(ic, font)
|
||||||
|
- font_metrics::descent(0xB4, font)
|
||||||
|
- (font_metrics::ascent(0xB4, font)
|
||||||
|
+ font_metrics::descent(0xB4, font)) / 2,
|
||||||
char(0xB4), font);
|
char(0xB4), font);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case GRAVE: // grave 0x60
|
case GRAVE: // grave 0x60
|
||||||
{
|
{
|
||||||
pain.text(int(x2 - (font_metrics::rbearing(0x60, font) - font_metrics::lbearing(0x60, font)) / 2),
|
pi.pain.text(int(x2 - (font_metrics::rbearing(0x60, font) - font_metrics::lbearing(0x60, font)) / 2),
|
||||||
int(baseline - font_metrics::ascent(ic, font) - font_metrics::descent(0x60, font) - (font_metrics::ascent(0x60, font) + font_metrics::descent(0x60, font)) / 2.0),
|
int(baseline - font_metrics::ascent(ic, font) - font_metrics::descent(0x60, font) - (font_metrics::ascent(0x60, font) + font_metrics::descent(0x60, font)) / 2.0),
|
||||||
char(0x60), font);
|
char(0x60), font);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case MACRON: // macron
|
case MACRON: // macron
|
||||||
{
|
{
|
||||||
pain.text(int(x2 - (font_metrics::rbearing(0xAF, font) - font_metrics::lbearing(0xAF, font)) / 2),
|
pi.pain.text(int(x2 - (font_metrics::rbearing(0xAF, font) - font_metrics::lbearing(0xAF, font)) / 2),
|
||||||
baseline - font_metrics::ascent(ic, font) - font_metrics::descent(0xAF, font) - (font_metrics::ascent(0xAF, font) + font_metrics::descent(0xAF, font)),
|
baseline - font_metrics::ascent(ic, font) - font_metrics::descent(0xAF, font) - (font_metrics::ascent(0xAF, font) + font_metrics::descent(0xAF, font)),
|
||||||
char(0xAF), font);
|
char(0xAF), font);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TILDE: // tilde
|
case TILDE: // tilde
|
||||||
{
|
{
|
||||||
pain.text(int(x2 - (font_metrics::rbearing('~', font) - font_metrics::lbearing('~', font)) / 2),
|
pi.pain.text(int(x2 - (font_metrics::rbearing('~', font) - font_metrics::lbearing('~', font)) / 2),
|
||||||
baseline - font_metrics::ascent(ic, font) - font_metrics::descent('~', font) - (font_metrics::ascent('~', font) + font_metrics::descent('~', font)) / 2,
|
baseline - font_metrics::ascent(ic, font) - font_metrics::descent('~', font) - (font_metrics::ascent('~', font) + font_metrics::descent('~', font)) / 2,
|
||||||
'~', font);
|
'~', font);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case UNDERBAR: // underbar 0x5F
|
case UNDERBAR: // underbar 0x5F
|
||||||
{
|
{
|
||||||
pain.text(int(x2 - (font_metrics::rbearing(0x5F, font) - font_metrics::lbearing(0x5F, font)) / 2), baseline,
|
pi.pain.text(int(x2 - (font_metrics::rbearing(0x5F, font) - font_metrics::lbearing(0x5F, font)) / 2), baseline,
|
||||||
char(0x5F), font);
|
char(0x5F), font);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case CEDILLA: // cedilla
|
case CEDILLA: // cedilla
|
||||||
{
|
{
|
||||||
pain.text(int(x2 - (font_metrics::rbearing(0xB8, font) - font_metrics::lbearing(0xB8, font)) / 2), baseline,
|
pi.pain.text(int(x2 - (font_metrics::rbearing(0xB8, font) - font_metrics::lbearing(0xB8, font)) / 2), baseline,
|
||||||
char(0xB8), font);
|
char(0xB8), font);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case UNDERDOT: // underdot
|
case UNDERDOT: // underdot
|
||||||
{
|
{
|
||||||
pain.text(int(x2 - (font_metrics::rbearing('.', font) - font_metrics::lbearing('.', font)) / 2.0),
|
pi.pain.text(int(x2 - (font_metrics::rbearing('.', font) - font_metrics::lbearing('.', font)) / 2.0),
|
||||||
int(baseline + 3.0 / 2.0 * (font_metrics::ascent('.', font) + font_metrics::descent('.', font))),
|
int(baseline + 3.0 / 2.0 * (font_metrics::ascent('.', font) + font_metrics::descent('.', font))),
|
||||||
'.', font);
|
'.', font);
|
||||||
break;
|
break;
|
||||||
@ -467,7 +466,7 @@ void InsetLatexAccent::draw(BufferView * bv, LyXFont const & font0,
|
|||||||
|
|
||||||
case DOT: // dot
|
case DOT: // dot
|
||||||
{
|
{
|
||||||
pain.text(int(x2 - (font_metrics::rbearing('.', font) - font_metrics::lbearing('.', font)) / 2.0),
|
pi.pain.text(int(x2 - (font_metrics::rbearing('.', font) - font_metrics::lbearing('.', font)) / 2.0),
|
||||||
baseline - font_metrics::ascent(ic, font) - font_metrics::descent('.', font) - (font_metrics::ascent('.', font) + font_metrics::descent('.', font)) / 2,
|
baseline - font_metrics::ascent(ic, font) - font_metrics::descent('.', font) - (font_metrics::ascent('.', font) + font_metrics::descent('.', font)) / 2,
|
||||||
'.', font);
|
'.', font);
|
||||||
break;
|
break;
|
||||||
@ -477,20 +476,20 @@ void InsetLatexAccent::draw(BufferView * bv, LyXFont const & font0,
|
|||||||
{
|
{
|
||||||
LyXFont tmpf(font);
|
LyXFont tmpf(font);
|
||||||
tmpf.decSize().decSize();
|
tmpf.decSize().decSize();
|
||||||
pain.text(int(x2 - (font_metrics::rbearing(0xB0, tmpf) - font_metrics::lbearing(0xB0, tmpf)) / 2.0),
|
pi.pain.text(int(x2 - (font_metrics::rbearing(0xB0, tmpf) - font_metrics::lbearing(0xB0, tmpf)) / 2.0),
|
||||||
int(baseline - font_metrics::ascent(ic, font) - font_metrics::descent(0xB0, tmpf) - (font_metrics::ascent(0xB0, tmpf) + font_metrics::descent(0xB0, tmpf)) / 3.0),
|
int(baseline - font_metrics::ascent(ic, font) - font_metrics::descent(0xB0, tmpf) - (font_metrics::ascent(0xB0, tmpf) + font_metrics::descent(0xB0, tmpf)) / 3.0),
|
||||||
char(0xB0), tmpf);
|
char(0xB0), tmpf);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TIE: // tie
|
case TIE: // tie
|
||||||
{
|
{
|
||||||
pain.arc(int(x2 + hg35), int(y + hg / 2.0),
|
pi.pain.arc(int(x2 + hg35), int(y + hg / 2.0),
|
||||||
int(2 * hg), int(hg), 0, 360 * 32);
|
int(2 * hg), int(hg), 0, 360 * 32);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case BREVE: // breve
|
case BREVE: // breve
|
||||||
{
|
{
|
||||||
pain.arc(int(x2 - (hg / 2.0)), y,
|
pi.pain.arc(int(x2 - (hg / 2.0)), y,
|
||||||
int(hg), int(hg), 0, -360*32);
|
int(hg), int(hg), 0, -360*32);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -501,41 +500,41 @@ void InsetLatexAccent::draw(BufferView * bv, LyXFont const & font0,
|
|||||||
xp[0] = int(x2 - hg35); yp[0] = int(y + hg35);
|
xp[0] = int(x2 - hg35); yp[0] = int(y + hg35);
|
||||||
xp[1] = int(x2); yp[1] = int(y + hg);
|
xp[1] = int(x2); yp[1] = int(y + hg);
|
||||||
xp[2] = int(x2 + hg35); yp[2] = int(y + hg35);
|
xp[2] = int(x2 + hg35); yp[2] = int(y + hg35);
|
||||||
pain.lines(xp, yp, 3);
|
pi.pain.lines(xp, yp, 3);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SPECIAL_CARON: // special caron
|
case SPECIAL_CARON: // special caron
|
||||||
{
|
{
|
||||||
switch (ic) {
|
switch (ic) {
|
||||||
case 'L': wid = int(4.0 * wid / 5.0); break;
|
case 'L': dim.wid = int(4.0 * dim.wid / 5.0); break;
|
||||||
case 't': y -= int(hg35 / 2.0); break;
|
case 't': y -= int(hg35 / 2.0); break;
|
||||||
}
|
}
|
||||||
int xp[3], yp[3];
|
int xp[3], yp[3];
|
||||||
xp[0] = int(x + wid);
|
xp[0] = int(x + dim.wid);
|
||||||
yp[0] = int(y + hg35 + hg);
|
yp[0] = int(y + hg35 + hg);
|
||||||
|
|
||||||
xp[1] = int(x + wid + (hg35 / 2.0));
|
xp[1] = int(x + dim.wid + (hg35 / 2.0));
|
||||||
yp[1] = int(y + hg + (hg35 / 2.0));
|
yp[1] = int(y + hg + (hg35 / 2.0));
|
||||||
|
|
||||||
xp[2] = int(x + wid + (hg35 / 2.0));
|
xp[2] = int(x + dim.wid + (hg35 / 2.0));
|
||||||
yp[2] = y + int(hg);
|
yp[2] = y + int(hg);
|
||||||
|
|
||||||
pain.lines(xp, yp, 3);
|
pi.pain.lines(xp, yp, 3);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case HUNGARIAN_UMLAUT: // hung. umlaut
|
case HUNGARIAN_UMLAUT: // hung. umlaut
|
||||||
{
|
{
|
||||||
pain.text(int(x2 - (font_metrics::rbearing('´', font) - font_metrics::lbearing('´', font))),
|
pi.pain.text(int(x2 - (font_metrics::rbearing('´', font) - font_metrics::lbearing('´', font))),
|
||||||
baseline - font_metrics::ascent(ic, font) - font_metrics::descent('´', font) - (font_metrics::ascent('´', font) + font_metrics::descent('´', font)) / 2,
|
baseline - font_metrics::ascent(ic, font) - font_metrics::descent('´', font) - (font_metrics::ascent('´', font) + font_metrics::descent('´', font)) / 2,
|
||||||
'´', font);
|
'´', font);
|
||||||
pain.text(int(x2),
|
pi.pain.text(int(x2),
|
||||||
baseline - font_metrics::ascent(ic, font) - font_metrics::descent('´', font) - (font_metrics::ascent('´', font) + font_metrics::descent('´', font)) / 2,
|
baseline - font_metrics::ascent(ic, font) - font_metrics::descent('´', font) - (font_metrics::ascent('´', font) + font_metrics::descent('´', font)) / 2,
|
||||||
'´', font);
|
'´', font);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case UMLAUT: // umlaut
|
case UMLAUT: // umlaut
|
||||||
{
|
{
|
||||||
pain.text(int(x2 - (font_metrics::rbearing('¨', font) - font_metrics::lbearing('¨', font)) / 2),
|
pi.pain.text(int(x2 - (font_metrics::rbearing('¨', font) - font_metrics::lbearing('¨', font)) / 2),
|
||||||
baseline - font_metrics::ascent(ic, font) - font_metrics::descent('¨', font) - (font_metrics::ascent('¨', font) + font_metrics::descent('¨', font)) / 2,
|
baseline - font_metrics::ascent(ic, font) - font_metrics::descent('¨', font) - (font_metrics::ascent('¨', font) + font_metrics::descent('¨', font)) / 2,
|
||||||
'¨', font);
|
'¨', font);
|
||||||
break;
|
break;
|
||||||
@ -544,7 +543,7 @@ void InsetLatexAccent::draw(BufferView * bv, LyXFont const & font0,
|
|||||||
{
|
{
|
||||||
LyXFont tmpf(font);
|
LyXFont tmpf(font);
|
||||||
tmpf.decSize().decSize().decSize();
|
tmpf.decSize().decSize().decSize();
|
||||||
pain.text(int(x2 - (font_metrics::rbearing(0x5E, tmpf) - font_metrics::lbearing(0x5E, tmpf)) / 2),
|
pi.pain.text(int(x2 - (font_metrics::rbearing(0x5E, tmpf) - font_metrics::lbearing(0x5E, tmpf)) / 2),
|
||||||
int(baseline - font_metrics::ascent(ic, font) - font_metrics::descent(0x5E, tmpf) - (font_metrics::ascent(0x5E, tmpf) + font_metrics::descent(0x5E, tmpf)) / 3.0),
|
int(baseline - font_metrics::ascent(ic, font) - font_metrics::descent(0x5E, tmpf) - (font_metrics::ascent(0x5E, tmpf) + font_metrics::descent(0x5E, tmpf)) / 3.0),
|
||||||
char(0x5E), tmpf);
|
char(0x5E), tmpf);
|
||||||
break;
|
break;
|
||||||
@ -567,7 +566,7 @@ void InsetLatexAccent::draw(BufferView * bv, LyXFont const & font0,
|
|||||||
xp[3] = int(x2 + hg / 4.0);
|
xp[3] = int(x2 + hg / 4.0);
|
||||||
yp[3] = y + int(hg);
|
yp[3] = y + int(hg);
|
||||||
|
|
||||||
pain.lines(xp, yp, 4);
|
pi.pain.lines(xp, yp, 4);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case lSLASH:
|
case lSLASH:
|
||||||
@ -578,10 +577,10 @@ void InsetLatexAccent::draw(BufferView * bv, LyXFont const & font0,
|
|||||||
xp[0] = int(x);
|
xp[0] = int(x);
|
||||||
yp[0] = y + int(3.0 * hg);
|
yp[0] = y + int(3.0 * hg);
|
||||||
|
|
||||||
xp[1] = int(x + float(wid) * 0.75);
|
xp[1] = int(x + float(dim.wid) * 0.75);
|
||||||
yp[1] = y + int(hg);
|
yp[1] = y + int(hg);
|
||||||
|
|
||||||
pain.lines(xp, yp, 2);
|
pi.pain.lines(xp, yp, 2);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case DOT_LESS_I: // dotless-i
|
case DOT_LESS_I: // dotless-i
|
||||||
@ -592,18 +591,13 @@ void InsetLatexAccent::draw(BufferView * bv, LyXFont const & font0,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
pain.fillRectangle(int(x + 1),
|
pi.pain.fillRectangle(x + 1,
|
||||||
baseline - ascent(bv, font) + 1,
|
baseline - dim.asc + 1, dim.wid - 2,
|
||||||
width(bv, font) - 2,
|
dim.asc + dim.des - 2, backgroundColor());
|
||||||
ascent(bv, font)
|
pi.pain.rectangle(x + 1, baseline - dim.asc + 1,
|
||||||
+ descent(bv, font) - 2,
|
dim.wid - 2, dim.asc + dim.des - 2);
|
||||||
backgroundColor());
|
pi.pain.text(x + 2, baseline, contents, font);
|
||||||
pain.rectangle(int(x + 1), baseline - ascent(bv, font) + 1,
|
|
||||||
width(bv, font) - 2,
|
|
||||||
ascent(bv, font) + descent(bv, font) - 2);
|
|
||||||
pain.text(int(x + 2), baseline, contents, font);
|
|
||||||
}
|
}
|
||||||
x += width(bv, font);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -36,14 +36,13 @@ public:
|
|||||||
///
|
///
|
||||||
void dimension(BufferView *, LyXFont const &, Dimension &) const;
|
void dimension(BufferView *, LyXFont const &, Dimension &) const;
|
||||||
///
|
///
|
||||||
void draw(BufferView *, LyXFont const &, int, float &) const;
|
void draw(PainterInfo & pi, int x, int y) const;
|
||||||
///
|
///
|
||||||
int lbearing(LyXFont const & font) const;
|
int lbearing(LyXFont const & font) const;
|
||||||
///
|
///
|
||||||
int rbearing(LyXFont const & font) const;
|
int rbearing(LyXFont const & font) const;
|
||||||
///
|
///
|
||||||
bool displayISO8859_9(BufferView *, LyXFont const & font,
|
bool displayISO8859_9(PainterInfo & pi, int x, int y) const;
|
||||||
int baseline, float & x) const;
|
|
||||||
///
|
///
|
||||||
void write(Buffer const *, std::ostream &) const;
|
void write(Buffer const *, std::ostream &) const;
|
||||||
///
|
///
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
#include "dimension.h"
|
#include "dimension.h"
|
||||||
#include "paragraph.h"
|
#include "paragraph.h"
|
||||||
#include "lyxtext.h"
|
#include "lyxtext.h"
|
||||||
|
#include "metricsinfo.h"
|
||||||
#include "support/LOstream.h"
|
#include "support/LOstream.h"
|
||||||
#include "frontends/Painter.h"
|
#include "frontends/Painter.h"
|
||||||
#include "frontends/font_metrics.h"
|
#include "frontends/font_metrics.h"
|
||||||
@ -75,18 +76,14 @@ int InsetNewline::docbook(Buffer const *, std::ostream &, bool) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void InsetNewline::draw(BufferView * bv, LyXFont const & font,
|
void InsetNewline::draw(PainterInfo & pi, int x, int y) const
|
||||||
int baseline, float & x) const
|
|
||||||
{
|
{
|
||||||
Painter & pain(bv->painter());
|
int const wid = font_metrics::width('n', pi.base.font);
|
||||||
|
int const asc = font_metrics::maxAscent(pi.base.font);
|
||||||
int const wid = font_metrics::width('n', font);
|
|
||||||
int const asc = font_metrics::maxAscent(font);
|
|
||||||
int const y = baseline;
|
|
||||||
|
|
||||||
// hack, and highly dubious
|
// hack, and highly dubious
|
||||||
lyx::pos_type pos = parOwner()->getPositionOfInset(this);
|
lyx::pos_type pos = parOwner()->getPositionOfInset(this);
|
||||||
bool const ltr_pos = (bv->text->bidi_level(pos) % 2 == 0);
|
bool const ltr_pos = (pi.base.bv->text->bidi_level(pos) % 2 == 0);
|
||||||
|
|
||||||
int xp[3];
|
int xp[3];
|
||||||
int yp[3];
|
int yp[3];
|
||||||
@ -105,7 +102,7 @@ void InsetNewline::draw(BufferView * bv, LyXFont const & font,
|
|||||||
xp[2] = int(x + wid * 0.625);
|
xp[2] = int(x + wid * 0.625);
|
||||||
}
|
}
|
||||||
|
|
||||||
pain.lines(xp, yp, 3, LColor::eolmarker);
|
pi.pain.lines(xp, yp, 3, LColor::eolmarker);
|
||||||
|
|
||||||
yp[0] = int(y - 0.500 * asc * 0.75);
|
yp[0] = int(y - 0.500 * asc * 0.75);
|
||||||
yp[1] = int(y - 0.500 * asc * 0.75);
|
yp[1] = int(y - 0.500 * asc * 0.75);
|
||||||
@ -121,7 +118,5 @@ void InsetNewline::draw(BufferView * bv, LyXFont const & font,
|
|||||||
xp[2] = int(x);
|
xp[2] = int(x);
|
||||||
}
|
}
|
||||||
|
|
||||||
pain.lines(xp, yp, 3, LColor::eolmarker);
|
pi.pain.lines(xp, yp, 3, LColor::eolmarker);
|
||||||
|
|
||||||
x += wid;
|
|
||||||
}
|
}
|
||||||
|
@ -28,8 +28,7 @@ public:
|
|||||||
|
|
||||||
void dimension(BufferView *, LyXFont const &, Dimension &) const;
|
void dimension(BufferView *, LyXFont const &, Dimension &) const;
|
||||||
|
|
||||||
virtual void draw(BufferView *, LyXFont const &,
|
virtual void draw(PainterInfo & pi, int x, int y) const;
|
||||||
int baseline, float & x) const;
|
|
||||||
|
|
||||||
virtual int latex(Buffer const *, std::ostream &,
|
virtual int latex(Buffer const *, std::ostream &,
|
||||||
LatexRunParams const &) const;
|
LatexRunParams const &) const;
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
#include "lyxlex.h"
|
#include "lyxlex.h"
|
||||||
#include "lyxrc.h"
|
#include "lyxrc.h"
|
||||||
#include "paragraph.h"
|
#include "paragraph.h"
|
||||||
|
#include "metricsinfo.h"
|
||||||
#include "frontends/font_metrics.h"
|
#include "frontends/font_metrics.h"
|
||||||
#include "frontends/Painter.h"
|
#include "frontends/Painter.h"
|
||||||
#include "support/LAssert.h"
|
#include "support/LAssert.h"
|
||||||
@ -202,18 +203,17 @@ LyXFont const InsetQuotes::convertFont(LyXFont const & f) const
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
void InsetQuotes::draw(BufferView * bv, LyXFont const & font,
|
void InsetQuotes::draw(PainterInfo & pi, int x, int y) const
|
||||||
int baseline, float & x) const
|
|
||||||
{
|
{
|
||||||
string const text = dispString(font.language());
|
string const text = dispString(pi.base.font.language());
|
||||||
|
|
||||||
if (text.length() == 2 && text[0] == text[1]) {
|
if (text.length() == 2 && text[0] == text[1]) {
|
||||||
bv->painter().text(int(x), baseline, text[0], font);
|
pi.pain.text(x, y, text[0], pi.base.font);
|
||||||
int x2 = int(x + font_metrics::width(',', font));
|
int const t = font_metrics::width(',', pi.base.font);
|
||||||
bv->painter().text(x2, baseline, text[0], font);
|
pi.pain.text(x + t, y, text[0], pi.base.font);
|
||||||
} else
|
} else {
|
||||||
bv->painter().text(int(x), baseline, text, font);
|
pi.pain.text(x, y, text, pi.base.font);
|
||||||
x += width(bv, font);
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -72,7 +72,7 @@ public:
|
|||||||
///
|
///
|
||||||
void dimension(BufferView *, LyXFont const &, Dimension &) const;
|
void dimension(BufferView *, LyXFont const &, Dimension &) const;
|
||||||
///
|
///
|
||||||
void draw(BufferView *, LyXFont const &, int, float &) const;
|
void draw(PainterInfo & pi, int x, int y) const;
|
||||||
#if 0
|
#if 0
|
||||||
///
|
///
|
||||||
LyXFont const convertFont(LyXFont const & font) const;
|
LyXFont const convertFont(LyXFont const & font) const;
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
#include "frontends/font_metrics.h"
|
#include "frontends/font_metrics.h"
|
||||||
#include "lyxlex.h"
|
#include "lyxlex.h"
|
||||||
#include "lyxfont.h"
|
#include "lyxfont.h"
|
||||||
|
#include "metricsinfo.h"
|
||||||
|
|
||||||
using std::ostream;
|
using std::ostream;
|
||||||
using std::max;
|
using std::max;
|
||||||
@ -73,31 +74,28 @@ void InsetSpace::dimension(BufferView *, LyXFont const & font,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void InsetSpace::draw(BufferView * bv, LyXFont const & f,
|
void InsetSpace::draw(PainterInfo & pi, int x, int y) const
|
||||||
int baseline, float & x) const
|
|
||||||
{
|
{
|
||||||
Painter & pain = bv->painter();
|
int const w = width(pi.base.bv, pi.base.font);
|
||||||
LyXFont font(f);
|
int const h = font_metrics::ascent('x', pi.base.font);
|
||||||
|
|
||||||
float w = width(bv, font);
|
|
||||||
int h = font_metrics::ascent('x', font);
|
|
||||||
int xp[4], yp[4];
|
int xp[4], yp[4];
|
||||||
|
|
||||||
xp[0] = int(x); yp[0] = baseline - max(h / 4, 1);
|
xp[0] = x;
|
||||||
|
yp[0] = y - max(h / 4, 1);
|
||||||
if (kind_ == NORMAL) {
|
if (kind_ == NORMAL) {
|
||||||
xp[1] = int(x); yp[1] = baseline;
|
xp[1] = x; yp[1] = y;
|
||||||
xp[2] = int(x + w); yp[2] = baseline;
|
xp[2] = x + w; yp[2] = y;
|
||||||
} else {
|
} else {
|
||||||
xp[1] = int(x); yp[1] = baseline + max(h / 4, 1);
|
xp[1] = x; yp[1] = y + max(h / 4, 1);
|
||||||
xp[2] = int(x + w); yp[2] = baseline + max(h / 4, 1);
|
xp[2] = x + w; yp[2] = y + max(h / 4, 1);
|
||||||
}
|
}
|
||||||
xp[3] = int(x + w); yp[3] = baseline - max(h / 4, 1);
|
xp[3] = x + w;
|
||||||
|
yp[3] = y - max(h / 4, 1);
|
||||||
|
|
||||||
if (kind_ == PROTECTED || kind_ == ENSPACE || kind_ == NEGTHIN)
|
if (kind_ == PROTECTED || kind_ == ENSPACE || kind_ == NEGTHIN)
|
||||||
pain.lines(xp, yp, 4, LColor::latex);
|
pi.pain.lines(xp, yp, 4, LColor::latex);
|
||||||
else
|
else
|
||||||
pain.lines(xp, yp, 4, LColor::special);
|
pi.pain.lines(xp, yp, 4, LColor::special);
|
||||||
x += w;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -56,7 +56,7 @@ public:
|
|||||||
///
|
///
|
||||||
void dimension(BufferView *, LyXFont const &, Dimension &) const;
|
void dimension(BufferView *, LyXFont const &, Dimension &) const;
|
||||||
///
|
///
|
||||||
void draw(BufferView *, LyXFont const &, int, float &) const;
|
void draw(PainterInfo & pi, int x, int y) const;
|
||||||
///
|
///
|
||||||
void write(Buffer const *, std::ostream &) const;
|
void write(Buffer const *, std::ostream &) const;
|
||||||
/// Will not be used when lyxf3
|
/// Will not be used when lyxf3
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
#include "frontends/font_metrics.h"
|
#include "frontends/font_metrics.h"
|
||||||
#include "lyxlex.h"
|
#include "lyxlex.h"
|
||||||
#include "lyxfont.h"
|
#include "lyxfont.h"
|
||||||
|
#include "metricsinfo.h"
|
||||||
|
|
||||||
using std::ostream;
|
using std::ostream;
|
||||||
using std::max;
|
using std::max;
|
||||||
@ -58,56 +59,49 @@ void InsetSpecialChar::dimension(BufferView *, LyXFont const & font,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void InsetSpecialChar::draw(BufferView * bv, LyXFont const & f,
|
void InsetSpecialChar::draw(PainterInfo & pi, int x, int y) const
|
||||||
int baseline, float & x) const
|
|
||||||
{
|
{
|
||||||
Painter & pain = bv->painter();
|
LyXFont font = pi.base.font;
|
||||||
LyXFont font(f);
|
|
||||||
|
|
||||||
switch (kind_) {
|
switch (kind_) {
|
||||||
case HYPHENATION:
|
case HYPHENATION:
|
||||||
{
|
{
|
||||||
font.setColor(LColor::special);
|
font.setColor(LColor::special);
|
||||||
pain.text(int(x), baseline, '-', font);
|
pi.pain.text(x, y, '-', font);
|
||||||
x += width(bv, font);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case LIGATURE_BREAK:
|
case LIGATURE_BREAK:
|
||||||
{
|
{
|
||||||
font.setColor(LColor::special);
|
font.setColor(LColor::special);
|
||||||
pain.text(int(x), baseline, '|', font);
|
pi.pain.text(x, y, '|', font);
|
||||||
x += width(bv, font);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case END_OF_SENTENCE:
|
case END_OF_SENTENCE:
|
||||||
{
|
{
|
||||||
font.setColor(LColor::special);
|
font.setColor(LColor::special);
|
||||||
pain.text(int(x), baseline, '.', font);
|
pi.pain.text(x, y, '.', font);
|
||||||
x += width(bv, font);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case LDOTS:
|
case LDOTS:
|
||||||
{
|
{
|
||||||
font.setColor(LColor::special);
|
font.setColor(LColor::special);
|
||||||
pain.text(int(x), baseline, ". . .", font);
|
pi.pain.text(x, y, ". . .", font);
|
||||||
x += width(bv, font);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case MENU_SEPARATOR:
|
case MENU_SEPARATOR:
|
||||||
{
|
{
|
||||||
// A triangle the width and height of an 'x'
|
// A triangle the width and height of an 'x'
|
||||||
int w = font_metrics::width('x', font);
|
int w = font_metrics::width('x', font);
|
||||||
int ox = font_metrics::width(' ', font) + int(x);
|
int ox = font_metrics::width(' ', font) + x;
|
||||||
int h = font_metrics::ascent('x', font);
|
int h = font_metrics::ascent('x', font);
|
||||||
int xp[4], yp[4];
|
int xp[4], yp[4];
|
||||||
|
|
||||||
xp[0] = ox; yp[0] = baseline;
|
xp[0] = ox; yp[0] = y;
|
||||||
xp[1] = ox; yp[1] = baseline - h;
|
xp[1] = ox; yp[1] = y - h;
|
||||||
xp[2] = ox + w; yp[2] = baseline - h/2;
|
xp[2] = ox + w; yp[2] = y - h/2;
|
||||||
xp[3] = ox; yp[3] = baseline;
|
xp[3] = ox; yp[3] = y;
|
||||||
|
|
||||||
pain.lines(xp, yp, 4, LColor::special);
|
pi.pain.lines(xp, yp, 4, LColor::special);
|
||||||
x += width(bv, font);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -48,7 +48,7 @@ public:
|
|||||||
///
|
///
|
||||||
void dimension(BufferView *, LyXFont const &, Dimension &) const;
|
void dimension(BufferView *, LyXFont const &, Dimension &) const;
|
||||||
///
|
///
|
||||||
void draw(BufferView *, LyXFont const &, int, float &) const;
|
void draw(PainterInfo & pi, int x, int y) const;
|
||||||
///
|
///
|
||||||
void write(Buffer const *, std::ostream &) const;
|
void write(Buffer const *, std::ostream &) const;
|
||||||
/// Will not be used when lyxf3
|
/// Will not be used when lyxf3
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
#include "ParagraphParameters.h"
|
#include "ParagraphParameters.h"
|
||||||
#include "undo_funcs.h"
|
#include "undo_funcs.h"
|
||||||
#include "WordLangTuple.h"
|
#include "WordLangTuple.h"
|
||||||
#include "Lsstream.h"
|
#include "metricsinfo.h"
|
||||||
|
|
||||||
#include "frontends/Alert.h"
|
#include "frontends/Alert.h"
|
||||||
#include "frontends/Dialogs.h"
|
#include "frontends/Dialogs.h"
|
||||||
@ -252,40 +252,39 @@ void InsetTabular::dimension(BufferView *, LyXFont const &,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void InsetTabular::draw(BufferView * bv, LyXFont const & font, int baseline,
|
void InsetTabular::draw(PainterInfo & pi, int x, int y) const
|
||||||
float & x) const
|
|
||||||
{
|
{
|
||||||
if (nodraw()) {
|
if (nodraw()) {
|
||||||
need_update = FULL;
|
need_update = FULL;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Painter & pain = bv->painter();
|
BufferView * bv = pi.base.bv;
|
||||||
int i;
|
int i;
|
||||||
int j;
|
int j;
|
||||||
int nx;
|
int nx;
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
UpdatableInset::draw(bv, font, baseline, x);
|
UpdatableInset::draw(pi, x, y);
|
||||||
#else
|
#else
|
||||||
if (!owner())
|
if (!owner())
|
||||||
x += static_cast<float>(scroll());
|
x += scroll();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
top_x = int(x);
|
top_x = x;
|
||||||
top_baseline = baseline;
|
top_baseline = y;
|
||||||
x += ADD_TO_TABULAR_WIDTH;
|
x += ADD_TO_TABULAR_WIDTH;
|
||||||
|
|
||||||
int cell = 0;
|
int cell = 0;
|
||||||
float cx;
|
int cx;
|
||||||
first_visible_cell = -1;
|
first_visible_cell = -1;
|
||||||
for (i = 0; i < tabular->rows(); ++i) {
|
for (i = 0; i < tabular->rows(); ++i) {
|
||||||
nx = int(x);
|
nx = x;
|
||||||
cell = tabular->GetCellNumber(i, 0);
|
cell = tabular->GetCellNumber(i, 0);
|
||||||
if (!((baseline + tabular->GetDescentOfRow(i)) > 0) &&
|
if (!((y + tabular->GetDescentOfRow(i)) > 0) &&
|
||||||
(baseline - tabular->GetAscentOfRow(i))<pain.paperHeight())
|
(y - tabular->GetAscentOfRow(i)) < pi.pain.paperHeight())
|
||||||
{
|
{
|
||||||
baseline += tabular->GetDescentOfRow(i) +
|
y += tabular->GetDescentOfRow(i) +
|
||||||
tabular->GetAscentOfRow(i + 1) +
|
tabular->GetAscentOfRow(i + 1) +
|
||||||
tabular->GetAdditionalHeight(i + 1);
|
tabular->GetAdditionalHeight(i + 1);
|
||||||
continue;
|
continue;
|
||||||
@ -299,32 +298,30 @@ void InsetTabular::draw(BufferView * bv, LyXFont const & font, int baseline,
|
|||||||
if (first_visible_cell < 0)
|
if (first_visible_cell < 0)
|
||||||
first_visible_cell = cell;
|
first_visible_cell = cell;
|
||||||
if (hasSelection()) {
|
if (hasSelection()) {
|
||||||
drawCellSelection(pain, nx, baseline, i, j, cell);
|
drawCellSelection(pi.pain, nx, y, i, j, cell);
|
||||||
}
|
}
|
||||||
|
|
||||||
tabular->GetCellInset(cell)->draw(bv, font, baseline, cx);
|
tabular->GetCellInset(cell)->draw(pi, cx, y);
|
||||||
drawCellLines(pain, nx, baseline, i, cell);
|
drawCellLines(pi.pain, nx, y, i, cell);
|
||||||
nx += tabular->GetWidthOfColumn(cell);
|
nx += tabular->GetWidthOfColumn(cell);
|
||||||
++cell;
|
++cell;
|
||||||
}
|
}
|
||||||
|
|
||||||
// avoiding drawing the rest of a long table is
|
// avoiding drawing the rest of a long table is
|
||||||
// a pretty big speedup
|
// a pretty big speedup
|
||||||
if (baseline > bv->workHeight())
|
if (y > bv->workHeight())
|
||||||
break;
|
break;
|
||||||
|
|
||||||
baseline += tabular->GetDescentOfRow(i) +
|
y += tabular->GetDescentOfRow(i) +
|
||||||
tabular->GetAscentOfRow(i + 1) +
|
tabular->GetAscentOfRow(i + 1) +
|
||||||
tabular->GetAdditionalHeight(i + 1);
|
tabular->GetAdditionalHeight(i + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
x -= ADD_TO_TABULAR_WIDTH;
|
|
||||||
x += width(bv, font);
|
|
||||||
need_update = NONE;
|
need_update = NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void InsetTabular::drawCellLines(Painter & pain, int x, int baseline,
|
void InsetTabular::drawCellLines(Painter & pain, int x, int y,
|
||||||
int row, int cell) const
|
int row, int cell) const
|
||||||
{
|
{
|
||||||
int x2 = x + tabular->GetWidthOfColumn(cell);
|
int x2 = x + tabular->GetWidthOfColumn(cell);
|
||||||
@ -332,34 +329,34 @@ void InsetTabular::drawCellLines(Painter & pain, int x, int baseline,
|
|||||||
|
|
||||||
if (!tabular->topAlreadyDrawn(cell)) {
|
if (!tabular->topAlreadyDrawn(cell)) {
|
||||||
on_off = !tabular->TopLine(cell);
|
on_off = !tabular->TopLine(cell);
|
||||||
pain.line(x, baseline - tabular->GetAscentOfRow(row),
|
pain.line(x, y - tabular->GetAscentOfRow(row),
|
||||||
x2, baseline - tabular->GetAscentOfRow(row),
|
x2, y - tabular->GetAscentOfRow(row),
|
||||||
on_off ? LColor::tabularonoffline : LColor::tabularline,
|
on_off ? LColor::tabularonoffline : LColor::tabularline,
|
||||||
on_off ? Painter::line_onoffdash : Painter::line_solid);
|
on_off ? Painter::line_onoffdash : Painter::line_solid);
|
||||||
}
|
}
|
||||||
on_off = !tabular->BottomLine(cell);
|
on_off = !tabular->BottomLine(cell);
|
||||||
pain.line(x, baseline + tabular->GetDescentOfRow(row),
|
pain.line(x, y + tabular->GetDescentOfRow(row),
|
||||||
x2, baseline + tabular->GetDescentOfRow(row),
|
x2, y + tabular->GetDescentOfRow(row),
|
||||||
on_off ? LColor::tabularonoffline : LColor::tabularline,
|
on_off ? LColor::tabularonoffline : LColor::tabularline,
|
||||||
on_off ? Painter::line_onoffdash : Painter::line_solid);
|
on_off ? Painter::line_onoffdash : Painter::line_solid);
|
||||||
if (!tabular->leftAlreadyDrawn(cell)) {
|
if (!tabular->leftAlreadyDrawn(cell)) {
|
||||||
on_off = !tabular->LeftLine(cell);
|
on_off = !tabular->LeftLine(cell);
|
||||||
pain.line(x, baseline - tabular->GetAscentOfRow(row),
|
pain.line(x, y - tabular->GetAscentOfRow(row),
|
||||||
x, baseline + tabular->GetDescentOfRow(row),
|
x, y + tabular->GetDescentOfRow(row),
|
||||||
on_off ? LColor::tabularonoffline : LColor::tabularline,
|
on_off ? LColor::tabularonoffline : LColor::tabularline,
|
||||||
on_off ? Painter::line_onoffdash : Painter::line_solid);
|
on_off ? Painter::line_onoffdash : Painter::line_solid);
|
||||||
}
|
}
|
||||||
on_off = !tabular->RightLine(cell);
|
on_off = !tabular->RightLine(cell);
|
||||||
pain.line(x2 - tabular->GetAdditionalWidth(cell),
|
pain.line(x2 - tabular->GetAdditionalWidth(cell),
|
||||||
baseline - tabular->GetAscentOfRow(row),
|
y - tabular->GetAscentOfRow(row),
|
||||||
x2 - tabular->GetAdditionalWidth(cell),
|
x2 - tabular->GetAdditionalWidth(cell),
|
||||||
baseline + tabular->GetDescentOfRow(row),
|
y + tabular->GetDescentOfRow(row),
|
||||||
on_off ? LColor::tabularonoffline : LColor::tabularline,
|
on_off ? LColor::tabularonoffline : LColor::tabularline,
|
||||||
on_off ? Painter::line_onoffdash : Painter::line_solid);
|
on_off ? Painter::line_onoffdash : Painter::line_solid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void InsetTabular::drawCellSelection(Painter & pain, int x, int baseline,
|
void InsetTabular::drawCellSelection(Painter & pain, int x, int y,
|
||||||
int row, int column, int cell) const
|
int row, int column, int cell) const
|
||||||
{
|
{
|
||||||
lyx::Assert(hasSelection());
|
lyx::Assert(hasSelection());
|
||||||
@ -380,7 +377,7 @@ void InsetTabular::drawCellSelection(Painter & pain, int x, int baseline,
|
|||||||
if ((column >= cs) && (column <= ce) && (row >= rs) && (row <= re)) {
|
if ((column >= cs) && (column <= ce) && (row >= rs) && (row <= re)) {
|
||||||
int w = tabular->GetWidthOfColumn(cell);
|
int w = tabular->GetWidthOfColumn(cell);
|
||||||
int h = tabular->GetAscentOfRow(row) + tabular->GetDescentOfRow(row)-1;
|
int h = tabular->GetAscentOfRow(row) + tabular->GetDescentOfRow(row)-1;
|
||||||
pain.fillRectangle(x, baseline - tabular->GetAscentOfRow(row) + 1,
|
pain.fillRectangle(x, y - tabular->GetAscentOfRow(row) + 1,
|
||||||
w, h, LColor::selection);
|
w, h, LColor::selection);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -88,7 +88,7 @@ public:
|
|||||||
///
|
///
|
||||||
void dimension(BufferView *, LyXFont const &, Dimension &) const;
|
void dimension(BufferView *, LyXFont const &, Dimension &) const;
|
||||||
///
|
///
|
||||||
void draw(BufferView *, const LyXFont &, int , float &) const;
|
void draw(PainterInfo & pi, int x, int y) const;
|
||||||
///
|
///
|
||||||
void update(BufferView *, bool = false);
|
void update(BufferView *, bool = false);
|
||||||
///
|
///
|
||||||
|
@ -39,7 +39,7 @@
|
|||||||
#include "sgml.h"
|
#include "sgml.h"
|
||||||
#include "rowpainter.h"
|
#include "rowpainter.h"
|
||||||
#include "insetnewline.h"
|
#include "insetnewline.h"
|
||||||
#include "Lsstream.h"
|
#include "metricsinfo.h"
|
||||||
|
|
||||||
#include "frontends/Alert.h"
|
#include "frontends/Alert.h"
|
||||||
#include "frontends/Dialogs.h"
|
#include "frontends/Dialogs.h"
|
||||||
@ -321,38 +321,37 @@ int InsetText::textWidth(BufferView * bv, bool fordraw) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void InsetText::draw(BufferView * bv, LyXFont const & f,
|
void InsetText::draw(PainterInfo & pi, int x, int baseline) const
|
||||||
int baseline, float & x) const
|
|
||||||
{
|
{
|
||||||
if (nodraw())
|
if (nodraw())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// update our idea of where we are. Clearly, we should
|
// update our idea of where we are. Clearly, we should
|
||||||
// not have to know this information.
|
// not have to know this information.
|
||||||
if (top_x != int(x))
|
if (top_x != x)
|
||||||
top_x = int(x);
|
top_x = x;
|
||||||
|
|
||||||
int const start_x = int(x);
|
int const start_x = x;
|
||||||
|
|
||||||
Painter & pain = bv->painter();
|
BufferView * bv = pi.base.bv;
|
||||||
|
Painter & pain = pi.pain;
|
||||||
|
|
||||||
// call this method so that dim_ has the right value
|
// call this method so that dim_ has the right value
|
||||||
dimension(bv, f, dim_);
|
dimension(bv, pi.base.font, dim_);
|
||||||
|
|
||||||
// repaint the background if needed
|
// repaint the background if needed
|
||||||
if (backgroundColor() != LColor::background)
|
if (backgroundColor() != LColor::background)
|
||||||
clearInset(bv, start_x + TEXT_TO_INSET_OFFSET, baseline);
|
clearInset(bv, start_x + TEXT_TO_INSET_OFFSET, baseline);
|
||||||
|
|
||||||
// no draw is necessary !!!
|
// no draw is necessary !!!
|
||||||
if ((drawFrame_ == LOCKED) && !locked && paragraphs.begin()->empty()) {
|
if (drawFrame_ == LOCKED && !locked && paragraphs.begin()->empty()) {
|
||||||
top_baseline = baseline;
|
top_baseline = baseline;
|
||||||
x += width(bv, f);
|
|
||||||
need_update = NONE;
|
need_update = NONE;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!owner())
|
if (!owner())
|
||||||
x += static_cast<float>(scroll());
|
x += scroll();
|
||||||
|
|
||||||
top_baseline = baseline;
|
top_baseline = baseline;
|
||||||
top_y = baseline - dim_.asc;
|
top_y = baseline - dim_.asc;
|
||||||
|
@ -91,7 +91,7 @@ public:
|
|||||||
///
|
///
|
||||||
int textWidth(BufferView *, bool fordraw = false) const;
|
int textWidth(BufferView *, bool fordraw = false) const;
|
||||||
///
|
///
|
||||||
void draw(BufferView *, LyXFont const &, int , float &) const;
|
void draw(PainterInfo & pi, int x, int y) const;
|
||||||
///
|
///
|
||||||
void update(BufferView *, bool = false);
|
void update(BufferView *, bool = false);
|
||||||
///
|
///
|
||||||
|
@ -52,13 +52,11 @@ void UpdatableInset::fitInsetCursor(BufferView *) const
|
|||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
void UpdatableInset::draw(BufferView *, LyXFont const &,
|
void UpdatableInset::draw(PainterInfo &, int, int) const
|
||||||
int /* baseline */, float & x) const
|
|
||||||
{
|
{
|
||||||
x += float(scx);
|
|
||||||
// ATTENTION: don't do the following here!!!
|
// ATTENTION: don't do the following here!!!
|
||||||
// top_x = int(x);
|
// top_x = x;
|
||||||
// top_baseline = baseline;
|
// top_baseline = y;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -66,8 +66,7 @@ public:
|
|||||||
///
|
///
|
||||||
virtual void insetUnlock(BufferView *);
|
virtual void insetUnlock(BufferView *);
|
||||||
///
|
///
|
||||||
virtual void draw(BufferView *, LyXFont const &,
|
virtual void draw(PainterInfo & pi, int x, int y) const;
|
||||||
int baseline, float & x) const;
|
|
||||||
///
|
///
|
||||||
virtual bool insertInset(BufferView *, Inset *) { return false; }
|
virtual bool insertInset(BufferView *, Inset *) { return false; }
|
||||||
///
|
///
|
||||||
|
@ -212,44 +212,42 @@ void InsetFormula::read(Buffer const *, LyXLex & lex)
|
|||||||
//}
|
//}
|
||||||
|
|
||||||
|
|
||||||
void InsetFormula::draw(BufferView * bv, LyXFont const & font,
|
void InsetFormula::draw(PainterInfo & pi, int x, int y) const
|
||||||
int y, float & xx) const
|
|
||||||
{
|
{
|
||||||
cache(bv);
|
cache(pi.base.bv);
|
||||||
// This initiates the loading of the preview, so should come
|
// This initiates the loading of the preview, so should come
|
||||||
// before the metrics are computed.
|
// before the metrics are computed.
|
||||||
bool const use_preview = preview_->previewReady();
|
bool const use_preview = preview_->previewReady();
|
||||||
|
|
||||||
int const x = int(xx);
|
Dimension dim;
|
||||||
int const w = width(bv, font);
|
dimension(pi.base.bv, pi.base.font, dim);
|
||||||
int const d = descent(bv, font);
|
int const w = dim.wid;
|
||||||
int const a = ascent(bv, font);
|
int const d = dim.des;
|
||||||
|
int const a = dim.asc;
|
||||||
int const h = a + d;
|
int const h = a + d;
|
||||||
|
|
||||||
PainterInfo pi(bv);
|
|
||||||
|
|
||||||
if (use_preview) {
|
if (use_preview) {
|
||||||
pi.pain.image(x + 1, y - a, w, h, // one pixel gap in front
|
pi.pain.image(x + 1, y - a, w, h, // one pixel gap in front
|
||||||
*(preview_->pimage()->image()));
|
*(preview_->pimage()->image()));
|
||||||
} else {
|
} else {
|
||||||
pi.base.style = LM_ST_TEXT;
|
PainterInfo p(pi.base.bv);
|
||||||
pi.base.font = font;
|
p.base.style = LM_ST_TEXT;
|
||||||
pi.base.font.setColor(LColor::math);
|
p.base.font = pi.base.font;
|
||||||
|
p.base.font.setColor(LColor::math);
|
||||||
if (lcolor.getX11Name(LColor::mathbg)
|
if (lcolor.getX11Name(LColor::mathbg)
|
||||||
!= lcolor.getX11Name(LColor::background))
|
!= lcolor.getX11Name(LColor::background))
|
||||||
pi.pain.fillRectangle(x, y - a, w, h, LColor::mathbg);
|
p.pain.fillRectangle(x, y - a, w, h, LColor::mathbg);
|
||||||
|
|
||||||
if (mathcursor &&
|
if (mathcursor &&
|
||||||
const_cast<InsetFormulaBase const *>(mathcursor->formula()) == this)
|
const_cast<InsetFormulaBase const *>(mathcursor->formula()) == this)
|
||||||
{
|
{
|
||||||
mathcursor->drawSelection(pi);
|
mathcursor->drawSelection(pi);
|
||||||
//pi.pain.rectangle(x, y - a, w, h, LColor::mathframe);
|
//p.pain.rectangle(x, y - a, w, h, LColor::mathframe);
|
||||||
}
|
}
|
||||||
|
|
||||||
par_->draw(pi, x, y);
|
par_->draw(p, x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
xx += w;
|
|
||||||
xo_ = x;
|
xo_ = x;
|
||||||
yo_ = y;
|
yo_ = y;
|
||||||
}
|
}
|
||||||
|
@ -37,7 +37,7 @@ public:
|
|||||||
///
|
///
|
||||||
void dimension(BufferView *, LyXFont const &, Dimension &) const;
|
void dimension(BufferView *, LyXFont const &, Dimension &) const;
|
||||||
///
|
///
|
||||||
void draw(BufferView *, LyXFont const &, int, float &) const;
|
void draw(PainterInfo & pi, int x, int y) const;
|
||||||
|
|
||||||
///
|
///
|
||||||
void write(Buffer const *, std::ostream &) const;
|
void write(Buffer const *, std::ostream &) const;
|
||||||
|
@ -31,8 +31,6 @@ public:
|
|||||||
InsetFormulaBase();
|
InsetFormulaBase();
|
||||||
///
|
///
|
||||||
Inset * clone(Buffer const &) const = 0;
|
Inset * clone(Buffer const &) const = 0;
|
||||||
///
|
|
||||||
virtual void draw(BufferView *,LyXFont const &, int, float &) const = 0;
|
|
||||||
/// lowest x coordinate
|
/// lowest x coordinate
|
||||||
virtual int xlow() const;
|
virtual int xlow() const;
|
||||||
/// highest x coordinate
|
/// highest x coordinate
|
||||||
|
@ -171,20 +171,18 @@ Inset::Code InsetFormulaMacro::lyxCode() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void InsetFormulaMacro::draw(BufferView * bv, LyXFont const & f,
|
void InsetFormulaMacro::draw(PainterInfo & p, int x, int y) const
|
||||||
int y, float & xx) const
|
|
||||||
{
|
{
|
||||||
// label
|
// label
|
||||||
LyXFont font(f);
|
LyXFont font = p.base.font;
|
||||||
font.setColor(LColor::math);
|
font.setColor(LColor::math);
|
||||||
|
|
||||||
PainterInfo pi(bv);
|
PainterInfo pi(p.base.bv);
|
||||||
pi.base.style = LM_ST_TEXT;
|
pi.base.style = LM_ST_TEXT;
|
||||||
pi.base.font = font;
|
pi.base.font = font;
|
||||||
|
|
||||||
Dimension dim;
|
Dimension dim;
|
||||||
dimension(bv, font, dim);
|
dimension(pi.base.bv, font, dim);
|
||||||
int const x = int(xx);
|
|
||||||
int const a = y - dim.asc + 1;
|
int const a = y - dim.asc + 1;
|
||||||
int const w = dim.wid - 2;
|
int const w = dim.wid - 2;
|
||||||
int const h = dim.height() - 2;
|
int const h = dim.height() - 2;
|
||||||
@ -200,8 +198,7 @@ void InsetFormulaMacro::draw(BufferView * bv, LyXFont const & f,
|
|||||||
pi.pain.text(x + 2, y, prefix(), font);
|
pi.pain.text(x + 2, y, prefix(), font);
|
||||||
|
|
||||||
// formula
|
// formula
|
||||||
par()->draw(pi, x + font_metrics::width(prefix(), f) + 5, y);
|
par()->draw(pi, x + font_metrics::width(prefix(), p.base.font) + 5, y);
|
||||||
xx += w + 2;
|
|
||||||
xo_ = x;
|
xo_ = x;
|
||||||
yo_ = y;
|
yo_ = y;
|
||||||
}
|
}
|
||||||
|
@ -35,7 +35,7 @@ public:
|
|||||||
///
|
///
|
||||||
void dimension(BufferView *, LyXFont const &, Dimension &) const;
|
void dimension(BufferView *, LyXFont const &, Dimension &) const;
|
||||||
///
|
///
|
||||||
void draw(BufferView *, LyXFont const &, int, float &) const;
|
void draw(PainterInfo & pi, int x, int y) const;
|
||||||
|
|
||||||
///
|
///
|
||||||
void read(Buffer const *, LyXLex & lex);
|
void read(Buffer const *, LyXLex & lex);
|
||||||
|
@ -33,6 +33,7 @@
|
|||||||
#include "rowpainter.h"
|
#include "rowpainter.h"
|
||||||
#include "lyxrc.h"
|
#include "lyxrc.h"
|
||||||
#include "lyxrow_funcs.h"
|
#include "lyxrow_funcs.h"
|
||||||
|
#include "metricsinfo.h"
|
||||||
|
|
||||||
using std::max;
|
using std::max;
|
||||||
using lyx::pos_type;
|
using lyx::pos_type;
|
||||||
@ -103,12 +104,14 @@ void RowPainter::paintInset(pos_type const pos)
|
|||||||
|
|
||||||
lyx::Assert(inset);
|
lyx::Assert(inset);
|
||||||
|
|
||||||
LyXFont const & font = getFont(pos);
|
|
||||||
|
|
||||||
#warning inset->update FIXME
|
#warning inset->update FIXME
|
||||||
inset->update(perv(bv_), false);
|
inset->update(perv(bv_), false);
|
||||||
|
|
||||||
inset->draw(perv(bv_), font, yo_ + row_->baseline(), x_);
|
PainterInfo pi(perv(bv_));
|
||||||
|
pi.base.font = getFont(pos);
|
||||||
|
int const w = inset->width(perv(bv_), pi.base.font);
|
||||||
|
inset->draw(pi, int(x_), yo_ + row_->baseline());
|
||||||
|
x_ += w;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user