2002-09-11 08:26:02 +00:00
|
|
|
// -*- C++ -*-
|
2002-12-01 22:59:25 +00:00
|
|
|
/**
|
2007-04-26 04:41:58 +00:00
|
|
|
* \file Dimension.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.
|
2002-09-11 08:26:02 +00:00
|
|
|
*
|
2008-11-14 15:58:50 +00:00
|
|
|
* \author André Pönitz
|
2002-09-11 08:26:02 +00:00
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
* Full author contact details are available in file CREDITS.
|
2002-09-11 08:26:02 +00:00
|
|
|
*/
|
|
|
|
|
2002-07-09 08:44:30 +00:00
|
|
|
#ifndef DIMENSION_H
|
|
|
|
#define DIMENSION_H
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
namespace lyx {
|
|
|
|
|
2002-09-11 08:26:02 +00:00
|
|
|
/// Simple wrapper around three ints
|
2005-01-18 14:15:57 +00:00
|
|
|
class Dimension {
|
2002-07-09 08:44:30 +00:00
|
|
|
public:
|
|
|
|
/// constructor
|
2020-11-19 11:24:04 +00:00
|
|
|
Dimension() = default;
|
2002-07-09 08:44:30 +00:00
|
|
|
/// initialize data
|
2003-05-27 13:55:03 +00:00
|
|
|
Dimension(int w, int a, int d) : wid(w), asc(a), des(d) {}
|
2020-11-19 11:24:04 +00:00
|
|
|
///
|
|
|
|
Dimension & operator=(Dimension const & dim) = default;
|
2002-07-09 08:44:30 +00:00
|
|
|
|
|
|
|
/// glue horizontally
|
|
|
|
void operator+=(Dimension const & dim);
|
|
|
|
/// set to empty box
|
2003-05-27 13:55:03 +00:00
|
|
|
void clear() { wid = asc = des = 0; }
|
2018-12-17 11:28:32 +00:00
|
|
|
/// check whether box is empty
|
|
|
|
bool empty() const { return wid == 0 && asc == 0 && des == 0; }
|
2002-07-09 08:44:30 +00:00
|
|
|
/// get height
|
2003-05-27 13:55:03 +00:00
|
|
|
int height() const { return asc + des; }
|
2002-07-09 08:44:30 +00:00
|
|
|
/// get ascent
|
2003-05-27 13:55:03 +00:00
|
|
|
int ascent() const { return asc; }
|
2002-07-11 11:27:24 +00:00
|
|
|
/// get descent
|
2003-05-27 13:55:03 +00:00
|
|
|
int descent() const { return des; }
|
2002-07-09 08:44:30 +00:00
|
|
|
/// get width
|
2003-05-27 13:55:03 +00:00
|
|
|
int width() const { return wid; }
|
2002-07-09 08:44:30 +00:00
|
|
|
|
2003-05-28 13:22:36 +00:00
|
|
|
/// add space for a frame
|
|
|
|
//void addFrame(int frame) const;
|
|
|
|
/// add space for bottom part of a frame
|
|
|
|
//void addFrameBottom(int frame) const;
|
|
|
|
|
2002-12-01 22:59:25 +00:00
|
|
|
public:
|
2003-05-19 17:03:12 +00:00
|
|
|
/// these are intentionally public as things like
|
|
|
|
///
|
2003-09-09 18:27:24 +00:00
|
|
|
/// dim.asc += 20;
|
2003-05-19 17:03:12 +00:00
|
|
|
///
|
|
|
|
/// are used all over the place and "hiding" those behind
|
|
|
|
///
|
|
|
|
/// dim.ascent(dim.ascent() + 20);
|
|
|
|
///
|
|
|
|
/// makes the code neither faster nor clearer
|
2002-07-09 08:44:30 +00:00
|
|
|
/// width
|
2020-11-19 11:24:04 +00:00
|
|
|
int wid = 0;
|
2002-07-09 08:44:30 +00:00
|
|
|
/// ascent
|
2020-11-19 11:24:04 +00:00
|
|
|
int asc = 0;
|
2002-07-09 08:44:30 +00:00
|
|
|
/// descent
|
2020-11-19 11:24:04 +00:00
|
|
|
int des = 0;
|
2002-07-09 08:44:30 +00:00
|
|
|
};
|
|
|
|
|
2005-05-31 14:40:30 +00:00
|
|
|
inline
|
|
|
|
bool operator==(Dimension const & a, Dimension const & b)
|
|
|
|
{
|
2020-11-19 11:24:04 +00:00
|
|
|
return a.wid == b.wid && a.asc == b.asc && a.des == b.des;
|
2006-11-28 15:15:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
inline
|
|
|
|
bool operator!=(Dimension const & a, Dimension const & b)
|
|
|
|
{
|
2020-11-19 11:24:04 +00:00
|
|
|
return !(a == b);
|
2005-05-31 14:40:30 +00:00
|
|
|
}
|
|
|
|
|
2007-10-11 09:59:01 +00:00
|
|
|
class Point {
|
|
|
|
public:
|
2020-11-19 11:24:04 +00:00
|
|
|
Point() = default;
|
2007-10-11 09:59:01 +00:00
|
|
|
Point(int x, int y);
|
|
|
|
|
2024-06-20 12:28:45 +00:00
|
|
|
int x = 0;
|
|
|
|
int y = 0;
|
2007-10-11 09:59:01 +00:00
|
|
|
};
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
} // namespace lyx
|
|
|
|
|
2002-07-09 08:44:30 +00:00
|
|
|
#endif
|