mirror of
https://git.lyx.org/repos/lyx.git
synced 2025-01-11 19:14:51 +00:00
several fixes concerning font size in scripts/fractions/etc
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@4865 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
5b3d1c64be
commit
06065364e5
@ -1332,7 +1332,7 @@ bool MathCursor::interpret(char c)
|
|||||||
// handle macroMode
|
// handle macroMode
|
||||||
if (inMacroMode()) {
|
if (inMacroMode()) {
|
||||||
string name = macroName();
|
string name = macroName();
|
||||||
lyxerr << "interpret name: '" << name << "'\n";
|
//lyxerr << "interpret name: '" << name << "'\n";
|
||||||
|
|
||||||
if (name.empty() && c == '\\') {
|
if (name.empty() && c == '\\') {
|
||||||
backspace();
|
backspace();
|
||||||
|
@ -441,7 +441,7 @@ void extractFunctions(MathArray & ar)
|
|||||||
// is it a function?
|
// is it a function?
|
||||||
if ((*it)->asUnknownInset()) {
|
if ((*it)->asUnknownInset()) {
|
||||||
// it certainly is if it is well known...
|
// it certainly is if it is well known...
|
||||||
name = (*it)->asUnknownInset()->name();
|
name = (*it)->name();
|
||||||
} else {
|
} else {
|
||||||
// is this a user defined function?
|
// is this a user defined function?
|
||||||
// it it probably not, if it doesn't have a name.
|
// it it probably not, if it doesn't have a name.
|
||||||
|
@ -62,8 +62,6 @@ class MathStringInset;
|
|||||||
class MathSpaceInset;
|
class MathSpaceInset;
|
||||||
class MathSymbolInset;
|
class MathSymbolInset;
|
||||||
class MathUnknownInset;
|
class MathUnknownInset;
|
||||||
class MathXYMatrixInset;
|
|
||||||
class MathXYMatrixInset;
|
|
||||||
|
|
||||||
class InsetRef;
|
class InsetRef;
|
||||||
|
|
||||||
@ -211,7 +209,6 @@ public:
|
|||||||
virtual MathSymbolInset const * asSymbolInset() const { return 0; }
|
virtual MathSymbolInset const * asSymbolInset() const { return 0; }
|
||||||
virtual MathUnknownInset * asUnknownInset() { return 0; }
|
virtual MathUnknownInset * asUnknownInset() { return 0; }
|
||||||
virtual MathUnknownInset const * asUnknownInset() const { return 0; }
|
virtual MathUnknownInset const * asUnknownInset() const { return 0; }
|
||||||
virtual MathXYMatrixInset const* asXYMatrixInset() const{ return 0; }
|
|
||||||
virtual InsetRef * asInsetRef() { return 0; }
|
virtual InsetRef * asInsetRef() { return 0; }
|
||||||
|
|
||||||
/// identifies things that can get scripts
|
/// identifies things that can get scripts
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
#include "math_metricsinfo.h"
|
#include "math_metricsinfo.h"
|
||||||
#include "math_support.h"
|
#include "math_support.h"
|
||||||
|
#include "debug.h"
|
||||||
#include "frontends/Painter.h"
|
#include "frontends/Painter.h"
|
||||||
|
|
||||||
|
|
||||||
@ -33,63 +34,48 @@ void MathPainterInfo::draw(int x, int y, char c)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
MathStyles smallerScriptStyle(MathStyles st)
|
||||||
|
{
|
||||||
|
switch (st) {
|
||||||
|
case LM_ST_DISPLAY:
|
||||||
|
case LM_ST_TEXT:
|
||||||
|
return LM_ST_SCRIPT;
|
||||||
|
case LM_ST_SCRIPT:
|
||||||
|
case LM_ST_SCRIPTSCRIPT:
|
||||||
|
return LM_ST_SCRIPTSCRIPT;
|
||||||
|
}
|
||||||
|
// shut up compiler
|
||||||
|
lyxerr << "should not happen\n";
|
||||||
|
return LM_ST_DISPLAY;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
MathScriptChanger::MathScriptChanger(MathMetricsBase & mb)
|
MathScriptChanger::MathScriptChanger(MathMetricsBase & mb)
|
||||||
: MathChanger<MathMetricsBase>(mb)
|
: MathStyleChanger(mb, smallerScriptStyle(mb.style))
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
MathStyles smallerFracStyle(MathStyles st)
|
||||||
{
|
{
|
||||||
save_ = mb;
|
switch (st) {
|
||||||
switch (mb.style) {
|
|
||||||
case LM_ST_DISPLAY:
|
case LM_ST_DISPLAY:
|
||||||
|
return LM_ST_TEXT;
|
||||||
case LM_ST_TEXT:
|
case LM_ST_TEXT:
|
||||||
mb.style = LM_ST_SCRIPT;
|
return LM_ST_SCRIPT;
|
||||||
mb.font.decSize();
|
|
||||||
mb.font.decSize();
|
|
||||||
break;
|
|
||||||
case LM_ST_SCRIPT:
|
case LM_ST_SCRIPT:
|
||||||
mb.style = LM_ST_SCRIPTSCRIPT;
|
case LM_ST_SCRIPTSCRIPT:
|
||||||
mb.font.decSize();
|
return LM_ST_SCRIPTSCRIPT;
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
// shut up compiler
|
||||||
|
lyxerr << "should not happen\n";
|
||||||
MathScriptChanger::~MathScriptChanger()
|
return LM_ST_DISPLAY;
|
||||||
{
|
|
||||||
orig_ = save_;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// decrease math size for fractions
|
|
||||||
MathFracChanger::MathFracChanger(MathMetricsBase & mb)
|
MathFracChanger::MathFracChanger(MathMetricsBase & mb)
|
||||||
: MathChanger<MathMetricsBase>(mb)
|
: MathStyleChanger(mb, smallerFracStyle(mb.style))
|
||||||
{
|
{}
|
||||||
save_ = mb;
|
|
||||||
switch (mb.style) {
|
|
||||||
case LM_ST_DISPLAY:
|
|
||||||
mb.style = LM_ST_TEXT;
|
|
||||||
break;
|
|
||||||
case LM_ST_TEXT:
|
|
||||||
mb.style = LM_ST_SCRIPT;
|
|
||||||
mb.font.decSize();
|
|
||||||
mb.font.decSize();
|
|
||||||
break;
|
|
||||||
case LM_ST_SCRIPT:
|
|
||||||
mb.style = LM_ST_SCRIPTSCRIPT;
|
|
||||||
mb.font.decSize();
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
MathFracChanger::~MathFracChanger()
|
|
||||||
{
|
|
||||||
orig_ = save_;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -108,22 +94,22 @@ MathShapeChanger::~MathShapeChanger()
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void changeSize(LyXFont & font, int diff)
|
|
||||||
{
|
|
||||||
if (diff < 0) {
|
|
||||||
font.decSize();
|
|
||||||
changeSize(font, diff + 1);
|
|
||||||
} else if (diff > 0) {
|
|
||||||
font.incSize();
|
|
||||||
changeSize(font, diff - 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
MathStyleChanger::MathStyleChanger(MathMetricsBase & mb, MathStyles style)
|
MathStyleChanger::MathStyleChanger(MathMetricsBase & mb, MathStyles style)
|
||||||
: MathChanger<MathMetricsBase>(mb)
|
: MathChanger<MathMetricsBase>(mb)
|
||||||
{
|
{
|
||||||
|
static const int diff[4][4] = { { 0, 0, -3, -5 },
|
||||||
|
{ 0, 0, -3, -5 },
|
||||||
|
{ 3, 3, 0, -2 },
|
||||||
|
{ 5, 5, 2, 0 } };
|
||||||
save_ = mb;
|
save_ = mb;
|
||||||
changeSize(mb.font, mb.style - style);
|
int t = diff[mb.style][style];
|
||||||
|
if (t > 0)
|
||||||
|
while (t--)
|
||||||
|
mb.font.incSize();
|
||||||
|
else
|
||||||
|
while (t++)
|
||||||
|
mb.font.decSize();
|
||||||
|
mb.style = style;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -79,23 +79,6 @@ protected:
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
struct MathScriptChanger : public MathChanger<MathMetricsBase> {
|
|
||||||
///
|
|
||||||
MathScriptChanger(MathMetricsBase & orig);
|
|
||||||
///
|
|
||||||
~MathScriptChanger();
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
struct MathFracChanger : public MathChanger<MathMetricsBase> {
|
|
||||||
///
|
|
||||||
MathFracChanger(MathMetricsBase & orig);
|
|
||||||
///
|
|
||||||
~MathFracChanger();
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
struct MathFontChanger : public MathChanger<LyXFont> {
|
struct MathFontChanger : public MathChanger<LyXFont> {
|
||||||
///
|
///
|
||||||
MathFontChanger(LyXFont & orig, char const * font);
|
MathFontChanger(LyXFont & orig, char const * font);
|
||||||
@ -120,6 +103,18 @@ struct MathStyleChanger : public MathChanger<MathMetricsBase> {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
struct MathScriptChanger : public MathStyleChanger {
|
||||||
|
///
|
||||||
|
MathScriptChanger(MathMetricsBase & mb);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
struct MathFracChanger : public MathStyleChanger {
|
||||||
|
///
|
||||||
|
MathFracChanger(MathMetricsBase & mb);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
struct MathShapeChanger : public MathChanger<LyXFont, LyXFont::FONT_SHAPE> {
|
struct MathShapeChanger : public MathChanger<LyXFont, LyXFont::FONT_SHAPE> {
|
||||||
///
|
///
|
||||||
MathShapeChanger(LyXFont & font, LyXFont::FONT_SHAPE shape);
|
MathShapeChanger(LyXFont & font, LyXFont::FONT_SHAPE shape);
|
||||||
|
@ -184,8 +184,10 @@ int MathScriptInset::ndes() const
|
|||||||
|
|
||||||
void MathScriptInset::metrics(MathMetricsInfo & mi) const
|
void MathScriptInset::metrics(MathMetricsInfo & mi) const
|
||||||
{
|
{
|
||||||
MathNestInset::metrics(mi);
|
cell(2).metrics(mi);
|
||||||
MathScriptChanger dummy(mi.base);
|
MathScriptChanger dummy(mi.base);
|
||||||
|
cell(0).metrics(mi);
|
||||||
|
cell(1).metrics(mi);
|
||||||
dim_.w = 0;
|
dim_.w = 0;
|
||||||
if (hasLimits()) {
|
if (hasLimits()) {
|
||||||
dim_.w = nwid();
|
dim_.w = nwid();
|
||||||
|
Loading…
Reference in New Issue
Block a user