PIKApp/libpikabase/pikaunit.h

121 lines
4.6 KiB
C
Raw Normal View History

2023-09-26 00:35:21 +02:00
/* LIBPIKA - The PIKA Library
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
*
* pikaunit.h
* Copyright (C) 1999-2003 Michael Natterer <mitch@gimp.org>
*
* This library is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see
* <https://www.gnu.org/licenses/>.
*/
#if !defined (__PIKA_BASE_H_INSIDE__) && !defined (PIKA_BASE_COMPILATION)
#error "Only <libpikabase/pikabase.h> can be included directly."
#endif
#ifndef __PIKA_UNIT_H__
#define __PIKA_UNIT_H__
G_BEGIN_DECLS
/* For information look into the C source or the html documentation */
/**
* PIKA_TYPE_UNIT:
*
* #PIKA_TYPE_UNIT is a #GType derived from #G_TYPE_INT.
**/
#define PIKA_TYPE_UNIT (pika_unit_get_type ())
#define PIKA_VALUE_HOLDS_UNIT(value) (G_TYPE_CHECK_VALUE_TYPE ((value), PIKA_TYPE_UNIT))
GType pika_unit_get_type (void) G_GNUC_CONST;
/*
* PIKA_TYPE_PARAM_UNIT
*/
#define PIKA_TYPE_PARAM_UNIT (pika_param_unit_get_type ())
#define PIKA_PARAM_SPEC_UNIT(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), PIKA_TYPE_PARAM_UNIT, PikaParamSpecUnit))
#define PIKA_IS_PARAM_SPEC_UNIT(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), PIKA_TYPE_PARAM_UNIT))
typedef struct _PikaParamSpecUnit PikaParamSpecUnit;
struct _PikaParamSpecUnit
{
GParamSpecInt parent_instance;
gboolean allow_percent;
};
GType pika_param_unit_get_type (void) G_GNUC_CONST;
GParamSpec * pika_param_spec_unit (const gchar *name,
const gchar *nick,
const gchar *blurb,
gboolean allow_pixels,
gboolean allow_percent,
PikaUnit default_value,
GParamFlags flags);
gint pika_unit_get_number_of_units (void);
gint pika_unit_get_number_of_built_in_units (void) G_GNUC_CONST;
PikaUnit pika_unit_new (gchar *identifier,
gdouble factor,
gint digits,
gchar *symbol,
gchar *abbreviation,
gchar *singular,
gchar *plural);
gboolean pika_unit_get_deletion_flag (PikaUnit unit);
void pika_unit_set_deletion_flag (PikaUnit unit,
gboolean deletion_flag);
gdouble pika_unit_get_factor (PikaUnit unit);
gint pika_unit_get_digits (PikaUnit unit);
gint pika_unit_get_scaled_digits (PikaUnit unit,
gdouble resolution);
const gchar * pika_unit_get_identifier (PikaUnit unit);
const gchar * pika_unit_get_symbol (PikaUnit unit);
const gchar * pika_unit_get_abbreviation (PikaUnit unit);
const gchar * pika_unit_get_singular (PikaUnit unit);
const gchar * pika_unit_get_plural (PikaUnit unit);
gchar * pika_unit_format_string (const gchar *format,
PikaUnit unit);
gdouble pika_pixels_to_units (gdouble pixels,
PikaUnit unit,
gdouble resolution);
gdouble pika_units_to_pixels (gdouble value,
PikaUnit unit,
gdouble resolution);
gdouble pika_units_to_points (gdouble value,
PikaUnit unit,
gdouble resolution);
gboolean pika_unit_is_metric (PikaUnit unit);
G_END_DECLS
#endif /* __PIKA_UNIT_H__ */