static void setRgbScale (Widget scale, int value) { int scaleMin, scaleMax, newValue; newValue = max (value, 0); newValue = min (newValue, 255); XmScaleSetValue (scale, newValue); }
void structGuiScale :: f_setValue (int value) { #if gtk gtk_range_set_value (GTK_RANGE (d_widget), value); #elif cocoa #elif motif XmScaleSetValue (d_widget, value); #endif }
static void select_light(Widget w, XtPointer data, XmListCallbackStruct *cbs) { extern float light_intensity(); Widget intensity = (Widget)*((Widget *)data); set_light(cbs->item_position-1); XmScaleSetValue(intensity, (int) (light_intensity()*100.0)); }
static void reset(Widget w) { int nid; int mems; Widget mems_scale = XtNameToWidget(w, "mems_scale"); XtVaGetValues(mems_scale, XmNuserData, &nid, NULL); DevLong(&nid, &mems); XmdsResetAllXds(w); XmScaleSetValue(mems_scale, mems); }
void UIsetSpeed(int val) { XmScaleSetValue(SpeedScale, val); if (val == 0) speed = 60000L; else if (val > 0) speed = (long) ((100.0 - (float)val) * (100.0 - (float)val) * (100.0 - (float)val) / 100.0) + 30L; }
void UI2DView::Set (DBRegion region) { int value, sliderSize; double freeLength, dVal; DBRegion dataEXT = (UIDataset ())->Extent (); SetExtent (region); SetActiveExtent (ViewEXT); sliderSize = (int) ((ViewEXT.UpperRight.X - ViewEXT.LowerLeft.X) * 100.0 / (dataEXT.UpperRight.X - dataEXT.LowerLeft.X)); sliderSize = sliderSize < 100 ? sliderSize : 100; sliderSize = sliderSize > 1 ? sliderSize : 1; freeLength = (dataEXT.UpperRight.X - dataEXT.LowerLeft.X) - (ViewEXT.UpperRight.X - ViewEXT.LowerLeft.X); if (freeLength == (double) 0.0) value = 0; else { value = (int) ((ViewEXT.LowerLeft.X - dataEXT.LowerLeft.X) * (100.0 - sliderSize) / freeLength); value = value < 100 - sliderSize ? value : 100 - sliderSize; value = value > 0 ? value : 0; } XmScrollBarSetValues (HorScrollBarW,value,sliderSize,(int) 0x0L,sliderSize,false); sliderSize = (int) ((ViewEXT.UpperRight.Y - ViewEXT.LowerLeft.Y) * 100.0 / (dataEXT.UpperRight.Y - dataEXT.LowerLeft.Y)); sliderSize = sliderSize < 100 ? sliderSize : 100; sliderSize = sliderSize > 1 ? sliderSize : 1; freeLength = (dataEXT.UpperRight.Y - dataEXT.LowerLeft.Y) - (ViewEXT.UpperRight.Y - ViewEXT.LowerLeft.Y); if (freeLength == (double) 0.0) value = 0; else { value = (int) ((dataEXT.UpperRight.Y - ViewEXT.UpperRight.Y) * (100.0 - sliderSize) / freeLength); value = value < 100 - sliderSize ? value : 100 - sliderSize; value = value > 0 ? value : 0; } XmScrollBarSetValues (VerScrollBarW,value,sliderSize,(int) 0x0L,sliderSize,false); dVal = (ViewEXT.UpperRight.X - ViewEXT.LowerLeft.X) / (dataEXT.UpperRight.X - dataEXT.LowerLeft.X) < (ViewEXT.UpperRight.Y - ViewEXT.LowerLeft.Y) / (dataEXT.UpperRight.Y - dataEXT.LowerLeft.Y) ? (ViewEXT.UpperRight.X - ViewEXT.LowerLeft.X) / (dataEXT.UpperRight.X - dataEXT.LowerLeft.X) : (ViewEXT.UpperRight.Y - ViewEXT.LowerLeft.Y) / (dataEXT.UpperRight.Y - dataEXT.LowerLeft.Y); value = (int) (dVal * 100.0); value = value < 100 ? value : 100; value = value > 0 ? value : 0; XmScaleSetValue (ScaleW,value); Draw (); }
static void ClickCallback ( Widget w, XtPointer clientData, XtPointer callData ) { XmScaleCallbackStruct *cbs = ( XmScaleCallbackStruct * ) callData; /* Round the value to the nearest multiple of 10 */ int value = ( ( cbs->value + 5 ) / 10 ) * 10; /* Move the slider to the rounded value. */ XmScaleSetValue ( w, value ); }
/*ARGSUSED*/ static void Generic_scaleCB(Widget widget, int data, XtPointer call_data) { XmScaleCallbackStruct *cbs = (XmScaleCallbackStruct *) call_data; if(data == MOTIF_CHANGE_LOCATOR) { Arg al[10]; int ac, nbfile; ac=0; XtSetArg(al[ac], XmNitemCount, &nbfile); ac++; XtGetValues(file_list, al, ac); if(file_number_to_play<=0||file_number_to_play>nbfile) { XmScaleSetValue(locator_scale,0); return; } } m_pipe_int_write( data ); m_pipe_int_write(cbs->value); }
void polygonformpop() { int ival, i, j; XmListDeselectAllItems(pmatsellist); for (j = 0; j < numlist; j++) { i = listmat[j]; if (active_mat[i]) XmListSelectPos(pmatsellist,j+1,FALSE); } ival = (int) (pexplodefact * 100.); XmScaleSetValue(pexplode,ival); XmToggleButtonGadgetSetState(pshade,polysflag,FALSE); XmToggleButtonGadgetSetState(pline,linesflag,FALSE); XmToggleButtonGadgetSetState(stipplebut,polystiplflag,FALSE); shadedraw = polysflag; linedraw = linesflag; MyManageChild(polygonform); }
void AFNI_thrdrag_lock_carryout( Three_D_View *im3d ) { Three_D_View *qq3d ; static int busy = 0 ; /* !=0 if this routine is "busy" */ int glock , cc,ii , dothresh,dopval , ival , stop ; float thresh , pval=0.0f , tval ; ENTRY("AFNI_thrdrag_lock_carryout") ; /* first, determine if there is anything to do */ glock = GLOBAL_library.controller_lock ; /* not a handgun */ if( busy ) EXRETURN; /* routine already busy */ if( glock == 0 ) EXRETURN; /* nothing to do */ if( !IM3D_OPEN(im3d) ) EXRETURN; /* bad input */ if( GLOBAL_library.ignore_lock ) EXRETURN; /* ordered not to do anything */ if (!GLOBAL_library.thr_lock) EXRETURN; dothresh = (GLOBAL_library.thr_lock == 1) ; dopval = (GLOBAL_library.thr_lock == 2) && im3d->fim_now != NULL ; if( !dothresh && !dopval ) EXRETURN ; /* no command? */ ii = AFNI_controller_index(im3d) ; /* which one am I? */ if( ii < 0 ) EXRETURN ; /* nobody? bad input! */ if( ((1<<ii) & glock) == 0 ) EXRETURN ; /* input not locked */ /* something to do? */ busy = 1 ; /* don't let this routine be called recursively */ ival = rint(im3d->vinfo->func_threshold/THR_factor) ; thresh = get_3Dview_func_thresh(im3d,1) ; stop = (int)( rint( pow(10.0,THR_top_expon) ) - 1.0 ) ; if( dopval ){ pval = THD_stat_to_pval( thresh , DSET_BRICK_STATCODE(im3d->fim_now,im3d->vinfo->thr_index) , DSET_BRICK_STATAUX (im3d->fim_now,im3d->vinfo->thr_index) ) ; if( pval < 0.0 || pval > 1.0 ){ dopval = 0; dothresh = 1; } } /* loop through other controllers: for those that ARE open, ARE NOT the current one, and ARE locked, set the new threshold */ for( cc=0 ; cc < MAX_CONTROLLERS ; cc++ ){ qq3d = GLOBAL_library.controllers[cc] ; /* controller */ if( IM3D_OPEN(qq3d) && qq3d != im3d && ((1<<cc) & glock) != 0 ){ if( qq3d->vinfo->func_thresh_top == im3d->vinfo->func_thresh_top ){ if( dopval && qq3d->fim_now != NULL && DSET_BRICK_STATCODE(qq3d->fim_now,qq3d->vinfo->thr_index) > 0 ){ tval = THD_pval_to_stat( pval , DSET_BRICK_STATCODE(qq3d->fim_now,qq3d->vinfo->thr_index), DSET_BRICK_STATAUX (qq3d->fim_now,qq3d->vinfo->thr_index) ); ival = rint( tval/(THR_factor*qq3d->vinfo->func_thresh_top) ) ; if( ival < 0 ) ival = 0 ; else if( ival > stop ) ival = stop ; } else if( !dothresh ){ continue ; /* skip this [dopval set, but not a statistic] */ } /* set the slider and pval marker */ XmScaleSetValue( qq3d->vwid->func->thr_scale , ival ) ; qq3d->vinfo->func_threshold = THR_factor * ival ; AFNI_set_thr_pval( qq3d ) ; } } } busy = 0 ; /* OK, let this routine be activated again */ EXRETURN ; }
void UIloadinterface() { Display *dpy; Widget MainWindow, InfoWindow, CommandWindow, InfoButton, CommandButton, PlayButton, StopButton, BStepButton, FStepButton, LoadButton, ScriptButton, CloseButton, AnimateTitle, InfoTitle, InfoText, InfoClose; XFontStruct *font; XmFontList fontlist; Arg args[10]; int n, oldstderr; int argcblah = 1; char *argvblah[1] = { "Animate" }; FILE *dummy; mib_Widget *MainForm, *InfoForm, *CommandForm; String fallbacks[] = { #ifdef dark_ui "*Foreground: gray20", "*Background: gray70", #endif #ifdef light_ui "*Foreground: #000000000000", "*Background: #afafafafafaf", #endif "*BorderWidth: 0", "*XmToggleButton.selectColor: yellow", "*XmToggleButton.indicatorSize: 16", "*XmToggleButtonGadget.selectColor: yellow", "*XmToggleButtonGadget.indicatorSize: 16", "*XmTextField.background: #cc7777", "*fontList:\ -adobe-helvetica-medium-r-normal--14-100-100-100-p-76-iso8859-1", NULL}; /* initialize application top level widget */ TopLevel = XtVaAppInitialize(&App, "animate", NULL, 0, &argcblah, argvblah, fallbacks, NULL); dpy = XtDisplay(TopLevel); oldstderr = dup(fileno(stderr)); dummy = freopen("/dev/null", "w", stderr); /* configure resize policy of window */ XtVaSetValues(TopLevel, XmNminWidth, 272, XmNminHeight, 319, XmNkeyboardFocusPolicy, XmPOINTER, NULL); /* create the application windows */ MainWindow = XtCreateManagedWidget("MainWindow", xmMainWindowWidgetClass, TopLevel, NULL, 0); /*****************************************************************************/ n = 0; XtSetArg(args[n], XmNminWidth, 359); n++; XtSetArg(args[n], XmNminHeight, 197); n++; XtSetArg(args[n], XmNtitle, "Info"); n++; InfoWindow = XmCreateFormDialog(MainWindow, "Info", args, n); /*****************************************************************************/ n = 0; XtSetArg(args[n], XmNminWidth, 365); n++; XtSetArg(args[n], XmNminHeight, 64); n++; XtSetArg(args[n], XmNmaxHeight, 64); n++; XtSetArg(args[n], XmNtitle, "Command"); n++; XtSetArg(args[n], XmNkeyboardFocusPolicy, XmPOINTER); n++; CommandWindow = XmCreateFormDialog(MainWindow, "Command", args, n); /*****************************************************************************/ /* load the interface via the mib library */ /* MainForm = mib_load_interface(MainWindow, "interface/animate.mib", MI_FROMFILE); InfoForm = mib_load_interface(InfoWindow, "interface/info.mib", MI_FROMFILE); CommandForm = mib_load_interface(CommandWindow, "interface/command.mib", MI_FROMFILE); */ MainForm = mib_load_interface(MainWindow, AnimRoot, MI_FROMSTRING); InfoForm = mib_load_interface(InfoWindow, InfoRoot, MI_FROMSTRING); CommandForm = mib_load_interface(CommandWindow, CommRoot, MI_FROMSTRING); /* Get widget pointers from interface */ AnimateTitle = mib_find_name(MainForm, "AnimateTitle")->me; CloseButton = mib_find_name(MainForm, "CloseButton")->me; InfoButton = mib_find_name(MainForm, "InfoButton")->me; CommandButton = mib_find_name(MainForm, "CommandButton")->me; ScriptButton = mib_find_name(MainForm, "Script")->me; LoadButton = mib_find_name(MainForm, "Load")->me; PlayButton = mib_find_name(MainForm, "Play")->me; StopButton = mib_find_name(MainForm, "Stop")->me; BStepButton = mib_find_name(MainForm, "BStep")->me; FStepButton = mib_find_name(MainForm, "FStep")->me; SpeedScale = mib_find_name(MainForm, "SpeedScale")->me; FileText = mib_find_name(MainForm, "FileText")->me; AnimList = mib_find_name(MainForm, "AnimList")->me; RangeToggle = mib_find_name(MainForm, "Range")->me; OnceToggle = mib_find_name(MainForm, "Once")->me; BounceToggle = mib_find_name(MainForm, "Bounce")->me; InfoTitle = mib_find_name(InfoForm, "Title")->me; InfoText = mib_find_name(InfoForm, "TextBig")->me; InfoClose = mib_find_name(InfoForm, "Close")->me; CommandText = mib_find_name(CommandForm, "TextBox")->me; /* Set large font for titles */ font = XLoadQueryFont(dpy, "-adobe-helvetica-bold-r-normal--24-240-75-75-p-138-iso8859-1"); fontlist = XmFontListCreate(font, "bigger"); XtVaSetValues(AnimateTitle, XmNfontList, fontlist, NULL); XtVaSetValues(InfoTitle, XmNfontList, fontlist, NULL); /* Set various resources and values */ XtVaSetValues(InfoText, XmNcursorPositionVisible, False, XmNeditable, False, NULL); XmTextSetString(InfoText, get_info()); XtVaSetValues(AnimList, XmNselectionPolicy, XmEXTENDED_SELECT, NULL); XmScaleSetValue(SpeedScale, 100); /* Set callbacks - stupid @#$@&%!@# boiler plate code */ XtAddCallback(CloseButton, XmNactivateCallback, (XtCallbackProc)close_callback, (XtPointer)NULL ); XtAddCallback(InfoButton, XmNactivateCallback, (XtCallbackProc)info_callback, (XtPointer)InfoWindow ); XtAddCallback(InfoClose, XmNactivateCallback, (XtCallbackProc)cinfo_callback, (XtPointer)InfoWindow ); XtAddCallback(BStepButton, XmNactivateCallback, (XtCallbackProc)bstep_callback, (XtPointer)NULL ); XtAddCallback(FStepButton, XmNactivateCallback, (XtCallbackProc)fstep_callback, (XtPointer)NULL ); XtAddCallback(PlayButton, XmNactivateCallback, (XtCallbackProc)play_callback, (XtPointer)NULL ); XtAddCallback(StopButton, XmNactivateCallback, (XtCallbackProc)stop_callback, (XtPointer)NULL ); XtAddCallback(LoadButton, XmNactivateCallback, (XtCallbackProc)load_callback, (XtPointer)FileText ); XtAddCallback(FileText, XmNactivateCallback, (XtCallbackProc)load_callback, (XtPointer)FileText ); XtAddCallback(ScriptButton, XmNactivateCallback, (XtCallbackProc)script_callback, (XtPointer)FileText ); XtAddCallback(CommandButton, XmNactivateCallback, (XtCallbackProc)command_callback, (XtPointer)CommandWindow ); XtAddCallback(AnimList, XmNdefaultActionCallback, (XtCallbackProc)frameselect_callback, (XtPointer)NULL ); XtAddCallback(RangeToggle, XmNvalueChangedCallback, (XtCallbackProc)range_callback, (XtPointer)NULL ); XtAddCallback(OnceToggle, XmNvalueChangedCallback, (XtCallbackProc)once_callback, (XtPointer)NULL ); XtAddCallback(BounceToggle, XmNvalueChangedCallback, (XtCallbackProc)bounce_callback, (XtPointer)NULL ); XtAddCallback(CommandText, XmNactivateCallback, (XtCallbackProc)typecommand_cback, (XtPointer)CommandWindow ); XtAddCallback(SpeedScale, XmNdragCallback, (XtCallbackProc)speed_callback, (XtPointer)NULL ); dummy = freopen("/dev/null", "w", stderr); dup2(oldstderr, fileno(stderr)); close(oldstderr); /* Bring the application window up on the screen. */ }
void backmen_buta(Widget iw_temp, XtPointer data, XtPointer calldata) { float fmint, fmaxt; float *fptrdum = NULL; /* Remove menu */ XtUnmanageChild(iw_backmen); /* Set wait cursor */ waitcursor(iwin, TRUE, 79); /* Set location for images */ placed = TRUE; if (leftside) { ixuln = ixull; iyuln = iyull; nsam2 = nsaml; nrow2 = nrowl; /* Find new displayed levels of fmin_spi and fmax_spi for left image */ fmint = (((float)(ngo - imagego) / (float)(imageend - imagego))) * (filedatal->fmax_spi - filedatal->fmin_spi) + filedatal->fmin_spi; fmaxt = (((float)(nend - imagego) / (float)(imageend - imagego))) * (filedatal->fmax_spi - filedatal->fmin_spi)+ filedatal->fmin_spi; /* Free up ximage buffer, before creating a new one */ if (imagel) { XFree((void *)imagel); imagel = NULL; } /* Show left image using new ramp */ showimage(filedatal, TRUE, &cptrduml, TRUE, &imagel, FALSE, &fptrdum, FALSE, fmint, fmaxt, imagego, imageend); /* Shift left image to shifted location and display */ pickdisp(TRUE, FALSE); } else { /* Set location for right images */ placed = TRUE; ixuln = ixulr; iyuln = iyulr; nsam2 = nsamr; nrow2 = nrowr; /* Find new displayed levels of fmin_spi and fmax_spi for right image */ fmint = (((float)(ngo - imagego) / (float)(imageend - imagego))) * (filedatar->fmax_spi - filedatar->fmin_spi) + filedatar->fmin_spi; fmaxt = (((float)(nend - imagego) / (float)(imageend - imagego))) * (filedatar->fmax_spi - filedatar->fmin_spi) + filedatar->fmin_spi; /* Free up ximage buffer, before creating a new one */ if (imager) { XFree((void *)imager); imager = NULL; } /* Show right image using new ramp */ showimage(filedatar, TRUE, &cptrdumr, TRUE, &imager, FALSE, &fptrdum, FALSE, fmint, fmaxt, imagego, imageend); /* Shift right image to shifted location and display */ pickdisp(FALSE, TRUE); } //printf ("%d...%d File Range: %7.2f ...%7.2f \n",imagego,imageend, // filedatar->fmin_spi,filedatar->fmax_spi); //printf ("%d...%d Range: %7.2f ...%7.2f \n",ngo,nend, fmint,fmaxt); /* Apply normal uncontrasted ramp to whole image */ ngo = imagego; nend = imageend; XmScaleSetValue(iw_ngob, ngo); XmScaleSetValue(iw_nendb, nend); /* Apply normal uncontrasted ramp to whole screen */ backmen_butm(NULL,NULL,NULL); /* Cancel waitcursor */ waitcursor(iwin, FALSE, 79); return; }
void set_light_display(int lightno) { extern float light_intensity(); XmScaleSetValue(lintensity, (int) (light_intensity()*100.0)); }
/*************************************************************************** This routine is called to pop up the process dialog/form. This is done only after obtaining information about the process and setting various fields. The form can be used to shows process information, set process priority and/or send a signal to the process or process group. If want_kill is True and active.quick_killis True, this routine instead sends the signal last selected to the process. ***************************************************************************/ void Handle_Process(Widget w, pid_t pid, XEvent *event, Boolean want_kill) { char line[MAXLINE]; FILE *fp; XmProcessTraversal(active.canvas, XmTRAVERSE_CURRENT); #ifdef HAVE_KILL if (active.quick_kill && want_kill) { if (last_global_signal_pos>=0 && last_global_signal_pos<sigmap_elts) { do_kill(w, pid, signal_map[last_global_signal_pos+1].sig); ForceRedisplay(); } else { char buf[300]; sprintf(buf, "Invalid signal position in signal list: %d\n", last_global_signal_pos+1); ShowDialog(w, XmDIALOG_ERROR, buf); } return; } #endif base.selected_pid = pid; ForceRedisplay(); /* Set priority to current priority value for the process */ #ifdef HAVE_GETPRIORITY errno = 0; priority = getpriority(PRIO_PROCESS, base.selected_pid); if ( priority == -1 && errno != 0 ) { /* beep if we can't get the priority. */ XBell(XtDisplay(active.shell),0); } else { XmScaleSetValue(priority_slider, priority); } #endif #ifdef HAVE_KILL /* Unless we have selected quick kill, make sure position 1 -- no action is selected for the signal value. */ if (active.quick_kill) { /* Off by one because we have "NO ACTION" while other menu doesn't */ XmListSelectPos(signal_list, last_global_signal_pos+1+1, False); } else { XmListSelectPos(signal_list, 1, False); } #endif /* process group button is not pushed/selected */ do_process_group = False; XmToggleButtonSetState(process_group_button, do_process_group, False); #ifdef HAVE_SETPRIORITY do_priority = False; XmToggleButtonSetState(priority_button, do_priority, False); #endif /* Set process command info . */ sprintf(line, base.ps_cmd_info, base.selected_pid); XmTextRemove(ps_info); /*XmScrollBarSetValues(ps_info, 1, 4, 1, 4, False);*/ fp = popen(line, "r"); if (fp != NULL) { int pos; XmTextSetString(ps_info, ""); while(fgets(line, MAXLINE, fp) != NULL) { pos = XmTextGetLastPosition(ps_info); XmTextInsert(ps_info, pos, line); } } pclose(fp); /* Set to show full command-line invocation. */ sprintf(line, base.ps_cmdline, base.selected_pid); fp = popen(line, "r"); if (fp != NULL) { int pos; while(fgets(line, MAXLINE, fp) != NULL) { pos = XmTextGetLastPosition(ps_info); XmTextInsert(ps_info, pos, line); } pclose(fp); } XtManageChild(ps_info); XtManageChild(process_dialog); /* By itself the popup appears at 0,0. I don't know why XMenuPosition doesn't do better. */ /* XmMenuPosition(process_dialog, (XButtonPressedEvent *) event); */ #ifdef TESTING switch (event->type) { case ButtonPress: XtVaSetValues(process_dialog, XmNx, event->xbutton.x, XmNy, event->xbutton.y, NULL); break; case KeyPress: XtVaSetValues(process_dialog, XmNx, event->xkey.x, XmNy, event->xkey.y, NULL); break; default: } #endif }