• Main Page
  • Related Pages
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

ut_units.h

Go to the documentation of this file.
00001 /* AbiSource Program Utilities
00002  * Copyright (C) 1998 AbiSource, Inc.
00003  *
00004  * This program is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU General Public License
00006  * as published by the Free Software Foundation; either version 2
00007  * of the License, or (at your option) any later version.
00008  *
00009  * This program is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software
00016  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
00017  * 02110-1301 USA.
00018  */
00019 
00020 #ifndef UT_UNITS_H
00021 #define UT_UNITS_H
00022 
00023 /* pre-emptive dismissal; ut_types.h is needed by just about everything,
00024  * so even if it's commented out in-file that's still a lot of work for
00025  * the preprocessor to do...
00026  */
00027 #ifndef UT_TYPES_H
00028 #include "ut_types.h"
00029 #endif
00030 
00031 G_BEGIN_DECLS
00032 
00033 #define UT_PAPER_UNITS_PER_INCH             100
00034 /* Units of UT_LAYOUT_RESOLUTION = dots per inch */
00035 #define UT_LAYOUT_RESOLUTION                1440
00036 
00037 /* 2^31 -1 */
00038 
00039 #define UT_INT_MAX 2147483647
00040 
00041 enum UT_Dimension {
00042   DIM_IN,
00043   DIM_CM,
00044   DIM_MM,
00045   DIM_PI,
00046   DIM_PT,
00047   DIM_PX,
00048   DIM_PERCENT,
00049   DIM_STAR,
00050   DIM_none
00051 };
00052 
00053 /*
00054  *  DIM_IN := inches
00055  *  DIM_CM := centimeters
00056  *  DIM_MM := millimeters
00057  *  DIM_PI := picas
00058  *  DIM_PT := points
00059  *  DIM_PX := pixels
00060  */
00061 
00062 ABI_EXPORT double UT_convertToInches(const char* s);
00063 ABI_EXPORT double UT_convertDimToInches (double f, UT_Dimension dim);
00064 ABI_EXPORT double UT_convertDimensions(double f, UT_Dimension from, UT_Dimension to);
00065 ABI_EXPORT double UT_convertToPoints(const char* s);
00066 ABI_EXPORT double UT_convertToDimension(const char* s, UT_Dimension dim);
00067 ABI_EXPORT UT_sint32 UT_convertToLogicalUnits(const char* s);
00068 ABI_EXPORT UT_sint32 UT_convertSizeToLayoutUnits(double Value, UT_Dimension dim);
00069 ABI_EXPORT double UT_convertDimensionless(const char * sz);
00070 ABI_EXPORT double UT_convertInchesToDimension(double inches, UT_Dimension dim);
00071 
00072 ABI_EXPORT UT_sint32 UT_paperUnits(const char * sz);
00073 ABI_EXPORT double    UT_inchesFromPaperUnits(UT_sint32 iPaperUnits);
00074 ABI_EXPORT UT_sint32 UT_paperUnitsFromInches(double dInches);
00075 
00076 ABI_EXPORT const char * UT_incrementDimString(const char * dimString, double inc);
00077 ABI_EXPORT const char * UT_multiplyDimString(const char * dimString, double mult);
00078 ABI_EXPORT UT_Dimension UT_determineDimension(const char * sz, UT_Dimension fallback = DIM_IN);
00079 ABI_EXPORT const char * UT_dimensionName(UT_Dimension dim);
00080 ABI_EXPORT const char * UT_convertInchesToDimensionString(UT_Dimension, double valueInInches, const char * szPrecision = NULL);
00081 ABI_EXPORT const char * UT_formatDimensionString(UT_Dimension, double value, const char * szPrecision = NULL);
00082 ABI_EXPORT const char * UT_reformatDimensionString(UT_Dimension dim, const char *sz, const char * szPrecision = NULL);
00083 ABI_EXPORT const char * UT_convertToDimensionlessString(double value, const char * szPrecision = NULL);
00084 ABI_EXPORT const char * UT_formatDimensionedValue(double value, const char * szUnits, const char * szPrecision = NULL);
00085 
00086 ABI_EXPORT bool UT_hasDimensionComponent(const char * sz);
00087 ABI_EXPORT bool UT_isValidDimensionString(const char * sz, size_t max_length = 0);
00088 
00089 ABI_EXPORT UT_uint32 UT_getDimensionPrecisicion (UT_Dimension dim);
00090 ABI_EXPORT double UT_getDimensionResolution (UT_Dimension dim);
00091 ABI_EXPORT double UT_convertFraction(const char * sz);
00092 
00093 G_END_DECLS
00094 
00095 #endif /* UT_UNITS_H */

Generated on Sun Feb 14 2021 for AbiWord by  doxygen 1.7.1