Example #1
0
static double get_panel_size(QSP_ARG_DECL  IOS_Item *ip,int index)
{
	double d;
	Panel_Obj *po;

	po = (Panel_Obj *)ip;

	switch(index){
		case 1:	d = PO_WIDTH(po); break;
		case 2:	d = PO_HEIGHT(po); break;
		default: d=1.0; break;
	}
	return(d);
}
Example #2
0
File: motif.c Project: E-LLP/QuIP
void make_edit_box(QSP_ARG_DECL  Screen_Obj *sop)
{
#ifdef HAVE_MOTIF
	Arg al[8];
	int ac = 0;

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

	XtSetArg(al[ac], XmNeditable, TRUE); ac++;
	XtSetArg(al[ac], XmNrecomputeSize, FALSE); ac++;
	XtSetArg(al[ac], XmNwidth, PO_WIDTH(curr_panel)-30 ); ac++;
	/* BUG do something sensible about the height... */
	//XtSetArg(al[ac], XmNheight, PO_HEIGHT(curr_panel)-30 ); ac++;
#define EDIT_BOX_HEIGHT 100	// height of editable area?
#define EDIT_BOX_EXTRA 30	// add for total height - this value is guessed!?
	XtSetArg(al[ac], XmNheight, EDIT_BOX_HEIGHT); ac++;

	XtSetArg(al[ac], XmNscrollHorizontal, FALSE); ac++;
	XtSetArg(al[ac], XmNwordWrap, TRUE); ac++;

	//sop->so_obj = XmCreateTextField(sop->so_frame, (char *)sop->so_name, al, ac);
	sop->so_obj = XmCreateScrolledText(sop->so_frame, (char *)sop->so_name, al, ac);

	XtAddCallback(sop->so_obj, XmNvalueChangedCallback, text_func, NULL);
	XtAddCallback(sop->so_obj, XmNlosingFocusCallback, text_func2, NULL);

	XtManageChild(sop->so_obj);

	/* this works for a TextField, but not ScrolledText!? */
	//XmTextFieldSetString(sop->so_obj, (char *)sop->so_content_text );

	/* this works! */
	XmTextSetString(sop->so_obj, (char *)sop->so_content_text );

	SET_SOB_HEIGHT(sop,EDIT_BOX_HEIGHT+EDIT_BOX_EXTRA);
#endif /* HAVE_MOTIF */
}
Example #3
0
static void mk_text_input_line(QSP_ARG_DECL  int so_code)
{
	Screen_Obj *to;
	const char *s;

	to = get_parts("text");		// sets name and action

	s = nameof("default value");

	if( to == NULL ) return;

	SET_SOB_CONTENT(to, save_possibly_empty_str(s));
	SET_SOB_TYPE(to, so_code);

#ifdef BUILD_FOR_IOS
	get_device_dims(to);	// sets width, height, and font size
#else
	SET_SOB_WIDTH(to, PO_WIDTH(curr_panel)-2*SIDE_GAP );
#endif // BUILD_FOR_IOS

	// height is set for console output...
	SET_SOB_HEIGHT(to, MESSAGE_HEIGHT);

	/*
	 * OLD COMMENT:
	 * we used to put this after addition to panel list,
	 * because setting initial value causes a callback
	 * (true for motif!!)
	 *
	 * Why did we stop doing that???
	 * We put it back for now, to prevent the warning...
	 *
	 * Note that most of the other functions add it to the
	 * panel list after the widget proper has been created...
	 *
	 * for iOS, add_to_panel must follow the widget creation,
	 * because that is where addSubview is called...
	 */
#ifdef BUILD_FOR_OBJC
	make_text_field(QSP_ARG  to);
//fprintf(stderr,"adding text field to panel...\n");
	add_to_panel(curr_panel,to);
#else // ! BUILD_FOR_OBJC
	// the callback that occurs is a "value changed" callback...
	// Is that because the widget creation routine
	// sets an initial value?
	add_to_panel(curr_panel,to);
	make_text_field(QSP_ARG  to);
#endif // ! BUILD_FOR_OBJC

#ifdef BUILD_FOR_IOS
	install_initial_text(to);	// set the placeholder value here...
#endif /* BUILD_FOR_IOS */

#ifdef BUILD_FOR_MACOS
	INC_PO_CURR_Y(curr_panel, SOB_HEIGHT(to) + GAP_HEIGHT );
#else // ! BUILD_FOR_MACOS
	// Why add an extra 10???  BUG?
	INC_PO_CURR_Y(curr_panel, MESSAGE_HEIGHT + GAP_HEIGHT + 10 );
#endif // ! BUILD_FOR_MACOS

} // mk_text_input_line