/* a row in a workspace ... part of a subcolumn
 */

/*

	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 ROW_TYPE (row_get_type())
#define ROW(obj) \
	(G_TYPE_CHECK_INSTANCE_CAST((obj), ROW_TYPE, Row))
#define ROW_CLASS(klass) \
	(G_TYPE_CHECK_CLASS_CAST((klass), ROW_TYPE, RowClass))
#define IS_ROW(obj) \
	(G_TYPE_CHECK_INSTANCE_TYPE((obj), ROW_TYPE))
#define IS_ROW_CLASS(klass) \
	(G_TYPE_CHECK_CLASS_TYPE((klass), ROW_TYPE))
#define ROW_GET_CLASS(obj) \
	(G_TYPE_INSTANCE_GET_CLASS((obj), ROW_TYPE, RowClass))

/* For when we're flashing the showstate up.
 */
typedef enum {
	ROW_SHOW_NONE,
	ROW_SHOW_PARENT,
	ROW_SHOW_CHILD
} RowShowState;

struct _Row {
	Heapmodel parent_class;

	/* Our context.
	 */
	Rhs *child_rhs;	 /* Child RHS */
	Workspace *ws;	 /* Enclosing workspace */
	Row *top_row;	 /* Enclosing root row */

	Symbol *sym; /* Symbol we represent */

	Expr *expr;	  /* The expr we edit */
	gboolean err; /* Set if this row is on the error list */

	gboolean selected; /* Selected or not */
	gboolean is_class; /* Display spin buttons */
	gboolean popup;	   /* Set to pop up view on 1st display */
	gboolean to_save;  /* Should be saved (part of only-save-modded) */

	GSList *parents;	 /* rows which depend on us */
	GSList *children;	 /* rows we depend on */
	gboolean dirty;		 /* If we're marked for recomp */
	GSList *recomp;		 /* If root of class display, subs to recomp */
	GSList *recomp_save; /* Previous recomp list */

	gboolean depend; /* For spotting dependency loops */

	RowShowState show; /* For showing parent/child stuff */
};

typedef struct _RowClass {
	HeapmodelClass parent_class;

	/* My methods.
	 */
} RowClass;

const char *row_name(Row *row);
void row_qualified_name_relative(Symbol *context, Row *row, VipsBuf *buf);
void row_qualified_name(Row *row, VipsBuf *buf);
void *row_name_print(Row *row);
Subcolumn *row_get_subcolumn(Row *row);
Column *row_get_column(Row *row);

void row_error_set(Row *row);
void row_error_clear(Row *row);

Workspace *row_get_workspace(Row *row);

GType row_get_type(void);
void row_link_symbol(Row *row, Symbol *sym, PElement *root);
Row *row_new(Subcolumn *scol, Symbol *sym, PElement *root);

void *row_dirty(Row *row, gboolean clear_dirty);
void *row_dirty_intrans(Row *row, gboolean clear_dirty);

void row_recomp(Row *row);

void *row_is_selected(Row *row);
void *row_deselect(Row *row);
void *row_select_ensure(Row *row);
void *row_select(Row *row);
void *row_select_extend(Row *row);
void *row_select_toggle(Row *row);
void row_select_modifier(Row *row, GdkModifierType modifers);

void row_show_dependents(Row *row);
void row_hide_dependents(Row *row);

Row *row_parse_name(Symbol *context, const char *path);

gboolean row_copy_value(Row *row, VipsBuf *buf);
