mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-25 10:58:52 +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>
|
||||
|
||||
* 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>
|
||||
|
||||
* insetgraphics.C: fix a bformat
|
||||
|
@ -167,8 +167,6 @@ public:
|
||||
int descent(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
|
||||
virtual void update(BufferView *, bool = false)
|
||||
{}
|
||||
|
@ -16,6 +16,8 @@
|
||||
|
||||
class BufferView;
|
||||
class FuncRequest;
|
||||
class MetricsInfo;
|
||||
class PainterInfo;
|
||||
|
||||
/** Dispatch result codes
|
||||
DISPATCHED = the inset catched the action
|
||||
@ -62,6 +64,8 @@ public:
|
||||
|
||||
/// small wrapper for the time being
|
||||
virtual dispatch_result localDispatch(FuncRequest const & cmd);
|
||||
///
|
||||
virtual void draw(PainterInfo & pi, int x, int y) const = 0;
|
||||
|
||||
///
|
||||
virtual ~InsetBase() {}
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include "frontends/Painter.h"
|
||||
#include "support/LAssert.h"
|
||||
#include "lyxfont.h"
|
||||
#include "metricsinfo.h"
|
||||
#include "frontends/font_metrics.h"
|
||||
|
||||
using std::ostream;
|
||||
@ -46,27 +47,23 @@ void InsetButton::dimension(BufferView * bv, LyXFont const &,
|
||||
}
|
||||
|
||||
|
||||
void InsetButton::draw(BufferView * bv, LyXFont const &,
|
||||
int baseline, float & x) const
|
||||
void InsetButton::draw(PainterInfo & pi, int x, int y) const
|
||||
{
|
||||
lyx::Assert(bv);
|
||||
cache(bv);
|
||||
lyx::Assert(pi.base.bv);
|
||||
cache(pi.base.bv);
|
||||
|
||||
Painter & pain = bv->painter();
|
||||
// Draw it as a box with the LaTeX text
|
||||
LyXFont font(LyXFont::ALL_SANE);
|
||||
font.setColor(LColor::command).decSize();
|
||||
|
||||
string const s = getScreenLabel(bv->buffer());
|
||||
string const s = getScreenLabel(pi.base.bv->buffer());
|
||||
|
||||
if (editable()) {
|
||||
pain.buttonText(int(x) + 2, baseline, s, font);
|
||||
pi.pain.buttonText(x + 2, y, s, font);
|
||||
} else {
|
||||
pain.rectText(int(x) + 2, baseline, s, font,
|
||||
pi.pain.rectText(x + 2, y, s, font,
|
||||
LColor::commandbg, LColor::commandframe);
|
||||
}
|
||||
|
||||
x += width(bv, font);
|
||||
}
|
||||
|
||||
|
||||
|
@ -25,7 +25,7 @@ public:
|
||||
///
|
||||
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);
|
||||
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include "debug.h"
|
||||
#include "gettext.h"
|
||||
#include "Lsstream.h"
|
||||
#include "metricsinfo.h"
|
||||
#include "support/lstrings.h"
|
||||
#include "support/LAssert.h"
|
||||
#include "support/BoostFormat.h"
|
||||
@ -66,8 +67,7 @@ string const InsetCaption::editMessage() const
|
||||
}
|
||||
|
||||
|
||||
void InsetCaption::draw(BufferView * bv, LyXFont const & f,
|
||||
int baseline, float & x) const
|
||||
void InsetCaption::draw(PainterInfo & pi, int x, int y) const
|
||||
{
|
||||
// We must draw the label, we should get the label string
|
||||
// from the enclosing float inset.
|
||||
@ -88,7 +88,7 @@ void InsetCaption::draw(BufferView * bv, LyXFont const & f,
|
||||
lyx::Assert(0);
|
||||
|
||||
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");
|
||||
|
||||
// Discover the number...
|
||||
@ -96,12 +96,9 @@ void InsetCaption::draw(BufferView * bv, LyXFont const & f,
|
||||
|
||||
// Generate the label
|
||||
string const label = bformat("%1$s %2$s:", _(fl), num);
|
||||
Painter & pain = bv->painter();
|
||||
int const w = font_metrics::width(label, f);
|
||||
pain.text(int(x), baseline, label, f);
|
||||
x += w;
|
||||
|
||||
InsetText::draw(bv, f, baseline, x);
|
||||
int const w = font_metrics::width(label, pi.base.font);
|
||||
pi.pain.text(x, y, label, pi.base.font);
|
||||
InsetText::draw(pi, x + w, y);
|
||||
}
|
||||
|
||||
|
||||
|
@ -34,8 +34,7 @@ public:
|
||||
///
|
||||
virtual string const editMessage() const;
|
||||
///
|
||||
virtual void draw(BufferView * bv, LyXFont const & f,
|
||||
int baseline, float & x) const;
|
||||
virtual void draw(PainterInfo & pi, int x, int y) const;
|
||||
///
|
||||
virtual int latex(Buffer const * buf, std::ostream & os,
|
||||
LatexRunParams const &) const;
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include "WordLangTuple.h"
|
||||
#include "funcrequest.h"
|
||||
#include "buffer.h"
|
||||
#include "metricsinfo.h"
|
||||
|
||||
#include "frontends/font_metrics.h"
|
||||
#include "frontends/Painter.h"
|
||||
@ -136,22 +137,16 @@ void InsetCollapsable::dimension(BufferView * bv, LyXFont const & font,
|
||||
}
|
||||
|
||||
|
||||
void InsetCollapsable::draw_collapsed(Painter & pain,
|
||||
int baseline, float & x) const
|
||||
void InsetCollapsable::draw_collapsed(PainterInfo & pi, int x, int y) const
|
||||
{
|
||||
pain.buttonText(int(x) + TEXT_TO_INSET_OFFSET,
|
||||
baseline, label, labelfont);
|
||||
Dimension dim;
|
||||
dimension_collapsed(dim);
|
||||
x += dim.wid;
|
||||
pi.pain.buttonText(x + TEXT_TO_INSET_OFFSET, y, label, labelfont);
|
||||
}
|
||||
|
||||
|
||||
void InsetCollapsable::draw(BufferView * bv, LyXFont const & f,
|
||||
int baseline, float & x, bool inlined) const
|
||||
void InsetCollapsable::draw(PainterInfo & pi, int x, int y, bool inlined) const
|
||||
{
|
||||
lyx::Assert(bv);
|
||||
cache(bv);
|
||||
lyx::Assert(pi.base.bv);
|
||||
cache(pi.base.bv);
|
||||
|
||||
if (nodraw())
|
||||
return;
|
||||
@ -159,45 +154,41 @@ void InsetCollapsable::draw(BufferView * bv, LyXFont const & f,
|
||||
Dimension 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_top_y = -ascent(bv, f);
|
||||
button_bottom_y = -ascent(bv, f) + dim_collapsed.height();
|
||||
button_top_y = -aa;
|
||||
button_bottom_y = -aa + dim_collapsed.height();
|
||||
|
||||
if (!isOpen()) {
|
||||
draw_collapsed(pain, baseline, x);
|
||||
draw_collapsed(pi, x, y);
|
||||
return;
|
||||
}
|
||||
|
||||
float old_x = x;
|
||||
int old_x = x;
|
||||
|
||||
if (!owner())
|
||||
x += scroll();
|
||||
|
||||
top_x = int(x);
|
||||
top_baseline = baseline;
|
||||
top_x = x;
|
||||
top_baseline = y;
|
||||
|
||||
int const bl = baseline - ascent(bv, f) + dim_collapsed.ascent();
|
||||
int const bl = y - aa + dim_collapsed.ascent();
|
||||
|
||||
if (inlined) {
|
||||
inset.draw(bv, f, baseline, x);
|
||||
inset.draw(pi, x, y);
|
||||
} else {
|
||||
draw_collapsed(pain, bl, old_x);
|
||||
int const yy = bl + dim_collapsed.descent() + inset.ascent(bv, f);
|
||||
inset.draw(bv, f, yy, x);
|
||||
// contained inset may be shorter than the button
|
||||
if (x < top_x + button_length + TEXT_TO_INSET_OFFSET)
|
||||
x = top_x + button_length + TEXT_TO_INSET_OFFSET;
|
||||
draw_collapsed(pi, old_x, bl);
|
||||
int const yy = bl + dim_collapsed.descent()
|
||||
+ inset.ascent(pi.base.bv, pi.base.font);
|
||||
inset.draw(pi, x, yy);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void InsetCollapsable::draw(BufferView * bv, LyXFont const & f,
|
||||
int baseline, float & x) const
|
||||
void InsetCollapsable::draw(PainterInfo & pi, int x, int y) const
|
||||
{
|
||||
// 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 draw(BufferView *, const LyXFont &, int, float &) const;
|
||||
void draw(PainterInfo & pi, int x, int y) const;
|
||||
/// draw, either inlined (no button) or collapsed/open
|
||||
void draw(BufferView * bv, LyXFont const & f,
|
||||
int baseline, float & x, bool inlined) const;
|
||||
void draw(PainterInfo & pi, int x, int y, bool inlined) const;
|
||||
///
|
||||
void update(BufferView *, bool = false);
|
||||
///
|
||||
@ -181,7 +180,7 @@ protected:
|
||||
///
|
||||
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;
|
||||
|
||||
|
@ -17,6 +17,7 @@
|
||||
#include "funcrequest.h"
|
||||
#include "gettext.h"
|
||||
#include "lyxfont.h"
|
||||
#include "metricsinfo.h"
|
||||
|
||||
#include "frontends/Dialogs.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,
|
||||
int baseline, float & x) const
|
||||
void InsetError::draw(PainterInfo & pi, int x, int y) const
|
||||
{
|
||||
lyx::Assert(bv);
|
||||
cache(bv);
|
||||
lyx::Assert(pi.base.bv);
|
||||
cache(pi.base.bv);
|
||||
|
||||
Painter & pain = bv->painter();
|
||||
LyXFont efont;
|
||||
efont.setSize(font.size()).decSize();
|
||||
efont.setSize(pi.base.font.size()).decSize();
|
||||
efont.setColor(LColor::error);
|
||||
|
||||
// Draw as "Error" in a framed box
|
||||
x += 1;
|
||||
pain.fillRectangle(int(x), baseline - ascent(bv, font) + 1,
|
||||
width(bv, font) - 2,
|
||||
ascent(bv, font) + descent(bv, font) - 2,
|
||||
LColor::insetbg);
|
||||
pain.rectangle(int(x), baseline - ascent(bv, font) + 1,
|
||||
width(bv, font) - 2,
|
||||
ascent(bv, font) + descent(bv, font) - 2,
|
||||
LColor::error);
|
||||
pain.text(int(x + 2), baseline, _("Error"), efont);
|
||||
|
||||
x += width(bv, font) - 1;
|
||||
Dimension dim;
|
||||
dimension(pi.base.bv, pi.base.font, dim);
|
||||
pi.pain.fillRectangle(x, y - dim.asc + 1,
|
||||
dim.wid - 2, dim.asc + dim.des - 2, LColor::insetbg);
|
||||
pi.pain.rectangle(x, y - dim.asc + 1,
|
||||
dim.wid - 2, dim.asc + dim.des - 2, LColor::error);
|
||||
pi.pain.text(x + 2, y, _("Error"), efont);
|
||||
}
|
||||
|
||||
|
||||
|
@ -32,7 +32,7 @@ public:
|
||||
///
|
||||
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 {}
|
||||
///
|
||||
|
@ -562,10 +562,9 @@ void InsetERT::dimension(BufferView * bv, LyXFont const & font,
|
||||
}
|
||||
|
||||
|
||||
void InsetERT::draw(BufferView * bv, LyXFont const & f,
|
||||
int baseline, float & x) const
|
||||
void InsetERT::draw(PainterInfo & pi, int x, int y) 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 draw(BufferView *, const LyXFont &, int , float &) const;
|
||||
void draw(PainterInfo & pi, int x, int y) const;
|
||||
/// set the status of the inset
|
||||
void status(BufferView *, ERTStatus const st) const;
|
||||
///
|
||||
|
@ -73,7 +73,7 @@ TODO
|
||||
#include "Lsstream.h"
|
||||
#include "lyxlex.h"
|
||||
#include "lyxrc.h"
|
||||
#include "Lsstream.h"
|
||||
#include "metricsinfo.h"
|
||||
|
||||
#include "frontends/lyx_gui.h"
|
||||
#include "frontends/Alert.h"
|
||||
@ -324,9 +324,9 @@ BufferView * InsetGraphics::view() const
|
||||
}
|
||||
|
||||
|
||||
void InsetGraphics::draw(BufferView * bv, LyXFont const & font,
|
||||
int baseline, float & x) const
|
||||
void InsetGraphics::draw(PainterInfo & pi, int x, int y) const
|
||||
{
|
||||
BufferView * bv = pi.base.bv;
|
||||
// MakeAbsPath returns params().filename unchanged if it absolute
|
||||
// already.
|
||||
string const file_with_path =
|
||||
@ -342,22 +342,18 @@ void InsetGraphics::draw(BufferView * bv, LyXFont const & font,
|
||||
cache_->view = bv->owner()->view();
|
||||
int oasc = cache_->old_ascent;
|
||||
|
||||
int ldescent = descent(bv, font);
|
||||
int lascent = ascent(bv, font);
|
||||
int lwidth = width(bv, font);
|
||||
Dimension dim;
|
||||
dimension(bv, pi.base.font, dim);
|
||||
|
||||
// we may have changed while someone other was drawing us so better
|
||||
// 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.
|
||||
// But I still don't know the best way to go. So let's do this like this
|
||||
// for now (Jug 20020311)
|
||||
if (lascent != oasc)
|
||||
if (dim.asc != oasc)
|
||||
return;
|
||||
|
||||
// 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();
|
||||
|
||||
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,
|
||||
// we draw just a rectangle.
|
||||
Painter & paint = bv->painter();
|
||||
|
||||
if (imageIsDrawable()) {
|
||||
paint.image(old_x + TEXT_TO_INSET_OFFSET, baseline - lascent,
|
||||
lwidth - 2 * TEXT_TO_INSET_OFFSET, lascent + ldescent,
|
||||
pi.pain.image(x + TEXT_TO_INSET_OFFSET, y - dim.asc,
|
||||
dim.wid - 2 * TEXT_TO_INSET_OFFSET, dim.asc + dim.des,
|
||||
*cache_->loader.image());
|
||||
|
||||
} else {
|
||||
|
||||
paint.rectangle(old_x + TEXT_TO_INSET_OFFSET, baseline - lascent,
|
||||
lwidth - 2 * TEXT_TO_INSET_OFFSET, lascent + ldescent);
|
||||
pi.pain.rectangle(x + TEXT_TO_INSET_OFFSET, y - dim.asc,
|
||||
dim.wid - 2 * TEXT_TO_INSET_OFFSET, dim.asc + dim.des);
|
||||
|
||||
// Print the file name.
|
||||
LyXFont msgFont(font);
|
||||
LyXFont msgFont = pi.base.font;
|
||||
msgFont.setFamily(LyXFont::SANS_FAMILY);
|
||||
string const justname = OnlyFilename (params().filename);
|
||||
if (!justname.empty()) {
|
||||
msgFont.setSize(LyXFont::SIZE_FOOTNOTE);
|
||||
paint.text(old_x + TEXT_TO_INSET_OFFSET + 6,
|
||||
baseline - font_metrics::maxAscent(msgFont) - 4,
|
||||
pi.pain.text(x + TEXT_TO_INSET_OFFSET + 6,
|
||||
y - font_metrics::maxAscent(msgFont) - 4,
|
||||
justname, msgFont);
|
||||
}
|
||||
|
||||
@ -396,7 +391,7 @@ void InsetGraphics::draw(BufferView * bv, LyXFont const & font,
|
||||
string const msg = statusMessage();
|
||||
if (!msg.empty()) {
|
||||
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 draw(BufferView *, LyXFont const &, int, float &) const;
|
||||
void draw(PainterInfo & pi, int x, int y) const;
|
||||
///
|
||||
EDITABLE editable() const;
|
||||
///
|
||||
|
@ -22,7 +22,8 @@
|
||||
#include "Lsstream.h"
|
||||
#include "lyxlex.h"
|
||||
#include "lyxrc.h"
|
||||
#include "Lsstream.h"
|
||||
#include "metricsinfo.h"
|
||||
#include "dimension.h"
|
||||
|
||||
#include "frontends/Dialogs.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,
|
||||
float & xx) const
|
||||
void InsetInclude::draw(PainterInfo & pi, int x, int y) const
|
||||
{
|
||||
cache(bv);
|
||||
cache(pi.base.bv);
|
||||
if (!preview_->previewReady()) {
|
||||
InsetButton::draw(bv, font, y, xx);
|
||||
InsetButton::draw(pi, x, y);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!preview_->monitoring())
|
||||
preview_->startMonitoring();
|
||||
|
||||
int const x = int(xx);
|
||||
int const w = width(bv, font);
|
||||
int const d = descent(bv, font);
|
||||
int const a = ascent(bv, font);
|
||||
int const h = a + d;
|
||||
Dimension dim;
|
||||
dimension(pi.base.bv, pi.base.font, dim);
|
||||
|
||||
bv->painter().image(x, y - a, w, h,
|
||||
pi.pain.image(x, y - dim.asc, dim.wid, dim.height(),
|
||||
*(preview_->pimage()->image()));
|
||||
|
||||
xx += w;
|
||||
}
|
||||
|
||||
|
||||
|
@ -66,7 +66,7 @@ public:
|
||||
///
|
||||
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
|
||||
Params const & params(void) const;
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include "frontends/font_metrics.h"
|
||||
#include "language.h"
|
||||
#include "lyxlex.h"
|
||||
#include "metricsinfo.h"
|
||||
|
||||
using std::ostream;
|
||||
using std::endl;
|
||||
@ -306,9 +307,7 @@ int InsetLatexAccent::rbearing(LyXFont const & font) const
|
||||
}
|
||||
|
||||
|
||||
bool InsetLatexAccent::displayISO8859_9(BufferView * bv, LyXFont const & font,
|
||||
int baseline,
|
||||
float & x) const
|
||||
bool InsetLatexAccent::displayISO8859_9(PainterInfo & pi, int x, int y) const
|
||||
{
|
||||
unsigned char tmpic = ic;
|
||||
|
||||
@ -339,9 +338,7 @@ bool InsetLatexAccent::displayISO8859_9(BufferView * bv, LyXFont const & font,
|
||||
default: return false;
|
||||
}
|
||||
if (tmpic != ic) {
|
||||
char ch = char(tmpic);
|
||||
bv->painter().text(int(x), baseline, ch, font);
|
||||
x += width(bv, font);
|
||||
pi.pain.text(x, y, char(tmpic), pi.base.font);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
@ -349,13 +346,10 @@ bool InsetLatexAccent::displayISO8859_9(BufferView * bv, LyXFont const & font,
|
||||
}
|
||||
|
||||
|
||||
void InsetLatexAccent::draw(BufferView * bv, LyXFont const & font0,
|
||||
int baseline, float & x) const
|
||||
void InsetLatexAccent::draw(PainterInfo & pi, int x, int baseline) const
|
||||
{
|
||||
Painter & pain = bv->painter();
|
||||
|
||||
if (lyxrc.font_norm_type == LyXRC::ISO_8859_9)
|
||||
if (displayISO8859_9(bv, font0, baseline, x))
|
||||
if (displayISO8859_9(pi, x, baseline))
|
||||
return;
|
||||
|
||||
/* draw it! */
|
||||
@ -363,27 +357,28 @@ void InsetLatexAccent::draw(BufferView * bv, LyXFont const & font0,
|
||||
// overhaul. Different ways of drawing (what metrics to use)
|
||||
// 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)
|
||||
font.setLanguage(english_language);
|
||||
|
||||
Dimension dim;
|
||||
dimension(bv, font, dim);
|
||||
|
||||
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 hg;
|
||||
int y;
|
||||
if (plusasc) {
|
||||
// mark at the top
|
||||
hg = font_metrics::maxDescent(font);
|
||||
y = baseline - asc;
|
||||
y = baseline - dim.asc;
|
||||
|
||||
if (font.shape() == LyXFont::ITALIC_SHAPE)
|
||||
x2 += (4.0 * hg) / 5.0; // italic
|
||||
} else {
|
||||
// at the bottom
|
||||
hg = desc;
|
||||
hg = dim.des;
|
||||
y = baseline;
|
||||
}
|
||||
|
||||
@ -391,18 +386,18 @@ void InsetLatexAccent::draw(BufferView * bv, LyXFont const & font0,
|
||||
|
||||
// display with proper accent mark
|
||||
// first the letter
|
||||
pain.text(int(x), baseline, ic, font);
|
||||
pi.pain.text(x, baseline, ic, font);
|
||||
|
||||
if (remdot) {
|
||||
int tmpvar = baseline - font_metrics::ascent('i', font);
|
||||
float tmpx = 0;
|
||||
int tmpx = 0;
|
||||
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;
|
||||
// remove the dot first
|
||||
pain.fillRectangle(int(x + tmpx), tmpvar, wid,
|
||||
font_metrics::ascent('i', font) -
|
||||
font_metrics::ascent('x', font) - 1,
|
||||
pi.pain.fillRectangle(x + tmpx, tmpvar, dim.wid,
|
||||
font_metrics::ascent('i', pi.base.font) -
|
||||
font_metrics::ascent('x', pi.base.font) - 1,
|
||||
backgroundColor());
|
||||
// the five lines below is a simple hack to
|
||||
// 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'.
|
||||
char tmpic = ic; // store the ic when we
|
||||
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
|
||||
y = baseline - asc; // update to new y coord.
|
||||
}
|
||||
@ -418,48 +413,52 @@ void InsetLatexAccent::draw(BufferView * bv, LyXFont const & font0,
|
||||
switch (modtype) {
|
||||
case ACUTE: // acute 0xB4
|
||||
{
|
||||
pain.text(int(x2 - (font_metrics::rbearing(0xB4, font) - 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,
|
||||
pi.pain.text(int(x2 - (font_metrics::rbearing(0xB4, font)
|
||||
- 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);
|
||||
break;
|
||||
}
|
||||
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),
|
||||
char(0x60), font);
|
||||
break;
|
||||
}
|
||||
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)),
|
||||
char(0xAF), font);
|
||||
break;
|
||||
}
|
||||
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,
|
||||
'~', font);
|
||||
break;
|
||||
}
|
||||
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);
|
||||
break;
|
||||
}
|
||||
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);
|
||||
|
||||
break;
|
||||
}
|
||||
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))),
|
||||
'.', font);
|
||||
break;
|
||||
@ -467,7 +466,7 @@ void InsetLatexAccent::draw(BufferView * bv, LyXFont const & font0,
|
||||
|
||||
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,
|
||||
'.', font);
|
||||
break;
|
||||
@ -477,20 +476,20 @@ void InsetLatexAccent::draw(BufferView * bv, LyXFont const & font0,
|
||||
{
|
||||
LyXFont tmpf(font);
|
||||
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),
|
||||
char(0xB0), tmpf);
|
||||
break;
|
||||
}
|
||||
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);
|
||||
break;
|
||||
}
|
||||
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);
|
||||
break;
|
||||
}
|
||||
@ -501,41 +500,41 @@ void InsetLatexAccent::draw(BufferView * bv, LyXFont const & font0,
|
||||
xp[0] = int(x2 - hg35); yp[0] = int(y + hg35);
|
||||
xp[1] = int(x2); yp[1] = int(y + hg);
|
||||
xp[2] = int(x2 + hg35); yp[2] = int(y + hg35);
|
||||
pain.lines(xp, yp, 3);
|
||||
pi.pain.lines(xp, yp, 3);
|
||||
break;
|
||||
}
|
||||
case SPECIAL_CARON: // special caron
|
||||
{
|
||||
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;
|
||||
}
|
||||
int xp[3], yp[3];
|
||||
xp[0] = int(x + wid);
|
||||
xp[0] = int(x + dim.wid);
|
||||
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));
|
||||
|
||||
xp[2] = int(x + wid + (hg35 / 2.0));
|
||||
xp[2] = int(x + dim.wid + (hg35 / 2.0));
|
||||
yp[2] = y + int(hg);
|
||||
|
||||
pain.lines(xp, yp, 3);
|
||||
pi.pain.lines(xp, yp, 3);
|
||||
break;
|
||||
}
|
||||
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,
|
||||
'´', 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,
|
||||
'´', font);
|
||||
break;
|
||||
}
|
||||
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,
|
||||
'¨', font);
|
||||
break;
|
||||
@ -544,7 +543,7 @@ void InsetLatexAccent::draw(BufferView * bv, LyXFont const & font0,
|
||||
{
|
||||
LyXFont tmpf(font);
|
||||
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),
|
||||
char(0x5E), tmpf);
|
||||
break;
|
||||
@ -567,7 +566,7 @@ void InsetLatexAccent::draw(BufferView * bv, LyXFont const & font0,
|
||||
xp[3] = int(x2 + hg / 4.0);
|
||||
yp[3] = y + int(hg);
|
||||
|
||||
pain.lines(xp, yp, 4);
|
||||
pi.pain.lines(xp, yp, 4);
|
||||
break;
|
||||
}
|
||||
case lSLASH:
|
||||
@ -578,10 +577,10 @@ void InsetLatexAccent::draw(BufferView * bv, LyXFont const & font0,
|
||||
xp[0] = int(x);
|
||||
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);
|
||||
|
||||
pain.lines(xp, yp, 2);
|
||||
pi.pain.lines(xp, yp, 2);
|
||||
break;
|
||||
}
|
||||
case DOT_LESS_I: // dotless-i
|
||||
@ -592,18 +591,13 @@ void InsetLatexAccent::draw(BufferView * bv, LyXFont const & font0,
|
||||
}
|
||||
}
|
||||
} else {
|
||||
pain.fillRectangle(int(x + 1),
|
||||
baseline - ascent(bv, font) + 1,
|
||||
width(bv, font) - 2,
|
||||
ascent(bv, font)
|
||||
+ descent(bv, font) - 2,
|
||||
backgroundColor());
|
||||
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);
|
||||
pi.pain.fillRectangle(x + 1,
|
||||
baseline - dim.asc + 1, dim.wid - 2,
|
||||
dim.asc + dim.des - 2, backgroundColor());
|
||||
pi.pain.rectangle(x + 1, baseline - dim.asc + 1,
|
||||
dim.wid - 2, dim.asc + dim.des - 2);
|
||||
pi.pain.text(x + 2, baseline, contents, font);
|
||||
}
|
||||
x += width(bv, font);
|
||||
}
|
||||
|
||||
|
||||
|
@ -36,14 +36,13 @@ public:
|
||||
///
|
||||
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 rbearing(LyXFont const & font) const;
|
||||
///
|
||||
bool displayISO8859_9(BufferView *, LyXFont const & font,
|
||||
int baseline, float & x) const;
|
||||
bool displayISO8859_9(PainterInfo & pi, int x, int y) const;
|
||||
///
|
||||
void write(Buffer const *, std::ostream &) const;
|
||||
///
|
||||
|
@ -17,6 +17,7 @@
|
||||
#include "dimension.h"
|
||||
#include "paragraph.h"
|
||||
#include "lyxtext.h"
|
||||
#include "metricsinfo.h"
|
||||
#include "support/LOstream.h"
|
||||
#include "frontends/Painter.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,
|
||||
int baseline, float & x) const
|
||||
void InsetNewline::draw(PainterInfo & pi, int x, int y) const
|
||||
{
|
||||
Painter & pain(bv->painter());
|
||||
|
||||
int const wid = font_metrics::width('n', font);
|
||||
int const asc = font_metrics::maxAscent(font);
|
||||
int const y = baseline;
|
||||
int const wid = font_metrics::width('n', pi.base.font);
|
||||
int const asc = font_metrics::maxAscent(pi.base.font);
|
||||
|
||||
// hack, and highly dubious
|
||||
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 yp[3];
|
||||
@ -105,7 +102,7 @@ void InsetNewline::draw(BufferView * bv, LyXFont const & font,
|
||||
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[1] = int(y - 0.500 * asc * 0.75);
|
||||
@ -121,7 +118,5 @@ void InsetNewline::draw(BufferView * bv, LyXFont const & font,
|
||||
xp[2] = int(x);
|
||||
}
|
||||
|
||||
pain.lines(xp, yp, 3, LColor::eolmarker);
|
||||
|
||||
x += wid;
|
||||
pi.pain.lines(xp, yp, 3, LColor::eolmarker);
|
||||
}
|
||||
|
@ -28,8 +28,7 @@ public:
|
||||
|
||||
void dimension(BufferView *, LyXFont const &, Dimension &) const;
|
||||
|
||||
virtual void draw(BufferView *, LyXFont const &,
|
||||
int baseline, float & x) const;
|
||||
virtual void draw(PainterInfo & pi, int x, int y) const;
|
||||
|
||||
virtual int latex(Buffer const *, std::ostream &,
|
||||
LatexRunParams const &) const;
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include "lyxlex.h"
|
||||
#include "lyxrc.h"
|
||||
#include "paragraph.h"
|
||||
#include "metricsinfo.h"
|
||||
#include "frontends/font_metrics.h"
|
||||
#include "frontends/Painter.h"
|
||||
#include "support/LAssert.h"
|
||||
@ -202,18 +203,17 @@ LyXFont const InsetQuotes::convertFont(LyXFont const & f) const
|
||||
#endif
|
||||
|
||||
|
||||
void InsetQuotes::draw(BufferView * bv, LyXFont const & font,
|
||||
int baseline, float & x) const
|
||||
void InsetQuotes::draw(PainterInfo & pi, int x, int y) const
|
||||
{
|
||||
string const text = dispString(font.language());
|
||||
string const text = dispString(pi.base.font.language());
|
||||
|
||||
if (text.length() == 2 && text[0] == text[1]) {
|
||||
bv->painter().text(int(x), baseline, text[0], font);
|
||||
int x2 = int(x + font_metrics::width(',', font));
|
||||
bv->painter().text(x2, baseline, text[0], font);
|
||||
} else
|
||||
bv->painter().text(int(x), baseline, text, font);
|
||||
x += width(bv, font);
|
||||
pi.pain.text(x, y, text[0], pi.base.font);
|
||||
int const t = font_metrics::width(',', pi.base.font);
|
||||
pi.pain.text(x + t, y, text[0], pi.base.font);
|
||||
} else {
|
||||
pi.pain.text(x, y, text, pi.base.font);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -72,7 +72,7 @@ public:
|
||||
///
|
||||
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
|
||||
///
|
||||
LyXFont const convertFont(LyXFont const & font) const;
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include "frontends/font_metrics.h"
|
||||
#include "lyxlex.h"
|
||||
#include "lyxfont.h"
|
||||
#include "metricsinfo.h"
|
||||
|
||||
using std::ostream;
|
||||
using std::max;
|
||||
@ -73,31 +74,28 @@ void InsetSpace::dimension(BufferView *, LyXFont const & font,
|
||||
}
|
||||
|
||||
|
||||
void InsetSpace::draw(BufferView * bv, LyXFont const & f,
|
||||
int baseline, float & x) const
|
||||
void InsetSpace::draw(PainterInfo & pi, int x, int y) const
|
||||
{
|
||||
Painter & pain = bv->painter();
|
||||
LyXFont font(f);
|
||||
|
||||
float w = width(bv, font);
|
||||
int h = font_metrics::ascent('x', font);
|
||||
int const w = width(pi.base.bv, pi.base.font);
|
||||
int const h = font_metrics::ascent('x', pi.base.font);
|
||||
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) {
|
||||
xp[1] = int(x); yp[1] = baseline;
|
||||
xp[2] = int(x + w); yp[2] = baseline;
|
||||
xp[1] = x; yp[1] = y;
|
||||
xp[2] = x + w; yp[2] = y;
|
||||
} else {
|
||||
xp[1] = int(x); yp[1] = baseline + max(h / 4, 1);
|
||||
xp[2] = int(x + w); yp[2] = baseline + max(h / 4, 1);
|
||||
xp[1] = x; yp[1] = y + 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)
|
||||
pain.lines(xp, yp, 4, LColor::latex);
|
||||
pi.pain.lines(xp, yp, 4, LColor::latex);
|
||||
else
|
||||
pain.lines(xp, yp, 4, LColor::special);
|
||||
x += w;
|
||||
pi.pain.lines(xp, yp, 4, LColor::special);
|
||||
}
|
||||
|
||||
|
||||
|
@ -56,7 +56,7 @@ public:
|
||||
///
|
||||
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;
|
||||
/// Will not be used when lyxf3
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include "frontends/font_metrics.h"
|
||||
#include "lyxlex.h"
|
||||
#include "lyxfont.h"
|
||||
#include "metricsinfo.h"
|
||||
|
||||
using std::ostream;
|
||||
using std::max;
|
||||
@ -58,56 +59,49 @@ void InsetSpecialChar::dimension(BufferView *, LyXFont const & font,
|
||||
}
|
||||
|
||||
|
||||
void InsetSpecialChar::draw(BufferView * bv, LyXFont const & f,
|
||||
int baseline, float & x) const
|
||||
void InsetSpecialChar::draw(PainterInfo & pi, int x, int y) const
|
||||
{
|
||||
Painter & pain = bv->painter();
|
||||
LyXFont font(f);
|
||||
LyXFont font = pi.base.font;
|
||||
|
||||
switch (kind_) {
|
||||
case HYPHENATION:
|
||||
{
|
||||
font.setColor(LColor::special);
|
||||
pain.text(int(x), baseline, '-', font);
|
||||
x += width(bv, font);
|
||||
pi.pain.text(x, y, '-', font);
|
||||
break;
|
||||
}
|
||||
case LIGATURE_BREAK:
|
||||
{
|
||||
font.setColor(LColor::special);
|
||||
pain.text(int(x), baseline, '|', font);
|
||||
x += width(bv, font);
|
||||
pi.pain.text(x, y, '|', font);
|
||||
break;
|
||||
}
|
||||
case END_OF_SENTENCE:
|
||||
{
|
||||
font.setColor(LColor::special);
|
||||
pain.text(int(x), baseline, '.', font);
|
||||
x += width(bv, font);
|
||||
pi.pain.text(x, y, '.', font);
|
||||
break;
|
||||
}
|
||||
case LDOTS:
|
||||
{
|
||||
font.setColor(LColor::special);
|
||||
pain.text(int(x), baseline, ". . .", font);
|
||||
x += width(bv, font);
|
||||
pi.pain.text(x, y, ". . .", font);
|
||||
break;
|
||||
}
|
||||
case MENU_SEPARATOR:
|
||||
{
|
||||
// A triangle the width and height of an 'x'
|
||||
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 xp[4], yp[4];
|
||||
|
||||
xp[0] = ox; yp[0] = baseline;
|
||||
xp[1] = ox; yp[1] = baseline - h;
|
||||
xp[2] = ox + w; yp[2] = baseline - h/2;
|
||||
xp[3] = ox; yp[3] = baseline;
|
||||
xp[0] = ox; yp[0] = y;
|
||||
xp[1] = ox; yp[1] = y - h;
|
||||
xp[2] = ox + w; yp[2] = y - h/2;
|
||||
xp[3] = ox; yp[3] = y;
|
||||
|
||||
pain.lines(xp, yp, 4, LColor::special);
|
||||
x += width(bv, font);
|
||||
pi.pain.lines(xp, yp, 4, LColor::special);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ public:
|
||||
///
|
||||
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;
|
||||
/// Will not be used when lyxf3
|
||||
|
@ -31,7 +31,7 @@
|
||||
#include "ParagraphParameters.h"
|
||||
#include "undo_funcs.h"
|
||||
#include "WordLangTuple.h"
|
||||
#include "Lsstream.h"
|
||||
#include "metricsinfo.h"
|
||||
|
||||
#include "frontends/Alert.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,
|
||||
float & x) const
|
||||
void InsetTabular::draw(PainterInfo & pi, int x, int y) const
|
||||
{
|
||||
if (nodraw()) {
|
||||
need_update = FULL;
|
||||
return;
|
||||
}
|
||||
|
||||
Painter & pain = bv->painter();
|
||||
BufferView * bv = pi.base.bv;
|
||||
int i;
|
||||
int j;
|
||||
int nx;
|
||||
|
||||
#if 0
|
||||
UpdatableInset::draw(bv, font, baseline, x);
|
||||
UpdatableInset::draw(pi, x, y);
|
||||
#else
|
||||
if (!owner())
|
||||
x += static_cast<float>(scroll());
|
||||
x += scroll();
|
||||
#endif
|
||||
|
||||
top_x = int(x);
|
||||
top_baseline = baseline;
|
||||
top_x = x;
|
||||
top_baseline = y;
|
||||
x += ADD_TO_TABULAR_WIDTH;
|
||||
|
||||
int cell = 0;
|
||||
float cx;
|
||||
int cx;
|
||||
first_visible_cell = -1;
|
||||
for (i = 0; i < tabular->rows(); ++i) {
|
||||
nx = int(x);
|
||||
nx = x;
|
||||
cell = tabular->GetCellNumber(i, 0);
|
||||
if (!((baseline + tabular->GetDescentOfRow(i)) > 0) &&
|
||||
(baseline - tabular->GetAscentOfRow(i))<pain.paperHeight())
|
||||
if (!((y + tabular->GetDescentOfRow(i)) > 0) &&
|
||||
(y - tabular->GetAscentOfRow(i)) < pi.pain.paperHeight())
|
||||
{
|
||||
baseline += tabular->GetDescentOfRow(i) +
|
||||
y += tabular->GetDescentOfRow(i) +
|
||||
tabular->GetAscentOfRow(i + 1) +
|
||||
tabular->GetAdditionalHeight(i + 1);
|
||||
continue;
|
||||
@ -299,32 +298,30 @@ void InsetTabular::draw(BufferView * bv, LyXFont const & font, int baseline,
|
||||
if (first_visible_cell < 0)
|
||||
first_visible_cell = cell;
|
||||
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);
|
||||
drawCellLines(pain, nx, baseline, i, cell);
|
||||
tabular->GetCellInset(cell)->draw(pi, cx, y);
|
||||
drawCellLines(pi.pain, nx, y, i, cell);
|
||||
nx += tabular->GetWidthOfColumn(cell);
|
||||
++cell;
|
||||
}
|
||||
|
||||
// avoiding drawing the rest of a long table is
|
||||
// a pretty big speedup
|
||||
if (baseline > bv->workHeight())
|
||||
if (y > bv->workHeight())
|
||||
break;
|
||||
|
||||
baseline += tabular->GetDescentOfRow(i) +
|
||||
y += tabular->GetDescentOfRow(i) +
|
||||
tabular->GetAscentOfRow(i + 1) +
|
||||
tabular->GetAdditionalHeight(i + 1);
|
||||
}
|
||||
|
||||
x -= ADD_TO_TABULAR_WIDTH;
|
||||
x += width(bv, font);
|
||||
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 x2 = x + tabular->GetWidthOfColumn(cell);
|
||||
@ -332,34 +329,34 @@ void InsetTabular::drawCellLines(Painter & pain, int x, int baseline,
|
||||
|
||||
if (!tabular->topAlreadyDrawn(cell)) {
|
||||
on_off = !tabular->TopLine(cell);
|
||||
pain.line(x, baseline - tabular->GetAscentOfRow(row),
|
||||
x2, baseline - tabular->GetAscentOfRow(row),
|
||||
pain.line(x, y - tabular->GetAscentOfRow(row),
|
||||
x2, y - tabular->GetAscentOfRow(row),
|
||||
on_off ? LColor::tabularonoffline : LColor::tabularline,
|
||||
on_off ? Painter::line_onoffdash : Painter::line_solid);
|
||||
}
|
||||
on_off = !tabular->BottomLine(cell);
|
||||
pain.line(x, baseline + tabular->GetDescentOfRow(row),
|
||||
x2, baseline + tabular->GetDescentOfRow(row),
|
||||
pain.line(x, y + tabular->GetDescentOfRow(row),
|
||||
x2, y + tabular->GetDescentOfRow(row),
|
||||
on_off ? LColor::tabularonoffline : LColor::tabularline,
|
||||
on_off ? Painter::line_onoffdash : Painter::line_solid);
|
||||
if (!tabular->leftAlreadyDrawn(cell)) {
|
||||
on_off = !tabular->LeftLine(cell);
|
||||
pain.line(x, baseline - tabular->GetAscentOfRow(row),
|
||||
x, baseline + tabular->GetDescentOfRow(row),
|
||||
pain.line(x, y - tabular->GetAscentOfRow(row),
|
||||
x, y + tabular->GetDescentOfRow(row),
|
||||
on_off ? LColor::tabularonoffline : LColor::tabularline,
|
||||
on_off ? Painter::line_onoffdash : Painter::line_solid);
|
||||
}
|
||||
on_off = !tabular->RightLine(cell);
|
||||
pain.line(x2 - tabular->GetAdditionalWidth(cell),
|
||||
baseline - tabular->GetAscentOfRow(row),
|
||||
y - tabular->GetAscentOfRow(row),
|
||||
x2 - tabular->GetAdditionalWidth(cell),
|
||||
baseline + tabular->GetDescentOfRow(row),
|
||||
y + tabular->GetDescentOfRow(row),
|
||||
on_off ? LColor::tabularonoffline : LColor::tabularline,
|
||||
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
|
||||
{
|
||||
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)) {
|
||||
int w = tabular->GetWidthOfColumn(cell);
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -88,7 +88,7 @@ public:
|
||||
///
|
||||
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);
|
||||
///
|
||||
|
@ -39,7 +39,7 @@
|
||||
#include "sgml.h"
|
||||
#include "rowpainter.h"
|
||||
#include "insetnewline.h"
|
||||
#include "Lsstream.h"
|
||||
#include "metricsinfo.h"
|
||||
|
||||
#include "frontends/Alert.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,
|
||||
int baseline, float & x) const
|
||||
void InsetText::draw(PainterInfo & pi, int x, int baseline) const
|
||||
{
|
||||
if (nodraw())
|
||||
return;
|
||||
|
||||
// update our idea of where we are. Clearly, we should
|
||||
// not have to know this information.
|
||||
if (top_x != int(x))
|
||||
top_x = int(x);
|
||||
if (top_x != 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
|
||||
dimension(bv, f, dim_);
|
||||
dimension(bv, pi.base.font, dim_);
|
||||
|
||||
// repaint the background if needed
|
||||
if (backgroundColor() != LColor::background)
|
||||
clearInset(bv, start_x + TEXT_TO_INSET_OFFSET, baseline);
|
||||
|
||||
// no draw is necessary !!!
|
||||
if ((drawFrame_ == LOCKED) && !locked && paragraphs.begin()->empty()) {
|
||||
if (drawFrame_ == LOCKED && !locked && paragraphs.begin()->empty()) {
|
||||
top_baseline = baseline;
|
||||
x += width(bv, f);
|
||||
need_update = NONE;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!owner())
|
||||
x += static_cast<float>(scroll());
|
||||
x += scroll();
|
||||
|
||||
top_baseline = baseline;
|
||||
top_y = baseline - dim_.asc;
|
||||
|
@ -91,7 +91,7 @@ public:
|
||||
///
|
||||
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);
|
||||
///
|
||||
|
@ -52,13 +52,11 @@ void UpdatableInset::fitInsetCursor(BufferView *) const
|
||||
{}
|
||||
|
||||
|
||||
void UpdatableInset::draw(BufferView *, LyXFont const &,
|
||||
int /* baseline */, float & x) const
|
||||
void UpdatableInset::draw(PainterInfo &, int, int) const
|
||||
{
|
||||
x += float(scx);
|
||||
// ATTENTION: don't do the following here!!!
|
||||
// top_x = int(x);
|
||||
// top_baseline = baseline;
|
||||
// top_x = x;
|
||||
// top_baseline = y;
|
||||
}
|
||||
|
||||
|
||||
|
@ -66,8 +66,7 @@ public:
|
||||
///
|
||||
virtual void insetUnlock(BufferView *);
|
||||
///
|
||||
virtual void draw(BufferView *, LyXFont const &,
|
||||
int baseline, float & x) const;
|
||||
virtual void draw(PainterInfo & pi, int x, int y) const;
|
||||
///
|
||||
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,
|
||||
int y, float & xx) const
|
||||
void InsetFormula::draw(PainterInfo & pi, int x, int y) const
|
||||
{
|
||||
cache(bv);
|
||||
cache(pi.base.bv);
|
||||
// This initiates the loading of the preview, so should come
|
||||
// before the metrics are computed.
|
||||
bool const use_preview = preview_->previewReady();
|
||||
|
||||
int const x = int(xx);
|
||||
int const w = width(bv, font);
|
||||
int const d = descent(bv, font);
|
||||
int const a = ascent(bv, font);
|
||||
Dimension dim;
|
||||
dimension(pi.base.bv, pi.base.font, dim);
|
||||
int const w = dim.wid;
|
||||
int const d = dim.des;
|
||||
int const a = dim.asc;
|
||||
int const h = a + d;
|
||||
|
||||
PainterInfo pi(bv);
|
||||
|
||||
if (use_preview) {
|
||||
pi.pain.image(x + 1, y - a, w, h, // one pixel gap in front
|
||||
*(preview_->pimage()->image()));
|
||||
} else {
|
||||
pi.base.style = LM_ST_TEXT;
|
||||
pi.base.font = font;
|
||||
pi.base.font.setColor(LColor::math);
|
||||
PainterInfo p(pi.base.bv);
|
||||
p.base.style = LM_ST_TEXT;
|
||||
p.base.font = pi.base.font;
|
||||
p.base.font.setColor(LColor::math);
|
||||
if (lcolor.getX11Name(LColor::mathbg)
|
||||
!= 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 &&
|
||||
const_cast<InsetFormulaBase const *>(mathcursor->formula()) == this)
|
||||
{
|
||||
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;
|
||||
yo_ = y;
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ public:
|
||||
///
|
||||
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;
|
||||
|
@ -31,8 +31,6 @@ public:
|
||||
InsetFormulaBase();
|
||||
///
|
||||
Inset * clone(Buffer const &) const = 0;
|
||||
///
|
||||
virtual void draw(BufferView *,LyXFont const &, int, float &) const = 0;
|
||||
/// lowest x coordinate
|
||||
virtual int xlow() const;
|
||||
/// highest x coordinate
|
||||
|
@ -171,20 +171,18 @@ Inset::Code InsetFormulaMacro::lyxCode() const
|
||||
}
|
||||
|
||||
|
||||
void InsetFormulaMacro::draw(BufferView * bv, LyXFont const & f,
|
||||
int y, float & xx) const
|
||||
void InsetFormulaMacro::draw(PainterInfo & p, int x, int y) const
|
||||
{
|
||||
// label
|
||||
LyXFont font(f);
|
||||
LyXFont font = p.base.font;
|
||||
font.setColor(LColor::math);
|
||||
|
||||
PainterInfo pi(bv);
|
||||
PainterInfo pi(p.base.bv);
|
||||
pi.base.style = LM_ST_TEXT;
|
||||
pi.base.font = font;
|
||||
|
||||
Dimension dim;
|
||||
dimension(bv, font, dim);
|
||||
int const x = int(xx);
|
||||
dimension(pi.base.bv, font, dim);
|
||||
int const a = y - dim.asc + 1;
|
||||
int const w = dim.wid - 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);
|
||||
|
||||
// formula
|
||||
par()->draw(pi, x + font_metrics::width(prefix(), f) + 5, y);
|
||||
xx += w + 2;
|
||||
par()->draw(pi, x + font_metrics::width(prefix(), p.base.font) + 5, y);
|
||||
xo_ = x;
|
||||
yo_ = y;
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ public:
|
||||
///
|
||||
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);
|
||||
|
@ -33,6 +33,7 @@
|
||||
#include "rowpainter.h"
|
||||
#include "lyxrc.h"
|
||||
#include "lyxrow_funcs.h"
|
||||
#include "metricsinfo.h"
|
||||
|
||||
using std::max;
|
||||
using lyx::pos_type;
|
||||
@ -103,12 +104,14 @@ void RowPainter::paintInset(pos_type const pos)
|
||||
|
||||
lyx::Assert(inset);
|
||||
|
||||
LyXFont const & font = getFont(pos);
|
||||
|
||||
#warning inset->update FIXME
|
||||
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