static Widget create_tool_controls_dialog( Widget topl) { Widget dialog, control, form; dialog = HGU_XmCreateStdDialog(topl, "tool_control_dialog", xmFormWidgetClass, NULL, 0); control = XtNameToWidget( dialog, "*.Cancel" ); XtRemoveAllCallbacks(control, XmNactivateCallback); XtAddCallback(control, XmNactivateCallback, UnmanageChildCb, (XtPointer) dialog); control = XtNameToWidget( dialog, "*.control" ); form = CreateDrawPaintBallControls( control ); (void) CreateThresholdControls( control ); (void) CreateGeometryObjectControls( control ); (void) CreateFillControls( control ); (void) CreateMorphologicalControls( control ); (void) CreateAffineControls( control ); (void) CreateTracking2DControls( control ); (void) CreateEdgeTracking2DControls( control ); #if !defined (LINUX2) && !defined (DARWIN) && !defined (SUNOS5) (void) CreateTabletControls( control ); #endif /* LINUX2 */ XtManageChild( form ); return( dialog ); }
/**************************************************************** ... *****************************************************************/ void popup_caravan_dialog(struct unit *punit, struct city *phomecity, struct city *pdestcity) { char buf[128]; fc_snprintf(buf, sizeof(buf), _("Your %s from %s reaches the city of %s.\nWhat now?"), unit_name_translation(punit), city_name(phomecity), city_name(pdestcity)); caravan_city_id=pdestcity->id; /* callbacks need these */ caravan_unit_id=punit->id; caravan_dialog=popup_message_dialog(toplevel, "caravandialog", buf, caravan_establish_trade_callback, 0, 0, caravan_help_build_wonder_callback, 0, 0, caravan_keep_moving_callback, 0, 0, NULL); if (!can_cities_trade(phomecity, pdestcity)) XtSetSensitive(XtNameToWidget(caravan_dialog, "*button0"), FALSE); if(!unit_can_help_build_wonder(punit, pdestcity)) XtSetSensitive(XtNameToWidget(caravan_dialog, "*button1"), FALSE); }
void UIDialogFormPopup (Widget widget) { Dimension actionHeight; if (!XtIsManaged (XtNameToWidget (widget,UIDialogBulletinName))) { Widget *children; int numChildren; XtVaGetValues (XtNameToWidget (widget,UIDialogPaneName), XmNchildren, &children, XmNnumChildren, &numChildren, NULL); XtManageChild (XtNameToWidget (widget,UIDialogBulletinName)); while (numChildren-- > 0) if (XmIsTraversable (children [numChildren])) XtVaSetValues (children [numChildren],XmNtraversalOn, false, NULL); XtVaGetValues (XtNameToWidget (widget,UIDialogActionFormName),XmNheight, &actionHeight, NULL); XtVaSetValues (XtNameToWidget (widget,UIDialogActionFormName),XmNpaneMaximum, actionHeight, XmNpaneMinimum, actionHeight, NULL); } XtPopup (widget,XtGrabNone); UILoop (); }
void x_set_edit_place( long index, int x, int y, int nx, int ny ) { Widget horiz_scroll, vert_scroll; float shown_horiz, shown_vert; Dimension list_nx, list_ny; int element_dx, element_dy, cx, cy; if( dataedit_popup_widget == NULL ) return; XawListHighlight( dataedit_list_widget, index ); horiz_scroll = XtNameToWidget( dataedit_viewport_widget, "horizontal" ); vert_scroll = XtNameToWidget( dataedit_viewport_widget, "vertical" ); XtVaGetValues( horiz_scroll, XtNshown, &shown_horiz, NULL ); XtVaGetValues( vert_scroll, XtNshown, &shown_vert, NULL ); XtVaGetValues( dataedit_list_widget, XtNwidth, &list_nx, XtNheight, &list_ny, NULL ); element_dx = list_nx / nx; element_dy = list_ny / ny; cx = (x-2)*element_dx; cy = (y-5)*element_dy; XawViewportSetCoordinates( dataedit_viewport_widget, cx, cy ); }
void HGU_XmSetSliderValue(Widget slider, float value) { Widget scale, text; XmScaleCallbackStruct cbs; short points; int min, max; HGU_XmSliderFunc func; if( (scale = XtNameToWidget(slider, ".scale")) == NULL ) return; if( (text = XtNameToWidget(slider, ".text")) == NULL ) return; XtVaGetValues(scale, XmNdecimalPoints, &points, XmNminimum, &min, XmNmaximum, &max, XmNuserData, &func, NULL); while( points-- > 0 ) value *= 10.0; if( func != NULL ) value = min + (max - min) * (*func)((float) (value - min) / (max - min), 1); cbs.reason = XmCR_VALUE_CHANGED; cbs.event = NULL; cbs.value = nint((double) value); XtVaSetValues(scale, XmNvalue, cbs.value, NULL); update_slider_text(scale, text, &cbs); return; }
static void OpenHost(Widget W, Widget w) { Widget Host; Widget Port; #ifdef DEBUG printf("OpenHost(%s,%s) - %s %s\n", XtName(W), XtName(w), Host_Name(w), Host_Port(w)); #endif Disconnect(w); Host = XtNameToWidget(W, "*HostText"); Port = XtNameToWidget(W, "*PortText"); /* I should be able to free this but can't seem to on HP-UX!! XtFree(Host_Name(w)); XtFree(Host_Port(w)); */ Host_Name(w) = XmTextFieldGetString(Host); Host_Port(w) = XmTextFieldGetString(Port); /* printf("Host (%s)>%s< Port (%s)>%s<\n", XtName(Host), Host_Name(w), XtName(Port), Host_Port(w)); */ /* Connect(w); */ XtAppAddTimeOut(XtWidgetToApplicationContext(w), 1000, (XtTimerCallbackProc)Connect, w); }
static void pts_activate_proc(Widget w) { Widget parent_w = XtParent(w); Widget mems_w = XtNameToWidget(parent_w, "mems_scale"); Widget header_w = XtNameToWidget(parent_w, "header_menu"); Widget pts_dlog = XtNameToWidget(parent_w, "*pts_dlog"); int pts[8]; int mems; struct descriptor_xd *header_xd = XmdsNidOptionMenuGetXd(header_w); static char header[7]; static struct descriptor header_dsc = {sizeof(header), DTYPE_T, CLASS_S, header}; int status = TdiText(header_xd, &header_dsc MDS_END_ARG); int i; XmScaleGetValue(mems_w, &mems); L8210HeaderToPTS(header, (char *)&mems, pts); for (i=0; i<8; i++) { char pts_str[10]; char name_str[9]; XmString lab; sprintf(pts_str, "%d", pts[i]); sprintf(name_str,"*.pts_%d",i); lab = XmStringCreateSimple(pts_str); XtVaSetValues(XtNameToWidget(pts_dlog,name_str), XmNlabelString, lab, NULL); XmStringFree(lab); } XtManageChild(pts_dlog); }
void XmdsXdBoxOnOffButtonReset(Widget w) { if (XmdsIsXdBoxOnOffButton(w)) { XmdsOnOffToggleButtonReset(XtNameToWidget(w,"xmds_xdbox_on_off")); XmdsXdBoxDialogButtonReset(XtNameToWidget(w,"xmds_xdbox_dialog_button")); } }
int XmdsXdBoxOnOffButtonApply(Widget w) { int status = 0; if (XmdsIsXdBoxOnOffButton(w)) if ((status = XmdsOnOffToggleButtonApply(XtNameToWidget(w,"xmds_xdbox_on_off"))) & 1) status = XmdsXdBoxDialogButtonApply(XtNameToWidget(w,"xmds_xdbox_dialog_button")); return status; }
void MakeSearchWidget(ManpageGlobals * man_globals, Widget parent) { Widget dialog, command, text, cancel; Arg arglist[2]; Cardinal num_args = 0; XtSetArg(arglist[0], XtNtransientFor, parent); man_globals->search_widget = XtCreatePopupShell(SEARCHNAME, transientShellWidgetClass, parent, arglist, 1); if (resources.clear_search_string) { XtSetArg(arglist[0], XtNvalue, ""); num_args++; } dialog = XtCreateManagedWidget(DIALOG, dialogWidgetClass, man_globals->search_widget, arglist, num_args); if ((text = XtNameToWidget(dialog, "value")) == (Widget) NULL) PopupWarning(NULL, "Could not find text widget in MakeSearchWidget."); else XtSetKeyboardFocus(dialog, text); XawDialogAddButton(dialog, MANUALSEARCH, NULL, NULL); XawDialogAddButton(dialog, APROPOSSEARCH, NULL, NULL); XawDialogAddButton(dialog, CANCEL, NULL, NULL); /* * This is a bit gross, but it get the cancel button underneath the * others, and forms them up to the right size.. */ if (((command = XtNameToWidget(dialog, MANUALSEARCH)) == (Widget) NULL) || ((cancel = XtNameToWidget(dialog, CANCEL)) == (Widget) NULL)) PopupWarning(NULL, "Could not find manual search widget in MakeSearchWidget."); else { static const char *half_size[] = { MANUALSEARCH, APROPOSSEARCH, NULL }; static const char *full_size[] = { "label", "value", CANCEL, NULL }; num_args = 0; XtSetArg(arglist[num_args], XtNfromVert, command); num_args++; XtSetArg(arglist[num_args], XtNfromHoriz, NULL); num_args++; XtSetValues(cancel, arglist, num_args); FormUpWidgets(dialog, full_size, half_size); } }
void UIAttribView::DrawField (char *fieldName,char *textSTR) { Widget label; label = XtNameToWidget (FieldsRowCol,fieldName); if (label != (Widget) NULL) { label = XtNameToWidget (label,"UIAttribViewTextField"); XmTextFieldSetString (label,textSTR); } }
/* * ------------------------------------------------------------------------ * Name: PdmJobBoxCreate * * Description: * * Creates a managed PDM Job options setup box widget. * * Return value: * * The passed PdmJobBox (PdmSetupBox) instance structure. * */ static void PdmJobBoxCreate(PdmSetupBox* me, Widget parent) { PdmJobBoxData* data = (PdmJobBoxData*)me->subclass_data; me->widget = _DtCreatePDMJobSetup(parent); XtManageChild(me->widget); /* * get the control widget ids */ data->notify_toggle = XtNameToWidget(me->widget, "*SendMail.button_0"); data->job_name_text = XtNameToWidget(me->widget, "*Banner"); data->job_options_text = XtNameToWidget(me->widget, "*Options"); /* * initialize the banner field */ if(data->job_name_supported) { XtVaSetValues(data->job_name_text, XmNvalue, data->job_name, NULL); } else { XtSetSensitive(data->job_name_text, False); XtSetSensitive(XtNameToWidget(me->widget, "*BannerLabel"), False); } /* * initialize the options field */ if(data->job_options_supported) { XtVaSetValues(data->job_options_text, XmNvalue, data->job_options, NULL); } else { XtSetSensitive(data->job_options_text, False); XtSetSensitive(XtNameToWidget(me->widget, "*OptionsLabel"), False); } /* * initialize the send mail toggle */ if(data->notification_profile_supported) { Boolean set; set = PDMOID_NOTIFY_EMAIL == data->notification_profile ? True : False; XmToggleButtonGadgetSetState(data->notify_toggle, set, False); } else { XtSetSensitive(data->notify_toggle, False); } }
static void scale_value_changed (Widget widget, XtPointer client_data, XtPointer call_data) { Widget form; Widget patch_widget; Widget text_widget; ColorDataPtr colordata; Arg arg[2]; XmScaleCallbackStruct *callback_data; char *tag; callback_data = (XmScaleCallbackStruct *) call_data; tag = (char *) client_data; form = XtParent(XtParent(widget)); patch_widget = XtNameToWidget(form,"color_patch"); text_widget = XmSelectionBoxGetChild( XtNameToWidget(form,"color_sb"), XmDIALOG_TEXT); XtSetArg(arg[0],XmNuserData,&colordata); XtGetValues(form,arg,1); /* based on the tag, set either the red,green, or blue static variables, */ /* then set color of label0 */ if(*tag == 'r'){ colordata->color.red = callback_data->value * COLOR_PCT_MULTIPLIER; sprintf(colordata->redname,"%4.4x",colordata->color.red); } else if(*tag == 'g'){ colordata->color.green = callback_data->value * COLOR_PCT_MULTIPLIER; sprintf(colordata->greenname,"%4.4x",colordata->color.green); } else if(*tag == 'b'){ colordata->color.blue = callback_data->value * COLOR_PCT_MULTIPLIER; sprintf(colordata->bluename,"%4.4x",colordata->color.blue); } /* update the color cell */ XStoreColor(dpy,cmap,&(colordata->color)); /* assemble complete hex-string and set editable text to it */ strcpy(colordata->colorname,"#"); strcat(colordata->colorname,colordata->redname); strcat(colordata->colorname,colordata->greenname); strcat(colordata->colorname,colordata->bluename); XmTextSetString(text_widget,colordata->colorname); }
Boolean CvtStringToWidget(Display *display, XrmValue *args, Cardinal *num_args, XrmValue *fromVal, XrmValue *toVal, XtPointer *) { // Convert first arg into parent if (*num_args != 1) { XtAppErrorMsg(XtDisplayToApplicationContext(display), "wrongParameters", "CvtStringToWidget", "XtToolkitError", "String to Widget conversion needs parent arg", (String *)0, (Cardinal *)0); } Widget parent = *(Widget *) args[0].addr; // Get widget const string value = str(fromVal, false); Widget w = XtNameToWidget(parent, value.chars()); if (w == 0) { XtDisplayStringConversionWarning(display, fromVal->addr, XtRWidget); return False; } done(Widget, w); }
/* Get a widget with `name' somewhere in the widget hierarchy below `parent' (matching is done against `*name') and return it in `ret'. If `report_error' is True, a warning message is popped up if the widget isn't found. */ Boolean get_widget_by_name(Widget *ret, Widget parent, const char *name, Boolean report_error) { char buf[1024]; Widget test; /* if (parent == 0 || !XtIsManaged(parent)) { */ /* fprintf(stderr, "Widget %p not managed!\n", parent); */ /* return False; */ /* } */ if (strlen(name) > 1023) { popup_message(globals.widgets.top_level, MSG_ERR, REPORT_XDVI_BUG_TEMPLATE, "Widget name `%s' too long, couldn't get parent", name); return False; } buf[0] = '*'; /* add wildcard to also match paths */ strcpy(buf + 1, name); if ((test = XtNameToWidget(parent, buf)) != NULL) { *ret = test; return True; } else { if (report_error) popup_message(globals.widgets.top_level, MSG_ERR, REPORT_XDVI_BUG_TEMPLATE, "XtNameToWidget failed for `%s', parent `%s'", name, XtName(parent)); return False; } }
void HGU_XmSetSliderRange(Widget slider, float minval, float maxval) { Widget scale; short points; float value, val; int minv, maxv, ivalue; if( maxval <= minval ) return; if( (scale = XtNameToWidget(slider, ".scale")) == NULL ) return; XtVaGetValues(scale, XmNdecimalPoints, &points, NULL); value = HGU_XmGetSliderValue( slider ); if( value > maxval ) value = maxval; if( value < minval ) value = minval; val = value; while( points-- > 0 ){ minval *= 10.0; maxval *= 10.0; val *= 10.0; } minv = (int) minval; maxv = (int) maxval; ivalue = (int) val; XtVaSetValues(scale, XmNminimum, minv, XmNmaximum, maxv, XmNvalue, ivalue, NULL); HGU_XmSetSliderValue( slider, value ); return; }
static void EnableMenu(Widget fc, char *s) { int nogood, j, ii; char *p, *q; char field[14][64]; /* ??? FIX ME */ Widget b; nogood = 0; p = s; for (j=0, s; j<14; j++) { /* Scan for a dash and a string starting at p, store it in field */ if (*p != '-') { fprintf(stderr, "%s: Can't scan font name '%s'\n", XtName(fc), s); nogood = 1; break; } p++; ii=0; field[j][ii++] = '*'; for (q=p; *q && *q != '-' && ii < 64; q++, ii++) field[j][ii] = *q; field[j][ii] = '\0'; b = XtNameToWidget(FC_Menus(fc)[j], field[j]); if (b) XtSetSensitive(b, True); if (*q) p = q; else break; } }
void HGU_XmGetSliderRange( Widget slider, float *minval, float *maxval) { Widget scale; short points; int minv, maxv; if( (scale = XtNameToWidget(slider, ".scale")) == NULL ) return; XtVaGetValues(scale, XmNdecimalPoints, &points, XmNminimum, &minv, XmNmaximum, &maxv, NULL); *minval = minv; *maxval = maxv; while( points-- > 0 ){ *minval /= 10.0; *maxval /= 10.0; } return; }
static void UpdateGraph(WorkingData_t *Data) { Dimension width, height; Widget title = XtNameToWidget(XtParent(Data->Da), "*Title"); XmString string; char buf[1024]; XtVaGetValues(Data->Da, XmNwidth, &width, XmNheight, &height, NULL); sprintf(buf, "%i%%", Data->percent); string = XmStringCreateSimple(buf); XtVaSetValues(title, XmNlabelString, string, NULL); XmStringFree(string); XFillRectangle(XtDisplay(Data->Da), XtWindow(Data->Da), Data->gc, 0, 0, (width * Data->percent) / 100, height); XmUpdateDisplay(Data->Da); Data->Id = XtAppAddTimeOut(XtWidgetToApplicationContext(Data->Da), 1000, (XtTimerCallbackProc)UpdateGraph, Data); }
void create_dialog(uschar *label, uschar *value) { Arg warg[4]; Dimension x, y, xx, yy; XtTranslations pop_trans; Widget text; /* Get the position of a reference widget so the dialog box can be put near to it. */ get_pos_args[0].value = (XtArgVal)(&x); get_pos_args[1].value = (XtArgVal)(&y); XtGetValues(dialog_ref_widget, get_pos_args, 2); /* When this is not a message_specific thing, the position of the reference widget is relative to the window. Get the position of the top level widget and add to the position. */ if (dialog_ref_widget != menushell) { get_pos_args[0].value = (XtArgVal)(&xx); get_pos_args[1].value = (XtArgVal)(&yy); XtGetValues(toplevel_widget, get_pos_args, 2); x += xx; y += yy; } /* Create a transient shell for the dialog box. */ XtSetArg(warg[0], XtNtransientFor, queue_widget); XtSetArg(warg[1], XtNx, x + 50); XtSetArg(warg[2], XtNy, y + 50); XtSetArg(warg[3], XtNallowShellResize, True); dialog_shell = XtCreatePopupShell("forDialog", transientShellWidgetClass, toplevel_widget, warg, 4); /* Create the dialog box. */ dialog_arg[0].value = (XtArgVal)label; dialog_arg[1].value = (XtArgVal)value; dialog_widget = XtCreateManagedWidget("dialog", dialogWidgetClass, dialog_shell, dialog_arg, XtNumber(dialog_arg)); /* Get the text widget from within the dialog box, give it the keyboard focus, make it wider than the default, and override its translations to make Return call the dialog action function. */ text = XtNameToWidget(dialog_widget, "value"); XawTextSetInsertionPoint(text, Ustrlen(value)); XtSetKeyboardFocus(dialog_widget, text); xs_SetValues(text, 1, "width", 200); pop_trans = XtParseTranslationTable( "<Key>Return: dialogAction()\n"); XtOverrideTranslations(text, pop_trans); /* Pop the thing up. */ XtPopup(dialog_shell, XtGrabExclusive); XFlush(X_display); }
void expand_command (Widget w, XtPointer client_data, XtPointer call_data) { font_type *f = (font_type *) client_data; /* We must use `*bitmap' here, since the editable Bitmap is a child of the Viewport. Incidentally, R3's XtNameToWidget won't work here. */ Widget bw = XtNameToWidget (XtParent (w), "*bitmap"); bitmap_type *b = BitmapBits (bw); char_type *c = XTALLOC (1, char_type); /* Copy the current character, so the `*_set_values' commands can notice something is changed. */ *c = *FONT_CURRENT_CHAR (*f); /* Do the enlargement. */ BCHAR_BITMAP (*c) = enlarge_bitmap (*b); /* We have to increase the bounding box for the character. The best way to do this is not obvious. Right now, we arrange things so that the origin of the character does not move, i.e., the new row at the bottom is below the baseline, and the new column at the left is into the side bearing. Perhaps we should have four separate expand commands (or something along those lines). */ BCHAR_SET_WIDTH (*c) += 2; BCHAR_MIN_COL (*c)--; BCHAR_MAX_COL (*c)++; BCHAR_MIN_ROW (*c)--; BCHAR_MAX_ROW (*c)++; /* Display the new values. */ show_char (XtParent (w), f, c); /* Free afterwards; see revert_command. */ free_bitmap (b); }
void EngineOutputPopDown () { Arg args[16]; int j; if (!engineOutputDialogUp) return; DoClearMemo(1); j = 0; XtSetArg(args[j], XtNx, &engineOutputX); j++; XtSetArg(args[j], XtNy, &engineOutputY); j++; XtSetArg(args[j], XtNwidth, &engineOutputW); j++; XtSetArg(args[j], XtNheight, &engineOutputH); j++; XtGetValues(engineOutputShell, args, j); wpEngineOutput.x = engineOutputX - 4; wpEngineOutput.y = engineOutputY - 23; wpEngineOutput.width = engineOutputW; wpEngineOutput.height = engineOutputH; XtPopdown(engineOutputShell); XSync(xDisplay, False); j=0; XtSetArg(args[j], XtNleftBitmap, None); j++; XtSetValues(XtNameToWidget(menuBarWidget, "menuView.Show Engine Output"), args, j); engineOutputDialogUp = False; ShowThinkingEvent(); // [HGM] thinking: might need to shut off thinking output }
void UIAttribView::Draw (DBObjRecord *record) { DBObjTableField *field; DBObjectLIST<DBObjTableField> *fields; UIXYGraphShell *graphCLS; if (record == (DBObjRecord *) NULL) { Cardinal i, numChildren; WidgetList rowCols; UIAuxSetLabelString (ItemNameWGT,(char *) ""); XtVaGetValues (FieldsRowCol,XmNchildren, &rowCols, XmNnumChildren, &numChildren,NULL); for (i = 0;i < numChildren; ++i) XmTextFieldSetString (XtNameToWidget (rowCols [i],"UIAttribViewTextField"),(char *) ""); return; } UIAuxSetLabelString (ItemNameWGT,record->Name ()); switch (DataPTR->Type ()) { case DBTypeVectorPoint: case DBTypeVectorLine: case DBTypeVectorPolygon: case DBTypeGridDiscrete: fields = ItemTable->Fields (); for (field = fields->First ();field != (DBObjTableField *) NULL;field = fields->Next ()) if (DBTableFieldIsVisible (field) == true) DrawField (field->Name (),field->String (record)); break; case DBTypeGridContinuous: { DBCoordinate coord = *((DBCoordinate *) (record->Data ())); DBGridIF *gridIF = new DBGridIF (DataPTR); for (record = ItemTable->First ();record != (DBObjRecord *) NULL;record = ItemTable->Next ()) DrawField (record->Name (),gridIF->ValueString (record,coord)); delete gridIF; } break; case DBTypeNetwork: { DBObjTable *cellTable = DataPTR->Table (DBrNCells); DBObjTableField *basinFLD = cellTable->Field (DBrNBasin); DBObjRecord *basinRec; if ((basinRec = ItemTable->Item (basinFLD->Int (record) - 1)) == (DBObjRecord *) NULL) { CMmsgPrint (CMmsgAppError, "BasinID Error in:%s %d",__FILE__,__LINE__); return; } DrawField ((char *) "Basin Name",basinRec->Name ()); fields = ItemTable->Fields (); for (field = fields->First ();field != (DBObjTableField *) NULL;field = fields->Next ()) if (DBTableFieldIsVisible (field) == true) DrawField (field->Name (),field->String (basinRec)); fields = cellTable->Fields (); for (field = fields->First ();field != (DBObjTableField *) NULL;field = fields->Next ()) if (DBTableFieldIsVisible (field) == true) DrawField (field->Name (),field->String (record)); } break; default: break; } if ((graphCLS = (UIXYGraphShell *) DataPTR->Display (UIXYGraphShellStr)) != (UIXYGraphShell *) NULL) graphCLS->Configure (record); }
Widget MakeMenuItem(Widget parent, char *name, ButtonCB func, void *arg) { int n = 0; Arg wargs[5]; /* Used to set widget resources */ Widget item, menu; if (lsx_curwin->toplevel == NULL && OpenDisplay(0,NULL) == 0) return NULL; if (parent == NULL) return NULL; /* * We get the "menu" widget child of the parent widget because the * parent is really a reference to the menu button widget, not the * popup-shell widget we really want. See the above comment in * MakeMenu(). */ if ((menu = XtNameToWidget(parent, "menu")) == NULL) return NULL; n = 0; XtSetArg(wargs[n], XtNlabel, name); n++; XtSetArg(wargs[n], XtNleftMargin, check_mark_width); n++; item = XtCreateManagedWidget("menu_item", smeBSBObjectClass, menu, wargs, n); if (item == NULL) return NULL; if (func) XtAddCallback(item, XtNcallback, (XtCallbackProc)func, arg); return item; }
PRIVATE void CreateLido () { Widget sink; Arg args[10]; int n; /* Create a new toplevel Shell */ n = 0; if (LidoGeometry[0] != '\0') { XtSetArg (args[n], XtNgeometry, LidoGeometry); n++; } XtSetArg (args[n], XtNtitle, Res.lido_name); n++; LidoTop = XtCreatePopupShell ("lido", topLevelShellWidgetClass, Toplevel, args, n); /* Create the Text Widget */ n = 0; XtSetArg (args[n], XtNtype, XawAsciiFile); n++; XtSetArg (args[n], XtNstring, Res.lido_name); n++; LidoText = XtCreateManagedWidget ("lidoText", asciiTextWidgetClass, LidoTop, args, n); /* Realize the new top level Widget */ XtPopup (LidoTop, XtGrabNone); /* * This is a hack so that wm_delete_window will close the rule graph window. */ /* Register Actions */ XtAppAddActions (XtWidgetToApplicationContext(LidoTop), lido_actions, XtNumber(lido_actions)); XtOverrideTranslations(LidoTop, XtParseTranslationTable ("<Message>WM_PROTOCOLS: close()")); wm_delete_window = XInternAtom (XtDisplay(LidoTop), "WM_DELETE_WINDOW", False); XSetWMProtocols (XtDisplay(LidoTop), XtWindow(LidoTop), &wm_delete_window, 1); /* Try to find text sink */ sink = XtNameToWidget (LidoTop, AsciiTextSinkName); if (sink == NULL) { /* Don't give warnings... XtNameToWidget has never worked! fprintf (stderr,"%s: Couldn't find window of LIDO text.\n", ProgName); fprintf (stderr, "Menu will not work in LIDO window.\n"); */ return; } /* Register a passive grab for menu-popup */ XGrabButton (XtDisplay (sink), AnyButton, AnyModifier, XtWindow (sink), TRUE, ButtonPressMask|ButtonReleaseMask, GrabModeAsync, GrabModeAsync, None, None); }
void GE_SliderSetProc( Widget slider, String value) { Widget scale, text; if( (scale = XtNameToWidget(slider, ".scale")) == NULL ) return; if( (text = XtNameToWidget(slider, ".text")) == NULL ) return; XtVaSetValues(text, XmNvalue, value, NULL); update_slider_value(text, scale, NULL); return; }
static void Callback(Widget W) { Widget w; w = XtNameToWidget(XtParent(W), "*BubbleButton1"); XtSetSensitive(w, !XtIsSensitive(w)); }
void toggle_scrollbars(void) { Widget x_bar = XtNameToWidget(globals.widgets.main_window, "HorScrollBar"); Widget y_bar = XtNameToWidget(globals.widgets.main_window, "VertScrollBar"); if ((resource.expert_mode & XPRT_SHOW_SCROLLBARS) == 0) { XtUnmanageChild(x_bar); XtUnmanageChild(y_bar); } else { XtManageChild(x_bar); XtManageChild(y_bar); } set_menu(&resource.expert_mode, Act_set_expert_mode, check_resource_expert); }
void DoClearMemo(int which) { Widget edit; edit = XtNameToWidget(engineOutputShell, which ? "*form2.text" : "*form.text"); XtCallActionProc(edit, "select-all", NULL, NULL, 0); XtCallActionProc(edit, "kill-selection", NULL, NULL, 0); }
static void MakePrompt(Widget centerw, const char *prompt, MakePromptFunc func, const char *def) { static Arg dialogArgs[] = { {XtNlabel, 0}, {XtNvalue, 0}, }; Arg valueArgs[1]; Arg centerArgs[2]; Position source_x, source_y; Position dest_x, dest_y; Dimension center_width, center_height; Dimension prompt_width, prompt_height; Widget valueWidget; CancelAction ((Widget)NULL, (XEvent *) 0, (String *) 0, (Cardinal *) 0); promptShell = XtCreatePopupShell ("promptShell", transientShellWidgetClass, toplevel, NULL, (Cardinal) 0); dialogArgs[0].value = (XtArgVal)prompt; dialogArgs[1].value = (XtArgVal)def; promptDialog = XtCreateManagedWidget( "promptDialog", dialogWidgetClass, promptShell, dialogArgs, XtNumber (dialogArgs)); XawDialogAddButton(promptDialog, "accept", NULL, (XtPointer) 0); XawDialogAddButton(promptDialog, "cancel", NULL, (XtPointer) 0); valueWidget = XtNameToWidget (promptDialog, "value"); if (valueWidget) { XtSetArg (valueArgs[0], (String)XtNresizable, TRUE); XtSetValues (valueWidget, valueArgs, 1); /* * as resizable isn't set until just above, the * default value will be displayed incorrectly. * rectify the situation by resetting the values */ XtSetValues (promptDialog, dialogArgs, XtNumber (dialogArgs)); } XtSetKeyboardFocus (promptDialog, valueWidget); XtSetKeyboardFocus (toplevel, valueWidget); XtRealizeWidget (promptShell); /* * place the widget in the center of the "parent" */ XtSetArg (centerArgs[0], XtNwidth, ¢er_width); XtSetArg (centerArgs[1], XtNheight, ¢er_height); XtGetValues (centerw, centerArgs, 2); XtSetArg (centerArgs[0], XtNwidth, &prompt_width); XtSetArg (centerArgs[1], XtNheight, &prompt_height); XtGetValues (promptShell, centerArgs, 2); source_x = (center_width - prompt_width) / 2; source_y = (center_height - prompt_height) / 3; XtTranslateCoords (centerw, source_x, source_y, &dest_x, &dest_y); XtSetArg (centerArgs[0], XtNx, dest_x); XtSetArg (centerArgs[1], XtNy, dest_y); XtSetValues (promptShell, centerArgs, 2); XtMapWidget(promptShell); promptfunction = func; }