2003-08-23 00:17:00 +00:00
|
|
|
|
// -*- C++ -*-
|
|
|
|
|
/**
|
2007-04-26 04:41:58 +00:00
|
|
|
|
* \file MetricsInfo.h
|
2003-08-23 00:17:00 +00:00
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
|
*
|
|
|
|
|
* \author Andr<EFBFBD> P<EFBFBD>nitz
|
|
|
|
|
*
|
|
|
|
|
* Full author contact details are available in file CREDITS.
|
|
|
|
|
*/
|
|
|
|
|
|
2003-03-21 14:20:48 +00:00
|
|
|
|
#ifndef METRICSINFO_H
|
|
|
|
|
#define METRICSINFO_H
|
|
|
|
|
|
2007-04-26 04:41:58 +00:00
|
|
|
|
#include "LyXFont.h"
|
2006-09-13 21:13:49 +00:00
|
|
|
|
#include "support/docstring.h"
|
2006-10-22 10:15:23 +00:00
|
|
|
|
#include <string>
|
2003-03-21 14:20:48 +00:00
|
|
|
|
|
2003-05-28 13:22:36 +00:00
|
|
|
|
class BufferView;
|
2003-03-21 14:20:48 +00:00
|
|
|
|
|
2006-06-20 08:39:16 +00:00
|
|
|
|
namespace lyx {
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
|
|
namespace frontend { class Painter; }
|
2006-06-20 08:39:16 +00:00
|
|
|
|
|
2003-03-21 14:20:48 +00:00
|
|
|
|
|
|
|
|
|
/// Standard Sizes (mode styles)
|
|
|
|
|
enum Styles {
|
|
|
|
|
///
|
|
|
|
|
LM_ST_DISPLAY = 0,
|
|
|
|
|
///
|
|
|
|
|
LM_ST_TEXT,
|
|
|
|
|
///
|
|
|
|
|
LM_ST_SCRIPT,
|
|
|
|
|
///
|
|
|
|
|
LM_ST_SCRIPTSCRIPT
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
2003-09-09 18:27:24 +00:00
|
|
|
|
//
|
2003-03-21 14:20:48 +00:00
|
|
|
|
// This is the part common to MetricsInfo and PainterInfo
|
|
|
|
|
//
|
2005-01-19 15:03:31 +00:00
|
|
|
|
class MetricsBase {
|
|
|
|
|
public:
|
2003-03-21 14:20:48 +00:00
|
|
|
|
///
|
|
|
|
|
MetricsBase();
|
2003-07-17 09:10:16 +00:00
|
|
|
|
///
|
2003-07-18 07:47:07 +00:00
|
|
|
|
MetricsBase(BufferView * bv, LyXFont const & font, int textwidth);
|
2003-03-21 14:20:48 +00:00
|
|
|
|
|
2003-05-28 13:22:36 +00:00
|
|
|
|
/// the current view
|
|
|
|
|
BufferView * bv;
|
|
|
|
|
/// current font
|
2003-03-21 14:20:48 +00:00
|
|
|
|
LyXFont font;
|
2003-05-28 13:22:36 +00:00
|
|
|
|
/// current math style (display/text/script/..)
|
2003-03-21 14:20:48 +00:00
|
|
|
|
Styles style;
|
2003-07-25 19:18:43 +00:00
|
|
|
|
/// name of current font - mathed specific
|
2003-10-06 15:43:21 +00:00
|
|
|
|
std::string fontname;
|
2003-07-25 19:18:43 +00:00
|
|
|
|
/// This is the width available in pixels
|
2003-03-21 14:20:48 +00:00
|
|
|
|
int textwidth;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//
|
2004-04-08 16:07:20 +00:00
|
|
|
|
// This contains a MetricsBase and information that's only relevant during
|
2003-03-21 14:20:48 +00:00
|
|
|
|
// the first phase of the two-phase draw
|
|
|
|
|
//
|
2005-01-19 15:03:31 +00:00
|
|
|
|
class MetricsInfo {
|
|
|
|
|
public:
|
2003-03-21 14:20:48 +00:00
|
|
|
|
///
|
|
|
|
|
MetricsInfo();
|
2003-07-17 09:10:16 +00:00
|
|
|
|
///
|
2003-07-18 07:47:07 +00:00
|
|
|
|
MetricsInfo(BufferView * bv, LyXFont const & font, int textwidth);
|
2003-03-21 14:20:48 +00:00
|
|
|
|
|
|
|
|
|
///
|
|
|
|
|
MetricsBase base;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//
|
2004-04-08 16:07:20 +00:00
|
|
|
|
// This contains a MetricsBase and information that's only relevant during
|
2003-03-21 14:20:48 +00:00
|
|
|
|
// the second phase of the two-phase draw
|
|
|
|
|
//
|
2005-01-19 15:03:31 +00:00
|
|
|
|
class PainterInfo {
|
|
|
|
|
public:
|
2003-03-21 14:20:48 +00:00
|
|
|
|
///
|
2006-10-21 00:16:43 +00:00
|
|
|
|
PainterInfo(BufferView * bv, frontend::Painter & pain);
|
2003-03-21 14:20:48 +00:00
|
|
|
|
///
|
2006-10-21 00:16:43 +00:00
|
|
|
|
void draw(int x, int y, char_type c);
|
2005-07-17 10:31:44 +00:00
|
|
|
|
///
|
2006-10-21 00:16:43 +00:00
|
|
|
|
void draw(int x, int y, docstring const & str);
|
2003-03-21 14:20:48 +00:00
|
|
|
|
|
|
|
|
|
///
|
|
|
|
|
MetricsBase base;
|
|
|
|
|
///
|
2006-10-21 00:16:43 +00:00
|
|
|
|
frontend::Painter & pain;
|
2004-08-14 23:57:29 +00:00
|
|
|
|
/// Whether the text at this point is right-to-left (for InsetNewline)
|
|
|
|
|
bool ltr_pos;
|
2005-09-07 10:37:05 +00:00
|
|
|
|
/// Whether the parent is deleted (change tracking)
|
|
|
|
|
bool erased_;
|
2003-03-21 14:20:48 +00:00
|
|
|
|
};
|
|
|
|
|
|
2005-01-19 15:03:31 +00:00
|
|
|
|
class TextMetricsInfo {};
|
2003-03-21 14:20:48 +00:00
|
|
|
|
|
2007-01-20 01:23:07 +00:00
|
|
|
|
enum ScreenUpdateStrategy {
|
|
|
|
|
NoScreenUpdate,
|
|
|
|
|
SingleParUpdate,
|
|
|
|
|
FullScreenUpdate,
|
|
|
|
|
DecorationUpdate
|
|
|
|
|
};
|
|
|
|
|
|
2005-01-19 15:03:31 +00:00
|
|
|
|
class ViewMetricsInfo
|
2004-11-30 01:59:49 +00:00
|
|
|
|
{
|
2005-01-19 15:03:31 +00:00
|
|
|
|
public:
|
2006-07-04 00:04:46 +00:00
|
|
|
|
ViewMetricsInfo()
|
2007-01-20 01:23:07 +00:00
|
|
|
|
: p1(0), p2(0), y1(0), y2(0),
|
2007-01-20 08:43:51 +00:00
|
|
|
|
update_strategy(FullScreenUpdate), size(0)
|
2006-10-21 00:16:43 +00:00
|
|
|
|
{}
|
|
|
|
|
ViewMetricsInfo(pit_type p1, pit_type p2, int y1, int y2,
|
2007-01-20 01:23:07 +00:00
|
|
|
|
ScreenUpdateStrategy updatestrategy, pit_type size)
|
|
|
|
|
: p1(p1), p2(p2), y1(y1), y2(y2),
|
2007-01-20 08:43:51 +00:00
|
|
|
|
update_strategy(updatestrategy), size(size)
|
2006-10-21 00:16:43 +00:00
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
pit_type p1;
|
|
|
|
|
pit_type p2;
|
2004-11-30 01:59:49 +00:00
|
|
|
|
int y1;
|
|
|
|
|
int y2;
|
2007-01-20 01:23:07 +00:00
|
|
|
|
ScreenUpdateStrategy update_strategy;
|
2006-10-21 00:16:43 +00:00
|
|
|
|
pit_type size;
|
2004-11-30 01:59:49 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
2003-03-21 14:20:48 +00:00
|
|
|
|
// Generic base for temporarily changing things.
|
|
|
|
|
// The original state gets restored when the Changer is destructed.
|
|
|
|
|
|
|
|
|
|
template <class Struct, class Temp = Struct>
|
2005-01-19 15:03:31 +00:00
|
|
|
|
class Changer {
|
|
|
|
|
public:
|
2003-03-21 14:20:48 +00:00
|
|
|
|
///
|
|
|
|
|
Changer(Struct & orig) : orig_(orig) {}
|
|
|
|
|
protected:
|
|
|
|
|
///
|
|
|
|
|
Struct & orig_;
|
|
|
|
|
///
|
|
|
|
|
Temp save_;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// temporarily change some aspect of a font
|
2005-01-19 15:03:31 +00:00
|
|
|
|
class FontChanger : public Changer<LyXFont> {
|
|
|
|
|
public:
|
2003-03-21 14:20:48 +00:00
|
|
|
|
///
|
2006-10-22 10:15:23 +00:00
|
|
|
|
FontChanger(LyXFont & orig, docstring const & font);
|
|
|
|
|
FontChanger(MetricsBase & mb, char const * const font);
|
2003-03-21 14:20:48 +00:00
|
|
|
|
///
|
|
|
|
|
~FontChanger();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// temporarily change a full font
|
2005-01-19 15:03:31 +00:00
|
|
|
|
class FontSetChanger : public Changer<MetricsBase> {
|
|
|
|
|
public:
|
2003-03-21 14:20:48 +00:00
|
|
|
|
///
|
2006-10-22 10:15:23 +00:00
|
|
|
|
FontSetChanger(MetricsBase & mb, docstring const & font);
|
|
|
|
|
FontSetChanger(MetricsBase & mb, char const * const font);
|
2003-03-21 14:20:48 +00:00
|
|
|
|
///
|
|
|
|
|
~FontSetChanger();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// temporarily change the style
|
2005-01-19 15:03:31 +00:00
|
|
|
|
class StyleChanger : public Changer<MetricsBase> {
|
|
|
|
|
public:
|
2003-03-21 14:20:48 +00:00
|
|
|
|
///
|
|
|
|
|
StyleChanger(MetricsBase & mb, Styles style);
|
|
|
|
|
///
|
|
|
|
|
~StyleChanger();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// temporarily change the style to script style
|
2005-01-19 15:03:31 +00:00
|
|
|
|
class ScriptChanger : public StyleChanger {
|
|
|
|
|
public:
|
2003-03-21 14:20:48 +00:00
|
|
|
|
///
|
|
|
|
|
ScriptChanger(MetricsBase & mb);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// temporarily change the style suitable for use in fractions
|
2005-01-19 15:03:31 +00:00
|
|
|
|
class FracChanger : public StyleChanger {
|
|
|
|
|
public:
|
2003-03-21 14:20:48 +00:00
|
|
|
|
///
|
|
|
|
|
FracChanger(MetricsBase & mb);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// temporarily change the style suitable for use in tabulars and arrays
|
2005-01-19 15:03:31 +00:00
|
|
|
|
class ArrayChanger : public StyleChanger {
|
|
|
|
|
public:
|
2003-03-21 14:20:48 +00:00
|
|
|
|
///
|
|
|
|
|
ArrayChanger(MetricsBase & mb);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// temporarily change the shape of a font
|
2005-01-19 15:03:31 +00:00
|
|
|
|
class ShapeChanger : public Changer<LyXFont, LyXFont::FONT_SHAPE> {
|
|
|
|
|
public:
|
2003-03-21 14:20:48 +00:00
|
|
|
|
///
|
|
|
|
|
ShapeChanger(LyXFont & font, LyXFont::FONT_SHAPE shape);
|
|
|
|
|
///
|
|
|
|
|
~ShapeChanger();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// temporarily change the available text width
|
2005-01-19 15:03:31 +00:00
|
|
|
|
class WidthChanger : public Changer<MetricsBase>
|
2003-03-21 14:20:48 +00:00
|
|
|
|
{
|
2005-01-19 15:03:31 +00:00
|
|
|
|
public:
|
2003-03-21 14:20:48 +00:00
|
|
|
|
///
|
|
|
|
|
WidthChanger(MetricsBase & mb, int width);
|
|
|
|
|
///
|
|
|
|
|
~WidthChanger();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
2003-10-02 14:42:31 +00:00
|
|
|
|
// temporarily change the used color
|
2005-01-19 15:03:31 +00:00
|
|
|
|
class ColorChanger : public Changer<LyXFont, std::string> {
|
|
|
|
|
public:
|
2003-10-02 14:42:31 +00:00
|
|
|
|
///
|
2003-10-06 15:43:21 +00:00
|
|
|
|
ColorChanger(LyXFont & font, std::string const & color);
|
2003-10-02 14:42:31 +00:00
|
|
|
|
///
|
|
|
|
|
~ColorChanger();
|
|
|
|
|
};
|
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
} // namespace lyx
|
|
|
|
|
|
2003-03-21 14:20:48 +00:00
|
|
|
|
#endif
|