Test change - can I push OK?
[kdeedu-porting.git] / kalzium / src / kalziumutils.h
blob5b6aa9060f3bc86a4419ea6d1ed0ee4377aa4b53
1 #ifndef KALZIUMUTILS_H
2 #define KALZIUMUTILS_H
4 /***************************************************************************
5 copyright : (C) 2005, 2006 by Carsten Niehaus
6 email : cniehaus@kde.org
7 ***************************************************************************/
8 /***************************************************************************
9 * *
10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. *
14 * *
15 ***************************************************************************/
17 class QString;
18 class QRect;
19 class QFont;
20 class QPainter;
21 class Element;
23 #include <chemicaldataobject.h>
25 class KalziumUtils
27 public:
28 /**
29 * @param string the string which is measured
30 * @param rect the rect needed for measurement
31 * @param font the used font
32 * @param painter the used painter
33 * @param maxFontSize the maximum fontsize
34 * @param minFontSize the maximum fontsize
36 static int maxSize( const QString& string, const QRect& rect, QFont font, QPainter* painter, int minFontSize = 4, int maxFontSize = 20 );
38 /**
39 * calculate the 4-digit value of the value @p w. For
40 * example, 12.3456 will be returned as 12.35
41 * @param value the value which will be stripped
42 * @return the 4-digit value
44 static double strippedValue( double value );
46 /**
47 * @param string the string which is measured
48 * @param font the used font
49 * @param painter the used painter
50 * @return the width of the string @p string
52 static int StringWidth( const QString& string, const QFont& font, QPainter* painter );
53 /**
54 * @param string the string which is measured
55 * @param font the used font
56 * @param painter the used painter
57 * @return the height of the string @p string
59 static int StringHeight( const QString& string, const QFont& font, QPainter* painter );
61 /**
62 * An almost standard way to get an unit well converted for
63 * displaying including (eventual) unit.
64 * @param el the element
65 * @param kind the unit we want to print of the element @p el
66 * @return the formatted string
68 static QString prettyUnit( const Element* el, ChemicalDataObject::BlueObelisk kind );
71 #endif // KALZIUMUTILS_H