Ejemplo n.º 1
0
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;
}
Ejemplo n.º 2
0
static void _del_picks( QSP_ARG_DECL  Screen_Obj *sop )
{
	int i, n_cyl;
	void *p;

	n_cyl = SOB_N_CYLINDERS(sop);
	assert( n_cyl >= 1 );

	for(i=0;i<n_cyl;i++){
		p = SOB_SELECTORS_AT_IDX(sop, i );
		givbuf(p);
		// these counts and pointers will be release later anyway
		//SET_SOB_N_SELECTORS_AT_IDX(sop, i, 0);
		//SET_SOB_SELECTORS_AT_IDX(sop, i, NULL );
	}

	p=SOB_SELECTOR_TBL(sop);
	givbuf(p);
	p=SOB_COUNT_TBL(sop);
	givbuf(p);

	SET_SOB_N_CYLINDERS(sop, 0 );
	SET_SOB_COUNT_TBL(sop,NULL);
	SET_SOB_SELECTOR_TBL(sop,NULL);
}
Ejemplo n.º 3
0
Archivo: motif.c Proyecto: 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 */
}