summaryrefslogtreecommitdiffstats
path: root/kalzium/src/kalziumutils.h
blob: f8feb10b17e7246c8bc8cb0592fb5f9605283008 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#ifndef KALZIUMUTILS_H
#define KALZIUMUTILS_H

/***************************************************************************
    copyright            : (C) 2005 by Carsten Niehaus
    email                : cniehaus@kde.org
 ***************************************************************************/
/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

class QString;
class QRect;
class QFont;
class QPainter;

class KalziumUtils
{
	public:

		enum FormatOptions { NoOptions,
				     Round = 1
				   };	
		/**
		 * @param string the string which is measured
		 * @param rect the rect needed for measurement
		 * @param font the used font
		 * @param painter the used painter
		 * @param maxFontSize the maximum fontsize
		 * @param minFontSize the maximum fontsize
		 */
		static int maxSize( const TQString& string, const TQRect& rect, TQFont font, TQPainter* painter, int minFontSize = 4, int maxFontSize = 20 );

		/**
		 * calculate the 4-digit value of the value @p w. For 
		 * example, 12.3456 will be returned as 12.35
		 * @param value the value which will be stripped
		 * @return the 4-digit value
		 */
		static double strippedValue( double value );

		/**
		 * format the given double with localized separators
		 * @param val the number value as double
		 * @param precision number of decimals
		 * @param options the options used for formatting of @p val
		 * @return
		 */
		static TQString localizedValue( double val, int precision, unsigned long options = 0   );

		/**
		 * @param string the string which is measured
		 * @param font the used font
		 * @param painter the used painter
		 * @return the width of the string @p string
		 */
		static int StringWidth( const TQString& string, const TQFont& font, TQPainter* painter );
		/**
		 * @param string the string which is measured
		 * @param font the used font
		 * @param painter the used painter
		 * @return the height of the string @p string
		 */
		static int StringHeight( const TQString& string, const TQFont& font, TQPainter* painter );
};

#endif // KALZIUMUTILS_H