/************************************************************************ * * DisplayDeleteChild * ************************************************************************/ static void DisplayDeleteChild( Widget w ) { if (XtIsRectObj(w)) { XtWidgetProc delete_child; _XmProcessLock(); delete_child = ((CompositeWidgetClass)compositeWidgetClass) ->composite_class.delete_child; _XmProcessUnlock(); (*delete_child)(w); } }
Boolean XtIsSensitive( Widget object) { Boolean retval; WIDGET_TO_APPCON(object); LOCK_APP(app); if (XtIsRectObj(object)) retval = object->core.sensitive && object->core.ancestor_sensitive; else retval = False; UNLOCK_APP(app); return retval; }
/************************************************************************ * * DisplayInsertChild * ************************************************************************/ static void DisplayInsertChild( Widget w ) { if (XtIsRectObj(w)) { XtWidgetProc insert_child; _XmProcessLock(); insert_child = ((CompositeWidgetClass)compositeWidgetClass) ->composite_class.insert_child; _XmProcessUnlock(); (*insert_child)(w); } }
Boolean XtIsManaged( Widget object) { Boolean retval; WIDGET_TO_APPCON(object); LOCK_APP(app); if (XtIsRectObj(object)) retval = object->core.managed; else retval = False; UNLOCK_APP(app); return retval; }
static Widget GetRectObjKid( CompositeWidget p ) { Cardinal i; Widget *currKid; for (i = 0, currKid = p->composite.children; i < p->composite.num_children; i++, currKid++) { if ((XtIsRectObj( *currKid) /* The Input Method child is a CoreClass object; ignore it. */ && ((*currKid)->core.widget_class != coreWidgetClass)) || XmeTraitGet((XtPointer) XtClass(*currKid), XmQTdialogShellSavvy)) { return (*currKid); } } return NULL; }
static void InsertChild( Widget w ) { CompositeWidget p = (CompositeWidget) XtParent (w); XtWidgetProc insert_child; /* * Make sure we only have a rectObj, a VendorObject, and * maybe an Input Method (CoreClass) object as children. */ if (!XtIsRectObj(w)) return; else { if( (w->core.widget_class != coreWidgetClass) /* The Input Method child is a CoreClass object. */ && GetRectObjKid( p) ) { /* we need _XmError() too! */ XtError(MSG1); } else { /* * make sure we're realized so people won't core dump when * doing incorrect managing prior to realize */ XtRealizeWidget((Widget) p); } } _XmProcessLock(); insert_child = ((CompositeWidgetClass) compositeWidgetClass) ->composite_class.insert_child; _XmProcessUnlock(); (*insert_child)(w); return ; }
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 */
/************************************************************************ * * * InsertChild * * * ************************************************************************/ static void InsertChild( Widget w ) { CompositeWidgetClass superclass = (CompositeWidgetClass) xmMainWindowClassRec.core_class.superclass ; XmMainWindowWidget mw = (XmMainWindowWidget ) w->core.parent; XmScrolledWindowConstraint nc = GetSWConstraint(w); XtWidgetProc insert_child; if (!XtIsRectObj(w)) return; /* Try to guess the nature of the child_type . If we're lucky, fine, otherwise, something bad might happens: the scrolledwindow can take it as a workwindow and possibly reparents it to the clipwindow. In the absence of a set childType constraint resource set, there is not much we can do to avoid the problem */ /* Note: auto created Separator were already labelled in Initialize */ if (nc->child_type == (unsigned char) RESOURCE_DEFAULT) { XmMenuSystemTrait menuSTrait; if ((menuSTrait = (XmMenuSystemTrait) XmeTraitGet ((XtPointer) XtClass(w), XmQTmenuSystem)) != NULL) { if (menuSTrait->type(w) == XmMENU_BAR && !mw->mwindow.MenuBar) { /* If it's a menubar, and we don't have one yet, use it. */ nc->child_type = XmMENU_BAR ; } } else if (XmIsCommandBox(w)) { if (!mw->mwindow.CommandWindow) { /* If it's a command, and we don't have one, get it */ nc->child_type = XmCOMMAND_WINDOW ; } } else /* new in 2.0 */ if (XmIsMessageBox(w)) { if (!mw->mwindow.Message) { nc->child_type = XmMESSAGE_WINDOW ; } } } if (nc->child_type == XmMENU_BAR) { mw->mwindow.MenuBar = w; } else if (nc->child_type == XmCOMMAND_WINDOW) { mw->mwindow.CommandWindow = w; } else if (nc->child_type == XmMESSAGE_WINDOW) { mw->mwindow.Message = w; } /* call ScrolledWindow InsertChild directly, since it does nothing to the MainWindow known childType */ _XmProcessLock(); insert_child = superclass->composite_class.insert_child; _XmProcessUnlock(); (*insert_child)(w); }