/* ARGSUSED */ static void sb_ValueChangedCB(Widget w, XtPointer client_data, XtPointer call_data) { char *buffer; XmSpinBoxCallbackStruct *cbs = (XmSpinBoxCallbackStruct *) call_data; int position = cbs->position; Widget textual = (Widget) NULL; if (XtIsSubclass(w, xmSimpleSpinBoxWidgetClass)) textual = ssb_GetTextField(w); else if (XtIsSubclass(w, xmSpinBoxWidgetClass)) textual = cbs->widget; else textual = (Widget) NULL; if (! textual) { printf("Null textual widget for %s\n", XtName(w)); return; } #ifdef SAMPLER_TEST_SSPINB if (XmStringGetLtoR(cbs->value, XmFONTLIST_DEFAULT_TAG, &buffer)) printf("ValueChanged value for %s.%s is %s\n", XtName(w), XtName(textual), buffer); #endif }
/*ARGSUSED*/ static void XawDialogConstraintInitialize(Widget request, Widget cnew, ArgList args, Cardinal *num_args) { DialogWidget dw = (DialogWidget)cnew->core.parent; DialogConstraints constraint = (DialogConstraints)cnew->core.constraints; if (!XtIsSubclass(cnew, commandWidgetClass)) /* if not a button */ return; /* then just use defaults */ constraint->form.left = constraint->form.right = XtChainLeft; if (dw->dialog.valueW == NULL) constraint->form.vert_base = dw->dialog.labelW; else constraint->form.vert_base = dw->dialog.valueW; if (dw->composite.num_children > 1) { WidgetList children = dw->composite.children; Widget *childP; for (childP = children + dw->composite.num_children - 1; childP >= children; childP-- ) { if (*childP == dw->dialog.labelW || *childP == dw->dialog.valueW) break; if (XtIsManaged(*childP) && XtIsSubclass(*childP, commandWidgetClass)) { constraint->form.horiz_base = *childP; break; } } } }
/* * Function: * XawAsciiSaveAsFile * * Arguments: * w - AsciiSrc widget * name - name of the file to save this file into * * Description: * Save the current buffer as a file. * * Returns: * True if the save was sucessful */ Bool XawAsciiSaveAsFile(Widget w, _Xconst char *name) { AsciiSrcObject src = (AsciiSrcObject)w; Bool ret; /* If the src is really a multi, call the multi save */ if (XtIsSubclass( w, multiSrcObjectClass)) return (_XawMultiSaveAsFile(w, name)); else if (!XtIsSubclass(w, asciiSrcObjectClass)) XtErrorMsg("bad argument", "asciiSource", "XawError", "XawAsciiSaveAsFile's 1st parameter must be an " "asciiSrc or multiSrc.", NULL, NULL); if (src->ascii_src.type == XawAsciiFile) ret = WritePiecesToFile(src, (String)name); else { String string = StorePiecesInString(src); ret = WriteToFile(string, (String)name, src->ascii_src.length); XtFree(string); } return (ret); }
void MenuBar::removeCommands( Widget pulldown, CmdList *redundant_list ) { // if(isValidMenuPane(pulldown) == FALSE) // return; int i, j, num_children; WidgetList children; XtVaGetValues(pulldown, XmNnumChildren, &num_children, NULL); children = (WidgetList)XtMalloc(sizeof(Widget) * num_children); XtVaGetValues(pulldown, XmNchildren, &children, NULL); // Loop through widget list. Destroy those widgets that map to those // in the redundant list. for (i=0; i<num_children; i++) { Widget wid = (Widget) children[i]; if (XtIsSubclass(wid, xmSeparatorWidgetClass)) { XtUnmanageChild(wid); } else if (XtIsSubclass(wid, xmPushButtonWidgetClass)) { for (j=0; j<redundant_list->size(); j++) { XmString str=NULL; String label=NULL; XtVaGetValues(wid, XmNlabelString, &str, NULL); if (str == NULL) continue; label = NULL; label = (char *) _XmStringUngenerate( str, NULL, XmMULTIBYTE_TEXT, XmMULTIBYTE_TEXT); XmStringFree(str); if (label == NULL) continue; if (strcmp(label, (*redundant_list)[j]->getLabel()) == 0) { // The redundant item has been found. XtUnmanageChild(wid); } XtFree(label); } } } }
/* * test if there is a menu that has the current focus * called from awt_Dialog.c and awt_Component.c */ Boolean awt_util_focusIsOnMenu(Display *display) { Window window; Widget widget; int32_t rtr; XGetInputFocus(display, &window, &rtr); if (window == None) { return False; } widget = XtWindowToWidget(display, window); if (widget == NULL) { return False; } if (XtIsSubclass(widget, xmMenuShellWidgetClass)) { return True; } #if MOTIF_VERSION!=1 /* Motif 2.1 uses XmGrabShell on XmComboBox instead of XmMenuShell */ if (XtIsSubclass(widget, xmGrabShellWidgetClass)) { return True; } /* Fix 4800638 check the ancestor of focus widget is GrabSell */ if (XtIsSubclass(widget, xmListWidgetClass)) { Widget shell = getShellWidget(widget); if (shell && XtIsSubclass(shell, xmGrabShellWidgetClass)) { return True; } } #endif if (XtIsSubclass(widget, xmRowColumnWidgetClass)) { unsigned char type; XtVaGetValues(widget, XmNrowColumnType, &type, NULL); if (type == XmMENU_BAR) { return True; } } return False; }
STRING ui_field_get_string( Widget field ) { char *string = NULL; if (XtIsSubclass(field, xmTextFieldWidgetClass)) string = XmTextFieldGetString(field); else if (XtIsSubclass(field, xmTextWidgetClass)) string = XmTextGetString(field); return((STRING)string); }
/* * Function: * XawAsciiSave * * Parameters: * w - asciiSrc Widget * * Description: * Saves all the pieces into a file or string as required. * * Returns: * True if the save was successful */ Bool XawAsciiSave(Widget w) { AsciiSrcObject src = (AsciiSrcObject)w; /* If the src is really a multi, call the multi save */ if (XtIsSubclass(w, multiSrcObjectClass )) return (_XawMultiSave(w)); else if (!XtIsSubclass(w, asciiSrcObjectClass)) XtErrorMsg("bad argument", "asciiSource", "XawError", "XawAsciiSave's parameter must be an asciiSrc or multiSrc.", NULL, NULL); /* * If using the string in place then there is no need to play games * to get the internal info into a readable string. */ if (src->ascii_src.use_string_in_place) return (True); if (src->ascii_src.type == XawAsciiFile) { #ifdef OLDXAW if (!src->ascii_src.changes) #else if (!src->text_src.changed) /* No changes to save */ #endif return (True); if (WritePiecesToFile(src, src->ascii_src.string) == False) return (False); } else { if (src->ascii_src.allocated_string == True) XtFree(src->ascii_src.string); else src->ascii_src.allocated_string = True; src->ascii_src.string = StorePiecesInString(src); } #ifdef OLDXAW src->ascii_src.changes = False; #else src->text_src.changed = False; #endif return (True); }
void HGU_XmFSD_SaveFunc( Widget w, XtPointer data, FILE *fp) { String name = XtName( w ), topl_name = (String) data; /* first the default save - position etc. */ default_save( w, data, fp ); /* save directory and pattern resources */ if( XtIsSubclass( w, xmFileSelectionBoxWidgetClass ) ){ XmString dir_xmstr, pat_xmstr; String str; XtVaGetValues(w, XmNdirectory, &dir_xmstr, XmNpattern, &pat_xmstr, NULL); if( XmStringGetLtoR(dir_xmstr, XmSTRING_DEFAULT_CHARSET, &str) ){ fprintf(fp, "%s*%s.directory: \t%s\n", topl_name, name, str); XtFree( str ); } if( XmStringGetLtoR(pat_xmstr, XmSTRING_DEFAULT_CHARSET, &str) ){ fprintf(fp, "%s*%s.pattern: \t%s\n", topl_name, name, str); XtFree( str ); } } return; }
void xaw_destroy_instance (widget_instance *instance) { #ifdef HAVE_XFT if (instance->xft_data) { int i; for (i = 0; i < instance->nr_xft_data; ++i) { if (instance->xft_data[i].xft_draw) XftDrawDestroy (instance->xft_data[i].xft_draw); if (instance->xft_data[i].p != None) { XtVaSetValues (instance->xft_data[i].widget, XtNbitmap, None, NULL); XFreePixmap (XtDisplay (instance->widget), instance->xft_data[i].p); } } if (instance->xft_data[0].xft_font) XftFontClose (XtDisplay (instance->widget), instance->xft_data[0].xft_font); xfree (instance->xft_data); } #endif if (XtIsSubclass (instance->widget, dialogWidgetClass)) /* Need to destroy the Shell too. */ XtDestroyWidget (XtParent (instance->widget)); else XtDestroyWidget (instance->widget); }
static void set_frame_size (EmacsFrame ew) { /* The widget hierarchy is argv[0] emacsShell pane Frame-NAME ApplicationShell EmacsShell Paned EmacsFrame We accept geometry specs in this order: *Frame-NAME.geometry *EmacsFrame.geometry Emacs.geometry Other possibilities for widget hierarchies might be argv[0] frame pane Frame-NAME ApplicationShell EmacsShell Paned EmacsFrame or argv[0] Frame-NAME pane Frame-NAME ApplicationShell EmacsShell Paned EmacsFrame or argv[0] Frame-NAME pane emacsTextPane ApplicationShell EmacsFrame Paned EmacsTextPane With the current setup, the text-display-area is the part which is an emacs "frame", since that's the only part managed by emacs proper (the menubar and the parent of the menubar and all that sort of thing are managed by lwlib.) The EmacsShell widget is simply a replacement for the Shell widget which is able to deal with using an externally-supplied window instead of always creating its own. It is not actually emacs specific, and should possibly have class "Shell" instead of "EmacsShell" to simplify the resources. */ /* Hairily merged geometry */ struct frame *f = ew->emacs_frame.frame; int w = FRAME_COLS (f); int h = FRAME_LINES (f); Widget wmshell = get_wm_shell ((Widget) ew); Dimension pixel_width, pixel_height; /* Each Emacs shell is now independent and top-level. */ if (! XtIsSubclass (wmshell, shellWidgetClass)) emacs_abort (); char_to_pixel_size (ew, w, h, &pixel_width, &pixel_height); ew->core.width = (frame_resize_pixelwise ? FRAME_PIXEL_WIDTH (f) : pixel_width); ew->core.height = (frame_resize_pixelwise ? FRAME_PIXEL_HEIGHT (f) : pixel_height); frame_size_history_add (f, Qset_frame_size, FRAME_TEXT_WIDTH (f), FRAME_TEXT_HEIGHT (f), list2 (make_number (ew->core.width), make_number (ew->core.height))); }
static int handle_dialog_child(Widget wgt, void (*manage_func) (Widget)) #endif { int i, num_children; Widget *children; int error_flag = UX_ERROR; XtVaGetValues(wgt, XmNnumChildren, &num_children, XmNchildren, &children, NULL); /*----------------------------------------------------- * We manage/unmanage the first rectObj child in the list. * Note that the check for rectObjClass is necessary since * some implementations of Motif add protocol children to * the dialogShell. Additionally, when the LANG is set to * Japanese, a widget of class Core is created. This widget * should not be managed. We'll skip it. *-----------------------------------------------------*/ for (i = 0; i < num_children; i++) { if (XtIsSubclass(children[i], rectObjClass) && (XtClass(children[i]) != coreWidgetClass)) { (*manage_func) (children[i]); error_flag = UX_NO_ERROR; break; } } return (error_flag); }
void ui_refresh_widget_tree( Widget widget ) { WidgetList children; int num_children = 0; int i; if (widget == NULL || !XtIsWidget(widget) || !XtIsRealized(widget)) return; if (XtIsSubclass(widget, compositeWidgetClass)) { XtVaGetValues(widget, XmNnumChildren, &num_children, XmNchildren, &children, NULL); /* Use recursion to traverse all the way to leaf nodes...*/ for (i=0; i < num_children; i++) ui_refresh_widget_tree(children[i]); } XClearArea(XtDisplay(widget), XtWindow(widget), 0, 0, 0, 0, TRUE); }
Screen *XtScreenOfObject( Widget object) { /* Attempts to LockApp() here will generate endless recursive loops */ if (XtIsSubclass(object, hookObjectClass)) return ((HookObject)object)->hooks.screen; return XtScreen(XtIsWidget(object) ? object : _XtWindowedAncestor(object)); }
/*ARGSUSED*/ static void XawAsciiSrcInitialize(Widget request, Widget cnew, ArgList args, Cardinal *num_args) { AsciiSrcObject src = (AsciiSrcObject)cnew; FILE *file; /* * Set correct flags (override resources) depending upon widget class */ src->text_src.text_format = XawFmt8Bit; #ifdef ASCII_DISK if (XtIsSubclass(XtParent(cnew), asciiDiskWidgetClass)) { src->ascii_src.type = XawAsciiFile; src->ascii_src.string = src->ascii_src.filename; } #endif #ifdef ASCII_STRING if (XtIsSubclass(XtParent(cnew), asciiStringWidgetClass)) { src->ascii_src.use_string_in_place = True; src->ascii_src.type = XawAsciiString; } #endif #ifdef OLDXAW src->ascii_src.changes = False; #else src->text_src.changed = False; #endif src->ascii_src.allocated_string = False; if (src->ascii_src.use_string_in_place && src->ascii_src.string == NULL) src->ascii_src.use_string_in_place = False; file = InitStringOrFile(src, src->ascii_src.type == XawAsciiFile); LoadPieces(src, file, NULL); if (file != NULL) fclose(file); }
void test_cb( Widget w, void *u, void *c ) { printf("cb\n"); if(! XtIsSubclass(w, weditWidgetClass ) ) return; char *s; XtVaGetValues(w, "label", &s, NULL ); if( is_empty(s) ) return; printf("Label: %s\n", s ); }
/* * Function: * XawAsciiSourceChanged * * Parameters: * w - ascii source widget * * Description: * Returns true if the source has changed since last saved. * * Returns: * A Boolean (see description). */ Bool XawAsciiSourceChanged(Widget w) { #ifdef OLDXAW if (XtIsSubclass(w, multiSrcObjectClass)) return (((MultiSrcObject)w)->multi_src.changes); if (XtIsSubclass(w, asciiSrcObjectClass)) return (((AsciiSrcObject)w)->ascii_src.changes); #else if (XtIsSubclass(w, textSrcObjectClass)) return (((TextSrcObject)w)->textSrc.changed); #endif XtErrorMsg("bad argument", "asciiSource", "XawError", "XawAsciiSourceChanged parameter must be an " "asciiSrc or multiSrc.", NULL, NULL); return (True); }
void xaw_destroy_instance (widget_instance *instance) { #ifdef LWLIB_DIALOGS_ATHENA if (XtIsSubclass (instance->widget, dialogWidgetClass)) /* Need to destroy the Shell too. */ XtDestroyWidget (XtParent (instance->widget)); else #endif XtDestroyWidget (instance->widget); }
void ui_field_select_string( Widget field, BOOL assign_focus ) { STRING valuestr = NULL; valuestr = ui_field_get_string(field); if (XtIsSubclass(field, xmTextFieldWidgetClass)) XmTextFieldSetSelection(field, 0, strlen(valuestr), CurrentTime); else if (XtIsSubclass(field, xmTextWidgetClass)) XmTextSetSelection(field, 0, strlen(valuestr), CurrentTime); if (assign_focus) XmProcessTraversal(field, XmTRAVERSE_CURRENT); util_free(valuestr); }
/**************************************************************************** * Function: void DisplayMain( * Widget parent, * char *helpVolume, * char *locationId) * * Parameters: * * Return Value: Void. * * Purpose: Displays help for helpdemo in the one helpDialog window * created for the applicaiton. * ****************************************************************************/ void DisplayMain ( Widget parent, char *helpVolume, char *locationId) { Arg args[10]; int n; if (helpMain != NULL) { n = 0; XtSetArg (args[n], XmNtitle, "hemodemo Help"); n++; if (helpVolume != NULL) { XtSetArg (args[n],DtNhelpVolume,helpVolume); n++; } XtSetArg (args[n], DtNlocationId,locationId); n++; XtSetValues(helpMain, args, n); XtManageChild(helpMain); } else { while (!XtIsSubclass(parent, applicationShellWidgetClass)) parent = XtParent(parent); /* Build a new one in our cached list */ n = 0; XtSetArg (args[n], XmNtitle, "Helpdemo Help"); n++; if (helpVolume != NULL) { XtSetArg (args[n],DtNhelpVolume,helpVolume); n++; } XtSetArg (args[n], DtNlocationId,locationId); n++; helpMain = DtCreateHelpDialog(parent, "helpWidget", args, n); XtAddCallback(helpMain, DtNhyperLinkCallback, ProcessLinkCB, NULL); XtAddCallback(helpMain, DtNcloseCallback, CloseMainCB, (XtPointer) helpMain); /* Add the popup position callback to our main help dialog */ XtAddCallback (XtParent(helpMain), XmNpopupCallback, (XtCallbackProc)HelpMapCB, (XtPointer)parent); XtManageChild(helpMain); } }
Widget XmLShellOfWidget(Widget w) { while(1) { if (!w) return 0; if (XtIsSubclass(w, shellWidgetClass)) return w; w = XtParent(w); } }
Widget ui_get_ancestor_dialog( Widget widget ) { Widget dialog = widget; while(dialog && !XtIsSubclass(XtParent(dialog), shellWidgetClass)) dialog = XtParent(dialog); return dialog; }
Widget ui_get_ancestor_shell( Widget widget ) { Widget shell = widget; while(shell && !XtIsSubclass(shell, shellWidgetClass)) shell = XtParent(shell); return shell; }
void xaw_update_one_value (widget_instance *instance, Widget widget, widget_value *val) { #ifdef LWLIB_WIDGETS_ATHENA widget_value *old_wv; /* copy the call_data slot into the "return" widget_value */ for (old_wv = instance->info->val->contents; old_wv; old_wv = old_wv->next) if (!strcmp (val->name, old_wv->name)) { val->call_data = old_wv->call_data; break; } if (XtIsSubclass (widget, toggleWidgetClass)) { Xt_GET_VALUE (widget, XtNstate, &val->selected); val->edited = True; } #ifndef NEED_MOTIF else if (XtIsSubclass (widget, asciiTextWidgetClass)) { String buf = 0; Xt_GET_VALUE (widget, XtNstring, &buf); if (val->value) { free (val->value); val->value = 0; } /* I don't think this causes a leak. */ if (buf) val->value = strdup (buf); val->edited = True; } #endif #endif /* LWLIB_WIDGETS_ATHENA */ }
/* callback notified when selection is made */ static void colorlist_selection_made(Widget widget, XtPointer client_data, XtPointer call_data) { char *color_string; XmListCallbackStruct *callback_data; callback_data = (XmListCallbackStruct *) call_data; color_string = extract_first_xms_segment(callback_data->item); /* the following code will fail if the list is not a descendant of a form */ while(!XtIsSubclass(widget,xmFormWidgetClass)) widget = XtParent(widget); setcolor_colorform(widget,color_string); }
void HelpAgent::context_help(Widget widget) { while(!XtIsSubclass(widget, topLevelShellWidgetClass)) widget = XtParent(widget); if (widget != NULL) { XEvent event; Widget sel_widget = XmTrackingEvent(widget, f_cursor, False, &event); if (sel_widget != NULL) display_help(sel_widget); } }
// For a given graph editor W, return its panner Widget pannerOfGraphEdit(Widget w) { XtCheckSubclass(w, GraphEditWidgetClass, "Bad widget class"); Widget parent = w; while (parent != 0) { if (XtIsSubclass(parent, formWidgetClass)) break; parent = XtParent(parent); } return parent; }
/* * Function: * XawAsciiSourceFreeString * * Parameters: * w - AsciiSrc widget * * Description: * Frees the string returned by a get values call * on the string when the source is of type string. */ void XawAsciiSourceFreeString(Widget w) { AsciiSrcObject src = (AsciiSrcObject)w; /* If the src is really a multi, call the multi routine */ if (XtIsSubclass(w, multiSrcObjectClass)) { _XawMultiSourceFreeString(w); return; } else if (!XtIsSubclass(w, asciiSrcObjectClass)) { XtErrorMsg("bad argument", "asciiSource", "XawError", "XawAsciiSourceFreeString's parameter must be " "an asciiSrc or multiSrc.", NULL, NULL); } if (src->ascii_src.allocated_string && src->ascii_src.type != XawAsciiFile) { src->ascii_src.allocated_string = False; XtFree(src->ascii_src.string); src->ascii_src.string = NULL; } }
static void default_save( Widget w, XtPointer data, FILE *fp) { Position x, y; Position x_off=0, y_off=0; Dimension width, height; String name = XtName( w ), topl_name = (String) data; fprintf(fp, "!\n! %s widget geometry\n!\n", name); if( XtIsTransientShell( w ) ) { HGU_XmGetShellOffsets( w, &x_off, &y_off ); if( HGU_XmIsViewable( w ) ) fprintf(fp, "%s*%s.mappedWhenManaged: True\n", topl_name, XtName(XtParent(w))); else fprintf(fp, "%s*%s.mappedWhenManaged: False\n", topl_name, XtName(XtParent(w))); } else if( XtIsTransientShell( XtParent( w )) ) { HGU_XmGetShellOffsets( XtParent( w ), &x_off, &y_off ); if( HGU_XmIsViewable( w ) ) fprintf(fp, "%s*%s.mappedWhenManaged: True\n", topl_name, XtName(XtParent(w))); else fprintf(fp, "%s*%s.mappedWhenManaged: False\n", topl_name, XtName(XtParent(w))); } if( XtIsSubclass( w, xmBulletinBoardWidgetClass ) ){ if( HGU_XmIsViewable( w ) ) fprintf(fp, "%s*%s.defaultPosition: \tFalse\n", topl_name, name); else fprintf(fp, "%s*%s.defaultPosition: \tTrue\n", topl_name, name); } XtVaGetValues(w, XmNx, &x, XmNy, &y, XmNwidth, &width, XmNheight, &height, NULL); fprintf(fp, "%s*%s.x: \t%d\n", topl_name, name, x - x_off); fprintf(fp, "%s*%s.y: \t%d\n", topl_name, name, y - y_off); fprintf(fp, "%s*%s.width: \t%d\n", topl_name, name, width); fprintf(fp, "%s*%s.height:\t%d\n", topl_name, name, height); return; }
int UxPopupInterface(Widget wgt, XtGrabKind grab_flag) #endif { if (!(wgt = GetTrueToplevel(wgt))) return (UX_ERROR); if (XtIsSubclass(wgt, xmDialogShellWidgetClass)) { popup_dialog(wgt, grab_flag); } else { XtPopup(wgt, grab_flag); } return (UX_NO_ERROR); }
int UxPopdownInterface(Widget wgt) #endif { if (!(wgt = GetTrueToplevel(wgt))) return (UX_ERROR); if (XtIsSubclass(wgt, xmDialogShellWidgetClass)) { popdown_dialog(wgt); } else { XtPopdown(wgt); } return (UX_NO_ERROR); }