|
Packit Service |
2b1f13 |
/*
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
Copyright 1994, 1998 The Open Group
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
Permission to use, copy, modify, distribute, and sell this software and its
|
|
Packit Service |
2b1f13 |
documentation for any purpose is hereby granted without fee, provided that
|
|
Packit Service |
2b1f13 |
the above copyright notice appear in all copies and that both that
|
|
Packit Service |
2b1f13 |
copyright notice and this permission notice appear in supporting
|
|
Packit Service |
2b1f13 |
documentation.
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
The above copyright notice and this permission notice shall be included in
|
|
Packit Service |
2b1f13 |
all copies or substantial portions of the Software.
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
Packit Service |
2b1f13 |
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
Packit Service |
2b1f13 |
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
Packit Service |
2b1f13 |
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
|
Packit Service |
2b1f13 |
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
Packit Service |
2b1f13 |
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
Except as contained in this notice, the name of The Open Group shall not be
|
|
Packit Service |
2b1f13 |
used in advertising or otherwise to promote the sale, use or other dealings
|
|
Packit Service |
2b1f13 |
in this Software without prior written authorization from The Open Group.
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
*/
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
/*
|
|
Packit Service |
2b1f13 |
* XmuCvtStringToWidget
|
|
Packit Service |
2b1f13 |
*
|
|
Packit Service |
2b1f13 |
* static XtConvertArgRec parentCvtArgs[] = {
|
|
Packit Service |
2b1f13 |
* {XtBaseOffset, (XtPointer)XtOffset(Widget, core.parent), sizeof(Widget)},
|
|
Packit Service |
2b1f13 |
* };
|
|
Packit Service |
2b1f13 |
*
|
|
Packit Service |
2b1f13 |
* matches the string against the name of the immediate children (normal
|
|
Packit Service |
2b1f13 |
* or popup) of the parent. If none match, compares string to classname
|
|
Packit Service |
2b1f13 |
* & returns first match. Case is significant.
|
|
Packit Service |
2b1f13 |
*/
|
|
Packit Service |
2b1f13 |
#ifdef HAVE_CONFIG_H
|
|
Packit Service |
2b1f13 |
#include <config.h>
|
|
Packit Service |
2b1f13 |
#endif
|
|
Packit Service |
2b1f13 |
#include <X11/IntrinsicP.h>
|
|
Packit Service |
2b1f13 |
#include <X11/StringDefs.h>
|
|
Packit Service |
2b1f13 |
#include <X11/ObjectP.h>
|
|
Packit Service |
2b1f13 |
#include <X11/Xmu/Converters.h>
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
#define done(address, type) \
|
|
Packit Service |
2b1f13 |
{ \
|
|
Packit Service |
2b1f13 |
toVal->size = sizeof(type); \
|
|
Packit Service |
2b1f13 |
toVal->addr = (XPointer)address; \
|
|
Packit Service |
2b1f13 |
return; \
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
/*ARGSUSED*/
|
|
Packit Service |
2b1f13 |
void
|
|
Packit Service |
2b1f13 |
XmuCvtStringToWidget(XrmValuePtr args, Cardinal *num_args,
|
|
Packit Service |
2b1f13 |
XrmValuePtr fromVal, XrmValuePtr toVal)
|
|
Packit Service |
2b1f13 |
{
|
|
Packit Service |
2b1f13 |
static Widget widget, *widgetP, parent;
|
|
Packit Service |
2b1f13 |
XrmName name = XrmStringToName(fromVal->addr);
|
|
Packit Service |
2b1f13 |
Cardinal i;
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
if (*num_args != 1) {
|
|
Packit Service |
2b1f13 |
i = 0;
|
|
Packit Service |
2b1f13 |
XtErrorMsg("wrongParameters", "cvtStringToWidget", "xtToolkitError",
|
|
Packit Service |
2b1f13 |
"StringToWidget conversion needs parent arg", NULL, &i);
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
parent = *(Widget *) args[0].addr;
|
|
Packit Service |
2b1f13 |
/* try to match names of normal children */
|
|
Packit Service |
2b1f13 |
if (XtIsComposite(parent)) {
|
|
Packit Service |
2b1f13 |
i = ((CompositeWidget) parent)->composite.num_children;
|
|
Packit Service |
2b1f13 |
for (widgetP = ((CompositeWidget) parent)->composite.children;
|
|
Packit Service |
2b1f13 |
i; i--, widgetP++) {
|
|
Packit Service |
2b1f13 |
if ((*widgetP)->core.xrm_name == name) {
|
|
Packit Service |
2b1f13 |
widget = *widgetP;
|
|
Packit Service |
2b1f13 |
done(&widget, Widget);
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
/* try to match names of popup children */
|
|
Packit Service |
2b1f13 |
i = parent->core.num_popups;
|
|
Packit Service |
2b1f13 |
for (widgetP = parent->core.popup_list; i; i--, widgetP++) {
|
|
Packit Service |
2b1f13 |
if ((*widgetP)->core.xrm_name == name) {
|
|
Packit Service |
2b1f13 |
widget = *widgetP;
|
|
Packit Service |
2b1f13 |
done(&widget, Widget);
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
/* try to match classes of normal children */
|
|
Packit Service |
2b1f13 |
if (XtIsComposite(parent)) {
|
|
Packit Service |
2b1f13 |
i = ((CompositeWidget) parent)->composite.num_children;
|
|
Packit Service |
2b1f13 |
for (widgetP = ((CompositeWidget) parent)->composite.children;
|
|
Packit Service |
2b1f13 |
i; i--, widgetP++) {
|
|
Packit Service |
2b1f13 |
if ((*widgetP)->core.widget_class->core_class.xrm_class == name) {
|
|
Packit Service |
2b1f13 |
widget = *widgetP;
|
|
Packit Service |
2b1f13 |
done(&widget, Widget);
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
/* try to match classes of popup children */
|
|
Packit Service |
2b1f13 |
i = parent->core.num_popups;
|
|
Packit Service |
2b1f13 |
for (widgetP = parent->core.popup_list; i; i--, widgetP++) {
|
|
Packit Service |
2b1f13 |
if ((*widgetP)->core.widget_class->core_class.xrm_class == name) {
|
|
Packit Service |
2b1f13 |
widget = *widgetP;
|
|
Packit Service |
2b1f13 |
done(&widget, Widget);
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
XtStringConversionWarning(fromVal->addr, XtRWidget);
|
|
Packit Service |
2b1f13 |
toVal->addr = NULL;
|
|
Packit Service |
2b1f13 |
toVal->size = 0;
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
#undef done
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
#define newDone(type, value) \
|
|
Packit Service |
2b1f13 |
{ \
|
|
Packit Service |
2b1f13 |
if (toVal->addr != NULL) { \
|
|
Packit Service |
2b1f13 |
if (toVal->size < sizeof(type)) { \
|
|
Packit Service |
2b1f13 |
toVal->size = sizeof(type); \
|
|
Packit Service |
2b1f13 |
return False; \
|
|
Packit Service |
2b1f13 |
} \
|
|
Packit Service |
2b1f13 |
*(type*)(toVal->addr) = (value); \
|
|
Packit Service |
2b1f13 |
} \
|
|
Packit Service |
2b1f13 |
else { \
|
|
Packit Service |
2b1f13 |
static type static_val; \
|
|
Packit Service |
2b1f13 |
static_val = (value); \
|
|
Packit Service |
2b1f13 |
toVal->addr = (XtPointer)&static_val; \
|
|
Packit Service |
2b1f13 |
} \
|
|
Packit Service |
2b1f13 |
toVal->size = sizeof(type); \
|
|
Packit Service |
2b1f13 |
return True; \
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
/*ARGSUSED*/
|
|
Packit Service |
2b1f13 |
Boolean
|
|
Packit Service |
2b1f13 |
XmuNewCvtStringToWidget(Display *dpy, XrmValue *args, Cardinal *num_args,
|
|
Packit Service |
2b1f13 |
XrmValue *fromVal, XrmValue *toVal,
|
|
Packit Service |
2b1f13 |
XtPointer *converter_data)
|
|
Packit Service |
2b1f13 |
{
|
|
Packit Service |
2b1f13 |
Widget *widgetP, parent;
|
|
Packit Service |
2b1f13 |
XrmName name = XrmStringToName(fromVal->addr);
|
|
Packit Service |
2b1f13 |
int i;
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
if (*num_args != 1)
|
|
Packit Service |
2b1f13 |
XtAppWarningMsg(XtDisplayToApplicationContext(dpy),
|
|
Packit Service |
2b1f13 |
"wrongParameters", "cvtStringToWidget",
|
|
Packit Service |
2b1f13 |
"xtToolkitError",
|
|
Packit Service |
2b1f13 |
"String To Widget conversion needs parent argument",
|
|
Packit Service |
2b1f13 |
(String *) NULL, (Cardinal *) NULL);
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
parent = *(Widget *) args[0].addr;
|
|
Packit Service |
2b1f13 |
/* try to match names of normal children */
|
|
Packit Service |
2b1f13 |
if (XtIsComposite(parent)) {
|
|
Packit Service |
2b1f13 |
i = ((CompositeWidget) parent)->composite.num_children;
|
|
Packit Service |
2b1f13 |
for (widgetP = ((CompositeWidget) parent)->composite.children;
|
|
Packit Service |
2b1f13 |
i; i--, widgetP++) {
|
|
Packit Service |
2b1f13 |
if ((*widgetP)->core.xrm_name == name)
|
|
Packit Service |
2b1f13 |
newDone(Widget, *widgetP);
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
/* try to match names of popup children */
|
|
Packit Service |
2b1f13 |
i = parent->core.num_popups;
|
|
Packit Service |
2b1f13 |
for (widgetP = parent->core.popup_list; i; i--, widgetP++) {
|
|
Packit Service |
2b1f13 |
if ((*widgetP)->core.xrm_name == name)
|
|
Packit Service |
2b1f13 |
newDone(Widget, *widgetP);
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
/* try to match classes of normal children */
|
|
Packit Service |
2b1f13 |
if (XtIsComposite(parent)) {
|
|
Packit Service |
2b1f13 |
i = ((CompositeWidget) parent)->composite.num_children;
|
|
Packit Service |
2b1f13 |
for (widgetP = ((CompositeWidget) parent)->composite.children;
|
|
Packit Service |
2b1f13 |
i; i--, widgetP++) {
|
|
Packit Service |
2b1f13 |
if ((*widgetP)->core.widget_class->core_class.xrm_class == name)
|
|
Packit Service |
2b1f13 |
newDone(Widget, *widgetP);
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
/* try to match classes of popup children */
|
|
Packit Service |
2b1f13 |
i = parent->core.num_popups;
|
|
Packit Service |
2b1f13 |
for (widgetP = parent->core.popup_list; i; i--, widgetP++) {
|
|
Packit Service |
2b1f13 |
if ((*widgetP)->core.widget_class->core_class.xrm_class == name)
|
|
Packit Service |
2b1f13 |
newDone(Widget, *widgetP);
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
XtDisplayStringConversionWarning(dpy, (String) fromVal->addr, XtRWidget);
|
|
Packit Service |
2b1f13 |
return (False);
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
/*ARGSUSED*/
|
|
Packit Service |
2b1f13 |
Boolean
|
|
Packit Service |
2b1f13 |
XmuCvtWidgetToString(Display *dpy, XrmValuePtr args, Cardinal *num_args,
|
|
Packit Service |
2b1f13 |
XrmValuePtr fromVal, XrmValuePtr toVal, XtPointer *data)
|
|
Packit Service |
2b1f13 |
{
|
|
Packit Service |
2b1f13 |
static String buffer;
|
|
Packit Service |
2b1f13 |
Cardinal size;
|
|
Packit Service |
2b1f13 |
Widget widget;
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
widget = *(Widget *) fromVal->addr;
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
if (widget)
|
|
Packit Service |
2b1f13 |
buffer = XrmQuarkToString(widget->core.xrm_name);
|
|
Packit Service |
2b1f13 |
else
|
|
Packit Service |
2b1f13 |
buffer = "(null)";
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
size = strlen(buffer) + 1;
|
|
Packit Service |
2b1f13 |
if (toVal->addr != NULL) {
|
|
Packit Service |
2b1f13 |
if (toVal->size < size) {
|
|
Packit Service |
2b1f13 |
toVal->size = size;
|
|
Packit Service |
2b1f13 |
return (False);
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
strcpy((char *) toVal->addr, buffer);
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
else {
|
|
Packit Service |
2b1f13 |
toVal->addr = (XPointer) buffer;
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
toVal->size = sizeof(String);
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
return (True);
|
|
Packit Service |
2b1f13 |
}
|