void XtPopup (Widget widget, XtGrabKind grab_kind) { Widget hookobj; switch (grab_kind) { case XtGrabNone: case XtGrabExclusive: case XtGrabNonexclusive: break; default: XtAppWarningMsg( XtWidgetToApplicationContext(widget), "invalidGrabKind","xtPopup",XtCXtToolkitError, "grab kind argument has invalid value; XtGrabNone assumed", (String *)NULL, (Cardinal *)NULL); grab_kind = XtGrabNone; } _XtPopup(widget, grab_kind, FALSE); hookobj = XtHooksOfDisplay(XtDisplay(widget)); if (XtHasCallbacks(hookobj, XtNchangeHook) == XtCallbackHasSome) { XtChangeHookDataRec call_data; call_data.type = XtHpopup; call_data.widget = widget; call_data.event_data = (XtPointer)grab_kind; XtCallCallbackList(hookobj, ((HookObject)hookobj)->hooks.changehook_callbacks, (XtPointer)&call_data); } } /* XtPopup */
void XtRemoveAllCallbacks( Widget widget, _Xconst char* name) { InternalCallbackList *callbacks; Widget hookobj; XtAppContext app = XtWidgetToApplicationContext(widget); LOCK_APP(app); callbacks = FetchInternalList(widget, name); if (!callbacks) { XtAppWarningMsg(app, XtNinvalidCallbackList,XtNxtRemoveAllCallback,XtCXtToolkitError, "Cannot find callback list in XtRemoveAllCallbacks", (String *)NULL, (Cardinal *)NULL); UNLOCK_APP(app); return; } _XtRemoveAllCallbacks(callbacks); hookobj = XtHooksOfDisplay(XtDisplayOfObject(widget)); if (XtHasCallbacks(hookobj, XtNchangeHook) == XtCallbackHasSome) { XtChangeHookDataRec call_data; call_data.type = XtHremoveAllCallbacks; call_data.widget = widget; call_data.event_data = (XtPointer) name; XtCallCallbackList(hookobj, ((HookObject)hookobj)->hooks.changehook_callbacks, (XtPointer)&call_data); } UNLOCK_APP(app); } /* XtRemoveAllCallbacks */
/*ARGSUSED*/ static Boolean XawCvtCompoundTextToString(Display *dpy, XrmValuePtr args, Cardinal *num_args, XrmValue *fromVal, XrmValue *toVal, XtPointer *cvt_data) { XTextProperty prop; char **list; int count; static char *mbs = NULL; int len; prop.value = (unsigned char *)fromVal->addr; prop.encoding = XA_COMPOUND_TEXT(dpy); prop.format = 8; prop.nitems = fromVal->size; if(XmbTextPropertyToTextList(dpy, &prop, &list, &count) < Success) { XtAppWarningMsg(XtDisplayToApplicationContext(dpy), "converter", "XmbTextPropertyToTextList", "XawError", "conversion from CT to MB failed.", NULL, 0); return False; } len = strlen(*list); toVal->size = len; mbs = XtRealloc(mbs, len + 1); /* keep buffer because no one call free :( */ strcpy(mbs, *list); XFreeStringList(list); toVal->addr = (XtPointer)mbs; return True; }
/*ARGSUSED*/ static Boolean _XawCvtPixelToString(Display *dpy, XrmValue *args, Cardinal *num_args, XrmValue *fromVal, XrmValue *toVal, XtPointer *converter_data) { static char buffer[19]; Cardinal size; Colormap colormap; XColor color; if (*num_args != 1) { XtAppWarningMsg(XtDisplayToApplicationContext(dpy), XtNwrongParameters, "cvtPixelToString", XtCToolkitError, "Pixel to String conversion needs colormap argument", NULL, NULL); return (False); } colormap = *(Colormap *)args[0].addr; color.pixel = *(Pixel *)fromVal->addr; /* Note: * If we know the visual type, we can calculate the xcolor * without asking Xlib. */ XQueryColor(dpy, colormap, &color); XmuSnprintf(buffer, sizeof(buffer), "rgb:%04hx/%04hx/%04hx", color.red, color.green, color.blue); size = strlen(buffer) + 1; string_done(buffer); }
void XtTranslateCoords( register Widget w, _XtPosition x, _XtPosition y, register Position *rootx, /* return */ register Position *rooty) /* return */ { Position garbagex, garbagey; XtAppContext app = XtWidgetToApplicationContext(w); LOCK_APP(app); if (rootx == NULL) rootx = &garbagex; if (rooty == NULL) rooty = &garbagey; *rootx = x; *rooty = y; for (; w != NULL && ! XtIsShell(w); w = w->core.parent) { *rootx += w->core.x + w->core.border_width; *rooty += w->core.y + w->core.border_width; } if (w == NULL) XtAppWarningMsg(app, "invalidShell","xtTranslateCoords",XtCXtToolkitError, "Widget has no shell ancestor", (String *)NULL, (Cardinal *)NULL); else { Position x, y; _XtShellGetCoordinates( w, &x, &y ); *rootx += x + w->core.border_width; *rooty += y + w->core.border_width; } UNLOCK_APP(app); }
/*ARGSUSED*/ static Boolean _XawCvtPixmapToString(Display *dpy, XrmValue *args, Cardinal *num_args, XrmValue *fromVal, XrmValue *toVal, XtPointer *converter_data) { XawPixmap *xaw_pixmap; Pixmap pixmap; Screen *screen; Colormap colormap; int depth; String buffer = NULL; Cardinal size; if (*num_args != 3) { XtAppWarningMsg(XtDisplayToApplicationContext(dpy), XtNwrongParameters, "cvtPixmapToString", XtCToolkitError, "Pixmap to String conversion needs screen, " "colormap, and depth arguments", NULL, NULL); return (False); } screen = *(Screen **)args[0].addr; colormap = *(Colormap *)args[1].addr; depth = *(int *)args[2].addr; pixmap = *(Pixmap *)(fromVal[0].addr); switch (pixmap) { case None: buffer = "None"; break; case ParentRelative: buffer = "ParentRelative"; break; case XtUnspecifiedPixmap: buffer = "XtUnspecifiedPixmap"; break; default: xaw_pixmap = XawPixmapFromXPixmap(pixmap, screen, colormap, depth); if (xaw_pixmap) buffer = xaw_pixmap->name; break; } if (!buffer) /* Bad Pixmap or Pixmap was not loaded by XawLoadPixmap() */ return (_XawCvtCARD32ToString(dpy, args, num_args, fromVal, toVal, converter_data)); size = strlen(buffer) + 1; string_done(buffer); }
static void ShapeError(Widget w) { String params[1]; Cardinal num_params = 1; params[0] = XtName(w); XtAppWarningMsg(XtWidgetToApplicationContext(w), "shapeUnknown", "xmuReshapeWidget", "XmuLibrary", "Unsupported shape style for Command widget \"%s\"", params, &num_params); }
/*ARGSUSED*/ static Boolean _XawCvtStringToPixmap(Display *dpy, XrmValue *args, Cardinal *num_args, XrmValue *fromVal, XrmValue *toVal, XtPointer *converter_data) { XawPixmap *xaw_pixmap; Pixmap pixmap; Screen *screen; Colormap colormap; int depth; String name; if (*num_args != 3) { XtAppWarningMsg(XtDisplayToApplicationContext(dpy), XtNwrongParameters, "cvtStringToPixmap", XtCToolkitError, "String to Pixmap conversion needs screen, " "colormap, and depth arguments", NULL, NULL); return (False); } screen = *(Screen **)args[0].addr; colormap = *(Colormap *)args[1].addr; depth = *(int *)args[2].addr; name = (String)(fromVal[0].addr); if (XmuCompareISOLatin1(name, "None") == 0) pixmap = None; else if (XmuCompareISOLatin1(name, "ParentRelative") == 0) pixmap = ParentRelative; else if (XmuCompareISOLatin1(name, "XtUnspecifiedPixmap") == 0) pixmap = XtUnspecifiedPixmap; else { xaw_pixmap = XawLoadPixmap(name, screen, colormap, depth); if (!xaw_pixmap) { XtDisplayStringConversionWarning(dpy, (String)fromVal->addr, XtRPixmap); toVal->addr = (XtPointer)XtUnspecifiedPixmap; toVal->size = sizeof(Pixmap); return (False); } else pixmap = xaw_pixmap->pixmap; } done(Pixmap, pixmap); }
static void UngrabKeyOrButton ( Widget widget, int keyOrButton, Modifiers modifiers, Boolean isKeyboard) { XtServerGrabRec tempGrab; XtPerWidgetInput pwi; XtCheckSubclass(widget, coreWidgetClass, "in XtUngrabKey or XtUngrabButton"); /* Build a temporary grab list entry */ tempGrab.widget = widget; tempGrab.modifiers = modifiers; tempGrab.keybut = keyOrButton; tempGrab.hasExt = False; LOCK_PROCESS; pwi = _XtGetPerWidgetInput(widget, FALSE); UNLOCK_PROCESS; /* * if there is no entry in the context manager then somethings wrong */ if (!pwi) { XtAppWarningMsg(XtWidgetToApplicationContext(widget), "invalidGrab", "ungrabKeyOrButton", XtCXtToolkitError, "Attempt to remove nonexistent passive grab", (String *)NULL, (Cardinal *)NULL); return; } if (XtIsRealized(widget)) { if (isKeyboard) XUngrabKey(widget->core.screen->display, keyOrButton, (unsigned int)modifiers, widget->core.window); else XUngrabButton(widget->core.screen->display, keyOrButton, (unsigned int)modifiers, widget->core.window); } /* Delete all entries which are encompassed by the specified grab. */ DeleteServerGrabFromList(isKeyboard ? &pwi->keyList : &pwi->ptrList, &tempGrab); }
void _XtCopyFromParent( Widget widget, int offset, XrmValue *value) { if (widget->core.parent == NULL) { XtAppWarningMsg(XtWidgetToApplicationContext(widget), "invalidParent","xtCopyFromParent",XtCXtToolkitError, "CopyFromParent must have non-NULL parent", (String *)NULL, (Cardinal *)NULL); value->addr = NULL; return; } value->addr = (XPointer)(((char *)widget->core.parent) + offset); } /* _XtCopyFromParent */
void XawTypeToStringWarning(Display *dpy, String type) { char fname[64]; String params[1]; Cardinal num_params; XmuSnprintf(fname, sizeof(fname), "cvt%sToString", type); params[0] = type; num_params = 1; XtAppWarningMsg(XtDisplayToApplicationContext(dpy), XtNconversionError, fname, XtCToolkitError, "Cannot convert %s to String", params, &num_params); }
void XtCallCallbacks( Widget widget, _Xconst char* name, XtPointer call_data ) { InternalCallbackList *callbacks; InternalCallbackList icl; XtCallbackList cl; int i; char ostate; XtAppContext app = XtWidgetToApplicationContext(widget); LOCK_APP(app); callbacks = FetchInternalList(widget, name); if (!callbacks) { XtAppWarningMsg(app, XtNinvalidCallbackList,XtNxtCallCallback,XtCXtToolkitError, "Cannot find callback list in XtCallCallbacks", (String *)NULL, (Cardinal *)NULL); UNLOCK_APP(app); return; } icl = *callbacks; if (!icl) { UNLOCK_APP(app); return; } cl = ToList(icl); if (icl->count == 1) { (*cl->callback) (widget, cl->closure, call_data); UNLOCK_APP(app); return; } ostate = icl->call_state; icl->call_state = _XtCBCalling; for (i = icl->count; --i >= 0; cl++) (*cl->callback) (widget, cl->closure, call_data); if (ostate) icl->call_state |= ostate; else if (icl->call_state & _XtCBFreeAfterCalling) XtFree((char *)icl); else icl->call_state = ostate; UNLOCK_APP(app); } /* XtCallCallbacks */
static void TypeToStringNoArgsWarning(Display *dpy, String type) { char fname[64]; String params[1]; Cardinal num_params; XmuSnprintf(fname, sizeof(fname), "cvt%sToString", type); params[0] = type; num_params = 1; XtAppWarningMsg(XtDisplayToApplicationContext(dpy), XtNconversionError, fname, XtCToolkitError, "%s to String conversion needs no extra arguments", params, &num_params); }
static void LayoutChild(Widget w) { FormConstraints form = (FormConstraints)w->core.constraints; Widget ref; switch (form->form.layout_state) { case LayoutPending: form->form.layout_state = LayoutInProgress; break; case LayoutDone: return; case LayoutInProgress: { String subs[2]; Cardinal num_subs = 2; subs[0] = w->core.name; subs[1] = w->core.parent->core.name; XtAppWarningMsg(XtWidgetToApplicationContext(w), "constraintLoop", "xawFormLayout", "XawToolkitError", "constraint loop detected while laying out " "child '%s' in FormWidget '%s'", subs, &num_subs); } return; } form->form.new_x = form->form.dx; form->form.new_y = form->form.dy; if ((ref = form->form.horiz_base) != NULL) { FormConstraints ref_form = (FormConstraints)ref->core.constraints; LayoutChild(ref); form->form.new_x += ref_form->form.new_x + XtWidth(ref) + (XtBorderWidth(ref) << 1); } if ((ref = form->form.vert_base) != NULL) { FormConstraints ref_form = (FormConstraints)ref->core.constraints; LayoutChild(ref); form->form.new_y += ref_form->form.new_y + XtHeight(ref) + (XtBorderWidth(ref) << 1); } form->form.layout_state = LayoutDone; }
/*ARGSUSED*/ Boolean XmuCvtStringToColorCursor(Display *dpy, XrmValuePtr args, Cardinal *num_args, XrmValuePtr fromVal, XrmValuePtr toVal, XtPointer *converter_data) { Cursor cursor; Screen *screen; Pixel fg, bg; Colormap c_map; XColor colors[2]; Cardinal number; XrmValue ret_val; if (*num_args != 4) { XtAppWarningMsg(XtDisplayToApplicationContext(dpy), "wrongParameters","cvtStringToColorCursor","XmuError", "String to color cursor conversion needs four arguments", (String *)NULL, (Cardinal *)NULL); return False; } screen = *((Screen **) args[0].addr); fg = *((Pixel *) args[1].addr); bg = *((Pixel *) args[2].addr); c_map = *((Colormap *) args[3].addr); number = 1; XmuCvtStringToCursor(args, &number, fromVal, &ret_val); cursor = *((Cursor *) ret_val.addr); if (cursor == None || (fg == BlackPixelOfScreen(screen) && bg == WhitePixelOfScreen(screen))) new_done(Cursor, cursor); colors[0].pixel = fg; colors[1].pixel = bg; XQueryColors (dpy, c_map, colors, 2); XRecolorCursor(dpy, cursor, colors, colors + 1); new_done(Cursor, cursor); }
void XtRemoveBlockHook( XtBlockHookId id) { BlockHook *p, hook = (BlockHook)id; XtAppContext app = hook->app; LOCK_APP(app); for (p = &app->block_hook_list; p != NULL && *p != hook; p = &(*p)->next); if (p == NULL) { #ifdef DEBUG XtAppWarningMsg(app, "badId", "xtRemoveBlockHook", XtCXtToolkitError, "XtRemoveBlockHook called with bad or old hook id", (String*)NULL, (Cardinal*)NULL); #endif /*DEBUG*/ UNLOCK_APP(app); return; } *p = hook->next; XtFree( (XtPointer)hook ); UNLOCK_APP(app); }
/*ARGSUSED*/ static Boolean _XawCvtStringToDisplayList(Display *dpy, XrmValue *args, Cardinal *num_args, XrmValue *fromVal, XrmValue *toVal, XtPointer *converter_data) { XawDisplayList *dlist; Screen *screen; Colormap colormap; int depth; String commands; if (*num_args != 3) { XtAppWarningMsg(XtDisplayToApplicationContext(dpy), XtNwrongParameters, "cvtStringToDisplayList", XtCToolkitError, "String to DisplayList conversion needs screen, " "colormap, and depth arguments", NULL, NULL); return (False); } screen = *(Screen **)args[0].addr; colormap = *(Colormap *)args[1].addr; depth = *(int *)args[2].addr; commands = (String)(fromVal[0].addr); dlist = XawCreateDisplayList(commands, screen, colormap, depth); if (!dlist) { XtDisplayStringConversionWarning(dpy, (String)fromVal->addr, XawRDisplayList); toVal->addr = NULL; toVal->size = sizeof(XawDisplayList*); return (False); } done(XawDisplayList*, dlist); }
void XtRemoveActionHook( XtActionHookId id) { ActionHook *p, hook = (ActionHook)id; XtAppContext app = hook->app; LOCK_APP(app); for (p = &app->action_hook_list; p != NULL && *p != hook; p = &(*p)->next); if (p) { *p = hook->next; XtFree( (XtPointer)hook ); if (app->action_hook_list == NULL) _XtRemoveCallback(&app->destroy_callbacks, FreeActionHookList, (XtPointer) &app->action_hook_list); } #ifdef DEBUG else { XtAppWarningMsg(app, "badId", "xtRemoveActionHook", XtCXtToolkitError, "XtRemoveActionHook called with bad or old hook id", (String*)NULL, (Cardinal*)NULL); } #endif /*DEBUG*/ UNLOCK_APP(app); }
static void CallConstraintGetValuesHook( WidgetClass widget_class, Widget w, ArgList args, Cardinal num_args) { ConstraintClassExtension ext; LOCK_PROCESS; if (widget_class->core_class.superclass ->core_class.class_inited & ConstraintClassFlag) { CallConstraintGetValuesHook (widget_class->core_class.superclass, w, args, num_args); } for (ext = (ConstraintClassExtension)((ConstraintWidgetClass)widget_class) ->constraint_class.extension; ext != NULL && ext->record_type != NULLQUARK; ext = (ConstraintClassExtension)ext->next_extension); if (ext != NULL) { if ( ext->version == XtConstraintExtensionVersion && ext->record_size == sizeof(ConstraintClassExtensionRec)) { if (ext->get_values_hook != NULL) (*(ext->get_values_hook)) (w, args, &num_args); } else { String params[1]; Cardinal num_params = 1; params[0] = widget_class->core_class.class_name; XtAppWarningMsg(XtWidgetToApplicationContext(w), "invalidExtension", "xtCreateWidget", XtCXtToolkitError, "widget class %s has invalid ConstraintClassExtension record", params, &num_params); } } UNLOCK_PROCESS; }
/* * Function: * InitStringOrFile * * Parameters: * src - AsciiSource * * Description: * Initializes the string or file. */ static FILE * InitStringOrFile(AsciiSrcObject src, Bool newString) { mode_t open_mode = 0; const char *fdopen_mode = NULL; int fd; FILE *file; if (src->ascii_src.type == XawAsciiString) { if (src->ascii_src.string == NULL) src->ascii_src.length = 0; else if (!src->ascii_src.use_string_in_place) { src->ascii_src.string = XtNewString(src->ascii_src.string); src->ascii_src.allocated_string = True; src->ascii_src.length = strlen(src->ascii_src.string); } if (src->ascii_src.use_string_in_place) { if (src->ascii_src.string != NULL) src->ascii_src.length = strlen(src->ascii_src.string); /* In case the length resource is incorrectly set */ if (src->ascii_src.length > src->ascii_src.ascii_length) src->ascii_src.ascii_length = src->ascii_src.length; if (src->ascii_src.ascii_length == MAGIC_VALUE) src->ascii_src.piece_size = src->ascii_src.length; else src->ascii_src.piece_size = src->ascii_src.ascii_length + 1; } return (NULL); } /* * type is XawAsciiFile */ src->ascii_src.is_tempfile = False; switch (src->text_src.edit_mode) { case XawtextRead: if (src->ascii_src.string == NULL) XtErrorMsg("NoFile", "asciiSourceCreate", "XawError", "Creating a read only disk widget and no file specified.", NULL, 0); open_mode = O_RDONLY; fdopen_mode = "r"; break; case XawtextAppend: case XawtextEdit: if (src->ascii_src.string == NULL) { src->ascii_src.string = "*ascii-src*"; src->ascii_src.is_tempfile = True; } else { /* O_NOFOLLOW is a FreeBSD & Linux extension */ #ifdef O_NOFOLLOW open_mode = O_RDWR | O_NOFOLLOW; #else open_mode = O_RDWR; /* unsafe; subject to race conditions */ #endif /* O_NOFOLLOW */ fdopen_mode = "r+"; } break; default: XtErrorMsg("badMode", "asciiSourceCreate", "XawError", "Bad editMode for ascii source; must be Read, " "Append or Edit.", NULL, NULL); } /* If is_tempfile, allocate a private copy of the text * Unlikely to be changed, just to set allocated_string */ if (newString || src->ascii_src.is_tempfile) { src->ascii_src.string = XtNewString(src->ascii_src.string); src->ascii_src.allocated_string = True; } if (!src->ascii_src.is_tempfile) { if ((fd = open(src->ascii_src.string, open_mode, 0666)) != -1) { if ((file = fdopen(fd, fdopen_mode))) { (void)fseek(file, 0, SEEK_END); src->ascii_src.length = (XawTextPosition)ftell(file); return (file); } } { String params[2]; Cardinal num_params = 2; params[0] = src->ascii_src.string; params[1] = strerror(errno); XtAppWarningMsg(XtWidgetToApplicationContext((Widget)src), "openError", "asciiSourceCreate", "XawWarning", "Cannot open file %s; %s", params, &num_params); } } src->ascii_src.length = 0; return (NULL); }
static Boolean DoGrab( StatePtr state, XtPointer data) { DoGrabRec *doGrabP = (DoGrabRec *)data; GrabActionRec* grabP = doGrabP->grabP; Widget widget = doGrabP->widget; TMShortCard count = doGrabP->count; TMShortCard typeIndex = state->typeIndex; TMShortCard modIndex = state->modIndex; ActionRec *action; TMTypeMatch typeMatch; TMModifierMatch modMatch; Modifiers careOn = 0; Modifiers careMask = 0; Boolean resolved; LOCK_PROCESS; typeMatch = TMGetTypeMatch(typeIndex); modMatch = TMGetModifierMatch(modIndex); for (action = state->actions; action; action = action->next) if (count == action->idx) break; if (!action) { UNLOCK_PROCESS; return False; } switch (typeMatch->eventType) { case ButtonPress: case ButtonRelease: if (modMatch->lateModifiers) { resolved = _XtComputeLateBindings(XtDisplay(widget), modMatch->lateModifiers, &careOn, &careMask); if (!resolved) break; } careOn |= modMatch->modifiers; XtGrabButton( widget, (unsigned) typeMatch->eventCode, careOn, grabP->owner_events, grabP->event_mask, grabP->pointer_mode, grabP->keyboard_mode, None, None ); break; case KeyPress: case KeyRelease: GrabAllCorrectKeys(widget, typeMatch, modMatch, grabP); break; case EnterNotify: break; default: XtAppWarningMsg(XtWidgetToApplicationContext(widget), "invalidPopup","unsupportedOperation",XtCXtToolkitError, "Pop-up menu creation is only supported on Button, Key or EnterNotify events.", (String *)NULL, (Cardinal *)NULL); break; } UNLOCK_PROCESS; return False; }
static XtCacheRef *GetResources( Widget widget, /* Widget resources are associated with */ char* base, /* Base address of memory to write to */ XrmNameList names, /* Full inheritance name of widget */ XrmClassList classes, /* Full inheritance class of widget */ XrmResourceList* table, /* The list of resources required. */ unsigned num_resources, /* number of items in resource list */ XrmQuarkList quark_args, /* Arg names quarkified */ ArgList args, /* ArgList to override resources */ unsigned num_args, /* number of items in arg list */ XtTypedArgList typed_args, /* Typed arg list to override resources */ Cardinal* pNumTypedArgs, /* number of items in typed arg list */ Boolean tm_hack) /* do baseTranslations */ { /* * assert: *pNumTypedArgs == 0 if num_args > 0 * assert: num_args == 0 if *pNumTypedArgs > 0 */ #define SEARCHLISTLEN 100 #define MAXRESOURCES 400 XrmValue value; XrmQuark rawType; XrmValue convValue; XrmHashTable stackSearchList[SEARCHLISTLEN]; XrmHashTable *searchList = stackSearchList; unsigned int searchListSize = SEARCHLISTLEN; Boolean found[MAXRESOURCES]; int typed[MAXRESOURCES]; XtCacheRef cache_ref[MAXRESOURCES]; XtCacheRef *cache_ptr, *cache_base; Boolean persistent_resources = True; Boolean found_persistence = False; int num_typed_args = *pNumTypedArgs; XrmDatabase db; Boolean do_tm_hack = False; if ((args == NULL) && (num_args != 0)) { XtAppWarningMsg(XtWidgetToApplicationContext(widget), "invalidArgCount","getResources",XtCXtToolkitError, "argument count > 0 on NULL argument list", (String *)NULL, (Cardinal *)NULL); num_args = 0; } if (num_resources == 0) { return NULL; } else if (num_resources >= MAXRESOURCES) { XtAppWarningMsg(XtWidgetToApplicationContext(widget), "invalidResourceCount","getResources",XtCXtToolkitError, "too many resources", (String *)NULL, (Cardinal *)NULL); return NULL; } else if (table == NULL) { XtAppWarningMsg(XtWidgetToApplicationContext(widget), "invalidResourceCount","getResources",XtCXtToolkitError, "resource count > 0 on NULL resource list", (String *)NULL, (Cardinal *)NULL); return NULL; } /* Mark each resource as not found on arg list */ bzero((char *) found, (int) (num_resources * sizeof(Boolean))); bzero((char *) typed, (int) (num_resources * sizeof(int))); /* Copy the args into the resources, mark each as found */ { register ArgList arg; register XtTypedArgList typed_arg; register XrmName argName; register Cardinal j; register int i; register XrmResourceList rx; register XrmResourceList *res; for (arg = args, i = 0; (Cardinal)i < num_args; i++, arg++) { argName = quark_args[i]; if (argName == QinitialResourcesPersistent) { persistent_resources = (Boolean)arg->value; found_persistence = True; continue; } for (j = 0, res = table; j < num_resources; j++, res++) { rx = *res; if (argName == rx->xrm_name) { _XtCopyFromArg( arg->value, base - rx->xrm_offset - 1, rx->xrm_size); found[j] = TRUE; break; } } } for (typed_arg = typed_args, i = 0; i < num_typed_args; i++, typed_arg++) { register XrmRepresentation argType; argName = quark_args[i]; argType = (typed_arg->type == NULL) ? NULLQUARK : XrmStringToRepresentation(typed_arg->type); if (argName == QinitialResourcesPersistent) { persistent_resources = (Boolean)typed_arg->value; found_persistence = True; break; } for (j = 0, res = table; j < num_resources; j++, res++) { rx = *res; if (argName == rx->xrm_name) { if (argType != NULLQUARK && argType != rx->xrm_type) { typed[j] = i + 1; } else { _XtCopyFromArg( typed_arg->value, base - rx->xrm_offset - 1, rx->xrm_size); } found[j] = TRUE; break; } } } } /* Ask resource manager for a list of database levels that we can do a single-level search on each resource */ db = XtScreenDatabase(XtScreenOfObject(widget)); while (!XrmQGetSearchList(db, names, classes, searchList, searchListSize)) { if (searchList == stackSearchList) searchList = NULL; searchList = (XrmHashTable*)XtRealloc((char*)searchList, sizeof(XrmHashTable) * (searchListSize *= 2)); } if (persistent_resources) cache_base = NULL; else cache_base = cache_ref; /* geez, this is an ugly mess */ if (XtIsShell(widget)) { register XrmResourceList *res; register Cardinal j; Screen *oldscreen = widget->core.screen; /* look up screen resource first, since real rdb depends on it */ for (res = table, j = 0; j < num_resources; j++, res++) { if ((*res)->xrm_name != Qscreen) continue; if (typed[j]) { register XtTypedArg* arg = typed_args + typed[j] - 1; XrmQuark from_type; XrmValue from_val, to_val; from_type = StringToQuark(arg->type); from_val.size = arg->size; if ((from_type == QString) || ((unsigned) arg->size > sizeof(XtArgVal))) from_val.addr = (XPointer)arg->value; else from_val.addr = (XPointer)&arg->value; to_val.size = sizeof(Screen*); to_val.addr = (XPointer)&widget->core.screen; found[j] = _XtConvert(widget, from_type, &from_val, QScreen, &to_val, cache_base); if (cache_base && *cache_base) cache_base++; } if (!found[j]) { if (XrmQGetSearchResource(searchList, Qscreen, QScreen, &rawType, &value)) { if (rawType != QScreen) { convValue.size = sizeof(Screen*); convValue.addr = (XPointer)&widget->core.screen; (void)_XtConvert(widget, rawType, &value, QScreen, &convValue, cache_base); if (cache_base && *cache_base) cache_base++; } else { widget->core.screen = *((Screen **)value.addr); } } } break; } /* now get the database to use for the rest of the resources */ if (widget->core.screen != oldscreen) { db = XtScreenDatabase(widget->core.screen); while (!XrmQGetSearchList(db, names, classes, searchList, searchListSize)) { if (searchList == stackSearchList) searchList = NULL; searchList = (XrmHashTable*)XtRealloc((char*)searchList, sizeof(XrmHashTable) * (searchListSize *= 2)); } } } /* go to the resource manager for those resources not found yet */ /* if it's not in the resource database use the default value */ { register XrmResourceList rx; register XrmResourceList *res; register Cardinal j; register XrmRepresentation xrm_type; register XrmRepresentation xrm_default_type; char char_val; short short_val; int int_val; long long_val; char* char_ptr; if (!found_persistence) { if (XrmQGetSearchResource(searchList, QinitialResourcesPersistent, QInitialResourcesPersistent, &rawType, &value)) { if (rawType != QBoolean) { convValue.size = sizeof(Boolean); convValue.addr = (XPointer)&persistent_resources; (void)_XtConvert(widget, rawType, &value, QBoolean, &convValue, NULL); } else persistent_resources = *(Boolean*)value.addr; } } if (persistent_resources) cache_ptr = NULL; else if (cache_base) cache_ptr = cache_base; else cache_ptr = cache_ref; for (res = table, j = 0; j < num_resources; j++, res++) { rx = *res; xrm_type = rx->xrm_type; if (typed[j]) { register XtTypedArg* arg = typed_args + typed[j] - 1; /* * This resource value has been specified as a typed arg and * has to be converted. Typed arg conversions are done here * to correctly interpose them with normal resource conversions. */ XrmQuark from_type; XrmValue from_val, to_val; Boolean converted; from_type = StringToQuark(arg->type); from_val.size = arg->size; if ((from_type == QString) || ((unsigned) arg->size > sizeof(XtArgVal))) from_val.addr = (XPointer)arg->value; else from_val.addr = (XPointer)&arg->value; to_val.size = rx->xrm_size; to_val.addr = base - rx->xrm_offset - 1; converted = _XtConvert(widget, from_type, &from_val, xrm_type, &to_val, cache_ptr); if (converted) { /* Copy the converted value back into the typed argument. * normally the data should be <= sizeof(XtArgVal) and * is stored directly into the 'value' field .... BUT * if the resource size is greater than sizeof(XtArgVal) * then we dynamically alloc a block of store to hold the * data and zap a copy in there !!! .... freeing it later * the size field in the typed arg is negated to indicate * that the store pointed to by the value field is * dynamic ....... * "freeing" happens in the case of _XtCreate after the * CallInitialize ..... other clients of GetResources * using typed args should be aware of the need to free * this store ..... */ if(rx->xrm_size > sizeof(XtArgVal)) { arg->value = (XtArgVal) __XtMalloc(rx->xrm_size); arg->size = -(arg->size); } else { /* will fit - copy directly into value field */ arg->value = (XtArgVal) NULL; } CopyToArg((char *)(base - rx->xrm_offset - 1), &arg->value, rx->xrm_size); } else { /* Conversion failed. Get default value. */ found[j] = False; } if (cache_ptr && *cache_ptr) cache_ptr++; } if (!found[j]) { Boolean already_copied = False; Boolean have_value = False; if (XrmQGetSearchResource(searchList, rx->xrm_name, rx->xrm_class, &rawType, &value)) { if (rawType != xrm_type) { convValue.size = rx->xrm_size; convValue.addr = (XPointer)(base - rx->xrm_offset - 1); already_copied = have_value = _XtConvert(widget, rawType, &value, xrm_type, &convValue, cache_ptr); if (cache_ptr && *cache_ptr) cache_ptr++; } else have_value = True; if (have_value && rx->xrm_name == Qtranslations) do_tm_hack = True; } LOCK_PROCESS; if (!have_value && ((rx->xrm_default_type == QImmediate) || (rx->xrm_default_type == xrm_type) || (rx->xrm_default_addr != NULL))) { /* Convert default value to proper type */ xrm_default_type = rx->xrm_default_type; if (xrm_default_type == QCallProc) { #ifdef CRAY if ( (int) Cjumpp != (int) Cjump) (*(XtResourceDefaultProc) (((int)(rx->xrm_default_addr))<<2))( widget,-(rx->xrm_offset+1), &value); else #endif (*(XtResourceDefaultProc)(rx->xrm_default_addr))( widget,-(rx->xrm_offset+1), &value); } else if (xrm_default_type == QImmediate) { /* XtRImmediate == XtRString for type XtRString */ if (xrm_type == QString) { value.addr = rx->xrm_default_addr; } else if (rx->xrm_size == sizeof(int)) { int_val = (int)(long)rx->xrm_default_addr; value.addr = (XPointer) &int_val; } else if (rx->xrm_size == sizeof(short)) { short_val = (short)(long)rx->xrm_default_addr; value.addr = (XPointer) &short_val; } else if (rx->xrm_size == sizeof(char)) { char_val = (char)(long)rx->xrm_default_addr; value.addr = (XPointer) &char_val; } else if (rx->xrm_size == sizeof(long)) { long_val = (long)rx->xrm_default_addr; value.addr = (XPointer) &long_val; } else if (rx->xrm_size == sizeof(char*)) { char_ptr = (char*)rx->xrm_default_addr; value.addr = (XPointer) &char_ptr; } else { value.addr = (XPointer) &(rx->xrm_default_addr); } } else if (xrm_default_type == xrm_type) { value.addr = rx->xrm_default_addr; } else { value.addr = rx->xrm_default_addr; if (xrm_default_type == QString) { value.size = strlen((char *)value.addr) + 1; } else { value.size = sizeof(XtPointer); } convValue.size = rx->xrm_size; convValue.addr = (XPointer)(base - rx->xrm_offset - 1); already_copied = _XtConvert(widget, xrm_default_type, &value, xrm_type, &convValue, cache_ptr); if (!already_copied) value.addr = NULL; if (cache_ptr && *cache_ptr) cache_ptr++; } } if (!already_copied) { if (xrm_type == QString) { *((String*)(base - rx->xrm_offset - 1)) = value.addr; } else { if (value.addr != NULL) { XtMemmove(base - rx->xrm_offset - 1, value.addr, rx->xrm_size); } else { /* didn't get value, initialize to NULL... */ XtBZero(base - rx->xrm_offset - 1, rx->xrm_size); } } } UNLOCK_PROCESS; if (typed[j]) { /* * This resource value was specified as a typed arg. * However, the default value is being used here since * type type conversion failed, so we compress the list. */ register XtTypedArg* arg = typed_args + typed[j] - 1; register int i; for (i = num_typed_args - typed[j]; i > 0; i--, arg++) { *arg = *(arg+1); } num_typed_args--; } } } if (tm_hack) widget->core.tm.current_state = NULL; if (tm_hack && (!widget->core.tm.translations || (do_tm_hack && widget->core.tm.translations->operation != XtTableReplace)) && XrmQGetSearchResource(searchList, QbaseTranslations, QTranslations, &rawType, &value)) { if (rawType != QTranslationTable) { convValue.size = sizeof(XtTranslations); convValue.addr = (XPointer)&widget->core.tm.current_state; (void)_XtConvert(widget, rawType, &value, QTranslationTable, &convValue, cache_ptr); if (cache_ptr && *cache_ptr) cache_ptr++; } else { /* value.addr can be NULL see: !already_copied */ if (value.addr) *((XtTranslations *)&widget->core.tm.current_state) = *((XtTranslations *)value.addr); } } } if ((Cardinal)num_typed_args != *pNumTypedArgs) *pNumTypedArgs = num_typed_args; if (searchList != stackSearchList) XtFree((char*)searchList); if (!cache_ptr) cache_ptr = cache_base; if (cache_ptr && cache_ptr != cache_ref) { int cache_ref_size = cache_ptr - cache_ref; XtCacheRef *refs = (XtCacheRef*) __XtMalloc((unsigned)sizeof(XtCacheRef)*(cache_ref_size + 1)); (void) memmove(refs, cache_ref, sizeof(XtCacheRef)*cache_ref_size ); refs[cache_ref_size] = NULL; return refs; } return (XtCacheRef*)NULL; }
// Convert String to XmString, using `@' for font specs: `@FONT TEXT' // makes TEXT be displayed in font FONT; a single space after FONT is // eaten. `@ ' displays a single `@'. static Boolean CvtStringToXmString(Display *display, XrmValue *, Cardinal *, XrmValue *fromVal, XrmValue *toVal, XtPointer *) { static const string font_esc = "@"; // Get string const string source = str(fromVal, false); string charset = (String)MSTRING_DEFAULT_CHARSET; const int n_segments = source.freq(font_esc) + 1; string *segments = new string[n_segments]; split(source, segments, n_segments, font_esc); MString buf(0, true); string txtbuf; for (int i = 0; i < n_segments; i++) { string segment; // set segment if (i == 0) { // At beginning of text segment = segments[i]; } else { int len = font_id_len(segments[i]); if (len > 0) { // Found @[font-id] <segment>: process it const string c = segments[i].before(len); segment = segments[i].from(int(c.length())); if (segment.empty()) { // Found @MACRO@ if (conversionMacroTable.has(c)) { // Replace @MACRO@ by value segment = conversionMacroTable[c]; segment += segments[++i]; } else { // No such macro Cardinal num_params = 1; String params = CONST_CAST(char*,c.chars()); XtAppWarningMsg(XtDisplayToApplicationContext(display), "noSuchMacro", "CvtStringToXmString", "XtToolkitError", "No such macro: @%s@", ¶ms, &num_params); segment.prepend(font_esc); segment += font_esc; } } else { // Found @CHARSET: set new charset charset = c; if (segment.contains(' ', 0) || segment.contains('\t', 0)) segment = segment.after(0); } } else if (segments[i].contains(' ', 0)) { // found @[space]: remove space segment = font_esc; segment += segments[i].from(1); } else { // found @[anything-else]: ignore @, take remainder literally segment = segments[i]; } }
_XvicImageSetStringCursor( XvicImageWidget iw, char *name) #endif /* _NO_PROTO */ { Display *dpy; char source_name[xvicPATH_MAX], mask_name[xvicPATH_MAX]; int source_char, mask_char, fields; Font source_font, mask_font; XrmValue fromString, toFont; Boolean success; #ifndef NO_XMU int i; unsigned int shape; Pixmap source, mask; int xhot, yhot; int len; #endif dpy = XtDisplay((Widget)iw); /* Check for font name/glyph index form */ if (strncmp(FONTSPECIFIER, name, strlen(FONTSPECIFIER)) == 0) { fields = sscanf(name, "FONT %s %d %s %d", source_name, &source_char, mask_name, &mask_char); if (fields < 2 || fields > 4) { XtAppWarningMsg(XtWidgetToApplicationContext((Widget)iw), "BadCursorString", "XvicImage", "XvicImageWidgetError", "Invalid format for Cursor string resource, cursor ignored", (String *)NULL, (Cardinal *)NULL); return; } fromString.addr = source_name; fromString.size = strlen(source_name) + 1; #if XtSpecificationRelease <= 4 XtConvert((Widget)iw, XtRString, &fromString, XtRFont, &toFont); success = (toFont.addr != NULL); if (success) source_font = *(Font *)toFont.addr; #else toFont.addr = (XtPointer) &source_font; toFont.size = sizeof(Font); success = XtConvertAndStore((Widget)iw, XtRString, &fromString, XtRFont, &toFont); #endif if (!success) { XtAppWarningMsg(XtWidgetToApplicationContext((Widget)iw), "BadCursorFont", "XvicImage", "XvicImageWidgetError", "Invalid font for Cursor string resource, cursor ignored", (String *)NULL, (Cardinal *)NULL); return; } switch (fields) { case 2: /* defaulted mask font & char */ mask_font = None; /* thus there is no mask, really */ mask_char = 0; break; case 3: /* defaulted mask font */ mask_font = source_font; mask_char = atoi(mask_name); break; case 4: /* specified mask font & char */ fromString.addr = mask_name; fromString.size = strlen(mask_name) + 1; #if XtSpecificationRelease <= 4 XtConvert((Widget)iw, XtRString, &fromString, XtRFont, &toFont); success = (toFont.addr != NULL); if (success) mask_font = *(Font *)toFont.addr; #else toFont.addr = (XtPointer) &mask_font; toFont.size = sizeof(Font); success = XtConvertAndStore((Widget)iw, XtRString, &fromString, XtRFont, &toFont); #endif if (!success) { XtAppWarningMsg(XtWidgetToApplicationContext((Widget)iw), "BadCursorMaskFont", "XvicImage", "XvicImageWidgetError", "Invalid mask font for Cursor string resource, cursor ignored", (String *)NULL, (Cardinal *)NULL); return; } } _XvicImageSetGlyphCursor(iw, source_font, mask_font, source_char, mask_char); /*!!!! Do we need to free fonts here???? !!!!*/ return; } #ifdef NO_XMU if (strcmp(name, DEFAULT_CURSOR) == 0) { _XvicImageSetFontCursor(iw, DEFAULT_CURSOR_SHAPE); /* default value */ return; } XtAppWarningMsg(XtWidgetToApplicationContext((Widget)iw), "BadCursorString", "XvicImage", "XvicImageWidgetError", "Invalid format for Cursor string resource, cursor ignored", (String *)NULL, (Cardinal *)NULL); return; #else /* Xmu is available */ /* Check for cursor shape name */ shape = XmuCursorNameToIndex(name); if (shape != -1) { _XvicImageSetFontCursor(iw, shape); return; } /* Check for bitmap file name */ source = XmuLocateBitmapFile(XtScreen((Widget)iw), name, mask_name, (sizeof mask_name) - 4, NULL, NULL, &xhot, &yhot); if (source == None) { XtAppWarningMsg(XtWidgetToApplicationContext((Widget)iw), "BadCursorString", "XvicImage", "XvicImageWidgetError", "Invalid format for Cursor string resource, cursor ignored", (String *)NULL, (Cardinal *)NULL); return; } len = strlen (mask_name); for (i = 0; i < 2; i++) { strcpy (mask_name + len, i == 0 ? "Mask" : "msk"); mask = XmuLocateBitmapFile (XtScreen((Widget)iw), mask_name, NULL, 0, NULL, NULL, NULL, NULL); if (mask != None) break; } _XvicImageSetPixmapCursor(iw, source, mask, xhot, yhot); XFreePixmap(XtDisplay((Widget)iw), source); if (mask != None) XFreePixmap(XtDisplay((Widget)iw), mask); return; #endif }
void XtRemoveCallbacks ( Widget widget, _Xconst char* name, XtCallbackList xtcallbacks) { InternalCallbackList *callbacks; Widget hookobj; int i; InternalCallbackList icl; XtCallbackList cl, ccl, rcl; XtAppContext app = XtWidgetToApplicationContext(widget); LOCK_APP(app); callbacks = FetchInternalList(widget, name); if (!callbacks) { XtAppWarningMsg(app, XtNinvalidCallbackList,XtNxtRemoveCallback,XtCXtToolkitError, "Cannot find callback list in XtRemoveCallbacks", (String *)NULL, (Cardinal *)NULL); UNLOCK_APP(app); return; } icl = *callbacks; if (!icl) { UNLOCK_APP(app); return; } i = icl->count; cl = ToList(icl); if (icl->call_state) { icl->call_state |= _XtCBFreeAfterCalling; icl = (InternalCallbackList)__XtMalloc(sizeof(InternalCallbackRec) + sizeof(XtCallbackRec) * i); icl->count = i; icl->call_state = 0; } ccl = ToList(icl); while (--i >= 0) { *ccl++ = *cl; for (rcl=xtcallbacks; rcl->callback; rcl++) { if (cl->callback == rcl->callback && cl->closure == rcl->closure) { ccl--; icl->count--; break; } } cl++; } if (icl->count) { icl = (InternalCallbackList) XtRealloc((char *)icl, (sizeof(InternalCallbackRec) + sizeof(XtCallbackRec) * icl->count)); icl->is_padded = 0; *callbacks = icl; } else { XtFree((char *)icl); *callbacks = NULL; } hookobj = XtHooksOfDisplay(XtDisplayOfObject(widget)); if (XtHasCallbacks(hookobj, XtNchangeHook) == XtCallbackHasSome) { XtChangeHookDataRec call_data; call_data.type = XtHremoveCallbacks; call_data.widget = widget; call_data.event_data = (XtPointer) name; XtCallCallbackList(hookobj, ((HookObject)hookobj)->hooks.changehook_callbacks, (XtPointer)&call_data); } UNLOCK_APP(app); } /* XtRemoveCallbacks */
void XtChangeManagedSet( WidgetList unmanage_children, Cardinal num_unmanage, XtDoChangeProc do_change_proc, XtPointer client_data, WidgetList manage_children, Cardinal num_manage) { WidgetList childp; Widget parent; int i; Cardinal some_unmanaged; Boolean call_out; CompositeClassExtension ext; XtAppContext app; Widget hookobj; XtChangeHookDataRec call_data; if (num_unmanage == 0 && num_manage == 0) return; /* specification doesn't state that library will check for NULL in list */ childp = num_unmanage ? unmanage_children : manage_children; app = XtWidgetToApplicationContext(*childp); LOCK_APP(app); parent = XtParent(*childp); childp = unmanage_children; for (i = num_unmanage; --i >= 0 && XtParent(*childp) == parent; childp++); call_out = (i >= 0); childp = manage_children; for (i = num_manage; --i >= 0 && XtParent(*childp) == parent; childp++); if (call_out || i >= 0) { XtAppWarningMsg(app, "ambiguousParent", XtNxtChangeManagedSet, XtCXtToolkitError, "Not all children have same parent", (String *)NULL, (Cardinal *)NULL); } if (! XtIsComposite(parent)) { UNLOCK_APP(app); XtAppErrorMsg(app, "invalidParent", XtNxtChangeManagedSet, XtCXtToolkitError, "Attempt to manage a child when parent is not Composite", (String *) NULL, (Cardinal *) NULL); } if (parent->core.being_destroyed) { UNLOCK_APP(app); return; } call_out = False; if (do_change_proc) { ext = (CompositeClassExtension) XtGetClassExtension(parent->core.widget_class, XtOffsetOf(CompositeClassRec, composite_class.extension), NULLQUARK, XtCompositeExtensionVersion, sizeof(CompositeClassExtensionRec)); if (!ext || !ext->allows_change_managed_set) call_out = True; } UnmanageChildren(unmanage_children, num_unmanage, parent, &some_unmanaged, call_out, XtNxtChangeManagedSet); hookobj = XtHooksOfDisplay(XtDisplay(parent)); if (XtHasCallbacks(hookobj, XtNchangeHook) == XtCallbackHasSome) { call_data.type = XtHunmanageSet; call_data.widget = parent; call_data.event_data = (XtPointer) unmanage_children; call_data.num_event_data = num_unmanage; XtCallCallbackList(hookobj, ((HookObject)hookobj)->hooks.changehook_callbacks, (XtPointer) &call_data); } if (do_change_proc) (*do_change_proc)(parent, unmanage_children, &num_unmanage, manage_children, &num_manage, client_data); call_out = (some_unmanaged && !call_out); ManageChildren(manage_children, num_manage, parent, call_out, XtNxtChangeManagedSet); if (XtHasCallbacks(hookobj, XtNchangeHook) == XtCallbackHasSome) { call_data.type = XtHmanageSet; call_data.event_data = (XtPointer) manage_children; call_data.num_event_data = num_manage; XtCallCallbackList(hookobj, ((HookObject)hookobj)->hooks.changehook_callbacks, (XtPointer) &call_data); } UNLOCK_APP(app); } /* XtChangeManagedSet */
static void UnmanageChildren( WidgetList children, Cardinal num_children, Widget parent, Cardinal* num_unique_children, Boolean call_change_managed, String caller_func) { Widget child; Cardinal i; XtWidgetProc change_managed = NULL; Bool parent_realized = False; *num_unique_children = 0; if (XtIsComposite((Widget) parent)) { LOCK_PROCESS; change_managed = ((CompositeWidgetClass) parent->core.widget_class) ->composite_class.change_managed; UNLOCK_PROCESS; parent_realized = XtIsRealized((Widget)parent); } else { XtAppErrorMsg(XtWidgetToApplicationContext((Widget)parent), "invalidParent",caller_func, XtCXtToolkitError, "Attempt to unmanage a child when parent is not Composite", (String *) NULL, (Cardinal *) NULL); } for (i = 0; i < num_children; i++) { child = children[i]; if (child == NULL) { XtAppWarningMsg(XtWidgetToApplicationContext(parent), XtNinvalidChild,caller_func,XtCXtToolkitError, "Null child passed to XtUnmanageChildren", (String *)NULL, (Cardinal *)NULL); return; } if (child->core.parent != parent) { XtAppWarningMsg(XtWidgetToApplicationContext(parent), "ambiguousParent",caller_func,XtCXtToolkitError, "Not all children have same parent in UnmanageChildren", (String *)NULL, (Cardinal *)NULL); } else if (child->core.managed) { (*num_unique_children)++; CALLGEOTAT(_XtGeoTrace(child,"Child \"%s\" is marked unmanaged\n", XtName(child))); child->core.managed = FALSE; if (XtIsWidget(child) && XtIsRealized(child) && child->core.mapped_when_managed) XtUnmapWidget(child); else { /* RectObj child */ Widget pw = child->core.parent; RectObj r = (RectObj) child; while ((pw!=NULL) && (!XtIsWidget(pw))) pw = pw->core.parent; if ((pw!=NULL) && XtIsRealized (pw)) XClearArea (XtDisplay (pw), XtWindow (pw), r->rectangle.x, r->rectangle.y, r->rectangle.width + (r->rectangle.border_width << 1), r->rectangle.height + (r->rectangle.border_width << 1), TRUE); } } } if (call_change_managed && *num_unique_children != 0 && change_managed != NULL && parent_realized) { CALLGEOTAT(_XtGeoTrace((Widget)parent, "Call parent: \"%s\"[%d,%d]'s changemanaged proc\n", XtName((Widget)parent), parent->core.width,parent->core.height)); (*change_managed) (parent); } } /* UnmanageChildren */
static Boolean __XmCvtRepToString(Display *display, XrmValue *args, Cardinal *num_args, XrmValue *from, XrmValue *to, XtPointer *converter_data) { XmRepTypeEntry entry = rep_types + *(int *)args[0].addr; static String value; if (from->addr == NULL) { String params[1]; Cardinal numParams = 1; params[0] = (String)from->addr; XtAppWarningMsg(XtDisplayToApplicationContext(display), "conversionError", entry->rep_type_name, "XtToolkitError", "Cannot convert value NULL of type %s to type string", params, &numParams); return False; } value = __XmRepTypeValueToString(entry, *(unsigned char *)from->addr); if (value == NULL) { String params[2]; Cardinal numParams = 2; char ASCIIValue[4]; error: value = entry->value_names[0]; sprintf(ASCIIValue, "%i", *(unsigned char *)from->addr); params[0] = ASCIIValue; params[1] = entry->rep_type_name; XtAppWarningMsg(XtDisplayToApplicationContext(display), "conversionError", entry->rep_type_name, "XtToolkitError", "Cannot convert value %s of type %s to type string", params, &numParams); return False; } if (to->addr == NULL) { to->addr = (XPointer)&value; } else { if (to->size >= sizeof value) { *(String *)to->addr = value; } else { goto error; } } to->size = sizeof value; return True; }
static void ManageChildren( WidgetList children, Cardinal num_children, Widget parent, Boolean call_change_managed, String caller_func) { #define MAXCHILDREN 100 Widget child; Cardinal num_unique_children, i; XtWidgetProc change_managed = NULL; WidgetList unique_children; Widget cache[MAXCHILDREN]; Bool parent_realized = False; if (XtIsComposite((Widget) parent)) { LOCK_PROCESS; change_managed = ((CompositeWidgetClass) parent->core.widget_class) ->composite_class.change_managed; UNLOCK_PROCESS; parent_realized = XtIsRealized((Widget)parent); } else { XtAppErrorMsg(XtWidgetToApplicationContext((Widget)parent), "invalidParent",caller_func, XtCXtToolkitError, "Attempt to manage a child when parent is not Composite", (String *) NULL, (Cardinal *) NULL); } /* Construct new list of children that really need to be operated upon. */ if (num_children <= MAXCHILDREN) { unique_children = cache; } else { unique_children = (WidgetList) __XtMalloc(num_children * sizeof(Widget)); } num_unique_children = 0; for (i = 0; i < num_children; i++) { child = children[i]; if (child == NULL) { XtAppWarningMsg(XtWidgetToApplicationContext((Widget)parent), XtNinvalidChild,caller_func,XtCXtToolkitError, "null child passed to ManageChildren", (String *)NULL, (Cardinal *)NULL); if (unique_children != cache) XtFree((char *) unique_children); return; } #ifdef DEBUG if (!XtIsRectObj(child)) { String params[2]; Cardinal num_params = 2; params[0] = XtName(child); params[1] = child->core.widget_class->core_class.class_name; XtAppWarningMsg(XtWidgetToApplicationContext((Widget)parent), "notRectObj",caller_func,XtCXtToolkitError, "child \"%s\", class %s is not a RectObj", params, &num_params); continue; } #endif /*DEBUG*/ if (child->core.parent != parent) { XtAppWarningMsg(XtWidgetToApplicationContext((Widget)parent), "ambiguousParent",caller_func,XtCXtToolkitError, "Not all children have same parent in XtManageChildren", (String *)NULL, (Cardinal *)NULL); } else if (! child->core.managed && !child->core.being_destroyed) { unique_children[num_unique_children++] = child; CALLGEOTAT(_XtGeoTrace(child, "Child \"%s\"[%d,%d] is marked managed\n", XtName(child), child->core.width,child->core.height)); child->core.managed = TRUE; } } if ((call_change_managed || num_unique_children != 0) && parent_realized) { /* Compute geometry of new managed set of children. */ if (change_managed != NULL) { CALLGEOTAT(_XtGeoTrace((Widget)parent, "Call parent: \"%s\"[%d,%d]'s changemanaged\n", XtName((Widget)parent), parent->core.width,parent->core.height)); (*change_managed) ((Widget)parent); } /* Realize each child if necessary, then map if necessary */ for (i = 0; i < num_unique_children; i++) { child = unique_children[i]; if (XtIsWidget(child)) { if (! XtIsRealized(child)) XtRealizeWidget(child); if (child->core.mapped_when_managed) XtMapWidget(child); } else { /* RectObj child */ Widget pw = child->core.parent; RectObj r = (RectObj) child; while ((pw!=NULL) && (!XtIsWidget(pw))) pw = pw->core.parent; if (pw != NULL) XClearArea (XtDisplay (pw), XtWindow (pw), r->rectangle.x, r->rectangle.y, r->rectangle.width + (r->rectangle.border_width << 1), r->rectangle.height + (r->rectangle.border_width << 1), TRUE); } } } if (unique_children != cache) XtFree((char *) unique_children); } /* ManageChildren */