Screen_Obj *_get_parts(QSP_ARG_DECL const char *class_str) { char pmpt[BUF_LEN]; //char text[BUF_LEN]; //char label[BUF_LEN]; Screen_Obj *sop; const char *text, *label; // Why are the label and text strings saved // in these local buffers??? sprintf(pmpt,"%s label",class_str); //strcpy( label, nameof(pmpt) ); label = nameof(pmpt) ; sprintf(pmpt,"%s action text",class_str); text = nameof(pmpt) ; if( curr_panel == NULL ) return NULL; if( label == NULL ) return NULL; // a non-existent variable, for example... if( text == NULL ) return NULL; // a non-existent variable, for example... sop = simple_object(label); if( sop == NULL ) return(sop); SET_SOB_ACTION(sop, savestr(text)); return(sop); }
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); }
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 */ }
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
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 ); }