1 /* LIBGIMP - The GIMP Library 2 * Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball 3 * 4 * gimpunit.h 5 * Copyright (C) 1999-2003 Michael Natterer <mitch@gimp.org> 6 * 7 * This library is free software: you can redistribute it and/or 8 * modify it under the terms of the GNU Lesser General Public 9 * License as published by the Free Software Foundation; either 10 * version 3 of the License, or (at your option) any later version. 11 * 12 * This library is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 * Lesser General Public License for more details. 16 * 17 * You should have received a copy of the GNU Lesser General Public 18 * License along with this library. If not, see 19 * <https://www.gnu.org/licenses/>. 20 */ 21 22 #if !defined (__GIMP_BASE_H_INSIDE__) && !defined (GIMP_BASE_COMPILATION) 23 #error "Only <libgimpbase/gimpbase.h> can be included directly." 24 #endif 25 26 #ifndef __GIMP_UNIT_H__ 27 #define __GIMP_UNIT_H__ 28 29 G_BEGIN_DECLS 30 31 /* For information look into the C source or the html documentation */ 32 33 /** 34 * GIMP_TYPE_UNIT: 35 * 36 * #GIMP_TYPE_UNIT is a #GType derived from #G_TYPE_INT. 37 **/ 38 39 #define GIMP_TYPE_UNIT (gimp_unit_get_type ()) 40 #define GIMP_VALUE_HOLDS_UNIT(value) (G_TYPE_CHECK_VALUE_TYPE ((value), GIMP_TYPE_UNIT)) 41 42 GType gimp_unit_get_type (void) G_GNUC_CONST; 43 44 45 /* 46 * GIMP_TYPE_PARAM_UNIT 47 */ 48 49 #define GIMP_TYPE_PARAM_UNIT (gimp_param_unit_get_type ()) 50 #define GIMP_IS_PARAM_SPEC_UNIT(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), GIMP_TYPE_PARAM_UNIT)) 51 52 GType gimp_param_unit_get_type (void) G_GNUC_CONST; 53 54 GParamSpec * gimp_param_spec_unit (const gchar *name, 55 const gchar *nick, 56 const gchar *blurb, 57 gboolean allow_pixels, 58 gboolean allow_percent, 59 GimpUnit default_value, 60 GParamFlags flags); 61 62 63 64 gint gimp_unit_get_number_of_units (void); 65 gint gimp_unit_get_number_of_built_in_units (void) G_GNUC_CONST; 66 67 GimpUnit gimp_unit_new (gchar *identifier, 68 gdouble factor, 69 gint digits, 70 gchar *symbol, 71 gchar *abbreviation, 72 gchar *singular, 73 gchar *plural); 74 75 gboolean gimp_unit_get_deletion_flag (GimpUnit unit); 76 void gimp_unit_set_deletion_flag (GimpUnit unit, 77 gboolean deletion_flag); 78 79 gdouble gimp_unit_get_factor (GimpUnit unit); 80 81 gint gimp_unit_get_digits (GimpUnit unit); 82 gint gimp_unit_get_scaled_digits (GimpUnit unit, 83 gdouble resolution); 84 85 const gchar * gimp_unit_get_identifier (GimpUnit unit); 86 87 const gchar * gimp_unit_get_symbol (GimpUnit unit); 88 const gchar * gimp_unit_get_abbreviation (GimpUnit unit); 89 const gchar * gimp_unit_get_singular (GimpUnit unit); 90 const gchar * gimp_unit_get_plural (GimpUnit unit); 91 92 gchar * gimp_unit_format_string (const gchar *format, 93 GimpUnit unit); 94 95 gdouble gimp_pixels_to_units (gdouble pixels, 96 GimpUnit unit, 97 gdouble resolution); 98 gdouble gimp_units_to_pixels (gdouble value, 99 GimpUnit unit, 100 gdouble resolution); 101 gdouble gimp_units_to_points (gdouble value, 102 GimpUnit unit, 103 gdouble resolution); 104 105 gboolean gimp_unit_is_metric (GimpUnit unit); 106 107 108 G_END_DECLS 109 110 #endif /* __GIMP_UNIT_H__ */ 111