LispObj * Lisp_XawScrollbarSetThumb(LispBuiltin *builtin) /* xaw-scrollbar-set-thumb widget top &optional shown */ { Widget widget; double top, shown; LispObj *owidget, *otop, *oshown; oshown = ARGUMENT(2); otop = ARGUMENT(1); owidget = ARGUMENT(0); if (!CHECKO(owidget, xawWidget_t)) LispDestroy("%s: cannot convert %s to Widget", STRFUN(builtin), STROBJ(owidget)); widget = (Widget)(owidget->data.opaque.data); CHECK_DFLOAT(otop); top = DFLOAT_VALUE(otop); if (oshown == UNSPEC) shown = 1.0; else { CHECK_DFLOAT(oshown); shown = DFLOAT_VALUE(oshown); } XawScrollbarSetThumb(widget, top, shown); return (oshown == UNSPEC ? DFLOAT(shown) : oshown); }
void ScrollBarDrawThumb(register Widget scrollWidget) { #ifdef MOTIF Arg args[4]; Cardinal nargs = XtNumber(args); #endif /* MOTIF */ register TScreen *screen = &term->screen; register int thumbTop, thumbHeight, totalHeight; thumbTop = screen->topline + screen->savedlines; thumbHeight = screen->max_row + 1; totalHeight = thumbHeight + screen->savedlines; #ifdef MOTIF XtSetArg(args[0], XmNmaximum, totalHeight); XtSetArg(args[1], XmNsliderSize, thumbHeight); XtSetArg(args[2], XmNvalue, thumbTop); XtSetArg(args[3], XmNpageIncrement, thumbHeight); XtSetValues(scrollWidget, args, nargs); #else XawScrollbarSetThumb(scrollWidget, ((float)thumbTop) / totalHeight, ((float)thumbHeight) / totalHeight); #endif /* MOTIF */ }
/************************************************************************** ... **************************************************************************/ void update_map_canvas_scrollbars(void) { float shown_h, top_h, shown_v, top_v; int xmin, ymin, xmax, ymax, xsize, ysize; int scroll_x, scroll_y; get_mapview_scroll_window(&xmin, &ymin, &xmax, &ymax, &xsize, &ysize); get_mapview_scroll_pos(&scroll_x, &scroll_y); top_h = (float)(scroll_x - xmin) / (float)(xmax - xmin); top_v = (float)(scroll_y - ymin) / (float)(ymax - ymin); shown_h = (float)xsize / (float)(xmax - xmin); shown_v = (float)ysize / (float)(ymax - ymin); XawScrollbarSetThumb(map_horizontal_scrollbar, top_h, shown_h); XawScrollbarSetThumb(map_vertical_scrollbar, top_v, shown_v); }
static void SetThumb(Widget w) { float location; ScrollByLineWidget sblw = (ScrollByLineWidget) w; if ( (sblw->scroll.lines == 0) || (sblw->scroll.bar == NULL) ) return; location = (float) sblw->scroll.line_pointer / (float) sblw->scroll.lines; XawScrollbarSetThumb( sblw->scroll.bar, location , (float) -1 ); }
void SetScroll (Option *opt, float f) { // sets top of thumb to given fraction static char *params[3] = { "", "Continuous", "Proportional" }; static XEvent event; Widget w = XtParent(opt->handle); // viewport Widget v = XtNameToWidget(w, "vertical"); if(!v) return; // no scroll bar XtCallActionProc(v, "StartScroll", &event, params+1, 1); XawScrollbarSetThumb(v, f, -1.0); XtCallActionProc(v, "NotifyThumb", &event, params, 0); // XtCallActionProc(v, "NotifyScroll", &event, params+2, 1); XtCallActionProc(v, "EndScroll", &event, params, 0); }
void ScrollBarDrawThumb(Widget scrollWidget) { XtermWidget xw = getXtermWidget(scrollWidget); if (xw != 0) { TScreen *screen = TScreenOf(xw); int thumbTop, thumbHeight, totalHeight; thumbTop = ROW2INX(screen, screen->savedlines); thumbHeight = MaxRows(screen); totalHeight = thumbHeight + screen->savedlines; XawScrollbarSetThumb(scrollWidget, ((float) thumbTop) / (float) totalHeight, ((float) thumbHeight) / (float) totalHeight); } }
static void SetThumbHeight(Widget w) { ScrollByLineWidget sblw = (ScrollByLineWidget) w; float shown; if (sblw->scroll.bar == NULL) return; if (sblw->scroll.lines == 0) shown = 1.0; else shown = (float) w->core.height / (float) (sblw->scroll.lines * sblw->scroll.font_height); if (shown > 1.0) shown = 1.0; XawScrollbarSetThumb( sblw->scroll.bar, (float) -1, shown ); }
static void xaw_update_scrollbar (widget_instance *instance, Widget widget, widget_value *val) { if (val->scrollbar_data) { scrollbar_values *data = val->scrollbar_data; float widget_shown, widget_topOfThumb; float new_shown, new_topOfThumb; Arg al [10]; /* First size and position the scrollbar widget. */ Xt_SET_ARG (al [0], XtNx, data->scrollbar_x); Xt_SET_ARG (al [1], XtNy, data->scrollbar_y); Xt_SET_ARG (al [2], XtNwidth, data->scrollbar_width); Xt_SET_ARG (al [3], XtNheight, data->scrollbar_height); XtSetValues (widget, al, 4); /* Now size the scrollbar's slider. */ Xt_SET_ARG (al [0], XtNtopOfThumb, &widget_topOfThumb); Xt_SET_ARG (al [1], XtNshown, &widget_shown); XtGetValues (widget, al, 2); new_shown = (double) data->slider_size / (double) (data->maximum - data->minimum); new_topOfThumb = (double) (data->slider_position - data->minimum) / (double) (data->maximum - data->minimum); if (new_shown > 1.0) new_shown = 1.0; else if (new_shown < 0) new_shown = 0; if (new_topOfThumb > 1.0) new_topOfThumb = 1.0; else if (new_topOfThumb < 0) new_topOfThumb = 0; if (new_shown != widget_shown || new_topOfThumb != widget_topOfThumb) XawScrollbarSetThumb (widget, new_topOfThumb, new_shown); } }
/************************************************************************** ... **************************************************************************/ void rates_set_values(int tax, int no_tax_scroll, int lux, int no_lux_scroll, int sci, int no_sci_scroll) { char buf[64]; Boolean tax_lock, lux_lock, sci_lock; int maxrate; if (!can_client_issue_orders()) { return; } XtVaGetValues(rates_tax_toggle, XtNstate, &tax_lock, NULL); XtVaGetValues(rates_lux_toggle, XtNstate, &lux_lock, NULL); XtVaGetValues(rates_sci_toggle, XtNstate, &sci_lock, NULL); maxrate = get_player_bonus(client.conn.playing, EFT_MAX_RATES); /* This's quite a simple-minded "double check".. */ tax=MIN(tax, maxrate); lux=MIN(lux, maxrate); sci=MIN(sci, maxrate); if(tax+sci+lux!=100) { if(tax!=rates_tax_value) { if(!lux_lock) lux=MIN(MAX(100-tax-sci, 0), maxrate); if(!sci_lock) sci=MIN(MAX(100-tax-lux, 0), maxrate); } else if(lux!=rates_lux_value) { if(!tax_lock) tax=MIN(MAX(100-lux-sci, 0), maxrate); if(!sci_lock) sci=MIN(MAX(100-lux-tax, 0), maxrate); } else if(sci!=rates_sci_value) { if(!lux_lock) lux=MIN(MAX(100-tax-sci, 0), maxrate); if(!tax_lock) tax=MIN(MAX(100-lux-sci, 0), maxrate); } if(tax+sci+lux!=100) { lux=rates_lux_value; sci=rates_sci_value; tax=rates_tax_value; rates_tax_value=-1; rates_lux_value=-1; rates_sci_value=-1; no_tax_scroll=0; no_lux_scroll=0; no_sci_scroll=0; } } if(tax!=rates_tax_value) { my_snprintf(buf, sizeof(buf), _("Tax: %d%%"), tax); xaw_set_label(rates_tax_label, buf); if(!no_tax_scroll) XawScrollbarSetThumb(rates_tax_scroll, (tax/10)*1/11.0f, 1/11.0f); rates_tax_value=tax; } if(lux!=rates_lux_value) { my_snprintf(buf, sizeof(buf), _("Luxury: %d%%"), lux); xaw_set_label(rates_lux_label, buf); if(!no_lux_scroll) XawScrollbarSetThumb(rates_lux_scroll, (lux/10)*1/11.0f, 1/11.0f); rates_lux_value=lux; } if(sci!=rates_sci_value) { my_snprintf(buf, sizeof(buf), _("Science: %d%%"), sci); xaw_set_label(rates_sci_label, buf); if(!no_sci_scroll) XawScrollbarSetThumb(rates_sci_scroll, (sci/10)*1/11.0f, 1/11.0f); rates_sci_value=sci; } }
/* ARGSUSED */ XtCallbackProc open_tform_popup_cback(Widget w, xgobidata *xg, XtPointer callback_data) { Widget close; Widget form0; Dimension width, height; register int j, k; Widget box_variables, box_varlabels, box_tforms; Widget power_form, reduce_exp_arr, exp_sbar; Widget increase_exp_arr; char str[64]; static char *domain_menu_str = "Domain adjustment:"; Widget domain_menu_box, domain_menu_lab, domain_menu; Widget vport, vport_child; /*Widget reset_vgroups_cmd;*/ Widget box_stage[4]; Boolean doit = false; Dimension maxwidth = 0; if (tpopup == NULL) { tform_cols = (int *) XtMalloc((Cardinal) (xg->ncols-1) * sizeof(int)); var_cbox = (Widget *) XtMalloc((Cardinal) (xg->ncols-1) * sizeof(Widget)); /* xg->sph_vars = (int *) XtMalloc((Cardinal) (xg->ncols-1) * sizeof(int));* sphere - moved back to tour_pp */ alloc_transform_tp(xg); if (popupx == -1 && popupy == -1) { XtVaGetValues(xg->workspace, XtNwidth, &width, XtNheight, &height, NULL); XtTranslateCoords(xg->workspace, (Position) width, (Position) (height/2), &popupx, &popupy); } tpopup = XtVaCreatePopupShell("Variable Transformation", topLevelShellWidgetClass, xg->shell, XtNx, popupx, XtNy, popupy, XtNinput, True, XtNtitle, "Transform variables", XtNiconName, "Tform", NULL); if (mono) set_mono(tpopup); /* * Create a paned widget so the 'Click here ...' * can be all across the bottom. */ tpane = XtVaCreateManagedWidget("Form", panedWidgetClass, tpopup, XtNorientation, (XtOrientation) XtorientVertical, XtNresizable, False, NULL); form0 = XtVaCreateManagedWidget("Form", formWidgetClass, tpane, XtNresizable, False, NULL); if (mono) set_mono(form0); box_tforms = XtVaCreateManagedWidget("Close", boxWidgetClass, form0, XtNorientation, (XtOrientation) XtorientVertical, XtNleft, (XtEdgeType) XtChainLeft, XtNright, (XtEdgeType) XtChainLeft, XtNtop, (XtEdgeType) XtChainTop, XtNbottom, (XtEdgeType) XtChainTop, NULL); /* Stage 0: domain adjustment */ box_stage[0] = XtVaCreateManagedWidget("Close", boxWidgetClass, box_tforms, XtNorientation, (XtOrientation) XtorientHorizontal, NULL); domain_ind = DOMAIN_OK; build_labelled_menu(&domain_menu_box, &domain_menu_lab, domain_menu_str, &domain_menu_cmd, &domain_menu, domain_menu_btn, domain_menu_btn_label, domain_menu_btn_label, /* no nicknames */ NDOMAINBTNS, domain_ind, box_stage[0], NULL, XtorientHorizontal, appdata.font, "Transformations", xg); for (k=0; k<NDOMAINBTNS; k++) XtAddCallback(domain_menu_btn[k], XtNcallback, (XtCallbackProc) set_domain_incr_cback, (XtPointer) xg); /* Stage 1: most transformations */ box_stage[1] = XtVaCreateManagedWidget("Close", boxWidgetClass, box_tforms, NULL); XtVaCreateManagedWidget("Transformation Stage 1:", labelWidgetClass, box_stage[1], NULL); /* Power family */ power_form = XtVaCreateManagedWidget("Form", boxWidgetClass, box_stage[1], XtNresizable, False, XtNorientation, XtorientHorizontal, XtNhSpace, 1, XtNvSpace, 1, NULL); XtVaCreateManagedWidget("Label", labelWidgetClass, power_form, XtNlabel, (String) "Power (Box-Cox)", NULL); reduce_exp_arr = XtVaCreateManagedWidget("Icon", commandWidgetClass, power_form, XtNinternalHeight, (Dimension) 0, XtNinternalWidth, (Dimension) 0, XtNborderColor, (Pixel) appdata.fg, XtNbitmap, (Pixmap) leftarr, NULL); if (mono) set_mono(reduce_exp_arr); XtAddCallback(reduce_exp_arr, XtNcallback, (XtCallbackProc) reduce_exp_cback, (XtPointer) xg); sprintf(str, "Power Tformations"); width = XTextWidth(appdata.font, str, strlen(str)); exp_sbar = XtVaCreateManagedWidget("Scrollbar", scrollbarWidgetClass, power_form, XtNhorizDistance, (Dimension) 0, XtNwidth, (Dimension) width, XtNheight, (Dimension) 20, XtNorientation, (XtOrientation) XtorientHorizontal, NULL); if (mono) set_mono(exp_sbar); XtAddCallback(exp_sbar, XtNjumpProc, (XtCallbackProc) exp_sbar_cback, (XtPointer) xg); /* * -4,4 -> 0,1 */ XawScrollbarSetThumb(exp_sbar, (1. + 4)/8., -1.); increase_exp_arr = XtVaCreateManagedWidget("Icon", commandWidgetClass, power_form, XtNinternalHeight, (Dimension) 0, XtNinternalWidth, (Dimension) 0, XtNborderColor, (Pixel) appdata.fg, XtNhorizDistance, (Dimension) 0, XtNbitmap, (Pixmap) rightarr, NULL); if (mono) set_mono(increase_exp_arr); XtAddCallback(increase_exp_arr, XtNcallback, (XtCallbackProc) increase_exp_cback, (XtPointer) xg); (void) sprintf(str, "%1.2f", -9.99); width = XTextWidth(appdata.font, str, strlen(str) + 2*ASCII_TEXT_BORDER_WIDTH); (void) sprintf(str, "%4.2f", exponent); exponent_lbl = XtVaCreateManagedWidget("StdizeLabel", labelWidgetClass, power_form, XtNlabel, (String) str, XtNwidth, width, NULL); if (mono) set_mono(exponent_lbl); /* From Absolute Value to Normal Score */ for (j=0; j<N1TFORMS; j++) { if (j != 2) { stage1_tform_cmd[j] = CreateCommand(xg, stage1_tform_names[j], True, NULL, NULL, box_stage[1], "Transformations"); XtManageChild(stage1_tform_cmd[j]); XtAddCallback(stage1_tform_cmd[j], XtNcallback, (XtCallbackProc) stage1_tform_cback, (XtPointer) xg); } } /* Stage 2: permutation, sorting, sphering */ box_stage[2] = XtVaCreateManagedWidget("Close", boxWidgetClass, box_tforms, NULL); XtVaCreateManagedWidget("Transformation Stage 2:", labelWidgetClass, box_stage[2], NULL); for (j=0; j<N2TFORMS-1; j++) { stage2_tform_cmd[j] = CreateCommand(xg, stage2_tform_names[j], True, NULL, NULL, box_stage[2], "Transformations"); XtManageChild(stage2_tform_cmd[j]); XtAddCallback(stage2_tform_cmd[j], XtNcallback, (XtCallbackProc) stage2_tform_cback, (XtPointer) xg); } stage2_tform_cmd[SPHERE] = CreateCommand(xg, stage2_tform_names[SPHERE], True, NULL, NULL, box_stage[2], "Transformations"); XtManageChild(stage2_tform_cmd[SPHERE]); XtAddCallback(stage2_tform_cmd[SPHERE], XtNcallback, (XtCallbackProc) open_sphere_popup_cback, (XtPointer) xg); vport = XtVaCreateManagedWidget("ViewPort", viewportWidgetClass, form0, XtNallowHoriz, False, XtNallowVert, True, XtNfromHoriz, box_tforms, XtNleft, (XtEdgeType) XtChainLeft, XtNmappedWhenManaged, False, NULL); vport_child = XtVaCreateManagedWidget("Box", boxWidgetClass, vport, XtNorientation, (XtOrientation) XtorientHorizontal, NULL); box_variables = XtVaCreateManagedWidget("Box", formWidgetClass, vport_child, XtNleft, (XtEdgeType) XtChainLeft, XtNright, (XtEdgeType) XtChainLeft, XtNtop, (XtEdgeType) XtChainTop, XtNbottom, (XtEdgeType) XtChainTop, NULL); for (j=0; j<xg->ncols-1; j++) { var_cbox[j] = CreateToggle(xg, xg->collab[j], True, NULL, NULL, NULL, False, ANY_OF_MANY, box_variables, "Transformations"); if (j>0) XtVaSetValues(var_cbox[j], XtNfromVert, var_cbox[j-1], NULL); XtAddCallback(var_cbox[j], XtNcallback, (XtCallbackProc) var_cback, (XtPointer) xg); } XtManageChildren(var_cbox, xg->ncols-1); /* * dfs: let's just hide this thing reset_vgroups_cmd = CreateCommand(xg, "Restore vgroups", True, box_tforms, vport, form0, "Transformations"); XtManageChild(reset_vgroups_cmd); XtAddCallback(reset_vgroups_cmd, XtNcallback, (XtCallbackProc) reset_vgroups_cback, (XtPointer) xg); */ box_varlabels = XtVaCreateManagedWidget("Form", formWidgetClass, vport_child, XtNorientation, (XtOrientation) XtorientVertical, XtNfromHoriz, box_variables, NULL); for (j=0; j<xg->ncols-1; j++) { sprintf(str, "%s(%s(%s)))", "Stdize", "Perm", xg->collab[j]); width = XTextWidth(appdata.font, str, strlen(str)) + 2*ASCII_TEXT_BORDER_WIDTH; if (width > maxwidth) maxwidth = width; } width = XTextWidth(appdata.font, "normsc()", strlen("normsc()")) + 2*ASCII_TEXT_BORDER_WIDTH; maxwidth += width; varlabel = (Widget *) XtMalloc((Cardinal) (xg->ncols-1) * sizeof(Widget)); for (j=0; j<xg->ncols-1; j++) { varlabel[j] = XtVaCreateWidget("Label", labelWidgetClass, box_varlabels, XtNlabel, (String) xg->collab_tform2[j], XtNfromVert, (j>0) ? varlabel[j-1] : NULL, XtNwidth, maxwidth, NULL); } XtManageChildren(varlabel, xg->ncols-1); close = XtVaCreateManagedWidget("Close", commandWidgetClass, tpane, XtNshowGrip, (Boolean) False, XtNskipAdjust, (Boolean) True, XtNlabel, (String) "Click here to dismiss", NULL); if (mono) set_mono(close); XtAddCallback(close, XtNcallback, (XtCallbackProc) close_cback, (XtPointer) xg); set_initial_variable(xg); doit = true; } XtPopup(tpopup, (XtGrabKind) XtGrabNone); set_wm_protocols(tpopup); XRaiseWindow(display, XtWindow(tpopup)); if (doit) { Dimension hgt; XtVaGetValues(box_tforms, XtNheight, &hgt, NULL); XtVaSetValues(vport, XtNheight, hgt, NULL); XtMapWidget(vport); } }
void make_plot1d(xgobidata *xg) { /* * Plot1DPanel: plot1d_panel */ char str[35]; Dimension width, max_width; Widget ptype_box, cycle_box, ash_box; /* * Widest button label used in this panel. */ (void) sprintf(str, "ASH smoothness"); max_width = XTextWidth(appdata.font, str, strlen(str)); plot1d_panel = XtVaCreateManagedWidget("Plot1DPanel", boxWidgetClass, xg->box0, XtNleft, (XtEdgeType) XtChainLeft, XtNright, (XtEdgeType) XtChainLeft, XtNtop, (XtEdgeType) XtChainTop, XtNbottom, (XtEdgeType) XtChainTop, XtNmappedWhenManaged, (Boolean) False, XtNorientation, (XtOrientation) XtorientVertical, NULL); if (mono) set_mono(plot1d_panel); ptype_box = XtVaCreateManagedWidget("Plot1DPanel", boxWidgetClass, plot1d_panel, XtNleft, (XtEdgeType) XtChainLeft, XtNright, (XtEdgeType) XtChainLeft, XtNtop, (XtEdgeType) XtChainTop, XtNbottom, (XtEdgeType) XtChainTop, XtNorientation, (XtOrientation) XtorientVertical, NULL); if (mono) set_mono(ptype_box); plot1d_type_cmd[DOTPLOT] = CreateToggle(xg, "Plot1D", True, (Widget) NULL, (Widget) NULL, (Widget) NULL, (plot1d_type == DOTPLOT), ONE_OF_MANY, ptype_box, "Plot1D"); XtManageChild(plot1d_type_cmd[DOTPLOT]); XtAddCallback(plot1d_type_cmd[DOTPLOT], XtNcallback, (XtCallbackProc) ptype_dotplot_cback, (XtPointer) xg); plot1d_type_cmd[ASH] = CreateToggle(xg, "1D ASH", True, (Widget) NULL, (Widget) NULL, plot1d_type_cmd[DOTPLOT], (plot1d_type == ASH), ONE_OF_MANY, ptype_box, "Plot1D"); XtManageChild(plot1d_type_cmd[ASH]); XtAddCallback(plot1d_type_cmd[ASH], XtNcallback, (XtCallbackProc) ptype_ash_cback, (XtPointer) xg); /* ASH parameter */ ash_box = XtVaCreateManagedWidget("Plot1DPanel", boxWidgetClass, plot1d_panel, NULL); (void) XtVaCreateManagedWidget("Label", labelWidgetClass, ash_box, XtNlabel, "ASH smoothness", NULL); nASHes_sbar = XtVaCreateManagedWidget("Scrollbar", scrollbarWidgetClass, ash_box, XtNorientation, (XtOrientation) XtorientHorizontal, XtNwidth, (Dimension) max_width, NULL); if (mono) set_mono(nASHes_sbar); /* * range of the scrollbar: 0 to 1.0 * desired range: .01 + (0 to .5), which is nASHes/nbins * * (float) (nASHes) / (float) nbins = (slidepos+.01) / 2; * nASHes = (int) (nbins * (slidepos+.01) / 2.0); * slidepos = 2 * (float) nASHes / (float) nbins - .01; */ XawScrollbarSetThumb(nASHes_sbar, 2 * (float) nASHes / (float) nbins - .01, /*-- 2*20/200 - .01 --*/ -1.); XtAddCallback(nASHes_sbar, XtNjumpProc, (XtCallbackProc) nASHes_cback, (XtPointer) xg); add_sbar_help(&xg->nhelpids.sbar, nASHes_sbar, "Plot1D"); sprintf(str, "%1.4f", 0.9999); width = XTextWidth(appdata.font, str, strlen(str)); sprintf(str, "%1.3f", (float)nASHes/(float)nbins); nASHes_label = XtVaCreateManagedWidget("Plot1D", labelWidgetClass, ash_box, XtNlabel, str, XtNwidth, width, NULL); if (mono) set_mono(nASHes_label); /* */ cycle_box = XtVaCreateManagedWidget("Plot1DPanel", boxWidgetClass, plot1d_panel, NULL); plot1d_cycle_cmd = CreateToggle(xg, "Cycle", True, (Widget) NULL, (Widget) NULL, (Widget) NULL, False, ANY_OF_MANY, cycle_box, "Plot1D_Cycle"); XtManageChild(plot1d_cycle_cmd); XtAddCallback(plot1d_cycle_cmd, XtNcallback, (XtCallbackProc) plot1d_cycle_cback, (XtPointer) xg); plot1d_delay_sbar = XtVaCreateManagedWidget("Scrollbar", scrollbarWidgetClass, cycle_box, XtNorientation, (XtOrientation) XtorientHorizontal, XtNwidth, (Dimension) max_width, XtNfromVert, (Widget) plot1d_cycle_cmd, NULL); if (mono) set_mono(plot1d_delay_sbar); /* * delay = 1 / (2*slidepos + .2) * slidepos = 1 / (2*delay) - .1 */ XawScrollbarSetThumb(plot1d_delay_sbar, 1.0 / (2.0 * delay) - 0.1, -1.); XtAddCallback(plot1d_delay_sbar, XtNjumpProc, (XtCallbackProc) plot1d_cycle_delay_cback, (XtPointer) xg); add_sbar_help(&xg->nhelpids.sbar, plot1d_delay_sbar, "Plot1D_Cycle"); plot1d_chdir_cmd = CreateCommand(xg, "Change direction", True, (Widget) NULL, (Widget) NULL, cycle_box, "Plot1D_Cycle"); XtManageChild(plot1d_chdir_cmd); XtAddCallback(plot1d_chdir_cmd, XtNcallback, (XtCallbackProc) plot1d_chdir_cback, (XtPointer) NULL); }
void SFupdatePath (void) { static int alloc; static int wasTwiddle = 0; char *begin, *end; int i, j; int prevChange; int SFdirPtrSave, SFdirEndSave; SFDir *dir; if (!SFdirs) { SFdirs = (SFDir *) XtMalloc ((alloc = 10) * sizeof (SFDir)); dir = &(SFdirs[0]); SFstrdup (&dir->dir, "/"); SFchdir ("/"); SFgetDir (dir); for (j = 1; j < alloc; j++) { SFdirs[j].dir = NULL; } dir->path = SFcurrentPath + 1; dir->vOrigin = 0; dir->hOrigin = 0; dir->changed = 1; dir->beginSelection = -1; dir->endSelection = -1; SFhomeDir.dir = NULL; } SFdirEndSave = SFdirEnd; SFdirEnd = 1; SFdirPtrSave = SFdirPtr; SFdirPtr = 0; begin = NULL; if (SFcurrentPath[0] == '~') { if (!SFtwiddle) { SFtwiddle = 1; dir = & (SFdirs[0]); SFrootDir = *dir; if (!SFhomeDir.dir) { SFgetHomeDirs (); } *dir = SFhomeDir; dir->changed = 1; } end = SFcurrentPath; SFdoNotTouchDirPtr = 1; wasTwiddle = 1; } else { if (SFtwiddle) { SFtwiddle = 0; dir = & (SFdirs[0]); *dir = SFrootDir; dir->changed = 1; } end = SFcurrentPath + 1; } i = 0; prevChange = 0; while (*end) { while (*end++ == '/') { ; } end--; begin = end; while ((*end) && (*end++ != '/')) { ; } if ((end - SFcurrentPath <= SFtextPos) && (* (end - 1) == '/')) { SFdirPtr = i - 1; if (SFdirPtr < 0) { SFdirPtr = 0; } } if (*begin) { if (*(end - 1) == '/') { char save = *end; if (SFtwiddle) { if (SFfindHomeDir (begin, end)) { return; } } *end = 0; i++; SFdirEnd++; if (i >= alloc) { SFdirs = (SFDir *) XtRealloc ( (char *) SFdirs, (unsigned) ((alloc *= 2) * sizeof (SFDir)) ); for (j = alloc / 2; j < alloc; j++) { SFdirs[j].dir = NULL; } } dir = &(SFdirs[i]); if ((!(dir->dir)) || prevChange || strcmp (dir->dir, begin)) { if (dir->dir) { SFfree (i); } prevChange = 1; SFstrdup (&dir->dir, begin); dir->path = end; dir->vOrigin = 0; dir->hOrigin = 0; dir->changed = 1; dir->beginSelection = -1; dir->endSelection = -1; SFfindFile (dir - 1, begin); if (SFchdir (SFcurrentPath) || SFgetDir (dir)) { SFunreadableDir (dir); break; } } *end = save; if (!save) { SFunselect (); } } else { if (SFfindFile (& (SFdirs[SFdirEnd-1]), begin)) { return; } } } else { SFunselect (); } } if ((end == SFcurrentPath + 1) && (!SFtwiddle)) { SFunselect (); } for (i = SFdirEnd; i < alloc; i++) { if (SFdirs[i].dir) { SFfree (i); } } if (SFdoNotTouchDirPtr) { if (wasTwiddle) { wasTwiddle = 0; SFdirPtr = SFdirEnd - 2; if (SFdirPtr < 0) { SFdirPtr = 0; } } else { SFdirPtr = SFdirPtrSave; } SFdoNotTouchDirPtr = 0; } if ((SFdirPtr != SFdirPtrSave) || (SFdirEnd != SFdirEndSave)) { XawScrollbarSetThumb ( selFileHScroll, (float) (((double) SFdirPtr) / SFdirEnd), (float) (((double) ((SFdirEnd < 3) ? SFdirEnd : 3)) / SFdirEnd) ); } if (SFdirPtr != SFdirPtrSave) { SFdrawLists (SF_DO_SCROLL); } else { for (i = 0; i < 3; i++) { if (SFdirPtr + i < SFdirEnd) { if (SFdirs[SFdirPtr + i].changed) { SFdirs[SFdirPtr + i].changed = 0; SFdrawList (i, SF_DO_SCROLL); } } else { SFclearList (i, SF_DO_SCROLL); } } } }
static void SetBar(Widget w, int top, unsigned int length, unsigned int total) { XawScrollbarSetThumb(w, (float)top / (float)total, (float)length / (float)total); }