コード例 #1
0
ファイル: screen_objs.c プロジェクト: nasa/QuIP
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
コード例 #2
0
ファイル: motif.c プロジェクト: E-LLP/QuIP
Nav_Panel *create_nav_panel(QSP_ARG_DECL  const char *name)
{
	Nav_Panel *np_p;
#ifdef HAVE_MOTIF
	Panel_Obj *po;
#endif


	np_p = new_nav_panel(QSP_ARG  name);
	if( np_p == NO_NAV_PANEL ){
		sprintf(ERROR_STRING,
"create_nav_panel:  error creating nav_panel \"%s\"!?",name);
		WARN(ERROR_STRING);
		return NO_NAV_PANEL;
	}
	SET_GW_TYPE( NAVP_GW(np_p), GW_NAV_PANEL );

#ifdef HAVE_MOTIF

// BUG on iOS the panel size defaults to the whole screen...

#define DEFAULT_NAV_PANEL_WIDTH		480
#define DEFAULT_NAV_PANEL_HEIGHT	720

	// Now make a regular panel...
	// new_panel is supposed to push a scrnobj context...
	po = new_panel(QSP_ARG  name, DEFAULT_NAV_PANEL_WIDTH, DEFAULT_NAV_PANEL_HEIGHT );
	if( po == NO_PANEL_OBJ ){
		WARN("Error creating panel for nav_panel!?");
		// BUG clean up (delete np_p)
		return NULL;
	}
	//np_p->np_po = po;
	SET_NAVP_PANEL(np_p,po);

	SET_GW_TYPE(PO_GW(po),GW_NAV_PANEL_OBJ);

#endif /* HAVE_MOTIF */

	IOS_Item_Context *icp;
	
	icp = create_navgrp_context(QSP_ARG  name );
	// We need to push the context, and pop when we finish?
	// We don't push until we enter the navigation submenu...

//fprintf(stderr,"create_nav_panel, pushing group context %s\n",
//CTX_NAME(icp));
//	PUSH_ITEM_CONTEXT(nav_group_itp, icp);
	SET_NAVP_GRP_CONTEXT(np_p, icp);

	icp = create_navitm_context(QSP_ARG  name );
//	PUSH_ITEM_CONTEXT(nav_item_itp, icp);
	SET_NAVP_ITM_CONTEXT(np_p, icp);

	// In motif, we don't have real nav panels (an iOS-ism)
	// So to emulate the functionality, we have to add
	// a "back" button...
	{
	Screen_Obj *bo;
	prepare_for_decoration(QSP_ARG  NAVP_PANEL(np_p) );

	// next 7 lines from get_parts, screen_objs.c
	bo = simple_object(QSP_ARG  "Back");
	if( bo == NO_SCREEN_OBJ ){
		WARN("Error creating back button for nav_panel!?");
		goto no_back_button;
	}

	SET_SOB_ACTION(bo, savestr("Pop_Nav"));

	// next 6 lines from mk_button, screen_objs.c
	SET_SOB_TYPE(bo, SOT_BUTTON);

	make_button(QSP_ARG  bo);
	add_to_panel(curr_panel,bo);

	INC_PO_CURR_Y(curr_panel, BUTTON_HEIGHT + GAP_HEIGHT );



	unprepare_for_decoration(SINGLE_QSP_ARG);
	}
no_back_button:

	return np_p;
} // create_nav_panel