Beispiel #1
0
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);
}
Beispiel #2
0
void XtResizeWindow(
    Widget w)
{
    XtConfigureHookDataRec req;
    Widget hookobj;
    WIDGET_TO_APPCON(w);

    LOCK_APP(app);
    if (XtIsRealized(w)) {
        req.changes.width = w->core.width;
        req.changes.height = w->core.height;
        req.changes.border_width = w->core.border_width;
        req.changeMask = CWWidth | CWHeight | CWBorderWidth;
        XConfigureWindow(XtDisplay(w), XtWindow(w),
                         (unsigned) req.changeMask, &req.changes);
        hookobj = XtHooksOfDisplay(XtDisplayOfObject(w));;
        if (XtHasCallbacks(hookobj, XtNconfigureHook) == XtCallbackHasSome) {
            req.type = XtHconfigure;
            req.widget = w;
            XtCallCallbackList(hookobj,
                               ((HookObject)hookobj)->hooks.confighook_callbacks,
                               (XtPointer)&req);
        }
    }
    UNLOCK_APP(app);
} /* XtResizeWindow */
Beispiel #3
0
Widget XtNameToWidget(
    Widget root,
    _Xconst char* name)
{
    XrmName *names;
    XrmBinding *bindings;
    int len, depth, found = 10000;
    Widget result;
    WIDGET_TO_APPCON(root);

    len = strlen(name);
    if (len == 0) return NULL;

    LOCK_APP(app);
    names = (XrmName *) ALLOCATE_LOCAL((unsigned) (len+1) * sizeof(XrmName));
    bindings = (XrmBinding *)
               ALLOCATE_LOCAL((unsigned) (len+1) * sizeof(XrmBinding));
    if (names == NULL || bindings == NULL) _XtAllocError(NULL);

    XrmStringToBindingQuarkList(name, bindings, names);
    if (names[0] == NULLQUARK) {
        DEALLOCATE_LOCAL((char *) bindings);
        DEALLOCATE_LOCAL((char *) names);
        UNLOCK_APP(app);
        return NULL;
    }

    result = NameListToWidget(root, names, bindings, 0, &depth, &found);

    DEALLOCATE_LOCAL((char *) bindings);
    DEALLOCATE_LOCAL((char *) names);
    UNLOCK_APP(app);
    return result;
} /* XtNameToWidget */
Beispiel #4
0
Widget
XtVaCreateManagedWidget(
    _Xconst char* name,
    WidgetClass widget_class,
    Widget parent,
    ...)
{
    va_list		var;
    register Widget	widget;
    int			total_count, typed_count;
    WIDGET_TO_APPCON(parent);

    LOCK_APP(app);
    va_start(var,parent);
    _XtCountVaList(var, &total_count, &typed_count);
    va_end(var);

    va_start(var,parent);
    widget = _XtVaCreateWidget((String)name, widget_class, parent, var,
				total_count);
    XtManageChild(widget);
    va_end(var);
    UNLOCK_APP(app);
    return widget;
}
Beispiel #5
0
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 */
Beispiel #6
0
void XtSetSensitive(
    register Widget widget,
    _XtBoolean	    sensitive)
{
    Arg			args[1];
    register Cardinal   i;
    register WidgetList children;
    WIDGET_TO_APPCON(widget);

    LOCK_APP(app);
    if (widget->core.sensitive == sensitive) {
	UNLOCK_APP(app);
	return;
    }

    XtSetArg(args[0], XtNsensitive, sensitive);
    XtSetValues(widget, args, XtNumber(args));

    /* If widget's ancestor_sensitive is TRUE, propagate new sensitive to
       children's ancestor_sensitive; else do nothing as children's
       ancestor_sensitive is already FALSE */
    
    if (widget->core.ancestor_sensitive && XtIsComposite (widget)) {
	children = ((CompositeWidget) widget)->composite.children;
	for (i = 0; i < ((CompositeWidget)widget)->composite.num_children; i++){
	    SetAncestorSensitive (children[i], sensitive);
	}
    }
    UNLOCK_APP(app);
} /* XtSetSensitive */
Beispiel #7
0
void XtUnrealizeWidget (
    Widget		widget)
{
    Window window;
    Widget hookobj;
    WIDGET_TO_APPCON(widget);

    LOCK_APP(app);
    window = XtWindow(widget);
    if (! XtIsRealized (widget)) {
        UNLOCK_APP(app);
        return;
    }
    if (widget->core.managed && widget->core.parent != NULL)
        XtUnmanageChild(widget);
    UnrealizeWidget(widget);
    if (window != None)
        XDestroyWindow(XtDisplay(widget), window);
    hookobj = XtHooksOfDisplay(XtDisplayOfObject(widget));
    if (XtHasCallbacks(hookobj, XtNchangeHook) == XtCallbackHasSome) {
        XtChangeHookDataRec call_data;

        call_data.type = XtHunrealizeWidget;
        call_data.widget = widget;
        XtCallCallbackList(hookobj,
                           ((HookObject)hookobj)->hooks.changehook_callbacks,
                           (XtPointer)&call_data);
    }
    UNLOCK_APP(app);
} /* XtUnrealizeWidget */
Beispiel #8
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 */
Beispiel #9
0
EventMask XtBuildEventMask(
    Widget widget)
{
    XtEventTable ev;
    EventMask	mask = 0L;
    WIDGET_TO_APPCON(widget);

    LOCK_APP(app);
    for (ev = widget->core.event_table; ev != NULL; ev = ev->next)
	if (ev->select) {
	    if (!ev->has_type_specifier)
		mask |= ev->mask;
	    else {
		if (EXT_TYPE(ev) < LASTEvent) {
		    Cardinal i;
		    for (i = 0; i < ev->mask; i++)
			if (EXT_SELECT_DATA(ev, i))
			    mask |= *(EventMask*)EXT_SELECT_DATA(ev, i);
		}
	    }
	}
    LOCK_PROCESS;
    if (widget->core.widget_class->core_class.expose != NULL)
	mask |= ExposureMask;
    if (widget->core.widget_class->core_class.visible_interest)
	mask |= VisibilityChangeMask;
    UNLOCK_PROCESS;
    if (widget->core.tm.translations)
	mask |= widget->core.tm.translations->eventMask;

    mask =  mask & ~NonMaskableMask;
    UNLOCK_APP(app);
    return mask;
}
Beispiel #10
0
void XtCallCallbackList(
    Widget widget,
    XtCallbackList callbacks,
    XtPointer call_data)
{
    register InternalCallbackList icl;
    register XtCallbackList cl;
    register int i;
    char ostate;
    WIDGET_TO_APPCON(widget);

    LOCK_APP(app);
    if (!callbacks) {
	UNLOCK_APP(app);
	return;
    }
    icl = (InternalCallbackList)callbacks;
    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 = 0;
    UNLOCK_APP(app);
} /* XtCallCallbackList */
Beispiel #11
0
XtGeometryResult XtMakeGeometryRequest (
    Widget         widget,
    XtWidgetGeometry *request,
    XtWidgetGeometry *reply)
{
    Boolean junk;
    XtGeometryResult r;
    XtGeometryHookDataRec call_data;
    Widget hookobj = XtHooksOfDisplay(XtDisplayOfObject(widget));
    WIDGET_TO_APPCON(widget);

    LOCK_APP(app);
    if (XtHasCallbacks(hookobj, XtNgeometryHook) == XtCallbackHasSome) {
        call_data.type = XtHpreGeometry;
        call_data.widget = widget;
        call_data.request = request;
        XtCallCallbackList(hookobj,
                           ((HookObject)hookobj)->hooks.geometryhook_callbacks,
                           (XtPointer)&call_data);
        call_data.result = r =
                               _XtMakeGeometryRequest(widget, request, reply, &junk);
        call_data.type = XtHpostGeometry;
        call_data.reply = reply;
        XtCallCallbackList(hookobj,
                           ((HookObject)hookobj)->hooks.geometryhook_callbacks,
                           (XtPointer)&call_data);
    } else {
        r = _XtMakeGeometryRequest(widget, request, reply, &junk);
    }
    UNLOCK_APP(app);

    return ((r == XtGeometryDone) ? XtGeometryYes : r);
}
Beispiel #12
0
void XtSetMultiClickTime(
    Display *dpy,
    int time)
{
    DPY_TO_APPCON(dpy);

    LOCK_APP(app);
    _XtGetPerDisplay(dpy)->multi_click_time = time;
    UNLOCK_APP(app);
}
Beispiel #13
0
void   XtUngrabKeyboard(
    Widget	widget,
    Time	time)
{
    WIDGET_TO_APPCON(widget);

    LOCK_APP(app);
    UngrabDevice(widget, time, KEYBOARD);
    UNLOCK_APP(app);
}
Beispiel #14
0
void   XtUngrabPointer(
    Widget	widget,
    Time	time)
{
    WIDGET_TO_APPCON(widget);

    LOCK_APP(app);
    UngrabDevice(widget, time, POINTER);
    UNLOCK_APP(app);
}
Beispiel #15
0
int XtGetMultiClickTime(
    Display *dpy)
{
    int retval;
    DPY_TO_APPCON(dpy);

    LOCK_APP(app);
    retval = _XtGetPerDisplay(dpy)->multi_click_time;
    UNLOCK_APP(app);
    return retval;
}
Beispiel #16
0
void   XtUngrabButton (
    Widget	widget,
    unsigned int button,
    Modifiers	modifiers)
{
    WIDGET_TO_APPCON(widget);

    LOCK_APP(app);
    UngrabKeyOrButton(widget, (KeyCode)button, modifiers, POINTER);
    UNLOCK_APP(app);
}
Beispiel #17
0
void   XtUngrabKey (
    Widget	widget,
    _XtKeyCode	keycode,
    Modifiers	modifiers)
{
    WIDGET_TO_APPCON(widget);

    LOCK_APP(app);
    UngrabKeyOrButton(widget, (int)keycode, modifiers, KEYBOARD);
    UNLOCK_APP(app);
}
Beispiel #18
0
Boolean XtIsRealized (
    Widget   object)
{
    Boolean retval;
    WIDGET_TO_APPCON(object);

    LOCK_APP(app);
    retval = XtWindowOfObject(object) != None;
    UNLOCK_APP(app);
    return retval;
} /* XtIsRealized */
Beispiel #19
0
XtGeometryResult
XtMakeResizeRequest(
    Widget	widget,
    _XtDimension width,
    _XtDimension height,
    Dimension	*replyWidth,
    Dimension	*replyHeight)
{
    XtWidgetGeometry request, reply;
    XtGeometryResult r;
    XtGeometryHookDataRec call_data;
    Boolean junk;
    Widget hookobj = XtHooksOfDisplay(XtDisplayOfObject(widget));
    WIDGET_TO_APPCON(widget);

    LOCK_APP(app);
    request.request_mode = CWWidth | CWHeight;
    request.width = width;
    request.height = height;

    if (XtHasCallbacks(hookobj, XtNgeometryHook) == XtCallbackHasSome) {
        call_data.type = XtHpreGeometry;
        call_data.widget = widget;
        call_data.request = &request;
        XtCallCallbackList(hookobj,
                           ((HookObject)hookobj)->hooks.geometryhook_callbacks,
                           (XtPointer)&call_data);
        call_data.result = r =
                               _XtMakeGeometryRequest(widget, &request, &reply, &junk);
        call_data.type = XtHpostGeometry;
        call_data.reply = &reply;
        XtCallCallbackList(hookobj,
                           ((HookObject)hookobj)->hooks.geometryhook_callbacks,
                           (XtPointer)&call_data);
    } else {
        r = _XtMakeGeometryRequest(widget, &request, &reply, &junk);
    }
    if (replyWidth != NULL) {
        if (r == XtGeometryAlmost && reply.request_mode & CWWidth)
            *replyWidth = reply.width;
        else
            *replyWidth = width;
    }
    if (replyHeight != NULL) {
        if (r == XtGeometryAlmost && reply.request_mode & CWHeight)
            *replyHeight = reply.height;
        else
            *replyHeight = height;
    }
    UNLOCK_APP(app);
    return ((r == XtGeometryDone) ? XtGeometryYes : r);
} /* XtMakeResizeRequest */
Beispiel #20
0
void XtRemoveEventTypeHandler(
    Widget	    widget,
    int		    type,
    XtPointer	    select_data,
    XtEventHandler  proc,
    XtPointer	    closure)
{
    WIDGET_TO_APPCON(widget);
    LOCK_APP(app);
    RemoveEventHandler(widget, select_data, type, TRUE,
		       FALSE, proc, closure, FALSE);
    UNLOCK_APP(app);
}
Beispiel #21
0
void XtAddRawEventHandler(
    Widget	    widget,
    EventMask       eventMask,
    _XtBoolean      other,
    XtEventHandler  proc,
    XtPointer	    closure)
{
    WIDGET_TO_APPCON(widget);
    LOCK_APP(app);
    AddEventHandler(widget, (XtPointer) &eventMask, 0, FALSE, other,
		    proc, closure, XtListTail, FALSE, TRUE);
    UNLOCK_APP(app);
}
Beispiel #22
0
void XtRemoveEventHandler(
    Widget	    widget,
    EventMask       eventMask,
    _XtBoolean	    other,
    XtEventHandler  proc,
    XtPointer	    closure)
{
    WIDGET_TO_APPCON(widget);
    LOCK_APP(app);
    RemoveEventHandler(widget, (XtPointer) &eventMask, 0, FALSE,
		       other, proc, closure, FALSE);
    UNLOCK_APP(app);
}
Beispiel #23
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 */
Beispiel #24
0
void XtInsertEventTypeHandler(
    Widget	    widget,
    int		    type,
    XtPointer	    select_data,
    XtEventHandler  proc,
    XtPointer	    closure,
    XtListPosition  position)
{
    WIDGET_TO_APPCON(widget);
    LOCK_APP(app);
    AddEventHandler(widget, select_data, type, TRUE, FALSE,
		    proc, closure, position, TRUE, FALSE);
    UNLOCK_APP(app);
}
Beispiel #25
0
void XtInsertEventHandler(
    Widget	    widget,
    EventMask       eventMask,
    _XtBoolean      other,
    XtEventHandler  proc,
    XtPointer	    closure,
    XtListPosition  position)
{
    WIDGET_TO_APPCON(widget);
    LOCK_APP(app);
    AddEventHandler(widget, (XtPointer) &eventMask, 0, FALSE, other,
		    proc, closure, position, TRUE, FALSE);
    UNLOCK_APP(app);
}
Beispiel #26
0
void XtRealizeWidget (
    Widget		widget)
{
    WIDGET_TO_APPCON(widget);

    LOCK_APP(app);
    if (XtIsRealized (widget)) {
        UNLOCK_APP(app);
        return;
    }
    CallChangeManaged(widget);
    RealizeWidget(widget);
    UNLOCK_APP(app);
} /* XtRealizeWidget */
Beispiel #27
0
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;
}
Beispiel #28
0
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;
}
Beispiel #29
0
XrmDatabase *XtAppGetErrorDatabase(
	XtAppContext app)
{
    XrmDatabase* retval;
#if GLOBALERRORS
    LOCK_PROCESS;
    retval = &errorDB;
    UNLOCK_PROCESS;
#else
    LOCK_APP(app);
    retval= &app->errorDB;
    UNLOCK_APP(app);
#endif /* GLOBALERRORS */
    return retval;
}
Beispiel #30
0
Widget XtHooksOfDisplay(
    Display* dpy)
{
    Widget retval;
    XtPerDisplay pd;
    DPY_TO_APPCON(dpy);

    LOCK_APP(app);
    pd = _XtGetPerDisplay(dpy);
    if (pd->hook_object == NULL)
	pd->hook_object =
	    _XtCreateHookObj((Screen*)DefaultScreenOfDisplay(dpy));
    retval = pd->hook_object;
    UNLOCK_APP(app);
    return retval;
}