Beispiel #1
0
/* 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);
  }
}
Beispiel #2
0
 virtual void RecreateWidget() { CreateToggle(); }
Beispiel #3
0
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);

}
Beispiel #4
0
int main(int argc, char **argv)
{
    register int  n;
    Arg args[MAX_ARGS];
    XmString tcs;
    void PostPopup();
    void ButtonCB();

    CommonTestInit(argc, argv);
    
    n = 0;
    XtSetArg(args[n], XmNwidth,  200);  n++;
    XtSetArg(args[n], XmNheight, 40);   n++;
    XtSetValues(Shell1, args, n);

    XtRealizeWidget(Shell1);

    Label = CreateLabel("Press MB3 to dismiss PopupMenu", Shell1);

    /*
    **  PopupMenu1
    */

    n = 0;
    XtSetArg(args[n], XmNx,  100);  n++;
    XtSetArg(args[n], XmNy, 100);   n++;
    XtSetArg(args[n], XmNmenuAccelerator, NULL); n++;
    PopupMenu1 = XmCreatePopupMenu(Label, "popupMenu", args, n);

    /*
    **  Menu1
    */

    Label1 = CreateLabel("Menu1", PopupMenu1);
    Separator1 = CreateSeparator(PopupMenu1, "Separator1");
    PushBtn1 = CreatePushButton("PushButton1", PopupMenu1);
    ToggleBtn1 = CreateToggle("Toggle1", PopupMenu1);
    XtManageChild(PopupMenu1);

    CommonPause();
    XtDestroyWidget(PopupMenu1);
    
    n =0;
    XtSetArg(args[n], XmNrowColumnType, XmMENU_POPUP); n++;
    PopupMenu2 = XmCreateRowColumn(Shell1, "popupMenu2", args, n);

    /*
    **  Menu2
    */

    Label2 = CreateLabel("Menu2", PopupMenu2);
    Separator2 = CreateSeparator(PopupMenu2, "Separator2");
    PushBtn2 = CreatePushButton("PushButton2", PopupMenu2);
    ToggleBtn2 = CreateToggle("Toggle2", PopupMenu2);
    XtManageChild(PopupMenu2);

    CommonPause();

    XtDestroyWidget(Label);
    XtDestroyWidget(PopupMenu2);

    /*
     *  Test 3 for PIR 2669
     */

    n = 0;
    testingArea = XmCreateBulletinBoard(Shell1, "PushButtonHere", args, n);

    n = 0;
    XtSetArg(args[n], XmNx, 10); n++;
    XtSetArg(args[n], XmNy, 30); n++;
    MainButton = XmCreatePushButton(testingArea, "button0", args, n);
    XtAddCallback(MainButton, XmNactivateCallback, ButtonCB, (XtPointer) 0); 
    XtManageChild(MainButton);

    popup = XmCreatePopupMenu(testingArea, "Popups", NULL, 0);
    XtAddEventHandler(testingArea, ButtonPressMask, FALSE, PostPopup, popup);
    
    XmAddToPostFromList(popup, MainButton);
    
    push = XmCreatePushButton(popup, "button1", NULL, 0);
    XtAddCallback(push, XmNactivateCallback, ButtonCB, (XtPointer) 1);
    XtManageChild(push);

    push = XmCreatePushButton(popup, "button2", NULL, 0);
    XtAddCallback(push, XmNactivateCallback, ButtonCB, (XtPointer) 2);
    XtManageChild(push);

    push = XmCreatePushButton(popup, "button3", NULL, 0);
    XtAddCallback(push, XmNactivateCallback, ButtonCB, (XtPointer) 3);
    XtManageChild(push);
    
    XtManageChild(testingArea);
    
    CommonPause();

    XtDestroyWidget(testingArea);

    CommonPause();

    XtAppMainLoop(app_context);
}