예제 #1
0
파일: screen_objs.c 프로젝트: nasa/QuIP
Screen_Obj *_mk_menu(QSP_ARG_DECL  Screen_Obj *mip)
{
	Screen_Obj *mp;

	char buf[BUF_LEN];

	mp=dup_so(QSP_ARG  mip);
	givbuf((void *)SOB_NAME(mp));

	/* append colon to name */
	strcpy(buf,SOB_NAME(mip));
	strcat(buf,COL_STR);
	SET_SOB_NAME(mp,buf);

#ifdef QUIP_DEBUG
if( debug ) fprintf(stderr,"Making menu \"%s\"\n",SOB_NAME(mp));
#endif /* QUIP_DEBUG */

	make_menu(QSP_ARG  mp,mip);

	get_menu_items(mp);

#ifdef QUIP_DEBUG
if( debug ) fprintf(stderr,"make_menu:  back from get_menu_items (menu %s)\n",
SOB_NAME(mp));
#endif /* QUIP_DEBUG */
	SET_SOB_TYPE(mp, SOT_MENU);
	return(mp);
}
예제 #2
0
파일: screen_objs.c 프로젝트: nasa/QuIP
void fix_names(QSP_ARG_DECL  Screen_Obj *mip,Screen_Obj *parent)
{
	char buf[BUF_LEN];

	SET_SOB_SELECTOR(mip,savestr(SOB_NAME(mip)) );
	strcpy(buf,SOB_NAME(parent));
	strcat(buf,".");
	strcat(buf,SOB_SELECTOR(mip));

	//rename_item(QSP_ARG  scrnobj_itp,mip,buf);
}
예제 #3
0
파일: screen_objs.c 프로젝트: nasa/QuIP
static void add_choice_to_picker(QSP_ARG_DECL  Screen_Obj *sop, const char *s)
{
	const char **new_selectors;
	int i, n;

	assert( SOB_TYPE(sop) == SOT_PICKER );
	if( insist_one_component(sop, "add_choice_to_picker") < 0 ) return;

	if( insist_choice_not_present(SOB_SELECTORS_AT_IDX(sop,0),SOB_N_SELECTORS_AT_IDX(sop,0),s,
			SOB_NAME(sop),"add_choice_to_picker") < 0 )
		return;

	n = 1 + SOB_N_SELECTORS_AT_IDX( sop, 0 );
	new_selectors = (const char **)getbuf( n * sizeof(char **) );

	i=0;
	if( SOB_N_SELECTORS_AT_IDX(sop,0) > 0 ){
		assert( SOB_SELECTORS_AT_IDX(sop,0) != NULL );
		for(;i<SOB_N_SELECTORS_AT_IDX(sop,0);i++)
			new_selectors[i] = SOB_SELECTOR_AT_IDX(sop,0,i);
		givbuf(SOB_SELECTORS_AT_IDX(sop,0));
	} else {
		assert( SOB_SELECTORS_AT_IDX(sop,0) == NULL );
	}

	new_selectors[i] = savestr(s);
	SET_SOB_N_SELECTORS_AT_IDX( sop, 0, n );
	SET_SOB_SELECTORS_AT_IDX(sop, 0, new_selectors );
}
예제 #4
0
파일: screen_objs.c 프로젝트: nasa/QuIP
static inline void add_choice_to_chooser(QSP_ARG_DECL  Screen_Obj *sop, const char *s)
{
	int i, n;
	const char **new_string_arr;
	
	assert( SOB_N_SELECTORS(sop) >= 0 );

	// first make sure that this choice is not already present...
	if( insist_choice_not_present(SOB_SELECTORS(sop),SOB_N_SELECTORS(sop),s,SOB_NAME(sop),"add_choice_to_chooser") < 0 )
		return;

	n = SOB_N_SELECTORS(sop) + 1;
	new_string_arr = getbuf( n * sizeof(char *) );

	i=0;
	if( SOB_N_SELECTORS(sop) > 0 ){
		assert( SOB_SELECTORS(sop) != NULL );
		for(;i<SOB_N_SELECTORS(sop);i++)
			new_string_arr[i] = SOB_SELECTORS(sop)[i];
		givbuf(SOB_SELECTORS(sop));	// release old string table
	} else {
		assert( SOB_SELECTORS(sop) == NULL );
	}
		
	new_string_arr[i] = savestr(s);
	SET_SOB_N_SELECTORS(sop,n);
	SET_SOB_SELECTORS(sop,new_string_arr);
}
예제 #5
0
파일: motif.c 프로젝트: E-LLP/QuIP
static void push_widget_context(QSP_ARG_DECL  Screen_Obj *sop)
{

	int n;
	Item_Context *icp;
	char *ctx_name;

	icp = current_scrnobj_context(SINGLE_QSP_ARG);
	assert( icp != NULL );
	n = 2 + strlen( CTX_NAME(icp) ) + strlen( SOB_NAME(sop) );
	ctx_name = getbuf(n);
	sprintf(ctx_name,"%s.%s",CTX_NAME(icp),SOB_NAME(sop) );
	icp = create_scrnobj_context(QSP_ARG  ctx_name );
	givbuf(ctx_name);
	push_scrnobj_context(QSP_ARG  icp);
}
예제 #6
0
파일: screen_objs.c 프로젝트: nasa/QuIP
static inline int insist_one_component(QSP_ARG_DECL  Screen_Obj *sop, const char *whence)
{
	if( SOB_N_CYLINDERS(sop) != 1 ){
		sprintf(ERROR_STRING,
			"%s:  picker %s has more than one component (%d)",
			whence,SOB_NAME(sop),SOB_N_CYLINDERS(sop));
		WARN(ERROR_STRING);
		return -1;
	}
	return 0;
}
예제 #7
0
파일: screen_objs.c 프로젝트: nasa/QuIP
void so_info(Screen_Obj *sop)
{
	if( sop==NULL ) return;

	printf("%s\t\t%s\n",SOB_NAME(sop),WIDGET_TYPE_NAME(sop));
	if( SOB_SELECTOR(sop) != NULL )
		printf("\tselector:\t%s\n",SOB_SELECTOR(sop));
	if( SOB_ACTION(sop) != NULL )
		printf("\taction text:\t%s\n",SOB_ACTION(sop));
	if( WIDGET_PANEL(sop) != NULL )
		printf("\tpanel:\t%s\n",PO_NAME(WIDGET_PANEL(sop)));
	/* else printf("no frame object; this must be a frame itself\n"); */
}
예제 #8
0
파일: screen_objs.c 프로젝트: nasa/QuIP
static inline Screen_Obj *pick_chooser_or_picker(SINGLE_QSP_ARG_DECL)
{
	Screen_Obj *sop;

	sop = pick_scrnobj("name of chooser or picker");
	if( sop == NULL ) return NULL;

	if( SOB_TYPE(sop) == SOT_CHOOSER ) return sop;
	if( SOB_TYPE(sop) == SOT_PICKER ) return sop;

	sprintf(ERROR_STRING,"Object %s is not a chooser or picker!?",SOB_NAME(sop));
	WARN(ERROR_STRING);

	return NULL;
}
예제 #9
0
파일: screen_objs.c 프로젝트: nasa/QuIP
void show_panel_children(Panel_Obj *po)
{
	Node *np;
	Screen_Obj *sop;

	np=QLIST_HEAD(PO_CHILDREN(po));
	while(np!=NULL){
		sop=(Screen_Obj *)np->n_data;
		if( sop != NULL ){
			sprintf(ERROR_STRING,"\t%s",SOB_NAME(sop));
			advise(ERROR_STRING);
		} else {
			advise("\tnull screen_obj!?");
		}
		np=np->n_next;
	}
}
예제 #10
0
파일: screen_objs.c 프로젝트: nasa/QuIP
Screen_Obj *dup_so(QSP_ARG_DECL  Screen_Obj *sop)
{
	Screen_Obj *dup;
	char name[BUF_LEN];

	sprintf(name,"%s.dup",SOB_NAME(sop));
	dup = simple_object(name);
	if( sop == NULL ) return(sop);
	SET_SOB_PARENT(dup, SOB_PARENT(sop) );
	SET_SOB_PANEL(dup, SOB_PANEL(sop) );
#ifdef HAVE_MOTIF
	SET_SOB_FRAME(dup, SOB_FRAME(sop) );
#endif /* HAVE_MOTIF */
	SET_SOB_ACTION(dup,savestr(SOB_ACTION(sop)));
	SET_SOB_SELECTOR(dup,NULL);
	return(dup);
}
예제 #11
0
파일: screen_objs.c 프로젝트: nasa/QuIP
static inline void delete_choice_from_chooser(QSP_ARG_DECL  Screen_Obj *sop, const char *s)
{
	const char **new_string_arr;

	assert( SOB_TYPE(sop) == SOT_CHOOSER );

	// first make sure that this choice is already present...
	if( insist_choice_present(SOB_SELECTORS(sop),SOB_N_SELECTORS(sop),s,SOB_NAME(sop),"delete_choice_from_chooser") < 0 )
		return;

	new_string_arr = new_selector_table_less_one(s,SOB_SELECTORS(sop),SOB_N_SELECTORS(sop));
	// can return NULL if table empty or item not found

	givbuf(SOB_SELECTORS(sop));	// release old string table
	SET_SOB_N_SELECTORS(sop,SOB_N_SELECTORS(sop)-1);
	SET_SOB_SELECTORS(sop,new_string_arr);
	reload_chooser(sop);
}
예제 #12
0
파일: motif.c 프로젝트: E-LLP/QuIP
static Widget generic_frame(Widget parent, Screen_Obj *sop, int shadow_type)
{
	Arg al[10];
	int ac = 0;
	Widget frame, label;

	/* set orientation */
	XtSetArg(al[ac], XmNorientation, XmVERTICAL); ac++;
	/* set shadow type */
	// How can we specify NO shadow???
	XtSetArg(al[ac], XmNshadowType, shadow_type); ac++;
	XtSetArg(al[ac], XmNshadowThickness, 2); ac++;
	/* set geometry and placement */
//fprintf(stderr,"generic_frame:  top offset = %d\n",curr_panel->po_curry);
	XtSetArg(al[ac], XmNtopAttachment, XmATTACH_FORM); ac++;
	XtSetArg(al[ac], XmNtopOffset, curr_panel->po_curry); ac++;
	XtSetArg(al[ac], XmNbottomAttachment, XmATTACH_NONE); ac++;
	XtSetArg(al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
	XtSetArg(al[ac], XmNleftOffset, curr_panel->po_currx); ac++;
	XtSetArg(al[ac], XmNrightAttachment, XmATTACH_NONE); ac++;

	frame = XmCreateFrame(parent, (char *)SOB_NAME(sop), al, ac);
	XtManageChild(frame);

	/* Save object position */
	// BUG with nav_panels, this is messed up...
	if( curr_panel != NULL ){
		sop->so_x = curr_panel->po_currx;
		sop->so_y = curr_panel->po_curry;
	} else {
		NWARN("CAUTIOUS:  generic_frame:  current_panel is NULL!?");
	}

	ac = 0;
	XtSetArg(al[ac], XmNchildType, XmFRAME_TITLE_CHILD); ac++;

	//label = XmCreateLabelGadget(frame,sop->so_name, al, ac);
	label = XmCreateLabel(frame, (char *)sop->so_name, al, ac);
	XtManageChild(label);

	return(frame);
}
예제 #13
0
파일: screen_objs.c 프로젝트: nasa/QuIP
static void _list_widgets(QSP_ARG_DECL  Panel_Obj *po)
{
	IOS_List *lp;
	IOS_Node *np;
	/* lp=item_list(QSP_ARG  scrnobj_itp); */
	lp = PO_CHILDREN(po);

	np=IOS_LIST_HEAD(lp);
	while(np!=NULL ){
		Screen_Obj *sop;

		sop=(Screen_Obj *)IOS_NODE_DATA(np);
		if( WIDGET_PANEL(sop) == po ){
			/* list_scrnobj(sop); */
		//	printf("\t%s\n",SOB_NAME(sop));
			so_info(sop);
		} else {
			sprintf(ERROR_STRING,"widget %s does not belong to panel %s!?",
				SOB_NAME(sop),PO_NAME(po));
			warn(ERROR_STRING);
		}
		np=IOS_NODE_NEXT(np);
	}
}
예제 #14
0
파일: screen_objs.c 프로젝트: nasa/QuIP
static inline void delete_choice_from_picker(QSP_ARG_DECL  Screen_Obj *sop, const char *s)
{
	const char **new_string_arr;

	assert( SOB_TYPE(sop) == SOT_PICKER );
	if( insist_one_component(sop, "add_choice_to_picker") < 0 ) return;

	if( insist_choice_present(SOB_SELECTORS_AT_IDX(sop,0),SOB_N_SELECTORS_AT_IDX(sop,0),s,SOB_NAME(sop),"delete_choice_from_picker") < 0 )
		return;

	new_string_arr = new_selector_table_less_one(s,SOB_SELECTORS_AT_IDX(sop,0),SOB_N_SELECTORS_AT_IDX(sop,0));
	// can return NULL if table empty or item not found

	givbuf(SOB_SELECTORS_AT_IDX(sop,0));	// release old string table
	SET_SOB_N_SELECTORS_AT_IDX(sop,0,SOB_N_SELECTORS_AT_IDX(sop,0)-1);
	SET_SOB_SELECTORS_AT_IDX(sop,0,new_string_arr);
	reload_chooser(sop);
}
예제 #15
0
파일: motif.c 프로젝트: E-LLP/QuIP
void make_picker(QSP_ARG_DECL  Screen_Obj *sop)
{
#ifdef HAVE_MOTIF
	int	j;
	Arg	al[20];
	int	ac = 0;
	Screen_Obj *b_sop;	/* button ptr */
	char buf[6];
	int n;
	const char **stringlist;

	if( SOB_N_CYLINDERS(sop) != 1 ){
		sprintf(ERROR_STRING,"picker %s needs %d components, but we're only implementing 1!?",
			SOB_NAME(sop),SOB_N_CYLINDERS(sop));
		WARN(ERROR_STRING);
	}
	n= SOB_N_SELECTORS_AT_IDX(sop,/*component*/ 0 );

	sop->so_frame = generic_frame(curr_panel->po_panel_obj,
		sop, XmSHADOW_IN);

	XtSetArg(al[ac], XmNentryClass, xmToggleButtonWidgetClass); ac++;
	strcpy(buf,"name");
	sop->so_obj = XmCreateRadioBox(sop->so_frame,
		buf, al, ac);

	XtManageChild(sop->so_obj);

#ifdef CAUTIOUS
	if( sop->so_children != NO_LIST ){
		sprintf(ERROR_STRING,"CAUTIOUS:  Picker %s already has a child list!?",SOB_NAME(sop));
		ERROR1(ERROR_STRING);
	}
#endif /* CAUTIOUS */

	SET_SOB_CHILDREN(sop,new_list());

	stringlist = SOB_SELECTORS_AT_IDX(sop,0);

	// The choices are created as screen_objs, we
	// need to create a special context for them so that we
	// can have the same choices in multiple pickers and choosers
	// The context name should be the concatenation of the current
	// scrnobj context, and the name of this widget...

	push_widget_context(QSP_ARG  sop);

	for(j=0; j<n; j++) {
		b_sop = simple_object(QSP_ARG  stringlist[j]);
		if( b_sop==NO_SCREEN_OBJ ) return;
		b_sop->so_action_text = savestr(stringlist[j]);
		b_sop->so_parent = sop;
		b_sop->so_flags |= SOT_MENU_ITEM;

		/* The choices need to be part of the panel list (so we can find them
		 * with find_object), but also on the parent list, so we can find them
		 * through it...
		 */

		addHead(curr_panel->po_children,mk_node(b_sop));
		addTail(sop->so_children,mk_node(b_sop));

		b_sop->so_obj = XtCreateManagedWidget(
			b_sop->so_name,			/* widget name */
			xmToggleButtonWidgetClass,	/* widget class */
			sop->so_obj,			/* parent widget */
			NULL, 0);
		fix_names(QSP_ARG  b_sop,sop);
										/* client data */
		XtAddCallback(b_sop->so_obj, XmNvalueChangedCallback, chooser_func, NULL);
		XtManageChild(b_sop->so_obj);
	}

	pop_scrnobj_context(SINGLE_QSP_ARG);

	SET_SOB_HEIGHT(sop, CHOOSER_HEIGHT + CHOOSER_ITEM_HEIGHT*n );
#endif /* HAVE_MOTIF */
}
예제 #16
0
파일: motif.c 프로젝트: E-LLP/QuIP
void make_chooser(QSP_ARG_DECL  Screen_Obj *sop, int n, const char **stringlist)
{
#ifdef HAVE_MOTIF
	int	j;
	Arg	al[20];
	int	ac = 0;
	Screen_Obj *b_sop;	/* button ptr */
	char buf[6];

	sop->so_frame = generic_frame(curr_panel->po_panel_obj,
		sop, XmSHADOW_IN);

	XtSetArg(al[ac], XmNentryClass, xmToggleButtonWidgetClass); ac++;
	strcpy(buf,"name");
	sop->so_obj = XmCreateRadioBox(sop->so_frame,
		buf, al, ac);

	XtManageChild(sop->so_obj);

#ifdef CAUTIOUS
	if( sop->so_children != NO_LIST ){
		sprintf(ERROR_STRING,"CAUTIOUS:  Chooser %s already has a child list!?",SOB_NAME(sop));
		ERROR1(ERROR_STRING);
	}
#endif /* CAUTIOUS */

	SET_SOB_CHILDREN(sop,new_list());

	push_widget_context(QSP_ARG  sop);

	for(j=0; j<n; j++)
	{
		b_sop = simple_object(QSP_ARG  stringlist[j]);
		if( b_sop==NO_SCREEN_OBJ ) return;
		b_sop->so_action_text = savestr(stringlist[j]);
		b_sop->so_parent = sop;
		b_sop->so_flags |= SOT_MENU_ITEM;

		/* The choices need to be part of the panel list (so we can find them
		 * with find_object), but also on the parent list, so we can find them
		 * through it...
		 */

		addHead(curr_panel->po_children,mk_node(b_sop));
		addTail(sop->so_children,mk_node(b_sop));

		b_sop->so_obj = XtCreateManagedWidget(
			b_sop->so_name,			/* widget name */
			xmToggleButtonWidgetClass,	/* widget class */
			sop->so_obj,			/* parent widget */
			NULL, 0);
		fix_names(QSP_ARG  b_sop,sop);
										/* client data */
		XtAddCallback(b_sop->so_obj, XmNvalueChangedCallback, chooser_func, NULL);
		XtManageChild(b_sop->so_obj);
	}

	pop_scrnobj_context(SINGLE_QSP_ARG);

#endif /* HAVE_MOTIF */

	SET_SOB_HEIGHT(sop, CHOOSER_HEIGHT + CHOOSER_ITEM_HEIGHT*n );
}