mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-26 06:15:16 +00:00
Fix bug 2884 and 3437:
* src/insets/insetbase.h: * src/insets/insetcollapsable.h: - make isFixedWidth (former insetcollapsable member) a member of insetbase. src/insets/insettext.h: - make border_ public (needed by insetcollapsable). src/insets/insettext.C (draw, drawSelection): - adjust drawing for fixed width insets * src/insets/insetcollapsable.C (metrics): - adjust dimension for fixed width insets src/insets/insetbox.C (metrics): - properly calculate metrics for fixed width insets. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@17879 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
2c0c3491d9
commit
bba7ac2a66
@ -357,6 +357,8 @@ public:
|
||||
/// if this inset has paragraphs should they be output all as default
|
||||
/// paragraphs with the default layout of the text class?
|
||||
virtual bool forceDefaultParagraphs(idx_type) const { return false; }
|
||||
/// Is the width forced to some value?
|
||||
virtual bool hasFixedWidth() const { return false; }
|
||||
|
||||
///
|
||||
virtual docstring const & getInsetName() const;
|
||||
|
@ -14,6 +14,7 @@
|
||||
|
||||
#include "insetbox.h"
|
||||
|
||||
#include "BufferView.h"
|
||||
#include "cursor.h"
|
||||
#include "dispatchresult.h"
|
||||
#include "debug.h"
|
||||
@ -25,6 +26,7 @@
|
||||
#include "lyxlex.h"
|
||||
#include "metricsinfo.h"
|
||||
#include "paragraph.h"
|
||||
#include "TextMetrics.h"
|
||||
|
||||
#include "support/translator.h"
|
||||
|
||||
@ -177,8 +179,13 @@ bool InsetBox::hasFixedWidth() const
|
||||
bool InsetBox::metrics(MetricsInfo & m, Dimension & dim) const
|
||||
{
|
||||
MetricsInfo mi = m;
|
||||
// first round in order to know the minimum size.
|
||||
InsetCollapsable::metrics(mi, dim);
|
||||
TextMetrics & tm = mi.base.bv->textMetrics(&text_);
|
||||
if (hasFixedWidth())
|
||||
mi.base.textwidth = params_.width.inPixels(m.base.textwidth);
|
||||
mi.base.textwidth =
|
||||
std::max(tm.width() + 2 * border_ + (int) (2.5 * TEXT_TO_INSET_OFFSET),
|
||||
params_.width.inPixels(m.base.textwidth));
|
||||
InsetCollapsable::metrics(mi, dim);
|
||||
bool const changed = dim_ != dim;
|
||||
dim_ = dim;
|
||||
|
@ -173,6 +173,8 @@ bool InsetCollapsable::metrics(MetricsInfo & mi, Dimension & dim) const
|
||||
} else {
|
||||
dim.des += textdim_.height() + TEXT_TO_BOTTOM_OFFSET;
|
||||
dim.wid = max(dim.wid, textdim_.wid);
|
||||
if (hasFixedWidth())
|
||||
dim.wid = max(dim.wid, mi.base.textwidth);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -98,8 +98,6 @@ protected:
|
||||
InsetBase * editXY(LCursor & cur, int x, int y);
|
||||
///
|
||||
void setInlined() { status_ = Inlined; }
|
||||
/// Is the width forced to some value?
|
||||
virtual bool hasFixedWidth() const { return false; }
|
||||
///
|
||||
docstring floatName(std::string const & type, BufferParams const &) const;
|
||||
|
||||
|
@ -198,8 +198,9 @@ void InsetText::draw(PainterInfo & pi, int x, int y) const
|
||||
int const w = tm.width() + 2 * border_;
|
||||
int const a = tm.ascent() + border_;
|
||||
int const h = a + tm.descent() + border_;
|
||||
pi.pain.rectangle(x, y - a, (wide() ? tm.maxWidth() : w), h,
|
||||
frameColor());
|
||||
pi.pain.rectangle(x, y - a,
|
||||
((wide() || hasFixedWidth()) ? tm.maxWidth() : w),
|
||||
h, frameColor());
|
||||
}
|
||||
}
|
||||
|
||||
@ -211,8 +212,9 @@ void InsetText::drawSelection(PainterInfo & pi, int x, int y) const
|
||||
int const w = tm.width() + 2 * border_;
|
||||
int const a = tm.ascent() + border_;
|
||||
int const h = a + tm.descent() + border_;
|
||||
pi.pain.fillRectangle(x, y - a, (wide() ? tm.maxWidth() : w), h,
|
||||
backgroundColor());
|
||||
pi.pain.fillRectangle(x, y - a,
|
||||
((wide() || hasFixedWidth()) ? tm.maxWidth() : w),
|
||||
h, backgroundColor());
|
||||
text_.drawSelection(pi, x + border_, y);
|
||||
}
|
||||
|
||||
|
@ -159,14 +159,14 @@ private:
|
||||
///
|
||||
mutable pit_type old_pit;
|
||||
///
|
||||
static int border_;
|
||||
///
|
||||
bool wide_inset_;
|
||||
public:
|
||||
///
|
||||
mutable LyXText text_;
|
||||
///
|
||||
mutable LyXFont font_;
|
||||
///
|
||||
static int border_;
|
||||
};
|
||||
|
||||
} // namespace lyx
|
||||
|
Loading…
Reference in New Issue
Block a user