/*
 * Copyright 1990 by Baylor College of Medicine ALL RIGHTS RESERVED. 
 *
 * This program is subject to a license agreement between 
 * Baylor College of Medicine and MIT. Any use inconsistent with
 * said license and any use by persons other than the faculty, 
 * students and staff at MIT or any use on a computer not operated 
 * as part of the Athena Computing Environment (ACE) is expressly 
 * prohibited.
 */
#include <Xm/Xm.h>
#include <X11/StringDefs.h>

#include "VnsP.h"
#include "props.h"

static
void
update_text(prop,obj)
	VnsProp prop;
	VnsObject *obj;
{
	VnsPropSetColor(obj->info.data.t_info.color);
	VnsPropSetFont(obj->info.data.t_info.font);
}

static
void
modify_text(prop,obj)
	VnsProp prop;
	VnsObject *obj;
{
	XFontStruct *font;
	char *color_name;
	char *font_name;
	long col;

	color_name = VnsPropGetColor();
	font_name = VnsPropGetFont();

	/* update specific object info */
	strcpy(obj->info.data.t_info.color,color_name);
	strcpy(obj->info.data.t_info.font,font_name);

	/* modify the database */
	srv_modify_object(ObjectToSrv(obj),obj->parent->parent->nid,obj->parent->pid,obj->oid,&obj->info);

	/* modifiy the foreground color and font for the displayed text object */
	col = VnsAllocNamedColor(ObjectToVns(obj),color_name);
	VtSetForeColor(obj->owd,col);
	font = alloc_named_font(ObjectToVns(obj),font_name);
	XtVaSetValues(obj->auxil.txt.wd,
		XtNfont,font,
		NULL);
}

init_text_props(vns)
	VnsContext *vns;
{
	VnsProp prop;

	prop = VnsPropCreate(vns,"Text Object",VNS_OBJECT,OT_TXT);
	VnsPropAddColor(prop);
	VnsPropAddFonts(prop);
	VnsPropAddUpdate(prop,update_text);
	VnsPropAddModify(prop,modify_text);
}
