summaryrefslogtreecommitdiff
path: root/xc/lib/Xmu/StrToWidg.c
diff options
context:
space:
mode:
authorswick <empty>1988-10-03 10:30:58 +0000
committerswick <empty>1988-10-03 10:30:58 +0000
commitf833a09ffe63fce7d544b0e38356ebc8c1d24807 (patch)
treed34e3a9c7e6865e9720ac99b3e7b59a094621e54 /xc/lib/Xmu/StrToWidg.c
parent7e5cf1bb69444db1236efb916392480a01ac6d4e (diff)
Initial revision
Diffstat (limited to 'xc/lib/Xmu/StrToWidg.c')
-rw-r--r--xc/lib/Xmu/StrToWidg.c85
1 files changed, 85 insertions, 0 deletions
diff --git a/xc/lib/Xmu/StrToWidg.c b/xc/lib/Xmu/StrToWidg.c
new file mode 100644
index 000000000..430f361b9
--- /dev/null
+++ b/xc/lib/Xmu/StrToWidg.c
@@ -0,0 +1,85 @@
+#ifndef lint
+static char Xrcsid[] = "$XConsortium: Form.c,v 1.19 88/09/06 16:41:20 jim Exp $";
+#endif lint
+
+/* Copyright 1988 Massachusetts Institute of Technology, Cambridge, Massachusetts.
+ *
+ * XmuCvtStringToWidget
+ *
+ * static XtConvertArgRec parentCvtArgs[] = {
+ * {XtBaseOffset, (caddr_t)XtOffset(Widget, core.parent), sizeof(Widget)},
+ * };
+ *
+ * matches the string against the name of the immediate children (normal
+ * or popup) of the parent. If none match, compares string to classname
+ * & returns first match. Case is significant.
+ */
+
+#include <X11/copyright.h>
+
+#include <X11/IntrinsicP.h>
+
+#define done(address, type) \
+ { toVal->size = sizeof(type); \
+ toVal->addr = (caddr_t) address; \
+ return; \
+ }
+
+/* ARGSUSED */
+void XmuCvtStringToWidget(args, num_args, fromVal, toVal)
+ XrmValuePtr args; /* parent */
+ Cardinal *num_args; /* 1 */
+ XrmValuePtr fromVal;
+ XrmValuePtr toVal;
+{
+ static Widget widget, *widgetP, parent;
+ XrmName name = XrmStringToName(fromVal->addr);
+ int i;
+
+ if (*num_args != 1)
+ XtErrorMsg("wrongParameters", "cvtStringToWidget", "xtToolkitError",
+ "StringToWidget conversion needs parent arg", NULL, 0);
+
+ parent = *(Widget*)args[0].addr;
+ /* try to match names of normal children */
+ if (XtIsComposite(parent)) {
+ i = ((CompositeWidget)parent)->composite.num_children;
+ for (widgetP = ((CompositeWidget)parent)->composite.children;
+ i; i--, widgetP++) {
+ if ((*widgetP)->core.xrm_name == name) {
+ widget = *widgetP;
+ done(&widget, Widget);
+ }
+ }
+ }
+ /* try to match names of popup children */
+ i = parent->core.num_popups;
+ for (widgetP = parent->core.popup_list; i; i--, widgetP++) {
+ if ((*widgetP)->core.xrm_name == name) {
+ widget = *widgetP;
+ done(&widget, Widget);
+ }
+ }
+ /* try to match classes of normal children */
+ if (XtIsComposite(parent)) {
+ i = ((CompositeWidget)parent)->composite.num_children;
+ for (widgetP = ((CompositeWidget)parent)->composite.children;
+ i; i--, widgetP++) {
+ if ((*widgetP)->core.widget_class->core_class.xrm_class == name) {
+ widget = *widgetP;
+ done(&widget, Widget);
+ }
+ }
+ }
+ /* try to match classes of popup children */
+ i = parent->core.num_popups;
+ for (widgetP = parent->core.popup_list; i; i--, widgetP++) {
+ if ((*widgetP)->core.widget_class->core_class.xrm_class == name) {
+ widget = *widgetP;
+ done(&widget, Widget);
+ }
+ }
+ XtStringConversionWarning(fromVal->addr, "Widget");
+ toVal->addr = NULL;
+ toVal->size = 0;
+}