DataMuseum.dkPresents historical artifacts from the history of: Rational R1000/400 Tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about Rational R1000/400 Tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - downloadIndex: ┃ C T c ┃
Length: 18309 (0x4785) Types: TextFile Names: »C0_FACE_C«, »c0_face.c«
└─⟦149519bd4⟧ Bits:30000546 8mm tape, Rational 1000, !projects 93-07-13 └─ ⟦124ff5788⟧ »DATA« └─⟦this⟧ └─⟦a7d1ea751⟧ Bits:30000550 8mm tape, Rational 1000, !users!projects 94_04_11 └─ ⟦129cab021⟧ »DATA« └─⟦this⟧ └─⟦f64eaa120⟧ Bits:30000752 8mm tape, Rational 1000, !projects 93 02 16 └─ ⟦6f12a12be⟧ »DATA« └─⟦this⟧ └─⟦2f6cfab89⟧ Bits:30000547 8mm tape, Rational 1000, !projects 94-01-04 └─ ⟦d65440be7⟧ »DATA« └─⟦this⟧ └─⟦149519bd4⟧ Bits:30000546 8mm tape, Rational 1000, !projects 93-07-13 └─ ⟦124ff5788⟧ »DATA« └─⟦f2882457c⟧ └─⟦a7d1ea751⟧ Bits:30000550 8mm tape, Rational 1000, !users!projects 94_04_11 └─ ⟦129cab021⟧ »DATA« └─⟦f2882457c⟧ └─⟦f64eaa120⟧ Bits:30000752 8mm tape, Rational 1000, !projects 93 02 16 └─ ⟦6f12a12be⟧ »DATA« └─⟦f2882457c⟧ └─⟦2f6cfab89⟧ Bits:30000547 8mm tape, Rational 1000, !projects 94-01-04 └─ ⟦d65440be7⟧ »DATA« └─⟦f2882457c⟧ └─ ⟦this⟧ »C/c0_face.c«
static char rcsid_c0_face_c[] = "$Id: c0_face.c,v 1.3 91/04/09 19:10:06 ed Exp $"; /****************************************************************************** ******************************************************************************* * * (c) Copyright 1990, Non Standard Logics S.A. * ALL RIGHTS RESERVED * * THIS SOFTWARE IS FURNISHED UNDER A LICENSE AND MAY BE USED * AND COPIED ONLY IN ACCORDANCE WITH THE TERMS OF SUCH LICENSE AND * WITH THE INCLUSION OF THE ABOVE COPYRIGHT NOTICE. THIS SOFTWARE OR * ANY OTHER COPIES THEREOF MAY NOT BE PROVIDED OR OTHERWISE MADE * AVAILABLE TO ANY OTHER PERSON. NO TITLE TO AND OWNERSHIP OF THE * SOFTWARE IS HEREBY TRANSFERRED. * * THE INFORMATION IN THIS SOFTWARE IS SUBJECT TO CHANGE WITHOUT * NOTICE AND SHOULD NOT BE CONSTRUED AS A COMMITMENT BY * Non Standard Logics S.A. OR ITS THIRD PARTY SUPPLIERS. * * Non Standard Logics S.A. AND ITS THIRD PARTY SUPPLIERS, * ASSUME NO RESPONSIBILITY FOR THE USE OR INABILITY TO USE ANY OF ITS * SOFTWARE . Non Standard Logics S.A SOFTWARE IS PROVIDED "AS IS" * WITHOUT WARRANTY OF ANY KIND, AND OSF EXPRESSLY DISCLAIMS ALL * IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. * * (c) Copyright 1990, Non Standard Logics S.A. Unpublished - all * rights reserved under the Copyright laws of France * * Non Standard Logics S.A. * 57-59 rue Lhomond, * 75005 Paris. * France. * * XFaceMaker is a registered trademark of Non Standard Logics S.A. * ******************************************************************************* ******************************************************************************/ #include <X11/IntrinsicP.h> #include <X11/CompositeP.h> #include <X11/StringDefs.h> #include <X11/Quarks.h> #ifdef MOTIF_1_1 #include <Xm/XmP.h> #endif MOTIF_1_1 #include <Xm/Text.h> #undef XtDisplay #undef XtScreen #undef XtWindow #undef XtClass #undef XtSuperClass #undef XtIsManaged #undef XtIsRealized #undef XtIsSensitive /* Public data structures and declarations for the FACE language. */ #ifndef XtRNone #define XtRNone "None" #endif #ifndef XtRAny #define XtRAny "Any" #endif #ifndef XtRFloat #define XtRFloat "Float" #endif #ifndef XtRWidget #define XtRWidget "Widget" #endif #ifndef XtRWindow #define XtRWindow "Window" #endif #ifndef XtRImage #define XtRImage "Image" #endif extern XrmQuark XtQNone; extern XrmQuark XtQAny; extern XrmQuark XtQFloat; extern XrmQuark XtQWidget; extern XrmQuark XtQCallback; typedef struct { int value; int type; } FaceVariable; typedef struct { char *class_name; XrmQuark qclass_name; XtResource *sub_resources; Cardinal num_sub_resources; } SubResourceList; extern Widget FaceGetWidget(); extern XtArgVal FaceGetResource(); extern int FaceSetResource(); extern int FaceGetProperty(); extern int FaceSetProperty(); #define CB_TOPLEVEL -1 #define CB_ROOT -2 XrmQuark XtQAny; XrmQuark XtQNone; XrmQuark XtQFloat; XrmQuark XtQWidget; static void FaceError(mess, a1, a2, a3) char *mess, *a1, *a2, *a3; { char tmp[1024]; sprintf(tmp, mess, a1, a2, a3); XtError(tmp); } static void FaceWarning(mess, a1, a2, a3) char *mess, *a1, *a2, *a3; { char tmp[1024]; sprintf(tmp, mess, a1, a2, a3); XtWarning(tmp); } /* Finds the first ancestor of a Widget which has a corresponding * Fm object: skip MenuShells, for instance. * * ARGLL ! This function calls an Fm function ! */ static Widget FaceParent(w) Widget w; { Widget parent = XtParent(w); if(parent && FmMustSkip(parent)) parent = XtParent(parent); return(parent); } /* Like XtNameToWidget, but skip non-objects (MenuShells). * This code is stolen from Intrinsic.c. */ static Widget NameListToWidget(root, names) register Widget root; XrmNameList names; { register Cardinal i; register WidgetList children; register XrmName name; name = *names; if (name == NULLQUARK) return root; if (XtIsComposite(root)) { children = ((CompositeWidget) root)->composite.children; for (i = 0; i < ((CompositeWidget) root)->composite.num_children; i++) { if (name == children[i]->core.xrm_name) return NameListToWidget(children[i], &names[1]); /* CODE AJOUTE pour sauter les MenuShells. */ if(FmMustSkip(children[i])){ Widget found = NameListToWidget(children[i], &names[0]); if(found) return(found); } } } children = root->core.popup_list; for (i = 0; i < root->core.num_popups; i++) { if (name == children[i]->core.xrm_name) return NameListToWidget(children[i], &names[1]); /* CODE AJOUTE pour sauter les MenuShells. */ if(FmMustSkip(children[i])){ Widget found = NameListToWidget(children[i], &names[0]); if(found) return(found); } } return NULL; } /* NameListToWidget */ static Widget FaceNameToWidget(root, name) Widget root; String name; { XrmName names[100]; XrmStringToNameList(name, names); if (names[0] == NULLQUARK) return NULL; return NameListToWidget(root, names); } /* XtNameToWidget */ Widget FaceGetWidget(ref, level, names) Widget ref; int level; char *names; { Widget w, parent; if(ref == 0){ FaceError("Null reference widget"); return(0); } /* * On cherche le widget de reference : * - pour TOPLEVEL, on cherche le dernier shell avant la racine, * - pour ROOT, on cherche le dernier ancetre, i.e. celui qui * n'a pas de parent, * - sinon, on remonte de 'level' niveaux dans la hierarchie. */ if(level == CB_TOPLEVEL){ Widget shell; while(parent = FaceParent(ref)){ shell = ref; ref = parent; } /* Si on est dans le shell 'principal', le toplevel * n'est pas l'avant-dernier widget mais le dernier : * on verifie qu'on a bien un shell, sinon on regarde * le parent. */ if(!XtIsShell(shell) && (parent = FaceParent(shell)) && XtIsShell(parent)) ref = parent; else ref = shell; } else if(level == CB_ROOT) while(parent = FaceParent(ref)) ref = parent; else while((level-- != 0) && (parent = FaceParent(ref))) ref = parent; if(ref == 0){ FaceError("Null reference widget"); return(0); } if(names == 0 || names[0] == 0){ return(ref); } w = FaceNameToWidget(ref, names); if(w == 0){ FaceWarning("Bad widget reference %s : no such subwidget", names); } return(w); } /*********************************************************************** * * Sous-resssources de la classe XmText : * on est oblige's de recopier le tableau des sous-ressources * de TextIn.c et TextOut.c. * * Je ne recopie pas les champs 'offset', qui ne nous servent pas * et qui nous obligeraient a` inclure toutes les de'clarations * prive'es du Text. * * Je ne recopie pas non plus les valeurs par de'faut. * **********************************************************************/ static XtResource TextSubResources[] = { { XmNselectionArray, XmCSelectionArray, XmRPointer, sizeof(caddr_t), 0, XmRPointer, 0 }, { XmNselectionArrayCount, XmCSelectionArrayCount, XmRInt, sizeof(int), 0, XmRInt, 0 }, { XmNpendingDelete, XmCPendingDelete, XmRBoolean, sizeof(Boolean), 0, XmRImmediate, 0 }, { XmNselectThreshold, XmCSelectThreshold, XmRInt, sizeof(int), 0, XmRImmediate, 0 }, { XmNfontList, XmCFontList, XmRFontList, sizeof(XmFontList), 0, XmRString, 0 }, { XmNwordWrap, XmCWordWrap, XmRBoolean, sizeof(Boolean), 0, XmRImmediate, 0 }, { XmNblinkRate, XmCBlinkRate, XmRInt, sizeof(int), 0, XmRImmediate, 0 }, { XmNcolumns, XmCColumns, XmRShort, sizeof(short), 0, XmRImmediate, 0 }, { XmNrows, XmCRows, XmRShort, sizeof(short), 0, XmRImmediate, 0 }, { XmNresizeWidth, XmCResizeWidth, XmRBoolean, sizeof(Boolean), 0, XmRImmediate, 0 }, { XmNresizeHeight, XmCResizeHeight, XmRBoolean, sizeof(Boolean), 0, XmRImmediate, 0 }, { XmNscrollVertical, XmCScroll, XmRBoolean, sizeof(Boolean), 0, XmRImmediate, 0 }, { XmNscrollHorizontal, XmCScroll, XmRBoolean, sizeof(Boolean), 0, XmRImmediate, 0 }, { XmNscrollLeftSide, XmCScrollSide, XmRBoolean, sizeof(Boolean), 0, XmRImmediate, 0 }, { XmNscrollTopSide, XmCScrollSide, XmRBoolean, sizeof(Boolean), 0, XmRImmediate, 0 }, { XmNcursorPositionVisible, XmCCursorPositionVisible, XmRBoolean, sizeof(Boolean), 0, XmRImmediate, 0 }, }; #ifdef MOTIF_1_1 /* Vendor */ static XtResource VendorSubResources[] = { { XmNextensionType, XmCExtensionType, XmRExtensionType, sizeof (unsigned char), 0, XmRImmediate, 0 }, { XmNdefaultFontList, XmCDefaultFontList, XmRFontList, sizeof (XmFontList), 0, XmRString, 0 }, { XmNshellUnitType, XmCShellUnitType, XmRShellUnitType, sizeof (unsigned char), 0, XmRImmediate, 0 }, { XmNdeleteResponse, XmCDeleteResponse, XmRDeleteResponse, sizeof(unsigned char), 0, XmRImmediate, 0 }, { XmNkeyboardFocusPolicy, XmCKeyboardFocusPolicy, XmRKeyboardFocusPolicy, sizeof(unsigned char), 0, XmRImmediate, 0 }, { XmNmwmDecorations, XmCMwmDecorations, XmRInt, sizeof(int), 0, XmRImmediate, 0 }, { XmNmwmFunctions, XmCMwmFunctions, XmRInt, sizeof(int), 0, XmRImmediate, 0 }, { XmNmwmInputMode, XmCMwmInputMode, XmRInt, sizeof(int), 0, XmRImmediate, 0 }, { XmNmwmMenu, XmCMwmMenu, XmRString, sizeof(int), 0, XmRString, 0 }, { XmNfocusMovedCallback, XmCCallback, XmRCallback, sizeof(XtCallbackList), 0, XmRImmediate, 0 }, { XmNrealizeCallback, XmCCallback, XmRCallback, sizeof(XtCallbackList), 0, XmRImmediate, 0 }, }; #endif MOTIF_1_1 static SubResourceList SubResourceTable[] = { #ifndef MOTIF_1_1 { "XmText", 0, TextSubResources, XtNumber(TextSubResources) } #else MOTIF_1_1 { "XmText", 0, TextSubResources, XtNumber(TextSubResources) }, { "VendorShell",0, VendorSubResources, XtNumber(VendorSubResources) } #endif MOTIF_1_1 }; static void CompileSubResources() { int i; for(i = 0; i < XtNumber(SubResourceTable); i++){ SubResourceTable[i].qclass_name = XrmStringToQuark(SubResourceTable[i].class_name); XrmCompileResourceList(SubResourceTable[i].sub_resources, SubResourceTable[i].num_sub_resources); } } static SubResourceList * GetSubResourceList(class_name) char *class_name; { int i; XrmQuark qclass_name = XrmStringToQuark(class_name); for(i = 0; i < XtNumber(SubResourceTable); i++){ if(qclass_name == SubResourceTable[i].qclass_name) return(&SubResourceTable[i]); } return(0); } /* La fonction GetClassResource permet de re'cupe'rer une ressource * depuis une classe. */ static XrmResource * GetResourceType(resources, num_resources, name) XrmResourceList resources; Cardinal num_resources; String name; { XrmResourceList *r; XrmResourceList pr; XrmQuark q; int n; q = XrmStringToQuark(name); for (r = (XrmResourceList *) resources, n = num_resources; n--; r++) { pr = *r; if (q == pr->xrm_name) return (pr); } return(0); } static XrmResource * GetSubresourceType(resources, num_resources, name) XrmResourceList resources; Cardinal num_resources; String name; { XrmResourceList pr; XrmQuark q; int n; q = XrmStringToQuark(name); for (pr = (XrmResourceList) resources, n = num_resources; n--; pr++) { if (q == pr->xrm_name) return (pr); } return(0); } /* FaceGetResource renvoie le type d'une ressource d'un widget. */ static XrmResource * FaceGetResourceType(w, name) Widget w; String name; { XrmResource *res; SubResourceList *subres; res = GetResourceType(XtClass(w)->core_class.resources, XtClass(w)->core_class.num_resources, name); if(res) return(res); if(w->core.constraints) res = GetResourceType(((ConstraintWidgetClass)XtClass(w->core.parent))->constraint_class.resources, ((ConstraintWidgetClass)XtClass(w->core.parent))->constraint_class.num_resources, name); if(res) return(res); #ifdef MOTIF_1_1 if(XtClass(w)->core_class.extension) res = GetResourceType(((XmBaseClassExt)XtClass(w)->core_class.extension)->secondaryObjectClass->core_class.resources, ((XmBaseClassExt)XtClass(w)->core_class.extension)->secondaryObjectClass->core_class.num_resources, name); if(res) return(res); #endif MOTIF_1_1 subres = GetSubResourceList(XtClass(w)->core_class.class_name); if(subres) res = GetSubresourceType(subres->sub_resources, subres->num_sub_resources, name); return(res); } XtArgVal FaceGetResource(w, name, v) Widget w; char *name; FaceVariable *v; { XrmResource *res; XrmQuark type; Arg arg; XtArgVal val; if(!w || !name || !v){ return(0); } XtSetArg(arg, name, &val); XtGetValues(w, &arg, 1); res = FaceGetResourceType(w, name); if(!res){ v->type = XtQNone; v->value = val; return(val); } type = res->xrm_type; if(res->xrm_size == sizeof(char)){ v->value = (XtArgVal)*((char *)&val); } else if(res->xrm_size == sizeof(short)){ if(type == XtQPosition || type == XtQDimension) type = XtQInt; v->value = (XtArgVal)*((short *)&val); } else v->value = val; v->type = type; return(v->value); } int FaceSetResource(w, name, v, type) Widget w; char *name; XtArgVal v; XrmQuark type; { Arg arg; XrmResource *res; if(!w || !name) return; res = FaceGetResourceType(w, name); if(res && res->xrm_type != XtQString && type == XtQString){ XrmValue from, to; to.addr = NULL; to.size = 0; from.size = strlen((char *)v)+1; from.addr = (caddr_t)v; XtConvert(w, XtRString, &from, XrmQuarkToString(res->xrm_type), &to); if(to.addr == 0){ FaceError("Resource conversion failed for %s", name); return; } if(res->xrm_size == sizeof(char)){ v = *(char *)to.addr; } else if(res->xrm_size == sizeof(short)){ v = *(short *)to.addr; } else if(res->xrm_size == sizeof(int)){ v = *(int *)to.addr; } else{ FaceWarning("Unusual size %d for resource %s\n", res->xrm_size, name); v = (XtArgVal)to.addr; } } XtSetArg(arg, name, v); XtSetValues(w, &arg, 1); } int FaceGetProperty(w, name, v) Widget w; char *name; FaceVariable *v; { Atom property; Atom actual_type; int actual_format; unsigned long nitems, bytes_after; char *prop; if(name[0] >= '0' && name[0] <= '7'){ prop = XFetchBuffer(XtDisplay(w), &nitems, name[0]-'0'); if(nitems == 0) { v->type = XtQNone; v->value = (XtArgVal)""; return(0); } else { v->type = XtQString; v->value = (XtArgVal)prop; return(1); } } if(!w){ return(0); } property = XInternAtom(XtDisplay(w), name, False); XGetWindowProperty(XtDisplay(w), XtWindow(w), property, 0, 1, False, AnyPropertyType, &actual_type, &actual_format, &nitems, &bytes_after, &prop); if(actual_format == 0){ return(0); } v->type = XrmStringToQuark(XGetAtomName(XtDisplay(w), actual_type)); v->value = *(XtArgVal *)prop; XFree(prop); return(1); } int FaceSetProperty(w, name, v, type) Widget w; char *name; XtArgVal v; XrmQuark type; { Atom aprop, atype; if(name[0] >= '0' && name[0] <= '7'){ XStoreBuffer(XtDisplay(w), (char *)v, strlen((char *)v)+1, name[0]-'0'); return(1); } if(!w){ return(0); } aprop = XInternAtom(XtDisplay(w), name, False); atype = XInternAtom(XtDisplay(w), XrmQuarkToString(type), False); XChangeProperty(XtDisplay(w), XtWindow(w), aprop, atype, 32, PropModeReplace, (char *)&v, 1); return(1); } int FmEqualString(a, b) char *a, *b; { return((a == 0 && b == 0) || (a != 0 && b != 0 && strcmp(a, b) == 0)); } int FmNotEqualString(a, b) char *a, *b; { return((a == 0 && b != 0) || (a != 0 && b == 0) || (a != 0 && b != 0 && strcmp(a, b) != 0)); } char * FmItoa(i) int i; { char buf[128]; sprintf(buf, "%d", i); return(XtNewString(buf)); } void FmItof(i, pf) int i; float *pf; { if(!pf) return; *pf = (float)i; } int FmFtoi(pf) float *pf; { if(!pf) return(0); return (int)*pf; } void FmItod(i, pd) int i; double *pd; { if(*pd) return; *pd = (double)i; } int FmDtoi(pd) double *pd; { if(!pd) return(0); return (int)*pd; } /* Explicitely convert a String to another type. */ XtArgVal FaceConvertString(w, s, to_type) Widget w; String s; String to_type; { XrmValue from, to; XtArgVal result; if(!strcmp(to_type, XtRString)){ return((XtArgVal)s); } from.addr = s; from.size = strlen(s)+1; XtConvert(w, XtRString, &from, to_type, &to); if(!to.addr){ FaceError("Cannot convert String to %s.", to_type); return(0); } if(to.size == sizeof(int)){ result = *(int *)to.addr; } else if(to.size == sizeof(long)){ result = *(long *)to.addr; } else if(to.size == sizeof(XtArgVal)){ result = *(XtArgVal *)to.addr; } else if(to.size == sizeof(char)){ result = *(char *)to.addr; } else if(to.size == sizeof(short)){ result = *(short *)to.addr; } else { FaceWarning("Converted value has unusual size %d !\n(returning address...)", to.size); result = (XtArgVal)to.addr; } return(result); } /* FACE function to set multiple values at one time. */ int FaceSetValues(w, num_resources, r1, v1, r2, v2, r3, v3, r4, v4, r5, v5) Widget w; int num_resources; char *r1; XtArgVal v1; char *r2; XtArgVal v2; char *r3; XtArgVal v3; char *r4; XtArgVal v4; char *r5; XtArgVal v5; { Arg arg[5]; if(num_resources > 5){ FaceError("You cannot set more than 5 resources using SetResources."); return(0); } if(num_resources >= 1) XtSetArg(arg[0], r1, v1); if(num_resources >= 2) XtSetArg(arg[1], r2, v2); if(num_resources >= 3) XtSetArg(arg[2], r3, v3); if(num_resources >= 4) XtSetArg(arg[3], r4, v4); if(num_resources >= 5) XtSetArg(arg[4], r5, v5); XtSetValues(w, arg, num_resources); return(1); } int FaceInit() { XtQNone = XrmStringToQuark(XtRNone); XtQAny = XrmStringToQuark(XtRAny); XtQFloat = XrmStringToQuark(XtRFloat); XtQWidget = XrmStringToQuark(XtRWidget); CompileSubResources(); }