Boolean XtIsObject( Widget object) { WidgetClass wc; String class_name; /* perform basic sanity checks */ if (object->core.self != object || object->core.xrm_name == NULLQUARK) return False; LOCK_PROCESS; wc = object->core.widget_class; if (wc->core_class.class_name == NULL || wc->core_class.xrm_class == NULLQUARK || (class_name = XrmClassToString(wc->core_class.xrm_class)) == NULL || strcmp(wc->core_class.class_name, class_name) != 0) { UNLOCK_PROCESS; return False; } UNLOCK_PROCESS; if (XtIsWidget(object)) { if (object->core.name == NULL || (class_name = XrmNameToString(object->core.xrm_name)) == NULL || strcmp(object->core.name, class_name) != 0) return False; } return True; }
static void _XmFastExpose(Widget widg) { register int i; register Widget child; XmGrabShellWidget gs = (XmGrabShellWidget)widg; _XmProcessLock(); (*(XtClass(widg)->core_class.expose)) (widg, NULL, NULL); _XmProcessUnlock(); /* Process each windowed child */ for (i = 0; i < gs->composite.num_children; i++) { child = gs->composite.children[i]; if (XtIsWidget(child) && XtIsManaged(child)) { _XmProcessLock(); (*(XtClass(child)->core_class.expose)) (child, NULL, NULL); _XmProcessUnlock(); } } XFlush(XtDisplay(widg)); DrawBorder(widg); }
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)); }
// Convert String to Pixmap (using XmGetPixmap) // A Pixmap will be read in as bitmap file // 1 and 0 values are set according to the widget's // foreground/background colors. static Boolean CvtStringToPixmap(Display *display, XrmValue *args, Cardinal *num_args, XrmValue *fromVal, XrmValue *toVal, XtPointer *) { // Default parameters Screen *screen = DefaultScreenOfDisplay(display); Pixel background = WhitePixelOfScreen(screen); Pixel foreground = BlackPixelOfScreen(screen); if (*num_args >= 1) { // convert first arg into widget Widget w = *(Widget *) args[0].addr; background = w->core.background_pixel; screen = XtScreen(w); if (XtIsWidget(w) && XmIsPrimitive(w)) { // Get foreground color from widget foreground = XmPrimitiveWidget(w)->primitive.foreground; } else { // Ask Motif for a default foreground color Pixel newfg, newtop, newbot, newselect; XmGetColors(screen, w->core.colormap, background, &newfg, &newtop, &newbot, &newselect); foreground = newfg; } } // Get pixmap Pixmap p = XmUNSPECIFIED_PIXMAP; string value = str(fromVal, false); // Some Motif versions use `unspecified_pixmap' and `unspecified pixmap' // as values for XmUNSPECIFIED_PIXMAP. Check for this. string v = downcase(value); v.gsub(" ", "_"); if (v.contains("xm", 0)) v = v.after("xm"); if (v != "unspecified_pixmap") { p = XmGetPixmap(screen, XMST(value.chars()), foreground, background); if (p == XmUNSPECIFIED_PIXMAP) { XtDisplayStringConversionWarning(display, fromVal->addr, XmRPixmap); return False; } } done(Pixmap, p); }
XtCacheRef *_XtGetResources( register Widget w, ArgList args, Cardinal num_args, XtTypedArgList typed_args, Cardinal* num_typed_args) { XrmName *names, names_s[50]; XrmClass *classes, classes_s[50]; XrmQuark quark_cache[100]; XrmQuarkList quark_args; WidgetClass wc; ConstraintWidgetClass cwc; XtCacheRef *cache_refs, *cache_refs_core; Cardinal count; wc = XtClass(w); count = CountTreeDepth(w); names = (XrmName*) XtStackAlloc (count * sizeof(XrmName), names_s); classes = (XrmClass*) XtStackAlloc (count * sizeof(XrmClass), classes_s); if (names == NULL || classes == NULL) _XtAllocError(NULL); /* Get names, classes for widget and ancestors */ GetNamesAndClasses(w, names, classes); /* Compile arg list into quarks */ CacheArgs(args, num_args, typed_args, *num_typed_args, quark_cache, XtNumber(quark_cache), &quark_args); /* Get normal resources */ LOCK_PROCESS; cache_refs = GetResources(w, (char*)w, names, classes, (XrmResourceList *) wc->core_class.resources, wc->core_class.num_resources, quark_args, args, num_args, typed_args, num_typed_args, XtIsWidget(w)); if (w->core.constraints != NULL) { cwc = (ConstraintWidgetClass) XtClass(w->core.parent); cache_refs_core = GetResources(w, (char*)w->core.constraints, names, classes, (XrmResourceList *) cwc->constraint_class.resources, cwc->constraint_class.num_resources, quark_args, args, num_args, typed_args, num_typed_args, False); if (cache_refs_core) { XtFree((char *)cache_refs_core); } } FreeCache(quark_cache, quark_args); UNLOCK_PROCESS; XtStackFree((XtPointer)names, names_s); XtStackFree((XtPointer)classes, classes_s); return cache_refs; } /* _XtGetResources */
void XtGetValues( register Widget w, register ArgList args, register Cardinal num_args) { WidgetClass wc; int targ; XtAppContext app = XtWidgetToApplicationContext(w); if (num_args == 0) return; if ((args == NULL) && (num_args != 0)) { XtAppErrorMsg(app, "invalidArgCount","xtGetValues",XtCXtToolkitError, "Argument count > 0 on NULL argument list in XtGetValues", (String *)NULL, (Cardinal *)NULL); } LOCK_APP(app); wc = XtClass(w); LOCK_PROCESS; /* Get widget values */ targ = GetValues((char*)w, (XrmResourceList *) wc->core_class.resources, wc->core_class.num_resources, args, num_args); UNLOCK_PROCESS; if (targ != -1 && XtIsWidget(w)) { XtTranslations translations = _XtGetTranslationValue(w); _XtCopyToArg((char*)&translations, &args[targ].value, sizeof(XtTranslations)); } /* Get constraint values if necessary */ /* constraints may be NULL if constraint_size==0 */ if (XtParent(w) != NULL && !XtIsShell(w) && XtIsConstraint(XtParent(w)) && w->core.constraints) { ConstraintWidgetClass cwc = (ConstraintWidgetClass) XtClass(XtParent(w)); LOCK_PROCESS; GetValues((char*)w->core.constraints, (XrmResourceList *)(cwc->constraint_class.resources), cwc->constraint_class.num_resources, args, num_args); UNLOCK_PROCESS; } /* Notify any class procedures that we have performed get_values */ CallGetValuesHook(wc, w, args, num_args); /* Notify constraint get_values if necessary */ if (XtParent(w) != NULL && !XtIsShell(w) && XtIsConstraint(XtParent(w))) CallConstraintGetValuesHook(XtClass(XtParent(w)), w, args,num_args); UNLOCK_APP(app); } /* XtGetValues */
static void MapChildren( CompositePart *cwp) { Cardinal i; WidgetList children; register Widget child; children = cwp->children; for (i = 0; i < cwp->num_children; i++) { child = children[i]; if (XtIsWidget (child)) { if (child->core.managed && child->core.mapped_when_managed) { XtMapWidget (children[i]); } } } } /* MapChildren */
/* * Internal routine; must be called only after XtIsWidget returns false */ Widget _XtWindowedAncestor( register Widget object) { Widget obj = object; for (object = XtParent(object); object && !XtIsWidget(object);) object = XtParent(object); if (object == NULL) { String params = XtName(obj); Cardinal num_params = 1; XtErrorMsg("noWidgetAncestor", "windowedAncestor", XtCXtToolkitError, "Object \"%s\" does not have windowed ancestor", ¶ms, &num_params); } return object; }
void MotifUI::DumpWidgets(Widget w, boolean verbose, int level) { DumpWidget(w, verbose, level); int i; if (XtIsWidget(w)) { for (i = 0; i < w->core.num_popups; i++) DumpWidgets(w->core.popup_list[i], verbose, level + 1); } if (XtIsComposite(w)) { CompositeWidget cw = (CompositeWidget) w; for (i = 0; i < cw->composite.num_children; i++) DumpWidgets(cw->composite.children[i], verbose, level + 1); } }
static void VerbosePass1(Widget w, int level) { int i; if (level == 0) G_width = 0; int new_width = (level * 3) + strlen(XrmQuarkToString(w->core.xrm_name)) + strlen(w->core.widget_class->core_class.class_name) + 3; if (new_width > G_width) G_width = new_width; if (XtIsWidget(w)) for (i = 0; i < w->core.num_popups; i++) VerbosePass1(w->core.popup_list[i], level + 1); if (XtIsComposite(w)) { CompositeWidget cw = (CompositeWidget) w; for (i = 0; i < cw->composite.num_children; i++) VerbosePass1(cw->composite.children[i], level + 1); } }
static void UnrealizeWidget( Widget widget) { CompositeWidget cw; Cardinal i; WidgetList children; if (!XtIsWidget(widget) || !XtIsRealized(widget)) return; /* If this is the application's popup shell, unmap it? */ /* no, the window is being destroyed */ /* Recurse on children */ if (XtIsComposite (widget)) { cw = (CompositeWidget) widget; children = cw->composite.children; /* Unrealize all children */ for (i = cw->composite.num_children; i != 0; --i) { UnrealizeWidget (children[i-1]); } /* Unmap children that are managed and mapped_when_managed? */ /* No, it's ok to be managed and unrealized as long as your parent */ /* is unrealized. XtUnrealize widget makes sure the "top" widget */ /* is unmanaged, we can ignore all descendents */ } if (XtHasCallbacks(widget, XtNunrealizeCallback) == XtCallbackHasSome) XtCallCallbacks(widget, XtNunrealizeCallback, NULL); /* Unregister window */ XtUnregisterDrawable(XtDisplay(widget), XtWindow(widget)); /* Remove Event Handlers */ /* remove grabs. Happens automatically when window is destroyed. */ /* Destroy X Window, done at outer level with one request */ widget->core.window = None; /* Removing the event handler here saves having to keep track if * the translation table is changed while the widget is unrealized. */ _XtRemoveTranslations(widget); } /* UnrealizeWidget */
static Boolean ShouldMapAllChildren( CompositePart *cwp) { Cardinal i; WidgetList children; register Widget child; children = cwp->children; for (i = 0; i < cwp->num_children; i++) { child = children[i]; if (XtIsWidget(child)) { if (XtIsRealized(child) && (! (child->core.managed && child->core.mapped_when_managed))) { return False; } } } return True; } /* ShouldMapAllChildren */
/* * Apply a function to all the subwidgets of a given widget recursively. * Stop as soon as the function returns non NULL and returns this as a value. */ void * XtApplyUntilToWidgets (Widget w, XtApplyUntilToWidgetsProc proc, XtPointer arg) { void* result; if (XtIsComposite (w)) { CompositeWidget cw = (CompositeWidget)w; int i; for (i = 0; i < cw->composite.num_children; i++) if (XtIsWidget (cw->composite.children [i])){ result = proc (cw->composite.children [i], arg); if (result) return result; result = XtApplyUntilToWidgets (cw->composite.children [i], proc, arg); if (result) return result; } } return NULL; }
/* ** Look for a widget in the widget tree w, with a mnemonic matching ** keycode. When one is found, simulate a button press on that widget ** and give it the keyboard focus. If the mnemonic is on a label, ** look in the userData field of the label to see if it points to ** another widget, and give that the focus. This routine is just ** sufficient for NEdit, no doubt it will need to be extended for ** mnemonics on widgets other than just buttons and text fields. */ static void findAndActivateMnemonic(Widget w, unsigned int keycode) { WidgetList children; int numChildren, i, isMenu; KeySym mnemonic = '\0'; char mneString[2]; Widget userData; unsigned char rowColType; if (XtIsComposite(w)) { if (XtClass(w) == xmRowColumnWidgetClass) { XtVaGetValues(w, XmNrowColumnType, &rowColType, 0); isMenu = rowColType != XmWORK_AREA; } else isMenu = False; if (!isMenu) { XtVaGetValues(w, XmNchildren, &children, XmNnumChildren, &numChildren, 0); for (i=0; i<numChildren; i++) findAndActivateMnemonic(children[i], keycode); } } else { XtVaGetValues(w, XmNmnemonic, &mnemonic, 0); if (mnemonic != '\0') { mneString[0] = mnemonic; mneString[1] = '\0'; if (XKeysymToKeycode(XtDisplay(XtParent(w)), XStringToKeysym(mneString)) == keycode) { if (XtClass(w) == xmLabelWidgetClass || XtClass(w) == xmLabelGadgetClass) { XtVaGetValues(w, XmNuserData, &userData, 0); if (userData!=NULL && XtIsWidget(userData)) XmProcessTraversal(userData, XmTRAVERSE_CURRENT); } else { XmProcessTraversal(w, XmTRAVERSE_CURRENT); SimulateButtonPress(w); } } } } }
static Widget NameListToWidget( register Widget root, XrmNameList names, XrmBindingList bindings, int in_depth, int *out_depth, int *found_depth) { Widget w1, w2; int d1, d2; if (in_depth >= *found_depth) { *out_depth = 10000; return NULL; } if (names[0] == NULLQUARK) { *out_depth = *found_depth = in_depth; return root; } if (! XtIsWidget(root)) { *out_depth = 10000; return NULL; } if (*bindings == XrmBindTightly) { return SearchChildren(root, names, bindings, MatchExactChildren, in_depth, out_depth, found_depth); } else { /* XrmBindLoosely */ w1 = SearchChildren(root, names, bindings, MatchExactChildren, in_depth, &d1, found_depth); w2 = SearchChildren(root, names, bindings, MatchWildChildren, in_depth, &d2, found_depth); *out_depth = (d1 < d2 ? d1 : d2); return (d1 < d2 ? w1 : w2); } } /* NameListToWidget */
void XtConfigureWidget( Widget w, _XtPosition x, _XtPosition y, _XtDimension width, _XtDimension height, _XtDimension borderWidth) { XtConfigureHookDataRec req; Widget hookobj; XWindowChanges old; WIDGET_TO_APPCON(w); CALLGEOTAT(_XtGeoTrace(w, "\"%s\" is being configured by its parent \"%s\"\n", XtName(w), (XtParent(w))?XtName(XtParent(w)):"Root")); CALLGEOTAT(_XtGeoTab(1)); LOCK_APP(app); req.changeMask = 0; if ((old.x = w->core.x) != x) { CALLGEOTAT(_XtGeoTrace(w,"x move from %d to %d\n",w->core.x, x)); req.changes.x = w->core.x = x; req.changeMask |= CWX; } if ((old.y = w->core.y) != y) { CALLGEOTAT(_XtGeoTrace(w,"y move from %d to %d\n",w->core.y, y)); req.changes.y = w->core.y = y; req.changeMask |= CWY; } if ((old.width = w->core.width) != width) { CALLGEOTAT(_XtGeoTrace(w, "width move from %d to %d\n",w->core.width, width)); req.changes.width = w->core.width = width; req.changeMask |= CWWidth; } if ((old.height = w->core.height) != height) { CALLGEOTAT(_XtGeoTrace(w, "height move from %d to %d\n",w->core.height, height)); req.changes.height = w->core.height = height; req.changeMask |= CWHeight; } if ((old.border_width = w->core.border_width) != borderWidth) { CALLGEOTAT(_XtGeoTrace(w,"border_width move from %d to %d\n", w->core.border_width,borderWidth )); req.changes.border_width = w->core.border_width = borderWidth; req.changeMask |= CWBorderWidth; } if (req.changeMask != 0) { if (XtIsRealized(w)) { if (XtIsWidget(w)) { CALLGEOTAT(_XtGeoTrace(w, "XConfigure \"%s\"'s window\n",XtName(w))); XConfigureWindow(XtDisplay(w), XtWindow(w), req.changeMask, &req.changes); } else { CALLGEOTAT(_XtGeoTrace(w, "ClearRectObj called on \"%s\"\n",XtName(w))); ClearRectObjAreas((RectObj)w, &old); } } hookobj = XtHooksOfDisplay(XtDisplayOfObject(w));; if (XtHasCallbacks(hookobj, XtNconfigureHook) == XtCallbackHasSome) { req.type = XtHconfigure; req.widget = w; XtCallCallbackList(hookobj, ((HookObject)hookobj)->hooks.confighook_callbacks, (XtPointer)&req); } { XtWidgetProc resize; LOCK_PROCESS; resize = XtClass(w)->core_class.resize; UNLOCK_PROCESS; if ((req.changeMask & (CWWidth | CWHeight)) && resize != (XtWidgetProc) NULL) { CALLGEOTAT(_XtGeoTrace(w,"Resize proc is called.\n")); (*resize)(w); } } } else { CALLGEOTAT(_XtGeoTrace(w,"No change in configuration\n")); } CALLGEOTAT(_XtGeoTab(-1)); UNLOCK_APP(app); } /* XtConfigureWidget */
void DumpWidgetLevel(Widget w, String Prefix, String SubPrefix) { char *p; Widget *child, *children, lp; int i, NumPopupChildren, NumObjChildren, NumChildren; String name; if ( XtIsWidget(w) ) { NumPopupChildren = w->core.num_popups; } else { NumPopupChildren = 0; } if ( _XmIsFastSubclass(XtClass(w), XmSCREEN_BIT ) ) { children = ((XmScreenRec *) w)->desktop.children; NumObjChildren = ((XmScreenRec *) w)->desktop.num_children; } else if ( XmIsDesktopObject(w) ) { children = ((XmDesktopRec *) w)->desktop.children; NumObjChildren = ((XmDesktopRec *) w)->desktop.num_children; } else { NumObjChildren = 0; } if ( XtIsComposite(w) ) { NumChildren = ((CompositeRec *) w)->composite.num_children; } else { NumChildren = 0; } p = TreeBuffer + strlen(TreeBuffer); DumpW(w, Prefix, SubPrefix, (NumChildren || NumObjChildren || NumPopupChildren) ? "| " : " "); strcpy(p, SubPrefix); /* * First dump all ordinary children... */ if ( XtIsComposite(w) ) { child = ((CompositeRec *) w)->composite.children; for ( i = NumChildren; i > 0; i-- ) { if ( (i != 1) || NumPopupChildren || NumObjChildren ) { DumpWidgetLevel(*child, "+-- ", "| "); } else { DumpWidgetLevel(*child, "`-- ", " "); } child++; } } /* * ...then dump all popup children... */ child = w->core.popup_list; for ( i = NumPopupChildren; i > 0; i-- ) { if ( (i != 1) ) { DumpWidgetLevel(*child, "+-- (POPUP CHILD) ", "| "); } else { DumpWidgetLevel(*child, "`-- (POPUP CHILD) ", " "); } child++; } /* * ...and finally the illegimate children... */ child = children; for ( i = NumObjChildren; i > 0; i-- ) { if ( (i != 1) ) { DumpWidgetLevel(*child, "+-- ", "| "); } else { DumpWidgetLevel(*child, "`-- ", " "); } child++; } *p = 0; } /* DumpWidgetLevel */
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 */
XtGeometryResult _XtMakeGeometryRequest ( Widget widget, XtWidgetGeometry *request, XtWidgetGeometry *reply, Boolean * clear_rect_obj) { XtWidgetGeometry junk; XtGeometryHandler manager = (XtGeometryHandler) NULL; XtGeometryResult returnCode; Widget parent = widget->core.parent; Boolean managed, parentRealized, rgm = False; XtConfigureHookDataRec req; Widget hookobj; *clear_rect_obj = FALSE; CALLGEOTAT(_XtGeoTrace(widget, "\"%s\" is making a %sgeometry request to its parent \"%s\".\n", XtName(widget), ((request->request_mode & XtCWQueryOnly))? "query only ":"", (XtParent(widget))?XtName(XtParent(widget)):"Root")); CALLGEOTAT(_XtGeoTab(1)); if (XtIsShell(widget)) { ShellClassExtension ext; LOCK_PROCESS; for (ext = (ShellClassExtension)((ShellWidgetClass)XtClass(widget)) ->shell_class.extension; ext != NULL && ext->record_type != NULLQUARK; ext = (ShellClassExtension)ext->next_extension); if (ext != NULL) { if ( ext->version == XtShellExtensionVersion && ext->record_size == sizeof(ShellClassExtensionRec)) { manager = ext->root_geometry_manager; rgm = True; } else { String params[1]; Cardinal num_params = 1; params[0] = XtClass(widget)->core_class.class_name; XtAppErrorMsg(XtWidgetToApplicationContext(widget), "invalidExtension", "xtMakeGeometryRequest", XtCXtToolkitError, "widget class %s has invalid ShellClassExtension record", params, &num_params); } } else { XtAppErrorMsg(XtWidgetToApplicationContext(widget), "internalError", "xtMakeGeometryRequest", XtCXtToolkitError, "internal error; ShellClassExtension is NULL", NULL, NULL); } managed = True; parentRealized = TRUE; UNLOCK_PROCESS; } else { /* not shell */ if (parent == NULL) XtAppErrorMsg(XtWidgetToApplicationContext(widget), "invalidParent","xtMakeGeometryRequest", XtCXtToolkitError, "non-shell has no parent in XtMakeGeometryRequest", (String *)NULL, (Cardinal *)NULL); managed = XtIsManaged(widget); parentRealized = XtIsRealized(parent); if (XtIsComposite(parent)) { LOCK_PROCESS; manager = ((CompositeWidgetClass) (parent->core.widget_class)) ->composite_class.geometry_manager; UNLOCK_PROCESS; } } #if 0 /* * The Xt spec says that these conditions must generate * error messages (not warnings), but many Xt applications * and toolkits (including parts of Xaw, Motif and Netscape) * depend on the previous Xt behaviour. Thus, these tests * should probably remain disabled. */ if (parentRealized && managed) { if (parent && !XtIsComposite(parent)) { /* * This shouldn't ever happen, we only test for this to pass * VSW5. Normally managing the widget will catch this, but VSW5 * does some really screwy stuff to get here. */ XtAppErrorMsg(XtWidgetToApplicationContext(widget), "invalidParent", "xtMakeGeometryRequest", XtCXtToolkitError, "XtMakeGeometryRequest - parent not composite", (String *)NULL, (Cardinal *)NULL); } else if (manager == (XtGeometryHandler) NULL) { XtAppErrorMsg(XtWidgetToApplicationContext(widget), "invalidGeometryManager","xtMakeGeometryRequest", XtCXtToolkitError, "XtMakeGeometryRequest - parent has no geometry manager", (String *)NULL, (Cardinal *)NULL); } } #else if (!manager) managed = False; #endif if (widget->core.being_destroyed) { CALLGEOTAT(_XtGeoTab(-1)); CALLGEOTAT(_XtGeoTrace(widget, "It is being destroyed, just return XtGeometryNo.\n")); return XtGeometryNo; } /* see if requesting anything to change */ req.changeMask = 0; if (request->request_mode & CWStackMode && request->stack_mode != XtSMDontChange) { req.changeMask |= CWStackMode; CALLGEOTAT(_XtGeoTrace(widget, "Asking for a change in StackMode!\n")); if (request->request_mode & CWSibling) { XtCheckSubclass(request->sibling, rectObjClass, "XtMakeGeometryRequest"); req.changeMask |= CWSibling; } } if (request->request_mode & CWX && widget->core.x != request->x) { CALLGEOTAT(_XtGeoTrace(widget, "Asking for a change in x: from %d to %d.\n", widget->core.x, request->x)); req.changeMask |= CWX; } if (request->request_mode & CWY && widget->core.y != request->y) { CALLGEOTAT(_XtGeoTrace(widget, "Asking for a change in y: from %d to %d.\n", widget->core.y, request->y)); req.changeMask |= CWY; } if (request->request_mode & CWWidth && widget->core.width != request->width) { CALLGEOTAT(_XtGeoTrace(widget,"Asking for a change in width: from %d to %d.\n", widget->core.width, request->width)); req.changeMask |= CWWidth; } if (request->request_mode & CWHeight && widget->core.height != request->height) { CALLGEOTAT(_XtGeoTrace(widget, "Asking for a change in height: from %d to %d.\n", widget->core.height, request->height)); req.changeMask |= CWHeight; } if (request->request_mode & CWBorderWidth && widget->core.border_width != request->border_width) { CALLGEOTAT(_XtGeoTrace(widget, "Asking for a change in border_width: from %d to %d.\n", widget->core.border_width, request->border_width)); req.changeMask |= CWBorderWidth; } if (! req.changeMask) { CALLGEOTAT(_XtGeoTrace(widget, "Asking for nothing new,\n")); CALLGEOTAT(_XtGeoTab(-1)); CALLGEOTAT(_XtGeoTrace(widget, "just return XtGeometryYes.\n")); return XtGeometryYes; } req.changeMask |= (request->request_mode & XtCWQueryOnly); if ( !(req.changeMask & XtCWQueryOnly) && XtIsRealized(widget) ) { /* keep record of the current geometry so we know what's changed */ req.changes.x = widget->core.x ; req.changes.y = widget->core.y ; req.changes.width = widget->core.width ; req.changes.height = widget->core.height ; req.changes.border_width = widget->core.border_width ; } if (!managed || !parentRealized) { CALLGEOTAT(_XtGeoTrace(widget, "Not Managed or Parent not realized.\n")); /* Don't get parent's manager involved--assume the answer is yes */ if (req.changeMask & XtCWQueryOnly) { /* He was just asking, don't change anything, just tell him yes */ CALLGEOTAT(_XtGeoTrace(widget,"QueryOnly request\n")); CALLGEOTAT(_XtGeoTab(-1)); CALLGEOTAT(_XtGeoTrace(widget,"just return XtGeometryYes.\n")); return XtGeometryYes; } else { CALLGEOTAT(_XtGeoTrace(widget, "Copy values from request to widget.\n")); /* copy values from request to widget */ if (request->request_mode & CWX) widget->core.x = request->x; if (request->request_mode & CWY) widget->core.y = request->y; if (request->request_mode & CWWidth) widget->core.width = request->width; if (request->request_mode & CWHeight) widget->core.height = request->height; if (request->request_mode & CWBorderWidth) widget->core.border_width = request->border_width; if (!parentRealized) { CALLGEOTAT(_XtGeoTab(-1)); CALLGEOTAT(_XtGeoTrace(widget,"and return XtGeometryYes.\n")); return XtGeometryYes; } else returnCode = XtGeometryYes; } } else { /* go ask the widget's geometry manager */ CALLGEOTAT(_XtGeoTrace(widget, "Go ask the parent geometry manager.\n")); if (reply == (XtWidgetGeometry *) NULL) { returnCode = (*manager)(widget, request, &junk); } else { returnCode = (*manager)(widget, request, reply); } } /* * If Unrealized, not a XtGeometryYes, or a query-only then we are done. */ if ((returnCode != XtGeometryYes) || (req.changeMask & XtCWQueryOnly) || !XtIsRealized(widget)) { #ifdef XT_GEO_TATTLER switch(returnCode) { case XtGeometryNo: CALLGEOTAT(_XtGeoTab(-1)); CALLGEOTAT(_XtGeoTrace(widget,"\"%s\" returns XtGeometryNo.\n", (XtParent(widget))?XtName(XtParent(widget)):"Root")); /* check for no change */ break ; case XtGeometryDone: CALLGEOTAT(_XtGeoTab(-1)); CALLGEOTAT(_XtGeoTrace(widget,"\"%s\" returns XtGeometryDone.\n", (XtParent(widget))?XtName(XtParent(widget)):"Root")); /* check for no change in queryonly */ break ; case XtGeometryAlmost: CALLGEOTAT(_XtGeoTab(-1)); CALLGEOTAT(_XtGeoTrace(widget,"\"%s\" returns XtGeometryAlmost.\n", (XtParent(widget))?XtName(XtParent(widget)):"Root")); CALLGEOTAT(_XtGeoTab(1)); CALLGEOTAT(_XtGeoTrace(widget,"Proposal: width %d height %d.\n", (reply)?reply->width:junk.width, (reply)?reply->height:junk.height)); CALLGEOTAT(_XtGeoTab(-1)); /* check for no change */ break ; case XtGeometryYes: if (req.changeMask & XtCWQueryOnly) { CALLGEOTAT(_XtGeoTrace(widget, "QueryOnly specified, no configuration.\n")); } if (!XtIsRealized(widget)) { CALLGEOTAT(_XtGeoTrace(widget, "\"%s\" not realized, no configuration.\n", XtName(widget))); } CALLGEOTAT(_XtGeoTab(-1)); CALLGEOTAT(_XtGeoTrace(widget,"\"%s\" returns XtGeometryYes.\n", (XtParent(widget))?XtName(XtParent(widget)):"Root")); break ; } #endif return returnCode; } CALLGEOTAT(_XtGeoTab(-1)); CALLGEOTAT(_XtGeoTrace(widget,"\"%s\" returns XtGeometryYes.\n", (XtParent(widget))?XtName(XtParent(widget)):"Root")); if (XtIsWidget(widget)) { /* reconfigure the window (if needed) */ if (rgm) return returnCode; if (req.changes.x != widget->core.x) { req.changeMask |= CWX; req.changes.x = widget->core.x; CALLGEOTAT(_XtGeoTrace(widget, "x changing to %d\n",widget->core.x)); } if (req.changes.y != widget->core.y) { req.changeMask |= CWY; req.changes.y = widget->core.y; CALLGEOTAT(_XtGeoTrace(widget, "y changing to %d\n",widget->core.y)); } if (req.changes.width != widget->core.width) { req.changeMask |= CWWidth; req.changes.width = widget->core.width; CALLGEOTAT(_XtGeoTrace(widget, "width changing to %d\n",widget->core.width)); } if (req.changes.height != widget->core.height) { req.changeMask |= CWHeight; req.changes.height = widget->core.height; CALLGEOTAT(_XtGeoTrace(widget, "height changing to %d\n",widget->core.height)); } if (req.changes.border_width != widget->core.border_width) { req.changeMask |= CWBorderWidth; req.changes.border_width = widget->core.border_width; CALLGEOTAT(_XtGeoTrace(widget, "border_width changing to %d\n", widget->core.border_width)); } if (req.changeMask & CWStackMode) { req.changes.stack_mode = request->stack_mode; CALLGEOTAT(_XtGeoTrace(widget,"stack_mode changing\n")); if (req.changeMask & CWSibling) { if (XtIsWidget(request->sibling)) req.changes.sibling = XtWindow(request->sibling); else req.changeMask &= ~(CWStackMode | CWSibling); } } #ifdef XT_GEO_TATTLER if (req.changeMask) { CALLGEOTAT(_XtGeoTrace(widget, "XConfigure \"%s\"'s window.\n", XtName(widget))); } else { CALLGEOTAT(_XtGeoTrace(widget, "No window configuration needed for \"%s\".\n", XtName(widget))); } #endif XConfigureWindow(XtDisplay(widget), XtWindow(widget), req.changeMask, &req.changes); } else { /* RectObj child of realized Widget */ *clear_rect_obj = TRUE; CALLGEOTAT(_XtGeoTrace(widget, "ClearRectObj on \"%s\".\n",XtName(widget))); ClearRectObjAreas((RectObj)widget, &req.changes); } hookobj = XtHooksOfDisplay(XtDisplayOfObject(widget));; if (XtHasCallbacks(hookobj, XtNconfigureHook) == XtCallbackHasSome) { req.type = XtHconfigure; req.widget = widget; XtCallCallbackList(hookobj, ((HookObject)hookobj)->hooks.confighook_callbacks, (XtPointer)&req); } return returnCode; } /* _XtMakeGeometryRequest */
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 */
Window XtWindowOfObject( Widget object) { return XtWindow(XtIsWidget(object) ? object : _XtWindowedAncestor(object)); }
void sizeSelectTypeCb( Widget w, XtPointer client_data, XtPointer call_data) { Widget option_menu = sizeSelectOptionMenu; /* for testing option menu */ int numChildren; Widget button, *children; int xpos, ypos; WlzUInt height, width, borderWidth, depth; Dimension gHeight, thickness; Pixmap pixmap; Window root; Status status; XmFontList fl; XFontStruct *font; /* some code here to pick apart the option menu */ if((button = XtNameToWidget(option_menu, "*xmCascadeButtonGadget"))){ fprintf(stderr, "CascadeButtonGadget found\n"); } if((button = XtNameToWidget(option_menu, "*xmCascadeButton"))){ fprintf(stderr, "CascadeButton found\n"); } XtVaGetValues(option_menu, XmNnumChildren, &numChildren, XmNchildren, &children, XmNmarginHeight, &gHeight, NULL); fprintf(stderr, "option_menu: %d children\n", numChildren); fprintf(stderr, "option_menu: marginHeight: %d\n", gHeight); fprintf(stderr, "child[0]: %s\n", XtName(children[0])); fprintf(stderr, "child[1]: %s\n", XtName(children[1])); fprintf(stderr, "OptionButton is %s\n", XtIsWidget(children[1])? "Widget":"Gadget"); if( XtClass(children[1]) == xmCascadeButtonGadgetClass ){ fprintf(stderr, "CascadeButtonGadget found\n"); } XtVaGetValues(children[1], XmNheight, &gHeight, XmNlabelPixmap, &pixmap, XmNfontList, &fl, XmNshadowThickness, &thickness, NULL); fprintf(stderr, "OptionButton: height: %d\n", gHeight); fprintf(stderr, "OptionButton: cascadePixmap: Ox%x\n", (unsigned int) pixmap); if( fl ){ XmeRenderTableGetDefaultFont(fl, &font); /* _XmFontListGetDefaultFont(fl, &font);*/ fprintf(stderr, "font hieghts: %d, %d\n", font->ascent, font->descent); } fprintf(stderr, "OptionButton: shadowThickness: %d\n", thickness); switch(status = XGetGeometry(globals.dpy, pixmap, &root, &xpos, &ypos, &width, &height, &borderWidth, &depth)){ case BadDrawable: fprintf(stderr, "returns BadDrawable\n"); break; case BadWindow: fprintf(stderr, "returns BadWindow\n"); break; default: fprintf(stderr, "returns %d\n", status); break; } fprintf(stderr, "OptionButton pixmap: %d, %d, %d, %d, %d, %d\n", xpos, ypos, width, height, borderWidth, depth); XtVaSetValues(children[0], XmNheight, 20, NULL); XtVaSetValues(children[1], XmNheight, 20, NULL); XtVaSetValues(option_menu, XmNheight, 26, NULL); return; }
static void RealizeWidget( Widget widget) { XtValueMask value_mask; XSetWindowAttributes values; XtRealizeProc realize; Window window; Display* display; String class_name; Widget hookobj; if (!XtIsWidget(widget) || XtIsRealized(widget)) return; display = XtDisplay(widget); _XtInstallTranslations(widget); ComputeWindowAttributes (widget, &value_mask, &values); LOCK_PROCESS; realize = widget->core.widget_class->core_class.realize; class_name = widget->core.widget_class->core_class.class_name; UNLOCK_PROCESS; if (realize == NULL) XtAppErrorMsg(XtWidgetToApplicationContext(widget), "invalidProcedure","realizeProc",XtCXtToolkitError, "No realize class procedure defined", (String *)NULL, (Cardinal *)NULL); else { CALLGEOTAT(_XtGeoTrace(widget,"Call \"%s\"[%d,%d]'s realize proc\n", XtName(widget), widget->core.width, widget->core.height)); (*realize) (widget, &value_mask, &values); } window = XtWindow(widget); hookobj = XtHooksOfDisplay(XtDisplayOfObject(widget)); if (XtHasCallbacks(hookobj,XtNchangeHook) == XtCallbackHasSome) { XtChangeHookDataRec call_data; call_data.type = XtHrealizeWidget; call_data.widget = widget; XtCallCallbackList(hookobj, ((HookObject)hookobj)->hooks.changehook_callbacks, (XtPointer)&call_data); } #ifndef NO_IDENTIFY_WINDOWS if (_XtGetPerDisplay(display)->appContext->identify_windows) { int len_nm, len_cl; char *s; len_nm = widget->core.name ? strlen(widget->core.name) : 0; len_cl = strlen(class_name); s = __XtMalloc((unsigned) (len_nm + len_cl + 2)); s[0] = '\0'; if (len_nm) strcpy(s, widget->core.name); strcpy(s + len_nm + 1, class_name); XChangeProperty(display, window, XInternAtom(display, "_MIT_OBJ_CLASS", False), XA_STRING, 8, PropModeReplace, (unsigned char *) s, len_nm + len_cl + 2); XtFree(s); } #endif #ifdef notdef _XtRegisterAsyncHandlers(widget); #endif /* (re)register any grabs extant in the translations */ _XtRegisterGrabs(widget); /* reregister any grabs added with XtGrab{Button,Key} */ _XtRegisterPassiveGrabs(widget); XtRegisterDrawable (display, window, widget); _XtExtensionSelect(widget); if (XtIsComposite (widget)) { Cardinal i; CompositePart *cwp = &(((CompositeWidget)widget)->composite); WidgetList children = cwp->children; /* Realize all children */ for (i = cwp->num_children; i != 0; --i) { RealizeWidget (children[i-1]); } /* Map children that are managed and mapped_when_managed */ if (cwp->num_children != 0) { if (ShouldMapAllChildren(cwp)) { XMapSubwindows (display, window); } else { MapChildren(cwp); } } } /* If this is the application's popup shell, map it */ if (widget->core.parent == NULL && widget->core.mapped_when_managed) { XtMapWidget (widget); } } /* RealizeWidget */