Ejemplo n.º 1
0
void _XtPopup(
    Widget      widget,
    XtGrabKind  grab_kind,
    _XtBoolean  spring_loaded)
{
    register ShellWidget shell_widget = (ShellWidget) widget;

    if (! XtIsShell(widget)) {
	XtAppErrorMsg(XtWidgetToApplicationContext(widget),
		"invalidClass","xtPopup",XtCXtToolkitError,
                "XtPopup requires a subclass of shellWidgetClass",
                  (String *)NULL, (Cardinal *)NULL);
    }

    if (! shell_widget->shell.popped_up) {
	XtGrabKind call_data = grab_kind;
	XtCallCallbacks(widget, XtNpopupCallback, (XtPointer)&call_data);
	shell_widget->shell.popped_up = TRUE;
	shell_widget->shell.grab_kind = grab_kind;
	shell_widget->shell.spring_loaded = spring_loaded;
	if (shell_widget->shell.create_popup_child_proc != NULL) {
	    (*(shell_widget->shell.create_popup_child_proc))(widget);
	}
	if (grab_kind == XtGrabExclusive) {
	    XtAddGrab(widget, TRUE, spring_loaded);
	} else if (grab_kind == XtGrabNonexclusive) {
	    XtAddGrab(widget, FALSE, spring_loaded);
	}
	XtRealizeWidget(widget);
	XMapRaised(XtDisplay(widget), XtWindow(widget));
    } else
	XRaiseWindow(XtDisplay(widget), XtWindow(widget));

} /* _XtPopup */
Ejemplo n.º 2
0
Boolean CvtStringToWidget(Display *display, 
			  XrmValue *args, Cardinal *num_args, 
			  XrmValue *fromVal, XrmValue *toVal,
			  XtPointer *)
{
    // Convert first arg into parent    
    if (*num_args != 1) 
    {
	XtAppErrorMsg(XtDisplayToApplicationContext(display),
	    "wrongParameters", "CvtStringToWidget",
	    "XtToolkitError",
	    "String to Widget conversion needs parent arg",
	    (String *)0, (Cardinal *)0);
    }
    Widget parent = *(Widget *) args[0].addr;

    // Get widget
    const string value = str(fromVal, false);
    Widget w = XtNameToWidget(parent, value.chars());
    if (w == 0)
    {
	XtDisplayStringConversionWarning(display, fromVal->addr, XtRWidget);
	return False;
    }

    done(Widget, w);
}
Ejemplo n.º 3
0
void XtCreateWindow(
    Widget		 widget,
    unsigned int	 window_class,
    Visual		 *visual,
    XtValueMask		 value_mask,
    XSetWindowAttributes *attributes)
{
    XtAppContext app = XtWidgetToApplicationContext(widget);

    LOCK_APP(app);
    if (widget->core.window == None) {
        if (widget->core.width == 0 || widget->core.height == 0) {
            Cardinal count = 1;
            XtAppErrorMsg(app,
                          "invalidDimension", "xtCreateWindow", XtCXtToolkitError,
                          "Widget %s has zero width and/or height",
                          &widget->core.name, &count);
        }
        widget->core.window =
            XCreateWindow (
                XtDisplay (widget),
                (widget->core.parent ?
                 widget->core.parent->core.window :
                 widget->core.screen->root),
                (int)widget->core.x, (int)widget->core.y,
                (unsigned)widget->core.width, (unsigned)widget->core.height,
                (unsigned)widget->core.border_width, (int) widget->core.depth,
                window_class, visual, value_mask, attributes);
    }
    UNLOCK_APP(app);
} /* XtCreateWindow */
Ejemplo n.º 4
0
Archivo: Logo.c Proyecto: aosm/X11
static void
XmuFreeXftColor (XtAppContext app, XrmValuePtr toVal, XtPointer closure,
		 XrmValuePtr args, Cardinal *num_args)
{
    Screen	*screen;
    Colormap	colormap;
    XftColor	*color;
    
    if (*num_args != 2)
    {
	XtAppErrorMsg (app,
		       "freeXftColor", "wrongParameters",
		       "XtToolkitError",
		       "Freeing an XftColor requires screen and colormap arguments",
		       (String *) NULL, (Cardinal *)NULL);
	return;
    }

    screen = *((Screen **) args[0].addr);
    colormap = *((Colormap *) args[1].addr);
    color = (XftColor *) toVal->addr;
    XftColorFree (DisplayOfScreen (screen),
		  DefaultVisual (DisplayOfScreen (screen),
				 XScreenNumberOfScreen (screen)),
		  colormap, color);
}
Ejemplo n.º 5
0
Archivo: Logo.c Proyecto: aosm/X11
static Boolean
XmuCvtStringToXftColor(Display *dpy,
		       XrmValue *args, Cardinal *num_args,
		       XrmValue *fromVal, XrmValue *toVal,
		       XtPointer *converter_data)
{
    char	    *spec;
    XRenderColor    renderColor;
    XftColor	    xftColor;
    Screen	    *screen;
    Colormap	    colormap;
    
    if (*num_args != 2)
    {
	XtAppErrorMsg (XtDisplayToApplicationContext (dpy),
		       "cvtStringToXftColor", "wrongParameters",
		       "XtToolkitError",
		       "String to render color conversion needs screen and colormap arguments",
		       (String *) NULL, (Cardinal *)NULL);
	return False;
    }

    screen = *((Screen **) args[0].addr);
    colormap = *((Colormap *) args[1].addr);

    spec = (char *) fromVal->addr;
    if (strcasecmp (spec, XtDefaultForeground) == 0)
    {
	renderColor.red = 0;
	renderColor.green = 0;
	renderColor.blue = 0;
	renderColor.alpha = 0xffff;
    }
    else if (strcasecmp (spec, XtDefaultBackground) == 0)
    {
	renderColor.red = 0xffff;
	renderColor.green = 0xffff;
	renderColor.blue = 0xffff;
	renderColor.alpha = 0xffff;
    }
    else if (!XRenderParseColor (dpy, spec, &renderColor))
	return False;
    if (!XftColorAllocValue (dpy, 
			     DefaultVisual (dpy,
					    XScreenNumberOfScreen (screen)),
			     colormap,
			     &renderColor,
			     &xftColor))
	return False;
    
    donestr (XftColor, xftColor, XtRXftColor);
}
Ejemplo n.º 6
0
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 */
Ejemplo n.º 7
0
Boolean
neXtawcvtStringToTilePixmap(
			       Display *display,
			       XrmValue * args,
			       Cardinal *num_args,
			       XrmValuePtr from,
			       XrmValuePtr to,
			       XtPointer *converter_data)
{
    String file = (String) from->addr;
    XpmAttributes attr;
    Pixmap pixmap, mask;
    Window win;

    if (*num_args != 2)
	XtAppErrorMsg(XtDisplayToApplicationContext(display),
		      "cvtStringToTilePixmap", "wrongParameters",
		      "XtToolkitError",
		      "String to TilePixmap conversion needs screen and colormap arguments",
		      (String *) NULL, (Cardinal *) NULL);
    win = RootWindow(display,
		     XScreenNumberOfScreen(*((Screen **) args[0].addr)));
    attr.colormap = *((Colormap *) args[1].addr);
    attr.valuemask = XpmSize | XpmReturnPixels | XpmColormap;
    if (XpmReadFileToPixmap(display, win, file, &pixmap, &mask,
			    &attr) != XpmSuccess) {
	XtDisplayStringConversionWarning(display, file, XtRTilePixmap);
	return False;
    }
    if (mask != None)
	XFreePixmap(display, mask);
    if (to->addr != NULL) {
	if (to->size < sizeof(Pixmap)) {
	    to->size = sizeof(Pixmap);
	    XtDisplayStringConversionWarning(display, file, XtRTilePixmap);
	    return False;
	}
	*(Pixmap *) (to->addr) = pixmap;
    } else {
	static Pixmap s_pixmap;

	s_pixmap = pixmap;
	to->addr = (XtPointer) &s_pixmap;
    }
    to->size = sizeof(Pixmap);
    return True;
}
Ejemplo n.º 8
0
void XtPopdown(
    Widget  widget)
{
    /* Unmap a shell widget if it is mapped, and remove from grab list */
    Widget hookobj;
    ShellWidget shell_widget = (ShellWidget) widget;
    XtGrabKind grab_kind;

    if (! XtIsShell(widget)) {
	XtAppErrorMsg(XtWidgetToApplicationContext(widget),
		"invalidClass","xtPopdown",XtCXtToolkitError,
            "XtPopdown requires a subclass of shellWidgetClass",
              (String *)NULL, (Cardinal *)NULL);
    }

#ifndef X_NO_XT_POPDOWN_CONFORMANCE
    if (!shell_widget->shell.popped_up)
        return;
#endif

    grab_kind = shell_widget->shell.grab_kind;
    XWithdrawWindow(XtDisplay(widget), XtWindow(widget),
		    XScreenNumberOfScreen(XtScreen(widget)));
    if (grab_kind != XtGrabNone)
	XtRemoveGrab(widget);
    shell_widget->shell.popped_up = FALSE;
    XtCallCallbacks(widget, XtNpopdownCallback, (XtPointer)&grab_kind);

    hookobj = XtHooksOfDisplay(XtDisplay(widget));
    if (XtHasCallbacks(hookobj, XtNchangeHook) == XtCallbackHasSome) {
	XtChangeHookDataRec call_data;

	call_data.type = XtHpopdown;
	call_data.widget = widget;
	XtCallCallbackList(hookobj,
		((HookObject)hookobj)->hooks.changehook_callbacks,
		(XtPointer)&call_data);
    }
} /* XtPopdown */
Ejemplo n.º 9
0
Archivo: Simple.c Proyecto: aosm/X11
/*
 * Function:
 *	ConvertCursor
 *
 * Parameters:
 *	w - simple widget
 *
 * Description:
 *	Converts a name to a new cursor.
 */
static void
ConvertCursor(Widget w)
{
    SimpleWidget simple = (SimpleWidget) w;
    XrmValue from, to;
    Cursor cursor = None;
   
    if (simple->simple.cursor_name == NULL)
	return;

    from.addr = (XPointer)simple->simple.cursor_name;
    from.size = strlen((char *)from.addr) + 1;

    to.size = sizeof(Cursor);
    to.addr = (XPointer)&cursor;

    if (XtConvertAndStore(w, XtRString, &from, XtRColorCursor, &to))
      simple->simple.cursor = cursor;
    else
	XtAppErrorMsg(XtWidgetToApplicationContext(w),
		      "convertFailed","ConvertCursor","XawError",
		      "Simple: ConvertCursor failed.",
		      NULL, NULL);
}
Ejemplo n.º 10
0
/* ARGSUSED */
static Boolean
_XawCvtStringToPixmap(Display *dpy, XrmValuePtr args, Cardinal *nargs,
                      XrmValuePtr from, XrmValuePtr to, XtPointer *data)
{
    static Pixmap pixmap;
    Window win;
    XpmAttributes attr;
    XpmColorSymbol colors[1];

    if (*nargs != 3)
	XtAppErrorMsg(XtDisplayToApplicationContext(dpy),
		"_XawCvtStringToPixmap", "wrongParameters", "XtToolkitError",
	"_XawCvtStringToPixmap needs screen, colormap, and background_pixel",
		      (String *) NULL, (Cardinal *) NULL);

    if (strcmp(from->addr, "None") == 0)
    {
	pixmap = None;
	DONE(Pixmap, &pixmap);
	return (True);
    }
    if (strcmp(from->addr, "ParentRelative") == 0)
    {
	pixmap = ParentRelative;
	DONE(Pixmap, &pixmap);
	return (True);
    }

    win = RootWindowOfScreen(*((Screen **) args[0].addr));

    attr.colormap = *((Colormap *) args[1].addr);
    attr.closeness = 32768;	/* might help on 8-bpp displays? */
    attr.valuemask = XpmColormap | XpmCloseness;

    colors[0].name = NULL;
    colors[0].value = "none";
    colors[0].pixel = *((Pixel *) args[2].addr);
    attr.colorsymbols = colors;
    attr.numsymbols = 1;
    attr.valuemask |= XpmColorSymbols;

    if (XpmReadFileToPixmap(dpy, win, (String) from->addr,
			    &pixmap, NULL, &attr) != XpmSuccess)
    {
	if ((pixmap = XmuLocateBitmapFile(*((Screen **) args[0].addr),
	      (char *)from->addr, NULL, 0, NULL, NULL, NULL, NULL)) == None)
	{
	    XtDisplayStringConversionWarning(dpy, (String) from->addr,
					     XtRPixmap);
	    return (False);
	}
    }

    if (to->addr == NULL)
	to->addr = (XtPointer) & pixmap;
    else
    {
	if (to->size < sizeof(Pixmap))
	{
	    to->size = sizeof(Pixmap);
	    XtDisplayStringConversionWarning(dpy, (String) from->addr,
					     XtRPixmap);
	    return (False);
	}

	*((Pixmap *) to->addr) = pixmap;
    }
    to->size = sizeof(Pixmap);
    return (True);
}
Ejemplo n.º 11
0
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 */
Ejemplo n.º 12
0
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 */
Ejemplo n.º 13
0
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 */
Ejemplo n.º 14
0
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 */
Ejemplo n.º 15
0
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 */