mirror of
https://git.lyx.org/repos/lyx.git
synced 2025-01-10 18:58:10 +00:00
the ascent/descent/width -> dimensions() change
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@6979 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
61861c8c89
commit
723ee136ba
@ -12,7 +12,6 @@
|
||||
#include "BufferView.h"
|
||||
#include "BufferView_pimpl.h"
|
||||
|
||||
#include "BufferView_pimpl.h"
|
||||
#include "LaTeX.h"
|
||||
#include "ParagraphParameters.h"
|
||||
#include "WordLangTuple.h"
|
||||
|
@ -1,4 +1,17 @@
|
||||
|
||||
2003-05-19 André Pönitz <poenitz@gmx.net>
|
||||
|
||||
* dimension.[Ch]: promote from mathed/dimension.[Ch]
|
||||
|
||||
* Makefile.am:
|
||||
* BufferView.C:
|
||||
* DepTable.h:
|
||||
* LaTeXFeatures.C:
|
||||
* buffer.C:
|
||||
* lyxfont.C:
|
||||
* lyxlex.h:
|
||||
* paragraph_funcs.C: dimensions() instead of ascend/descend/width
|
||||
|
||||
2003-05-19 André Pönitz <poenitz@gmx.net>
|
||||
|
||||
* buffer.C:
|
||||
|
@ -25,8 +25,7 @@ public:
|
||||
/** This one is a little bit harder since we need the absolute
|
||||
filename. Should we insert files with .sty .cls etc as
|
||||
extension? */
|
||||
void insert(string const & f,
|
||||
bool upd = false);
|
||||
void insert(string const & f, bool upd = false);
|
||||
///
|
||||
void update();
|
||||
|
||||
|
@ -176,12 +176,12 @@ int const nb_simplefeatures = sizeof(simplefeatures) / sizeof(char const *);
|
||||
|
||||
}
|
||||
|
||||
|
||||
string const LaTeXFeatures::getPackages() const
|
||||
{
|
||||
ostringstream packages;
|
||||
LyXTextClass const & tclass = params.getLyXTextClass();
|
||||
|
||||
|
||||
//
|
||||
// These are all the 'simple' includes. i.e
|
||||
// packages which we just \usepackage{package}
|
||||
|
@ -121,6 +121,8 @@ lyx_SOURCES = \
|
||||
counters.h \
|
||||
debug.C \
|
||||
debug.h \
|
||||
dimension.C \
|
||||
dimension.h \
|
||||
encoding.C \
|
||||
encoding.h \
|
||||
exporter.C \
|
||||
|
@ -161,10 +161,7 @@ Buffer::~Buffer()
|
||||
string const Buffer::getLatexName(bool no_path) const
|
||||
{
|
||||
string const name = ChangeExtension(MakeLatexName(fileName()), ".tex");
|
||||
if (no_path)
|
||||
return OnlyFilename(name);
|
||||
else
|
||||
return name;
|
||||
return no_path ? OnlyFilename(name) : name;
|
||||
}
|
||||
|
||||
|
||||
|
@ -10,10 +10,9 @@
|
||||
|
||||
|
||||
#include <config.h>
|
||||
#include "dimension.h"
|
||||
#include "math_support.h"
|
||||
|
||||
#include <iostream>
|
||||
#include "dimension.h"
|
||||
#include "frontends/font_metrics.h"
|
||||
|
||||
|
||||
void Dimension::operator+=(Dimension const & dim)
|
||||
@ -26,15 +25,9 @@ void Dimension::operator+=(Dimension const & dim)
|
||||
}
|
||||
|
||||
|
||||
std::ostream & operator<<(std::ostream & os, Dimension const & dim)
|
||||
{
|
||||
os << " (" << dim.w << 'x' << dim.a << '-' << dim.d << ") ";
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
void Dimension::clear(LyXFont const & font)
|
||||
{
|
||||
math_font_max_dim(font, a, d);
|
||||
a = font_metrics::maxAscent(font);
|
||||
d = font_metrics::maxDescent(font);
|
||||
w = 0;
|
||||
}
|
@ -15,12 +15,10 @@
|
||||
#define DIMENSION_H
|
||||
|
||||
|
||||
#include <iosfwd>
|
||||
|
||||
class LyXFont;
|
||||
|
||||
/// Simple wrapper around three ints
|
||||
class Dimension {
|
||||
struct Dimension {
|
||||
public:
|
||||
/// constructor
|
||||
Dimension() : w(0), a(0), d(0) {}
|
||||
@ -43,6 +41,15 @@ public:
|
||||
int width() const { return w; }
|
||||
|
||||
public:
|
||||
/// these are intentionally public as things like
|
||||
///
|
||||
/// dim.a += 20;
|
||||
///
|
||||
/// are used all over the place and "hiding" those behind
|
||||
///
|
||||
/// dim.ascent(dim.ascent() + 20);
|
||||
///
|
||||
/// makes the code neither faster nor clearer
|
||||
/// width
|
||||
int w;
|
||||
/// ascent
|
||||
@ -51,6 +58,4 @@ public:
|
||||
int d;
|
||||
};
|
||||
|
||||
std::ostream & operator<<(std::ostream & os, Dimension const & dim);
|
||||
|
||||
#endif
|
@ -62,7 +62,6 @@ void ControlDocument::apply()
|
||||
if (!bufferIsAvailable())
|
||||
return;
|
||||
|
||||
|
||||
classApply();
|
||||
|
||||
view().apply();
|
||||
|
@ -10,7 +10,6 @@
|
||||
|
||||
#include <config.h>
|
||||
|
||||
|
||||
#include <qmessagebox.h>
|
||||
#include <qlabel.h>
|
||||
#include <qlineedit.h>
|
||||
|
@ -10,7 +10,6 @@
|
||||
|
||||
#include <config.h>
|
||||
|
||||
|
||||
#include "xformsImage.h"
|
||||
#include "graphics/GraphicsParams.h"
|
||||
#include "Color.h"
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include "support/LAssert.h"
|
||||
#include "support/FileInfo.h"
|
||||
#include "support/filetools.h"
|
||||
#include "support/tostr.h"
|
||||
#include "support/lstrings.h" // frontStrip, strip
|
||||
|
||||
#include "lyx_forms.h"
|
||||
@ -196,9 +197,7 @@ void updateWidgetsFromLength(FL_OBJECT * input, FL_OBJECT * choice,
|
||||
fl_set_input(input, "");
|
||||
fl_set_choice_text(choice, default_unit.c_str());
|
||||
} else {
|
||||
ostringstream buffer;
|
||||
buffer << len.value();
|
||||
fl_set_input(input, buffer.str().c_str());
|
||||
fl_set_input(input, tostr(len.value()).c_str());
|
||||
|
||||
// Set the choice to the desired unit, if present in the choice.
|
||||
// Else set the choice to the default unit.
|
||||
@ -220,7 +219,8 @@ void updateWidgetsFromLength(FL_OBJECT * input, FL_OBJECT * choice,
|
||||
string formatted(string const & sin, int w, int size, int style)
|
||||
{
|
||||
string sout;
|
||||
if (sin.empty()) return sout;
|
||||
if (sin.empty())
|
||||
return sout;
|
||||
|
||||
string::size_type curpos = 0;
|
||||
string line;
|
||||
|
@ -1,4 +1,22 @@
|
||||
|
||||
2003-05-19 André Pönitz <poenitz@gmx.net>
|
||||
|
||||
* inset.[Ch]:
|
||||
* insetbutton.[Ch]:
|
||||
* insetcollapsable.[Ch]:
|
||||
* inseterror.[Ch]:
|
||||
* insetert.[Ch]:
|
||||
* insetfoot.[Ch]:
|
||||
* insetgraphics.[Ch]:
|
||||
* insetgraphicsParams.[Ch]:
|
||||
* insetlatexaccent.[Ch]:
|
||||
* insetminipage.[Ch]:
|
||||
* insetnewline.[Ch]:
|
||||
* insetquotes.[Ch]:
|
||||
* insetspecialchar.[Ch]:
|
||||
* insettabular.[Ch]:
|
||||
* insettext.[Ch]: dimensions() instead of ascend/descend/width
|
||||
|
||||
2003-05-19 André Pönitz <poenitz@gmx.net>
|
||||
|
||||
* insetenv.[Ch]:
|
||||
|
@ -13,14 +13,13 @@
|
||||
|
||||
#include <config.h>
|
||||
|
||||
|
||||
#include "inset.h"
|
||||
|
||||
#include "BufferView.h"
|
||||
#include "funcrequest.h"
|
||||
#include "gettext.h"
|
||||
#include "lyxfont.h"
|
||||
#include "lyxtext.h"
|
||||
#include "dimension.h"
|
||||
|
||||
#include "frontends/Painter.h"
|
||||
#include "frontends/mouse_state.h"
|
||||
@ -148,3 +147,27 @@ int Inset::latexTextWidth(BufferView * bv) const
|
||||
return bv->workWidth();
|
||||
}
|
||||
|
||||
|
||||
int Inset::ascent(BufferView * bv, LyXFont const & font) const
|
||||
{
|
||||
Dimension dim;
|
||||
dimension(bv, font, dim);
|
||||
return dim.ascent();
|
||||
}
|
||||
|
||||
|
||||
int Inset::descent(BufferView * bv, LyXFont const & font) const
|
||||
{
|
||||
Dimension dim;
|
||||
dimension(bv, font, dim);
|
||||
return dim.descent();
|
||||
}
|
||||
|
||||
|
||||
int Inset::width(BufferView * bv, LyXFont const & font) const
|
||||
{
|
||||
Dimension dim;
|
||||
dimension(bv, font, dim);
|
||||
return dim.width();
|
||||
}
|
||||
|
||||
|
@ -18,12 +18,12 @@
|
||||
#include "LString.h"
|
||||
#include "LColor.h"
|
||||
#include "insetbase.h"
|
||||
#include "frontends/mouse_state.h"
|
||||
#include "support/types.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
class LyXFont;
|
||||
class Dimension;
|
||||
class Buffer;
|
||||
class Painter;
|
||||
class LyXText;
|
||||
@ -157,11 +157,13 @@ public:
|
||||
///
|
||||
Inset(Inset const & in, bool same_id = false);
|
||||
///
|
||||
virtual int ascent(BufferView *, LyXFont const &) const = 0;
|
||||
virtual void dimension(BufferView *, LyXFont const &, Dimension &) const = 0;
|
||||
///
|
||||
virtual int descent(BufferView *, LyXFont const &) const = 0;
|
||||
int ascent(BufferView *, LyXFont const &) const;
|
||||
///
|
||||
virtual int width(BufferView *, LyXFont const &) const = 0;
|
||||
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
|
||||
|
@ -1,4 +1,3 @@
|
||||
|
||||
#include "insetbase.h"
|
||||
|
||||
|
||||
|
@ -12,9 +12,9 @@
|
||||
|
||||
#include <config.h>
|
||||
|
||||
|
||||
#include "insetbutton.h"
|
||||
#include "debug.h"
|
||||
#include "dimension.h"
|
||||
#include "BufferView.h"
|
||||
#include "funcrequest.h"
|
||||
#include "frontends/LyXView.h"
|
||||
@ -27,69 +27,22 @@ using std::ostream;
|
||||
using std::endl;
|
||||
|
||||
|
||||
int InsetButton::ascent(BufferView * bv, LyXFont const &) const
|
||||
void InsetButton::dimension(BufferView * bv, LyXFont const &,
|
||||
Dimension & dim) const
|
||||
{
|
||||
lyx::Assert(bv);
|
||||
|
||||
LyXFont font(LyXFont::ALL_SANE);
|
||||
font.decSize();
|
||||
|
||||
int width;
|
||||
int ascent;
|
||||
int descent;
|
||||
string const s = getScreenLabel(bv->buffer());
|
||||
|
||||
if (editable()) {
|
||||
font_metrics::buttonText(s, font, width, ascent, descent);
|
||||
} else {
|
||||
font_metrics::rectText(s, font, width, ascent, descent);
|
||||
}
|
||||
|
||||
return ascent;
|
||||
}
|
||||
|
||||
|
||||
int InsetButton::descent(BufferView * bv, LyXFont const &) const
|
||||
{
|
||||
lyx::Assert(bv);
|
||||
|
||||
LyXFont font(LyXFont::ALL_SANE);
|
||||
font.decSize();
|
||||
|
||||
int width;
|
||||
int ascent;
|
||||
int descent;
|
||||
string const s = getScreenLabel(bv->buffer());
|
||||
|
||||
if (editable()) {
|
||||
font_metrics::buttonText(s, font, width, ascent, descent);
|
||||
} else {
|
||||
font_metrics::rectText(s, font, width, ascent, descent);
|
||||
}
|
||||
|
||||
return descent;
|
||||
}
|
||||
|
||||
|
||||
int InsetButton::width(BufferView * bv, LyXFont const &) const
|
||||
{
|
||||
lyx::Assert(bv);
|
||||
|
||||
LyXFont font(LyXFont::ALL_SANE);
|
||||
font.decSize();
|
||||
|
||||
int width;
|
||||
int ascent;
|
||||
int descent;
|
||||
string const s = getScreenLabel(bv->buffer());
|
||||
|
||||
if (editable()) {
|
||||
font_metrics::buttonText(s, font, width, ascent, descent);
|
||||
} else {
|
||||
font_metrics::rectText(s, font, width, ascent, descent);
|
||||
}
|
||||
|
||||
return width + 4;
|
||||
if (editable())
|
||||
font_metrics::buttonText(s, font, dim.w, dim.a, dim.d);
|
||||
else
|
||||
font_metrics::rectText(s, font, dim.w, dim.a, dim.d);
|
||||
|
||||
dim.w += 4;
|
||||
}
|
||||
|
||||
|
||||
|
@ -24,11 +24,7 @@
|
||||
class InsetButton: public Inset {
|
||||
public:
|
||||
///
|
||||
int ascent(BufferView *, LyXFont const &) const;
|
||||
///
|
||||
int descent(BufferView *, LyXFont const &) const;
|
||||
///
|
||||
int width(BufferView *, LyXFont const &) const;
|
||||
void dimension(BufferView *, LyXFont const &, Dimension &) const;
|
||||
///
|
||||
void draw(BufferView *, LyXFont const &, int, float &) const;
|
||||
///
|
||||
|
@ -26,33 +26,23 @@ public:
|
||||
///
|
||||
void read(Buffer const * buf, LyXLex & lex);
|
||||
///
|
||||
virtual
|
||||
bool display() const;
|
||||
virtual bool display() const;
|
||||
///
|
||||
virtual
|
||||
bool needFullRow() const;
|
||||
virtual bool needFullRow() const;
|
||||
///
|
||||
virtual
|
||||
Inset::Code lyxCode() const;
|
||||
virtual Inset::Code lyxCode() const;
|
||||
///
|
||||
virtual
|
||||
string const editMessage() const;
|
||||
virtual string const editMessage() const;
|
||||
///
|
||||
virtual
|
||||
void draw(BufferView * bv, LyXFont const & f,
|
||||
virtual void draw(BufferView * bv, LyXFont const & f,
|
||||
int baseline, float & x) const;
|
||||
///
|
||||
virtual
|
||||
int latex(Buffer const * buf, std::ostream & os,
|
||||
virtual int latex(Buffer const * buf, std::ostream & os,
|
||||
bool fragile, bool free_spc) const;
|
||||
///
|
||||
virtual
|
||||
int ascii(Buffer const * buf, std::ostream & os, int linelen) const;
|
||||
///
|
||||
virtual
|
||||
int docbook(Buffer const * buf, std::ostream & os, bool mixcont) const;
|
||||
protected:
|
||||
private:
|
||||
};
|
||||
|
||||
|
||||
@ -75,4 +65,5 @@ Inset::Code InsetCaption::lyxCode() const
|
||||
{
|
||||
return CAPTION_CODE;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -17,6 +17,7 @@
|
||||
|
||||
#include "BufferView.h"
|
||||
#include "debug.h"
|
||||
#include "dimension.h"
|
||||
#include "gettext.h"
|
||||
#include "lyxfont.h"
|
||||
#include "lyxlex.h"
|
||||
@ -88,7 +89,6 @@ void InsetCollapsable::write(Buffer const * buf, ostream & os) const
|
||||
}
|
||||
|
||||
|
||||
|
||||
void InsetCollapsable::read(Buffer const * buf, LyXLex & lex)
|
||||
{
|
||||
if (lex.isOK()) {
|
||||
@ -108,64 +108,31 @@ void InsetCollapsable::read(Buffer const * buf, LyXLex & lex)
|
||||
}
|
||||
|
||||
|
||||
int InsetCollapsable::ascent_collapsed() const
|
||||
void InsetCollapsable::dimension_collapsed(Dimension & dim) const
|
||||
{
|
||||
int width = 0;
|
||||
int ascent = 0;
|
||||
int descent = 0;
|
||||
font_metrics::buttonText(label, labelfont, width, ascent, descent);
|
||||
return ascent;
|
||||
font_metrics::buttonText(label, labelfont, dim.w, dim.a, dim.d);
|
||||
dim.w += 2 * TEXT_TO_INSET_OFFSET;
|
||||
}
|
||||
|
||||
|
||||
int InsetCollapsable::descent_collapsed() const
|
||||
int InsetCollapsable::height_collapsed() const
|
||||
{
|
||||
int width = 0;
|
||||
int ascent = 0;
|
||||
int descent = 0;
|
||||
font_metrics::buttonText(label, labelfont, width, ascent, descent);
|
||||
return descent;
|
||||
Dimension dim;
|
||||
font_metrics::buttonText(label, labelfont, dim.w, dim.a, dim.d);
|
||||
return dim.a + dim.d;
|
||||
}
|
||||
|
||||
|
||||
//int InsetCollapsable::width_collapsed(Painter & pain) const
|
||||
int InsetCollapsable::width_collapsed() const
|
||||
void InsetCollapsable::dimension(BufferView * bv, LyXFont const & font,
|
||||
Dimension & dim) const
|
||||
{
|
||||
int width;
|
||||
int ascent;
|
||||
int descent;
|
||||
font_metrics::buttonText(label, labelfont, width, ascent, descent);
|
||||
return width + 2 * TEXT_TO_INSET_OFFSET;
|
||||
}
|
||||
|
||||
|
||||
int InsetCollapsable::ascent(BufferView * /*bv*/, LyXFont const &) const
|
||||
{
|
||||
return ascent_collapsed();
|
||||
}
|
||||
|
||||
|
||||
int InsetCollapsable::descent(BufferView * bv, LyXFont const & font) const
|
||||
{
|
||||
if (collapsed_)
|
||||
return descent_collapsed();
|
||||
|
||||
return descent_collapsed()
|
||||
+ inset.descent(bv, font)
|
||||
+ inset.ascent(bv, font)
|
||||
+ TEXT_TO_BOTTOM_OFFSET;
|
||||
}
|
||||
|
||||
|
||||
int InsetCollapsable::width(BufferView * bv, LyXFont const & font) const
|
||||
{
|
||||
if (collapsed_)
|
||||
return width_collapsed();
|
||||
|
||||
int const collapsed_width = width_collapsed();
|
||||
int const contents_width = inset.width(bv, font);
|
||||
|
||||
return max(collapsed_width, contents_width);
|
||||
dimension_collapsed(dim);
|
||||
if (collapsed_)
|
||||
return;
|
||||
Dimension insetdim;
|
||||
inset.dimension(bv, font, insetdim);
|
||||
dim.d += insetdim.height() + TEXT_TO_BOTTOM_OFFSET;
|
||||
dim.w = max(dim.w, insetdim.width());
|
||||
}
|
||||
|
||||
|
||||
@ -174,7 +141,9 @@ void InsetCollapsable::draw_collapsed(Painter & pain,
|
||||
{
|
||||
pain.buttonText(int(x) + TEXT_TO_INSET_OFFSET,
|
||||
baseline, label, labelfont);
|
||||
x += width_collapsed();
|
||||
Dimension dim;
|
||||
dimension_collapsed(dim);
|
||||
x += dim.w;
|
||||
}
|
||||
|
||||
|
||||
@ -187,12 +156,14 @@ void InsetCollapsable::draw(BufferView * bv, LyXFont const & f,
|
||||
if (nodraw())
|
||||
return;
|
||||
|
||||
Dimension dim_collapsed;
|
||||
dimension_collapsed(dim_collapsed);
|
||||
|
||||
Painter & pain = bv->painter();
|
||||
|
||||
button_length = width_collapsed();
|
||||
button_top_y = -ascent(bv, f);
|
||||
button_bottom_y = -ascent(bv, f) + ascent_collapsed() +
|
||||
descent_collapsed();
|
||||
button_length = dim_collapsed.width();
|
||||
button_top_y = -ascent(bv, f);
|
||||
button_bottom_y = -ascent(bv, f) + dim_collapsed.height();
|
||||
|
||||
if (!isOpen()) {
|
||||
draw_collapsed(pain, baseline, x);
|
||||
@ -207,15 +178,16 @@ void InsetCollapsable::draw(BufferView * bv, LyXFont const & f,
|
||||
top_x = int(x);
|
||||
top_baseline = baseline;
|
||||
|
||||
int const bl = baseline - ascent(bv, f) + ascent_collapsed();
|
||||
int const bl = baseline - ascent(bv, f) + dim_collapsed.ascent();
|
||||
|
||||
if (inlined) {
|
||||
inset.draw(bv, f, baseline, x);
|
||||
} else {
|
||||
draw_collapsed(pain, bl, old_x);
|
||||
inset.draw(bv, f, bl + descent_collapsed() + inset.ascent(bv, f), 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))
|
||||
if (x < top_x + button_length + TEXT_TO_INSET_OFFSET)
|
||||
x = top_x + button_length + TEXT_TO_INSET_OFFSET;
|
||||
}
|
||||
}
|
||||
@ -259,9 +231,7 @@ FuncRequest InsetCollapsable::adjustCommand(FuncRequest const & cmd)
|
||||
LyXFont font(LyXFont::ALL_SANE);
|
||||
FuncRequest cmd1 = cmd;
|
||||
cmd1.y = ascent(cmd.view(), font) + cmd.y -
|
||||
(ascent_collapsed() +
|
||||
descent_collapsed() +
|
||||
inset.ascent(cmd.view(), font));
|
||||
(height_collapsed() + inset.ascent(cmd.view(), font));
|
||||
return cmd1;
|
||||
}
|
||||
|
||||
@ -394,9 +364,7 @@ Inset::RESULT InsetCollapsable::localDispatch(FuncRequest const & cmd)
|
||||
} else {
|
||||
LyXFont font(LyXFont::ALL_SANE);
|
||||
cmd1.y = ascent(bv, font) + cmd.y -
|
||||
(ascent_collapsed() +
|
||||
descent_collapsed() +
|
||||
inset.ascent(bv, font));
|
||||
(height_collapsed() + inset.ascent(bv, font));
|
||||
}
|
||||
inset.localDispatch(cmd);
|
||||
}
|
||||
|
@ -45,18 +45,14 @@ public:
|
||||
///
|
||||
void write(Buffer const *, std::ostream &) const;
|
||||
///
|
||||
int ascent(BufferView *, LyXFont const &) const;
|
||||
void dimension(BufferView *, LyXFont const &, Dimension &) const;
|
||||
///
|
||||
int descent(BufferView *, LyXFont const &) const;
|
||||
///
|
||||
int width(BufferView *, LyXFont const &) const;
|
||||
///
|
||||
void draw(BufferView *, const LyXFont &, int , float &) const;
|
||||
void draw(BufferView *, const LyXFont &, int, float &) const;
|
||||
/// draw, either inlined (no button) or collapsed/open
|
||||
void draw(BufferView * bv, LyXFont const & f,
|
||||
int baseline, float & x, bool inlined) const;
|
||||
///
|
||||
void update(BufferView *, bool =false);
|
||||
void update(BufferView *, bool = false);
|
||||
///
|
||||
EDITABLE editable() const;
|
||||
///
|
||||
@ -181,13 +177,11 @@ protected:
|
||||
virtual BufferView * view() const;
|
||||
|
||||
///
|
||||
int ascent_collapsed() const;
|
||||
void dimension_collapsed(Dimension &) const;
|
||||
///
|
||||
int descent_collapsed() const;
|
||||
int height_collapsed() const;
|
||||
///
|
||||
int width_collapsed() const;
|
||||
///
|
||||
void draw_collapsed(Painter & pain, int , float &) const;
|
||||
void draw_collapsed(Painter & pain, int, float &) const;
|
||||
///
|
||||
int getMaxTextWidth(Painter & pain, UpdatableInset const *) const;
|
||||
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include "inseterror.h"
|
||||
|
||||
#include "BufferView.h"
|
||||
#include "dimension.h"
|
||||
#include "funcrequest.h"
|
||||
#include "gettext.h"
|
||||
#include "lyxfont.h"
|
||||
@ -54,27 +55,14 @@ dispatch_result InsetError::localDispatch(FuncRequest const & cmd)
|
||||
}
|
||||
|
||||
|
||||
int InsetError::ascent(BufferView *, LyXFont const & font) const
|
||||
void InsetError::dimension(BufferView *, LyXFont const & font,
|
||||
Dimension & dim) const
|
||||
{
|
||||
LyXFont efont;
|
||||
efont.setSize(font.size()).decSize();
|
||||
return font_metrics::maxAscent(efont) + 1;
|
||||
}
|
||||
|
||||
|
||||
int InsetError::descent(BufferView *, LyXFont const & font) const
|
||||
{
|
||||
LyXFont efont;
|
||||
efont.setSize(font.size()).decSize();
|
||||
return font_metrics::maxDescent(efont) + 1;
|
||||
}
|
||||
|
||||
|
||||
int InsetError::width(BufferView *, LyXFont const & font) const
|
||||
{
|
||||
LyXFont efont;
|
||||
efont.setSize(font.size()).decSize();
|
||||
return 6 + font_metrics::width(_("Error"), efont);
|
||||
dim.a = font_metrics::maxAscent(efont) + 1;
|
||||
dim.d = font_metrics::maxDescent(efont) + 1;
|
||||
dim.w = 6 + font_metrics::width(_("Error"), efont);
|
||||
}
|
||||
|
||||
|
||||
|
@ -30,11 +30,7 @@ public:
|
||||
///
|
||||
virtual dispatch_result localDispatch(FuncRequest const & cmd);
|
||||
///
|
||||
int ascent(BufferView *, LyXFont const &) const;
|
||||
///
|
||||
int descent(BufferView *, LyXFont const &) const;
|
||||
///
|
||||
int width(BufferView *, LyXFont const &) const;
|
||||
void dimension(BufferView *, LyXFont const &, Dimension &) const;
|
||||
///
|
||||
void draw(BufferView *, LyXFont const &, int, float &) const;
|
||||
///
|
||||
|
@ -306,7 +306,7 @@ bool InsetERT::lfunMouseRelease(FuncRequest const & cmd)
|
||||
if (status_ == Inlined)
|
||||
inset.localDispatch(cmd1);
|
||||
else if (!collapsed_ && (cmd.y > button_bottom_y)) {
|
||||
cmd1.y -= ascent_collapsed() + descent_collapsed();
|
||||
cmd1.y -= height_collapsed();
|
||||
inset.localDispatch(cmd1);
|
||||
}
|
||||
}
|
||||
@ -552,30 +552,13 @@ bool InsetERT::checkInsertChar(LyXFont & /* font */)
|
||||
}
|
||||
|
||||
|
||||
int InsetERT::ascent(BufferView * bv, LyXFont const & font) const
|
||||
void InsetERT::dimension(BufferView * bv, LyXFont const & font,
|
||||
Dimension & dim) const
|
||||
{
|
||||
if (!inlined())
|
||||
return InsetCollapsable::ascent(bv, font);
|
||||
|
||||
return inset.ascent(bv, font);
|
||||
}
|
||||
|
||||
|
||||
int InsetERT::descent(BufferView * bv, LyXFont const & font) const
|
||||
{
|
||||
if (!inlined())
|
||||
return InsetCollapsable::descent(bv, font);
|
||||
|
||||
return inset.descent(bv, font);
|
||||
}
|
||||
|
||||
|
||||
int InsetERT::width(BufferView * bv, LyXFont const & font) const
|
||||
{
|
||||
if (!inlined())
|
||||
return InsetCollapsable::width(bv, font);
|
||||
|
||||
return inset.width(bv, font);
|
||||
if (inlined())
|
||||
inset.dimension(bv, font, dim);
|
||||
else
|
||||
InsetCollapsable::dimension(bv, font, dim);
|
||||
}
|
||||
|
||||
|
||||
|
@ -99,11 +99,7 @@ public:
|
||||
WordLangTuple const
|
||||
selectNextWordToSpellcheck(BufferView *, float &) const;
|
||||
///
|
||||
int ascent(BufferView *, LyXFont const &) const;
|
||||
///
|
||||
int descent(BufferView *, LyXFont const &) const;
|
||||
///
|
||||
int width(BufferView *, LyXFont const &) const;
|
||||
void dimension(BufferView *, LyXFont const &, Dimension &) const;
|
||||
///
|
||||
void draw(BufferView *, const LyXFont &, int , float &) const;
|
||||
/// set the status of the inset
|
||||
|
@ -11,7 +11,6 @@
|
||||
|
||||
#include <config.h>
|
||||
|
||||
|
||||
#include "insetfoot.h"
|
||||
#include "gettext.h"
|
||||
#include "lyxfont.h"
|
||||
|
@ -12,14 +12,11 @@
|
||||
#ifndef INSETFOOTLIKE_H
|
||||
#define INSETFOOTLIKE_H
|
||||
|
||||
|
||||
#include "insetcollapsable.h"
|
||||
|
||||
// To have this class is probably a bit overkill... (Lgb)
|
||||
|
||||
/** The footnote inset
|
||||
|
||||
*/
|
||||
// The footnote inset
|
||||
class InsetFootlike : public InsetCollapsable {
|
||||
public:
|
||||
///
|
||||
|
@ -60,6 +60,7 @@ TODO
|
||||
#include "graphics/GraphicsParams.h"
|
||||
|
||||
#include "lyxtext.h"
|
||||
#include "dimension.h"
|
||||
#include "buffer.h"
|
||||
#include "BufferView.h"
|
||||
#include "converter.h"
|
||||
@ -88,11 +89,11 @@ TODO
|
||||
#include "support/tostr.h"
|
||||
#include "support/systemcall.h"
|
||||
#include "support/os.h"
|
||||
#include "support/lstrings.h"
|
||||
|
||||
#include <boost/weak_ptr.hpp>
|
||||
#include <boost/bind.hpp>
|
||||
#include <boost/signals/trackable.hpp>
|
||||
#include "support/BoostFormat.h"
|
||||
|
||||
#include <algorithm> // For the std::max
|
||||
|
||||
@ -287,45 +288,36 @@ bool InsetGraphics::imageIsDrawable() const
|
||||
}
|
||||
|
||||
|
||||
int InsetGraphics::ascent(BufferView *, LyXFont const &) const
|
||||
void InsetGraphics::dimension(BufferView *, LyXFont const & font,
|
||||
Dimension & dim) const
|
||||
{
|
||||
cache_->old_ascent = 50;
|
||||
if (imageIsDrawable())
|
||||
cache_->old_ascent = cache_->loader.image()->getHeight();
|
||||
return cache_->old_ascent;
|
||||
}
|
||||
|
||||
|
||||
int InsetGraphics::descent(BufferView *, LyXFont const &) const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int InsetGraphics::width(BufferView *, LyXFont const & font) const
|
||||
{
|
||||
dim.a = cache_->old_ascent;
|
||||
dim.d = 0;
|
||||
if (imageIsDrawable())
|
||||
return cache_->loader.image()->getWidth() + 2 * TEXT_TO_INSET_OFFSET;
|
||||
dim.w = cache_->loader.image()->getWidth() + 2 * TEXT_TO_INSET_OFFSET;
|
||||
else {
|
||||
int font_width = 0;
|
||||
|
||||
int font_width = 0;
|
||||
LyXFont msgFont(font);
|
||||
msgFont.setFamily(LyXFont::SANS_FAMILY);
|
||||
|
||||
LyXFont msgFont(font);
|
||||
msgFont.setFamily(LyXFont::SANS_FAMILY);
|
||||
string const justname = OnlyFilename(params().filename);
|
||||
if (!justname.empty()) {
|
||||
msgFont.setSize(LyXFont::SIZE_FOOTNOTE);
|
||||
font_width = font_metrics::width(justname, msgFont);
|
||||
}
|
||||
|
||||
string const justname = OnlyFilename (params().filename);
|
||||
if (!justname.empty()) {
|
||||
msgFont.setSize(LyXFont::SIZE_FOOTNOTE);
|
||||
font_width = font_metrics::width(justname, msgFont);
|
||||
string const msg = statusMessage();
|
||||
if (!msg.empty()) {
|
||||
msgFont.setSize(LyXFont::SIZE_TINY);
|
||||
font_width = std::max(font_width, font_metrics::width(msg, msgFont));
|
||||
}
|
||||
|
||||
dim.w = std::max(50, font_width + 15);
|
||||
}
|
||||
|
||||
string const msg = statusMessage();
|
||||
if (!msg.empty()) {
|
||||
msgFont.setSize(LyXFont::SIZE_TINY);
|
||||
int const msg_width = font_metrics::width(msg, msgFont);
|
||||
font_width = std::max(font_width, msg_width);
|
||||
}
|
||||
|
||||
return std::max(50, font_width + 15);
|
||||
}
|
||||
|
||||
|
||||
@ -633,15 +625,8 @@ string const InsetGraphics::prepareFile(Buffer const * buf) const
|
||||
<< temp_file
|
||||
<< (success ? " succeeded\n" : " failed\n");
|
||||
if (!success) {
|
||||
#if USE_BOOST_FORMAT
|
||||
boost::format fmt(_("Could not copy the file\n%1$s\ninto the temporary directory."));
|
||||
fmt % orig_file_with_path;
|
||||
string str = fmt.str();
|
||||
#else
|
||||
string str = _("Could not copy the file\n");
|
||||
str += orig_file_with_path;
|
||||
str += _("\ninto the temporary directory.");
|
||||
#endif
|
||||
string str = bformat(_("Could not copy the file\n%1$s\n"
|
||||
"into the temporary directory."), orig_file_with_path);
|
||||
Alert::error(_("Graphics display failed"), str);
|
||||
return orig_file;
|
||||
}
|
||||
@ -677,16 +662,9 @@ string const InsetGraphics::prepareFile(Buffer const * buf) const
|
||||
Systemcall one;
|
||||
one.startscript(Systemcall::Wait, command);
|
||||
if (!IsFileReadable(ChangeExtension(outfile_base, to))) {
|
||||
#if USE_BOOST_FORMAT
|
||||
boost::format fmt(_("No information for converting %1$s format files to %1$s.\n"
|
||||
"Try defining a convertor in the preferences."));
|
||||
fmt % from % to;
|
||||
string str = fmt.str();
|
||||
#else
|
||||
string str = _("No information for converting ");
|
||||
str += from + _(" format files to ") + to;
|
||||
str += _(".\nTry defining a convertor in the preferences.");
|
||||
#endif
|
||||
string str = bformat(_("No information for converting %1$s "
|
||||
"format files to %1$s.\n"
|
||||
"Try defining a convertor in the preferences."), from, to);
|
||||
Alert::error(_("Could not convert image"), str);
|
||||
}
|
||||
}
|
||||
|
@ -35,11 +35,7 @@ public:
|
||||
///
|
||||
virtual dispatch_result localDispatch(FuncRequest const & cmd);
|
||||
///
|
||||
int ascent(BufferView *, LyXFont const &) const;
|
||||
///
|
||||
int descent(BufferView *, LyXFont const &) const;
|
||||
///
|
||||
int width(BufferView *, LyXFont const &) const;
|
||||
void dimension(BufferView *, LyXFont const &, Dimension &) const;
|
||||
///
|
||||
void draw(BufferView *, LyXFont const &, int, float &) const;
|
||||
///
|
||||
|
@ -28,11 +28,13 @@
|
||||
|
||||
using std::ostream;
|
||||
|
||||
|
||||
InsetGraphicsParams::InsetGraphicsParams()
|
||||
{
|
||||
init();
|
||||
}
|
||||
|
||||
|
||||
InsetGraphicsParams::InsetGraphicsParams(InsetGraphicsParams const & igp)
|
||||
{
|
||||
// I decided to skip the initialization since the copy will overwrite
|
||||
@ -41,6 +43,7 @@ InsetGraphicsParams::InsetGraphicsParams(InsetGraphicsParams const & igp)
|
||||
copy(igp);
|
||||
}
|
||||
|
||||
|
||||
InsetGraphicsParams &
|
||||
InsetGraphicsParams::operator=(InsetGraphicsParams const & params)
|
||||
{
|
||||
@ -51,6 +54,7 @@ InsetGraphicsParams::operator=(InsetGraphicsParams const & params)
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
void InsetGraphicsParams::init()
|
||||
{
|
||||
filename.erase();
|
||||
@ -73,6 +77,7 @@ void InsetGraphicsParams::init()
|
||||
special.erase(); // additional userdefined stuff
|
||||
}
|
||||
|
||||
|
||||
void InsetGraphicsParams::copy(InsetGraphicsParams const & igp)
|
||||
{
|
||||
filename = igp.filename;
|
||||
@ -95,6 +100,7 @@ void InsetGraphicsParams::copy(InsetGraphicsParams const & igp)
|
||||
special = igp.special;
|
||||
}
|
||||
|
||||
|
||||
bool operator==(InsetGraphicsParams const & left,
|
||||
InsetGraphicsParams const & right)
|
||||
{
|
||||
@ -123,12 +129,14 @@ bool operator==(InsetGraphicsParams const & left,
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool operator!=(InsetGraphicsParams const & left,
|
||||
InsetGraphicsParams const & right)
|
||||
{
|
||||
return !(left == right);
|
||||
}
|
||||
|
||||
|
||||
void InsetGraphicsParams::Write(ostream & os) const
|
||||
{
|
||||
// Do not write the default values
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include "insetlatexaccent.h"
|
||||
|
||||
#include "debug.h"
|
||||
#include "dimension.h"
|
||||
#include "lyxrc.h"
|
||||
#include "support/lstrings.h"
|
||||
#include "BufferView.h"
|
||||
@ -262,48 +263,34 @@ void InsetLatexAccent::checkContents()
|
||||
}
|
||||
|
||||
|
||||
int InsetLatexAccent::ascent(BufferView *, LyXFont const & font) const
|
||||
void InsetLatexAccent::dimension(BufferView *, LyXFont const & font,
|
||||
Dimension & dim) const
|
||||
{
|
||||
// This function is a bit too simplistix and is just a
|
||||
// This function is a bit too simplistic and is just a
|
||||
// "try to make a fit for all accents" approach, to
|
||||
// make it better we need to know what kind of accent is
|
||||
// used and add to max based on that.
|
||||
int max;
|
||||
if (candisp) {
|
||||
if (ic == ' ')
|
||||
max = font_metrics::ascent('a', font);
|
||||
dim.a = font_metrics::ascent('a', font);
|
||||
else
|
||||
max = font_metrics::ascent(ic, font);
|
||||
dim.a = font_metrics::ascent(ic, font);
|
||||
if (plusasc)
|
||||
max += (font_metrics::maxAscent(font) + 3) / 3;
|
||||
} else
|
||||
max = font_metrics::maxAscent(font) + 4;
|
||||
return max;
|
||||
}
|
||||
dim.a += (font_metrics::maxAscent(font) + 3) / 3;
|
||||
|
||||
|
||||
int InsetLatexAccent::descent(BufferView *, LyXFont const & font) const
|
||||
{
|
||||
int max;
|
||||
if (candisp) {
|
||||
if (ic == ' ')
|
||||
max = font_metrics::descent('a', font);
|
||||
dim.d = font_metrics::descent('a', font);
|
||||
else
|
||||
max = font_metrics::descent(ic, font);
|
||||
dim.d = font_metrics::descent(ic, font);
|
||||
if (plusdesc)
|
||||
max += 3;
|
||||
} else
|
||||
max = font_metrics::maxDescent(font) + 4;
|
||||
return max;
|
||||
}
|
||||
dim.d += 3;
|
||||
|
||||
|
||||
int InsetLatexAccent::width(BufferView *, LyXFont const & font) const
|
||||
{
|
||||
if (candisp)
|
||||
return font_metrics::width(ic, font);
|
||||
else
|
||||
return font_metrics::width(contents, font) + 4;
|
||||
dim.w = font_metrics::width(ic, font);
|
||||
} else {
|
||||
dim.a = font_metrics::maxAscent(font) + 4;
|
||||
dim.d = font_metrics::maxDescent(font) + 4;
|
||||
dim.w = font_metrics::width(contents, font) + 4;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -34,11 +34,7 @@ public:
|
||||
explicit
|
||||
InsetLatexAccent(string const & string);
|
||||
///
|
||||
int ascent(BufferView *, LyXFont const &) const;
|
||||
///
|
||||
int descent(BufferView *, LyXFont const &) const;
|
||||
///
|
||||
int width(BufferView *, LyXFont const &) const;
|
||||
void dimension(BufferView *, LyXFont const &, Dimension &) const;
|
||||
///
|
||||
void draw(BufferView *, LyXFont const &, int, float &) const;
|
||||
///
|
||||
|
@ -9,8 +9,8 @@
|
||||
* Full author contact details are available in file CREDITS
|
||||
*/
|
||||
|
||||
#ifndef InsetList_H
|
||||
#define InsetList_H
|
||||
#ifndef INSETLIST_H
|
||||
#define INSETLIST_H
|
||||
|
||||
|
||||
#include "insetcollapsable.h"
|
||||
|
@ -16,8 +16,10 @@
|
||||
|
||||
#include "BufferView.h"
|
||||
#include "debug.h"
|
||||
#include "dimension.h"
|
||||
#include "funcrequest.h"
|
||||
#include "gettext.h"
|
||||
#include "Lsstream.h"
|
||||
#include "lyxfont.h"
|
||||
#include "lyxlex.h"
|
||||
#include "lyxtext.h"
|
||||
@ -27,7 +29,6 @@
|
||||
#include "frontends/Dialogs.h"
|
||||
|
||||
#include "support/LOstream.h"
|
||||
#include "support/lstrings.h"
|
||||
|
||||
using std::ostream;
|
||||
using std::endl;
|
||||
@ -217,50 +218,28 @@ void InsetMinipage::read(Buffer const * buf, LyXLex & lex)
|
||||
}
|
||||
|
||||
|
||||
int InsetMinipage::ascent(BufferView * bv, LyXFont const & font) const
|
||||
void InsetMinipage::dimension(BufferView * bv, LyXFont const & font,
|
||||
Dimension & dim) const
|
||||
{
|
||||
if (collapsed_)
|
||||
return ascent_collapsed();
|
||||
dimension_collapsed(dim);
|
||||
else {
|
||||
// Take placement into account.
|
||||
int i = 0;
|
||||
Dimension d;
|
||||
InsetCollapsable::dimension(bv, font, dim);
|
||||
switch (params_.pos) {
|
||||
case top:
|
||||
i = InsetCollapsable::ascent(bv, font);
|
||||
dim.a = d.a;
|
||||
dim.d = d.d;
|
||||
break;
|
||||
case center:
|
||||
i = (InsetCollapsable::ascent(bv, font)
|
||||
+ InsetCollapsable::descent(bv, font)) / 2;
|
||||
dim.a = d.height() / 2;
|
||||
dim.d = dim.a;
|
||||
break;
|
||||
case bottom:
|
||||
i = InsetCollapsable::descent(bv, font);
|
||||
dim.a = d.d;
|
||||
dim.d = d.a;
|
||||
break;
|
||||
}
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int InsetMinipage::descent(BufferView * bv, LyXFont const & font) const
|
||||
{
|
||||
if (collapsed_)
|
||||
return descent_collapsed();
|
||||
else {
|
||||
// Take placement into account.
|
||||
int i = 0;
|
||||
switch (params_.pos) {
|
||||
case top:
|
||||
i = InsetCollapsable::descent(bv, font);
|
||||
break;
|
||||
case center:
|
||||
i = (InsetCollapsable::ascent(bv, font)
|
||||
+ InsetCollapsable::descent(bv, font)) / 2;
|
||||
break;
|
||||
case bottom:
|
||||
i = InsetCollapsable::ascent(bv, font);
|
||||
break;
|
||||
}
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -68,9 +68,7 @@ public:
|
||||
///
|
||||
Inset * clone(Buffer const &, bool same_id = false) const;
|
||||
///
|
||||
int ascent(BufferView *, LyXFont const &) const;
|
||||
///
|
||||
int descent(BufferView *, LyXFont const &) const;
|
||||
void dimension(BufferView *, LyXFont const &, Dimension &) const;
|
||||
///
|
||||
Inset::Code lyxCode() const { return Inset::MINIPAGE_CODE; }
|
||||
///
|
||||
|
@ -10,24 +10,20 @@
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "insetnewline.h"
|
||||
|
||||
#include "BufferView.h"
|
||||
#include "debug.h"
|
||||
#include "dimension.h"
|
||||
#include "paragraph.h"
|
||||
#include "lyxtext.h"
|
||||
#include "insetnewline.h"
|
||||
#include "support/LOstream.h"
|
||||
#include "frontends/Painter.h"
|
||||
#include "frontends/font_metrics.h"
|
||||
|
||||
#include "debug.h"
|
||||
|
||||
using std::ostream;
|
||||
using std::endl;
|
||||
|
||||
InsetNewline::InsetNewline()
|
||||
: Inset()
|
||||
{}
|
||||
|
||||
|
||||
void InsetNewline::read(Buffer const *, LyXLex &)
|
||||
{
|
||||
@ -41,21 +37,12 @@ void InsetNewline::write(Buffer const *, ostream & os) const
|
||||
}
|
||||
|
||||
|
||||
int InsetNewline::ascent(BufferView *, LyXFont const & font) const
|
||||
void InsetNewline::dimension(BufferView *, LyXFont const & font,
|
||||
Dimension & dim) const
|
||||
{
|
||||
return font_metrics::maxAscent(font);
|
||||
}
|
||||
|
||||
|
||||
int InsetNewline::descent(BufferView *, LyXFont const & font) const
|
||||
{
|
||||
return font_metrics::maxDescent(font);
|
||||
}
|
||||
|
||||
|
||||
int InsetNewline::width(BufferView *, LyXFont const & font) const
|
||||
{
|
||||
return font_metrics::width('n', font);
|
||||
dim.a = font_metrics::maxAscent(font);
|
||||
dim.d = font_metrics::maxDescent(font);
|
||||
dim.w = font_metrics::width('n', font);
|
||||
}
|
||||
|
||||
|
||||
|
@ -18,7 +18,7 @@
|
||||
class InsetNewline : public Inset {
|
||||
public:
|
||||
|
||||
InsetNewline();
|
||||
InsetNewline() {}
|
||||
|
||||
virtual Inset * clone(Buffer const &, bool = false) const {
|
||||
return new InsetNewline;
|
||||
@ -26,11 +26,7 @@ public:
|
||||
|
||||
Inset::Code lyxCode() const { return Inset::NEWLINE_CODE; }
|
||||
|
||||
virtual int ascent(BufferView *, LyXFont const &) const;
|
||||
|
||||
virtual int descent(BufferView *, LyXFont const &) const;
|
||||
|
||||
virtual int width(BufferView *, LyXFont const &) const;
|
||||
void dimension(BufferView *, LyXFont const &, Dimension &) const;
|
||||
|
||||
virtual void draw(BufferView *, LyXFont const &,
|
||||
int baseline, float & x) const;
|
||||
|
@ -10,29 +10,26 @@
|
||||
|
||||
#include <config.h>
|
||||
|
||||
|
||||
#include "insetquotes.h"
|
||||
|
||||
#include "support/LAssert.h"
|
||||
#include "support/lstrings.h"
|
||||
#include "BufferView.h"
|
||||
#include "LaTeXFeatures.h"
|
||||
#include "frontends/Painter.h"
|
||||
#include "buffer.h"
|
||||
#include "debug.h"
|
||||
#include "dimension.h"
|
||||
#include "frontends/font_metrics.h"
|
||||
#include "language.h"
|
||||
#include "lyxfont.h"
|
||||
#include "lyxrc.h"
|
||||
#include "paragraph.h"
|
||||
#include "lyxlex.h"
|
||||
#include "support/LAssert.h"
|
||||
#include "support/lstrings.h"
|
||||
|
||||
using std::ostream;
|
||||
using std::endl;
|
||||
|
||||
// Quotes. Used for the various quotes. German, English, French,
|
||||
// Danish, Polish, all either double or single.
|
||||
|
||||
namespace {
|
||||
|
||||
// codes used to read/write quotes to LyX files
|
||||
@ -73,9 +70,7 @@ InsetQuotes::InsetQuotes(string const & str)
|
||||
}
|
||||
|
||||
|
||||
InsetQuotes::InsetQuotes(quote_language l,
|
||||
quote_side s,
|
||||
quote_times t)
|
||||
InsetQuotes::InsetQuotes(quote_language l, quote_side s, quote_times t)
|
||||
: language_(l), side_(s), times_(t)
|
||||
{}
|
||||
|
||||
@ -174,33 +169,22 @@ string const InsetQuotes::dispString(Language const * loclang) const
|
||||
}
|
||||
|
||||
|
||||
int InsetQuotes::ascent(BufferView *, LyXFont const & font) const
|
||||
void InsetQuotes::dimension(BufferView *, LyXFont const & font,
|
||||
Dimension & dim) const
|
||||
{
|
||||
return font_metrics::maxAscent(font);
|
||||
}
|
||||
dim.a = font_metrics::maxAscent(font);
|
||||
dim.d = font_metrics::maxDescent(font);
|
||||
dim.w = 0;
|
||||
|
||||
|
||||
int InsetQuotes::descent(BufferView *, LyXFont const & font) const
|
||||
{
|
||||
return font_metrics::maxDescent(font);
|
||||
}
|
||||
|
||||
|
||||
int InsetQuotes::width(BufferView *, LyXFont const & font) const
|
||||
{
|
||||
string const text = dispString(font.language());
|
||||
int w = 0;
|
||||
|
||||
for (string::size_type i = 0; i < text.length(); ++i) {
|
||||
if (text[i] == ' ')
|
||||
w += font_metrics::width('i', font);
|
||||
dim.w += font_metrics::width('i', font);
|
||||
else if (i == 0 || text[i] != text[i - 1])
|
||||
w += font_metrics::width(text[i], font);
|
||||
dim.w += font_metrics::width(text[i], font);
|
||||
else
|
||||
w += font_metrics::width(',', font);
|
||||
dim.w += font_metrics::width(',', font);
|
||||
}
|
||||
|
||||
return w;
|
||||
}
|
||||
|
||||
|
||||
|
@ -22,7 +22,6 @@ struct LaTeXFeatures;
|
||||
|
||||
|
||||
/** Quotes.
|
||||
|
||||
Used for the various quotes. German, English, French, all either
|
||||
double or single **/
|
||||
class InsetQuotes : public Inset {
|
||||
@ -68,13 +67,11 @@ public:
|
||||
InsetQuotes(string const & str = "eld");
|
||||
/// Create the right quote inset after character c
|
||||
InsetQuotes(char c, BufferParams const & params);
|
||||
///
|
||||
Inset * clone(Buffer const &, bool same_id = false) const;
|
||||
|
||||
///
|
||||
int ascent(BufferView *, LyXFont const &) const;
|
||||
///
|
||||
int descent(BufferView *, LyXFont const &) const;
|
||||
///
|
||||
int width(BufferView *, LyXFont const &) const;
|
||||
void dimension(BufferView *, LyXFont const &, Dimension &) const;
|
||||
///
|
||||
void draw(BufferView *, LyXFont const &, int, float &) const;
|
||||
#if 0
|
||||
@ -97,8 +94,6 @@ public:
|
||||
///
|
||||
void validate(LaTeXFeatures &) const;
|
||||
///
|
||||
virtual Inset * clone(Buffer const &, bool same_id = false) const;
|
||||
///
|
||||
Inset::Code lyxCode() const;
|
||||
// should this inset be handled like a normal charater
|
||||
bool isChar() const { return true; }
|
||||
|
@ -12,9 +12,10 @@
|
||||
|
||||
#include <config.h>
|
||||
|
||||
|
||||
#include "insetspecialchar.h"
|
||||
|
||||
#include "debug.h"
|
||||
#include "dimension.h"
|
||||
#include "LaTeXFeatures.h"
|
||||
#include "BufferView.h"
|
||||
#include "frontends/Painter.h"
|
||||
@ -25,6 +26,7 @@
|
||||
using std::ostream;
|
||||
using std::max;
|
||||
|
||||
|
||||
InsetSpecialChar::InsetSpecialChar(Kind k)
|
||||
: kind_(k)
|
||||
{}
|
||||
@ -36,51 +38,23 @@ InsetSpecialChar::Kind InsetSpecialChar::kind() const
|
||||
}
|
||||
|
||||
|
||||
int InsetSpecialChar::ascent(BufferView *, LyXFont const & font) const
|
||||
void InsetSpecialChar::dimension(BufferView *, LyXFont const & font,
|
||||
Dimension & dim) const
|
||||
{
|
||||
return font_metrics::maxAscent(font);
|
||||
}
|
||||
dim.a = font_metrics::maxAscent(font);
|
||||
dim.d = font_metrics::maxDescent(font);
|
||||
|
||||
|
||||
int InsetSpecialChar::descent(BufferView *, LyXFont const & font) const
|
||||
{
|
||||
return font_metrics::maxDescent(font);
|
||||
}
|
||||
|
||||
|
||||
int InsetSpecialChar::width(BufferView *, LyXFont const & font) const
|
||||
{
|
||||
char const * s = 0;
|
||||
switch (kind_) {
|
||||
case HYPHENATION:
|
||||
{
|
||||
int w = font_metrics::width('-', font);
|
||||
if (w > 5)
|
||||
w -= 2; // to make it look shorter
|
||||
return w;
|
||||
case LIGATURE_BREAK: s = "|"; break;
|
||||
case END_OF_SENTENCE: s = "."; break;
|
||||
case LDOTS: s = ". . ."; break;
|
||||
case MENU_SEPARATOR: s = " x "; break;
|
||||
case PROTECTED_SEPARATOR: s = "x"; break;
|
||||
}
|
||||
case LIGATURE_BREAK:
|
||||
{
|
||||
return font_metrics::width('|', font);
|
||||
}
|
||||
case END_OF_SENTENCE:
|
||||
{
|
||||
return font_metrics::width('.', font);
|
||||
}
|
||||
case LDOTS:
|
||||
{
|
||||
return font_metrics::width(". . .", font);
|
||||
}
|
||||
case MENU_SEPARATOR:
|
||||
{
|
||||
return font_metrics::width(" x ", font);
|
||||
}
|
||||
case PROTECTED_SEPARATOR:
|
||||
{
|
||||
return font_metrics::width('x', font);
|
||||
}
|
||||
|
||||
}
|
||||
return 1; // To shut up gcc
|
||||
dim.w = font_metrics::width('x', font);
|
||||
if (kind_ == HYPHENATION && dim.w > 5)
|
||||
dim.w -= 2; // to make it look shorter
|
||||
}
|
||||
|
||||
|
||||
|
@ -48,11 +48,7 @@ public:
|
||||
///
|
||||
Kind kind() const;
|
||||
///
|
||||
int ascent(BufferView *, LyXFont const &) const;
|
||||
///
|
||||
int descent(BufferView *, LyXFont const &) const;
|
||||
///
|
||||
int width(BufferView *, LyXFont const &) const;
|
||||
void dimension(BufferView *, LyXFont const &, Dimension &) const;
|
||||
///
|
||||
void draw(BufferView *, LyXFont const &, int, float &) const;
|
||||
///
|
||||
|
@ -17,10 +17,12 @@
|
||||
#include "BufferView.h"
|
||||
#include "lfuns.h"
|
||||
#include "debug.h"
|
||||
#include "dimension.h"
|
||||
#include "funcrequest.h"
|
||||
#include "gettext.h"
|
||||
#include "language.h"
|
||||
#include "LaTeXFeatures.h"
|
||||
#include "Lsstream.h"
|
||||
#include "lyx_cb.h"
|
||||
#include "lyxfunc.h"
|
||||
#include "lyxlength.h"
|
||||
@ -242,21 +244,12 @@ void InsetTabular::read(Buffer const * buf, LyXLex & lex)
|
||||
}
|
||||
|
||||
|
||||
int InsetTabular::ascent(BufferView *, LyXFont const &) const
|
||||
void InsetTabular::dimension(BufferView *, LyXFont const &,
|
||||
Dimension & dim) const
|
||||
{
|
||||
return tabular->GetAscentOfRow(0);
|
||||
}
|
||||
|
||||
|
||||
int InsetTabular::descent(BufferView *, LyXFont const &) const
|
||||
{
|
||||
return tabular->GetHeightOfTabular() - tabular->GetAscentOfRow(0) + 1;
|
||||
}
|
||||
|
||||
|
||||
int InsetTabular::width(BufferView *, LyXFont const &) const
|
||||
{
|
||||
return tabular->GetWidthOfTabular() + (2 * ADD_TO_TABULAR_WIDTH);
|
||||
dim.a = tabular->GetAscentOfRow(0);
|
||||
dim.d = tabular->GetHeightOfTabular() - tabular->GetAscentOfRow(0) + 1;
|
||||
dim.w = tabular->GetWidthOfTabular() + 2 * ADD_TO_TABULAR_WIDTH;
|
||||
}
|
||||
|
||||
|
||||
|
@ -50,6 +50,7 @@
|
||||
#include "LString.h"
|
||||
#include "lyxcursor.h"
|
||||
#include "FuncStatus.h"
|
||||
#include "frontends/mouse_state.h"
|
||||
|
||||
#include <boost/scoped_ptr.hpp>
|
||||
#include <boost/weak_ptr.hpp>
|
||||
@ -85,11 +86,7 @@ public:
|
||||
///
|
||||
void write(Buffer const *, std::ostream &) const;
|
||||
///
|
||||
int ascent(BufferView *, LyXFont const &) const;
|
||||
///
|
||||
int descent(BufferView *, LyXFont const &) const;
|
||||
///
|
||||
int width(BufferView *, LyXFont const & f) const;
|
||||
void dimension(BufferView *, LyXFont const &, Dimension &) const;
|
||||
///
|
||||
void draw(BufferView *, const LyXFont &, int , float &) const;
|
||||
///
|
||||
|
@ -16,11 +16,13 @@
|
||||
#include "BufferView.h"
|
||||
#include "CutAndPaste.h"
|
||||
#include "debug.h"
|
||||
#include "dimension.h"
|
||||
#include "funcrequest.h"
|
||||
#include "gettext.h"
|
||||
#include "intl.h"
|
||||
#include "LaTeXFeatures.h"
|
||||
#include "LColor.h"
|
||||
#include "Lsstream.h"
|
||||
#include "lyxfont.h"
|
||||
#include "lyxcursor.h"
|
||||
#include "lyxfind.h"
|
||||
@ -296,47 +298,29 @@ void InsetText::read(Buffer const * buf, LyXLex & lex)
|
||||
}
|
||||
|
||||
|
||||
int InsetText::ascent(BufferView * bv, LyXFont const &) const
|
||||
void InsetText::dimension(BufferView * bv, LyXFont const &,
|
||||
Dimension & dim) const
|
||||
{
|
||||
insetAscent = getLyXText(bv)->rows().begin()->ascent_of_text() +
|
||||
TEXT_TO_INSET_OFFSET;
|
||||
return insetAscent;
|
||||
}
|
||||
|
||||
|
||||
int InsetText::descent(BufferView * bv, LyXFont const &) const
|
||||
{
|
||||
LyXText * llt = getLyXText(bv);
|
||||
insetDescent = llt->height - llt->rows().begin()->ascent_of_text() +
|
||||
TEXT_TO_INSET_OFFSET;
|
||||
return insetDescent;
|
||||
}
|
||||
|
||||
|
||||
int InsetText::width(BufferView * bv, LyXFont const &) const
|
||||
{
|
||||
insetWidth = max(textWidth(bv), (int)getLyXText(bv)->width) +
|
||||
(2 * TEXT_TO_INSET_OFFSET);
|
||||
insetWidth = max(insetWidth, 10);
|
||||
return insetWidth;
|
||||
LyXText * text = getLyXText(bv);
|
||||
dim.a = text->rows().begin()->ascent_of_text() + TEXT_TO_INSET_OFFSET;
|
||||
dim.d = text->height - dim.a + TEXT_TO_INSET_OFFSET;
|
||||
dim.w = max(textWidth(bv), int(text->width)) + 2 * TEXT_TO_INSET_OFFSET;
|
||||
dim.w = max(dim.w, 10);
|
||||
}
|
||||
|
||||
|
||||
int InsetText::textWidth(BufferView * bv, bool fordraw) const
|
||||
{
|
||||
int w;
|
||||
if (!autoBreakRows) {
|
||||
w = -1;
|
||||
} else {
|
||||
w = getMaxWidth(bv, this);
|
||||
}
|
||||
if (fordraw) {
|
||||
return max(w - (2 * TEXT_TO_INSET_OFFSET),
|
||||
int w = autoBreakRows ? getMaxWidth(bv, this) : -1;
|
||||
|
||||
if (fordraw)
|
||||
return max(w - 2 * TEXT_TO_INSET_OFFSET,
|
||||
(int)getLyXText(bv)->width);
|
||||
} else if (w < 0) {
|
||||
return -1;
|
||||
}
|
||||
return w - (2 * TEXT_TO_INSET_OFFSET);
|
||||
|
||||
if (w < 0)
|
||||
return -1;
|
||||
|
||||
return w - 2 * TEXT_TO_INSET_OFFSET;
|
||||
}
|
||||
|
||||
|
||||
@ -2626,14 +2610,13 @@ void InsetText::getDrawFont(LyXFont & font) const
|
||||
}
|
||||
|
||||
|
||||
void InsetText::appendParagraphs(Buffer * buffer,
|
||||
ParagraphList & plist)
|
||||
void InsetText::appendParagraphs(Buffer * buffer, ParagraphList & plist)
|
||||
{
|
||||
#warning FIXME Check if Changes stuff needs changing here. (Lgb)
|
||||
// And it probably does. You have to take a look at this John. (Lgb)
|
||||
#warning John, have a look here. (Lgb)
|
||||
BufferParams const & bparams = buffer->params;
|
||||
#if 0
|
||||
BufferParams const & bparams = buffer->params;
|
||||
Paragraph * buf;
|
||||
Paragraph * tmpbuf = newpar;
|
||||
Paragraph * lastbuffer = buf = new Paragraph(*tmpbuf, false);
|
||||
|
@ -86,11 +86,7 @@ public:
|
||||
///
|
||||
void write(Buffer const *, std::ostream &) const;
|
||||
///
|
||||
int ascent(BufferView *, LyXFont const &) const;
|
||||
///
|
||||
int descent(BufferView *, LyXFont const &) const;
|
||||
///
|
||||
int width(BufferView *, LyXFont const & f) const;
|
||||
void dimension(BufferView *, LyXFont const &, Dimension &) const;
|
||||
///
|
||||
int textWidth(BufferView *, bool fordraw = false) const;
|
||||
///
|
||||
|
@ -542,10 +542,11 @@ LyXFont & LyXFont::setLyXFamily(string const & fam)
|
||||
string const s = ascii_lowercase(fam);
|
||||
|
||||
int i = 0;
|
||||
while (s != LyXFamilyNames[i] && LyXFamilyNames[i] != "error") ++i;
|
||||
if (s == LyXFamilyNames[i]) {
|
||||
while (s != LyXFamilyNames[i] && LyXFamilyNames[i] != "error")
|
||||
++i;
|
||||
if (s == LyXFamilyNames[i])
|
||||
setFamily(LyXFont::FONT_FAMILY(i));
|
||||
} else
|
||||
else
|
||||
lyxerr << "LyXFont::setLyXFamily: Unknown family `"
|
||||
<< s << '\'' << endl;
|
||||
return *this;
|
||||
|
@ -28,7 +28,7 @@ struct keyword_item {
|
||||
class LyXLex : boost::noncopyable {
|
||||
public:
|
||||
///
|
||||
LyXLex (keyword_item *, int);
|
||||
LyXLex(keyword_item *, int);
|
||||
///
|
||||
~LyXLex();
|
||||
|
||||
|
@ -1,4 +1,14 @@
|
||||
|
||||
2003-05-19 André Pönitz <poenitz@gmx.net>
|
||||
|
||||
* Makefile.am:
|
||||
* dimension.[Ch]: promote files to src/dimension.[Ch[
|
||||
|
||||
* formula.[Ch]:
|
||||
* formulamacro.[Ch]:
|
||||
* formulamacro.h:
|
||||
* math_inset.h: replace ascents/descent/witdh with dimension()
|
||||
|
||||
2003-05-14 André Pönitz <poenitz@gmx.net>
|
||||
|
||||
* math_substack.[Ch]: add markers
|
||||
|
@ -5,8 +5,6 @@ noinst_LTLIBRARIES = libmathed.la
|
||||
INCLUDES = -I$(srcdir)/../ $(BOOST_INCLUDES)
|
||||
|
||||
libmathed_la_SOURCES = \
|
||||
dimension.C \
|
||||
dimension.h \
|
||||
textpainter.C \
|
||||
textpainter.h \
|
||||
formulabase.C \
|
||||
|
@ -34,6 +34,7 @@
|
||||
#include "debug.h"
|
||||
#include "lyxrc.h"
|
||||
#include "funcrequest.h"
|
||||
#include "Lsstream.h"
|
||||
|
||||
#include "support/LOstream.h"
|
||||
#include "support/LAssert.h"
|
||||
@ -275,29 +276,21 @@ bool InsetFormula::insetAllowed(Inset::Code code) const
|
||||
}
|
||||
|
||||
|
||||
int InsetFormula::ascent(BufferView *, LyXFont const &) const
|
||||
{
|
||||
return preview_->previewReady() ?
|
||||
preview_->pimage()->ascent() : 1 + par_->ascent();
|
||||
}
|
||||
|
||||
|
||||
int InsetFormula::descent(BufferView *, LyXFont const &) const
|
||||
{
|
||||
if (!preview_->previewReady())
|
||||
return 1 + par_->descent();
|
||||
|
||||
int const descent = preview_->pimage()->descent();
|
||||
return display() ? descent + 12 : descent;
|
||||
}
|
||||
|
||||
|
||||
int InsetFormula::width(BufferView * bv, LyXFont const & font) const
|
||||
void InsetFormula::dimension(BufferView * bv, LyXFont const & font,
|
||||
Dimension & dim) const
|
||||
{
|
||||
metrics(bv, font);
|
||||
return preview_->previewReady() ?
|
||||
1 + preview_->pimage()->width() : par_->width();
|
||||
if (preview_->previewReady()) {
|
||||
dim.a = preview_->pimage()->ascent();
|
||||
int const descent = preview_->pimage()->descent();
|
||||
dim.d = display() ? descent + 12 : descent;
|
||||
// insert a one pixel gap in front of the formula
|
||||
dim.w = 1 + preview_->pimage()->width();
|
||||
} else {
|
||||
dim = par_->dimensions();
|
||||
dim.a += 1;
|
||||
dim.d += 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -35,11 +35,7 @@ public:
|
||||
///
|
||||
~InsetFormula();
|
||||
///
|
||||
int ascent(BufferView *, LyXFont const &) const;
|
||||
///
|
||||
int descent(BufferView *, LyXFont const &) const;
|
||||
///
|
||||
int width(BufferView *, LyXFont const &) const;
|
||||
void dimension(BufferView *, LyXFont const &, Dimension &) const;
|
||||
///
|
||||
void draw(BufferView *, LyXFont const &, int, float &) const;
|
||||
|
||||
|
@ -13,9 +13,7 @@
|
||||
#ifndef INSET_FORMULABASE_H
|
||||
#define INSET_FORMULABASE_H
|
||||
|
||||
|
||||
#include "insets/updatableinset.h"
|
||||
#include "frontends/mouse_state.h"
|
||||
#include "lyxfont.h"
|
||||
|
||||
#include <boost/weak_ptr.hpp>
|
||||
@ -25,17 +23,14 @@ class Buffer;
|
||||
class BufferView;
|
||||
class MathAtom;
|
||||
|
||||
|
||||
/// An abstract base class for all math related LyX insets
|
||||
class InsetFormulaBase : public UpdatableInset {
|
||||
public:
|
||||
///
|
||||
InsetFormulaBase();
|
||||
///
|
||||
virtual int ascent(BufferView *, LyXFont const &) const = 0;
|
||||
///
|
||||
virtual int descent(BufferView *, LyXFont const &) const = 0;
|
||||
///
|
||||
virtual int width(BufferView *, LyXFont const &) const = 0;
|
||||
Inset * clone(Buffer const &, bool same_id = false) const = 0;
|
||||
///
|
||||
virtual void draw(BufferView *,LyXFont const &, int, float &) const = 0;
|
||||
/// lowest x coordinate
|
||||
@ -53,8 +48,6 @@ public:
|
||||
// user-accessible way to override "false positives"
|
||||
virtual void validate(LaTeXFeatures &) const;
|
||||
///
|
||||
virtual Inset * clone(Buffer const &, bool same_id = false) const = 0;
|
||||
///
|
||||
virtual Inset::Code lyxCode() const;
|
||||
/// what appears in the minibuffer when opening
|
||||
virtual string const editMessage() const;
|
||||
|
@ -126,29 +126,22 @@ void InsetFormulaMacro::read(std::istream & is)
|
||||
string InsetFormulaMacro::prefix() const
|
||||
{
|
||||
#if USE_BOOST_FORMAT
|
||||
return boost::io::str(boost::format(_(" Macro: %s: ")) % getInsetName());
|
||||
return STRCONV(boost::io::str(boost::format(_(" Macro: %s: ")) %
|
||||
STRCONV(getInsetName())));
|
||||
#else
|
||||
return _(" Macro: ") + getInsetName() + ": ";
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
int InsetFormulaMacro::ascent(BufferView *, LyXFont const &) const
|
||||
void InsetFormulaMacro::dimension(BufferView * bv, LyXFont const & font,
|
||||
Dimension & dim) const
|
||||
{
|
||||
return par()->ascent() + 5;
|
||||
}
|
||||
|
||||
|
||||
int InsetFormulaMacro::descent(BufferView *, LyXFont const &) const
|
||||
{
|
||||
return par()->descent() + 5;
|
||||
}
|
||||
|
||||
|
||||
int InsetFormulaMacro::width(BufferView * bv, LyXFont const & f) const
|
||||
{
|
||||
metrics(bv, f);
|
||||
return 10 + font_metrics::width(prefix(), f) + par()->width();
|
||||
metrics(bv, font);
|
||||
dim = par()->dimensions();
|
||||
dim.a += 5;
|
||||
dim.d += 5;
|
||||
dim.w += 10 + font_metrics::width(prefix(), font);
|
||||
}
|
||||
|
||||
|
||||
|
@ -33,11 +33,7 @@ public:
|
||||
/// constructs a mocro from its LaTeX definition
|
||||
explicit InsetFormulaMacro(string const & s);
|
||||
///
|
||||
int ascent(BufferView *, LyXFont const &) const;
|
||||
///
|
||||
int descent(BufferView *, LyXFont const &) const;
|
||||
///
|
||||
int width(BufferView *, LyXFont const &) const;
|
||||
void dimension(BufferView *, LyXFont const &, Dimension &) const;
|
||||
///
|
||||
void draw(BufferView *, LyXFont const &, int, float &) const;
|
||||
|
||||
|
@ -22,11 +22,9 @@
|
||||
#ifndef MATH_INSET_H
|
||||
#define MATH_INSET_H
|
||||
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "LString.h"
|
||||
#include "frontends/mouse_state.h"
|
||||
#include "insets/insetbase.h"
|
||||
#include "math_data.h"
|
||||
|
||||
|
@ -41,6 +41,7 @@ using lyx::pos_type;
|
||||
using std::endl;
|
||||
using std::ostream;
|
||||
|
||||
|
||||
void breakParagraph(BufferParams const & bparams,
|
||||
ParagraphList & paragraphs,
|
||||
ParagraphList::iterator par,
|
||||
|
Loading…
Reference in New Issue
Block a user