/* a text button in a workspace
 */

/*

	Copyright (C) 1991-2003 The National Gallery

	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.

	This program 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 General Public License for more details.

	You should have received a copy of the GNU General Public License along
	with this program; if not, write to the Free Software Foundation, Inc.,
	51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA

 */

/*

	These files are distributed with VIPS - http://www.vips.ecs.soton.ac.uk

 */

#define ITEXT_TYPE (itext_get_type())
#define ITEXT(obj) \
	(G_TYPE_CHECK_INSTANCE_CAST((obj), ITEXT_TYPE, iText))
#define ITEXT_CLASS(klass) \
	(G_TYPE_CHECK_CLASS_CAST((klass), ITEXT_TYPE, iTextClass))
#define IS_ITEXT(obj) \
	(G_TYPE_CHECK_INSTANCE_TYPE((obj), ITEXT_TYPE))
#define IS_ITEXT_CLASS(klass) \
	(G_TYPE_CHECK_CLASS_TYPE((klass), ITEXT_TYPE))
#define ITEXT_GET_CLASS(obj) \
	(G_TYPE_INSTANCE_GET_CLASS((obj), ITEXT_TYPE, iTextClass))

struct _iText {
	Heapmodel parent_class;

	VipsBuf value;		   /* The value displayed as a [char] */
	char *formula;		   /* The formula we edit */
	char *formula_default; /* Formula we inherit */
	VipsBuf decompile;	   /* The value decompiled to a [char] */

	/* TRUE if the formula has been entered by the user and should be
	 * saved.
	 *
	 * Can't use classmodel edited, as text must inherit from heapmodel.
	 * Some duplication of code ... see itext_clear_edited()
	 */
	gboolean edited;
};

typedef struct _iTextClass {
	HeapmodelClass parent_class;

	/* My methods.
	 */
} iTextClass;

GType itext_get_type(void);
iText *itext_new(Rhs *rhs);

gboolean itext_value(Reduce *rc, VipsBuf *buf, PElement *root);
void itext_value_ev(Reduce *rc, VipsBuf *buf, PElement *root);
gboolean itext_make_value_string(Expr *expr, VipsBuf *buf);
gboolean itext_make_decompiled_string(Expr *expr, VipsBuf *buf);

void itext_set_edited(iText *text, gboolean edited);
gboolean itext_set_formula(iText *text, const char *formula);
