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.
|
|
|
|
*
|
2008-11-14 15:58:50 +00:00
|
|
|
* \author André Pönitz
|
2007-11-01 11:13:07 +00:00
|
|
|
* \author Stefan Schimanski
|
2003-08-23 00:17:00 +00:00
|
|
|
*
|
|
|
|
* Full author contact details are available in file CREDITS.
|
|
|
|
*/
|
|
|
|
|
2003-03-21 14:20:48 +00:00
|
|
|
#ifndef METRICSINFO_H
|
|
|
|
#define METRICSINFO_H
|
|
|
|
|
2009-02-09 21:14:23 +00:00
|
|
|
#include "Changes.h"
|
2010-09-09 13:02:20 +00:00
|
|
|
#include "ColorCode.h"
|
2007-10-28 18:51:54 +00:00
|
|
|
#include "FontInfo.h"
|
2007-10-31 22:40:34 +00:00
|
|
|
|
|
|
|
#include "support/strfwd.h"
|
2016-05-23 21:30:23 +00:00
|
|
|
#include "support/Changer.h"
|
|
|
|
|
2016-12-12 00:17:41 +00:00
|
|
|
#include "insets/Inset.h"
|
|
|
|
|
2007-10-31 22:40:34 +00:00
|
|
|
|
2006-10-22 10:15:23 +00:00
|
|
|
#include <string>
|
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; }
|
2015-11-16 20:51:30 +00:00
|
|
|
class BufferView;
|
2018-01-05 18:59:31 +00:00
|
|
|
class Length;
|
2007-11-01 11:13:07 +00:00
|
|
|
class MacroContext;
|
2006-06-20 08:39:16 +00:00
|
|
|
|
2003-03-21 14:20:48 +00:00
|
|
|
|
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
|
|
|
///
|
2016-06-14 18:22:24 +00:00
|
|
|
MetricsBase(BufferView * bv = 0, FontInfo font = FontInfo(),
|
|
|
|
int textwidth = 0);
|
2003-03-21 14:20:48 +00:00
|
|
|
|
2003-05-28 13:22:36 +00:00
|
|
|
/// the current view
|
|
|
|
BufferView * bv;
|
|
|
|
/// current font
|
2007-10-28 18:51:54 +00:00
|
|
|
FontInfo font;
|
2023-11-02 16:54:02 +00:00
|
|
|
/// font of the containing inset
|
|
|
|
FontInfo outer_font;
|
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;
|
2016-11-14 17:01:56 +00:00
|
|
|
/// count wether the current mathdata is nested in macro(s)
|
|
|
|
int macro_nesting;
|
2016-05-23 21:30:23 +00:00
|
|
|
|
|
|
|
/// Temporarily change a full font.
|
2020-10-31 17:18:51 +00:00
|
|
|
Changer changeFontSet(std::string const & name);
|
2023-11-06 17:04:44 +00:00
|
|
|
/// Temporarily change font size in text mode, only record it in math mode.
|
|
|
|
Changer changeFontSize(std::string const & fontsize, bool mathmode);
|
2016-11-22 10:26:15 +00:00
|
|
|
/// Temporarily change the font to math if needed.
|
2016-12-12 00:17:41 +00:00
|
|
|
Changer changeEnsureMath(Inset::mode_type mode = Inset::MATH_MODE);
|
2016-05-23 21:30:23 +00:00
|
|
|
// Temporarily change to the style suitable for use in fractions
|
2016-11-20 18:53:16 +00:00
|
|
|
Changer changeFrac();
|
|
|
|
// Temporarily change to the style suitable for use in arrays
|
2019-07-15 11:36:28 +00:00
|
|
|
// or to style suitable for smallmatrix when \c small is true.
|
|
|
|
Changer changeArray(bool small = false);
|
2016-05-23 21:30:23 +00:00
|
|
|
// Temporarily change the style to (script)script style
|
2016-11-20 18:53:16 +00:00
|
|
|
Changer changeScript();
|
2016-05-22 21:48:28 +00:00
|
|
|
///
|
|
|
|
int solidLineThickness() const { return solid_line_thickness_; }
|
|
|
|
///
|
|
|
|
int solidLineOffset() const { return solid_line_offset_; }
|
|
|
|
///
|
|
|
|
int dottedLineThickness() const { return dotted_line_thickness_; }
|
2018-01-05 18:59:31 +00:00
|
|
|
/** return the on-screen size of this length
|
|
|
|
*
|
|
|
|
* This version of the function uses the current inset width as
|
|
|
|
* width and the EM value of the current font.
|
|
|
|
*/
|
|
|
|
int inPixels(Length const & len) const;
|
|
|
|
|
2016-05-22 21:48:28 +00:00
|
|
|
private:
|
|
|
|
int solid_line_thickness_;
|
|
|
|
int solid_line_offset_;
|
|
|
|
int dotted_line_thickness_;
|
2003-03-21 14:20:48 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
//
|
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
|
|
|
///
|
2016-05-22 21:48:28 +00:00
|
|
|
MetricsInfo(BufferView * bv, FontInfo font, int textwidth,
|
2020-07-14 21:28:43 +00:00
|
|
|
MacroContext const & mc, bool vm, bool tight_insets);
|
2003-03-21 14:20:48 +00:00
|
|
|
|
|
|
|
///
|
|
|
|
MetricsBase base;
|
2007-11-01 11:13:07 +00:00
|
|
|
/// The context to resolve macros
|
|
|
|
MacroContext const & macrocontext;
|
2020-08-25 11:05:29 +00:00
|
|
|
/// Are we at the start of a paragraph (vertical mode)?
|
|
|
|
bool vmode;
|
2020-07-14 21:28:43 +00:00
|
|
|
/// if true, do not expand insets to max width artificially
|
|
|
|
bool tight_insets;
|
2023-07-14 00:13:18 +00:00
|
|
|
/// Extra width required by an inset, in addition to its dimension
|
|
|
|
int extrawidth;
|
2003-03-21 14:20:48 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
//
|
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);
|
2020-06-05 20:32:58 +00:00
|
|
|
/// Determines the background color based on the
|
2017-07-03 17:45:58 +00:00
|
|
|
/// selection state, the background color inherited from the parent inset
|
2020-06-05 20:32:58 +00:00
|
|
|
/// and the inset's own background color (if one is specified).
|
2008-10-25 10:47:38 +00:00
|
|
|
/// \param sel whether to take the selection state into account
|
2020-06-05 20:32:58 +00:00
|
|
|
ColorCode backgroundColor(Inset const * inset = nullptr, bool sel = true) const;
|
2003-03-21 14:20:48 +00:00
|
|
|
|
2010-09-02 12:13:54 +00:00
|
|
|
/// Determines the text color based on the intended color, the
|
2017-07-03 17:45:58 +00:00
|
|
|
/// change tracking state and the selection state.
|
2010-09-02 12:13:54 +00:00
|
|
|
/// \param color what the color should be by default
|
|
|
|
Color textColor(Color const & color) const;
|
|
|
|
|
2003-03-21 14:20:48 +00:00
|
|
|
///
|
|
|
|
MetricsBase base;
|
|
|
|
///
|
2006-10-21 00:16:43 +00:00
|
|
|
frontend::Painter & pain;
|
2018-07-19 21:05:00 +00:00
|
|
|
/// Whether the text at this point is right-to-left (for insets)
|
2004-08-14 23:57:29 +00:00
|
|
|
bool ltr_pos;
|
2009-02-09 21:14:23 +00:00
|
|
|
/// The change the parent is part of (change tracking)
|
2020-01-14 10:50:44 +00:00
|
|
|
Change change;
|
2008-10-25 10:47:38 +00:00
|
|
|
/// Whether the parent is selected as a whole
|
|
|
|
bool selected;
|
2021-07-01 16:35:16 +00:00
|
|
|
/// Whether the left/right margins are selected
|
|
|
|
bool selected_left, selected_right;
|
2015-05-06 16:39:24 +00:00
|
|
|
/// Whether the spell checker is enabled for the parent
|
|
|
|
bool do_spellcheck;
|
2017-07-20 21:31:05 +00:00
|
|
|
/// True when it can be assumed that the screen has been cleared
|
2007-08-30 13:53:02 +00:00
|
|
|
bool full_repaint;
|
2008-10-25 10:47:38 +00:00
|
|
|
/// Current background color
|
2007-10-29 10:36:20 +00:00
|
|
|
ColorCode background_color;
|
2021-07-01 16:35:16 +00:00
|
|
|
/// The left and right position of current line (inside margins).
|
2019-04-02 09:05:19 +00:00
|
|
|
/// Useful for drawing display math numbering
|
|
|
|
int leftx, rightx;
|
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
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
} // namespace lyx
|
|
|
|
|
2003-03-21 14:20:48 +00:00
|
|
|
#endif
|