/* Generated by wbuild from "OptButton.w"
** (generator version $Revision: 1.17 $ of $Date: 92/12/07 19:32:00 $)
*/
#include <X11/IntrinsicP.h>
#include <X11/StringDefs.h>
#line 140 "OptButton.w"
#include <stdio.h>
#include <Xfwf/OptButtonP.h>
#line 127 "OptButton.w"
static void menu_action(
#if NeedFunctionPrototypes
Widget,XEvent*,String*,Cardinal*
#endif
);

static XtActionsRec actionsList[] = {
{"menu_action", menu_action},
};

static char defaultTranslations[] = "\
<Btn1Down>: open_menu() \n\
Button1<Enter>: open_menu() \n\
<Key>Return: open_menu() \n\
";
static void _resolve_inheritance(
#if NeedFunctionPrototypes
WidgetClass
#endif
);
#line 58 "OptButton.w"
static void initialize(
#if NeedFunctionPrototypes
Widget ,Widget,ArgList ,Cardinal *
#endif
);
#line 67 "OptButton.w"
static Boolean  set_values(
#if NeedFunctionPrototypes
Widget ,Widget ,Widget,ArgList ,Cardinal *
#endif
);
#line 96 "OptButton.w"
static void create_menu_string(
#if NeedFunctionPrototypes
Widget
#endif
);
#line 96 "OptButton.w"
/*ARGSUSED*/static void create_menu_string(self)Widget self;
{
    String p, s = NULL;
    int l = 1;

    s = XtMalloc(1);
    s[0]= '\0';
    p = strtok(((XfwfOptionButtonWidget)self)->xfwfOptionButton.options, "\n");
    while (p != NULL) {
	l += 2*strlen(p) + strlen("(item \"\" (action \"menu_action()\"))");
	s = XtRealloc(s, l);
	if (s == NULL) XtError("Out of memory");
	(void) strcat(s, "(item \"");
	(void) strcat(s, p);
	(void) strcat(s, "\" (action \"menu_action(");
	(void) strcat(s, p);
	(void) strcat(s, ")\"))");
	p = strtok(NULL, "\n");
    }
    XtVaSetValues(self, XtNmenu, s, NULL);
}

static XtResource resources[] = {
#line 37 "OptButton.w"
{XtNcallback,XtCCallback,XtRCallback,sizeof(((XfwfOptionButtonRec*)NULL)->xfwfOptionButton.callback),XtOffsetOf(XfwfOptionButtonRec,xfwfOptionButton.callback),XtRImmediate,(XtPointer)NULL },
#line 44 "OptButton.w"
{XtNoptions,XtCOptions,XtRString,sizeof(((XfwfOptionButtonRec*)NULL)->xfwfOptionButton.options),XtOffsetOf(XfwfOptionButtonRec,xfwfOptionButton.options),XtRImmediate,(XtPointer)NULL },
#line 49 "OptButton.w"
{XtNframeWidth,XtCFrameWidth,XtRDimension,sizeof(((XfwfOptionButtonRec*)NULL)->xfwfFrame.frameWidth),XtOffsetOf(XfwfOptionButtonRec,xfwfFrame.frameWidth),XtRImmediate,(XtPointer)2 },
};

XfwfOptionButtonClassRec xfwfOptionButtonClassRec = {
{ /* core_class part */
(WidgetClass) &xfwfPullDownClassRec,
"XfwfOptionButton",
sizeof(XfwfOptionButtonRec),
NULL,
_resolve_inheritance,
FALSE,
initialize,
NULL,
XtInheritRealize,
actionsList,
1,
resources,
3,
NULLQUARK,
False ,
FALSE ,
False ,
False ,
NULL,
XtInheritResize,
XtInheritExpose,
set_values,
NULL,
XtInheritSetValuesAlmost,
NULL,
XtInheritAcceptFocus,
XtVersion,
NULL,
defaultTranslations,
XtInheritQueryGeometry,
XtInheritDisplayAccelerator,
NULL 
},
{ /* composite_class part */
XtInheritGeometryManager,
XtInheritChangeManaged,
XtInheritInsertChild,
XtInheritDeleteChild,
NULL
},
{ /* XfwfCommon_class part */
XtInherit_compute_inside,
XtInherit_highlight_border,
XtInherit_unhighlight_border,
XtInherit_would_accept_focus,
XtInherit_traverse,
XtInherit_choose_color,
XtInherit_lighter_color,
XtInherit_darker_color,
NULL ,
},
{ /* XfwfFrame_class part */
0
},
{ /* XfwfBoard_class part */
XtInherit_set_abs_location,
},
{ /* XfwfLabel_class part */
XtInherit_set_label,
},
{ /* XfwfButton_class part */
0
},
{ /* XfwfPullDown_class part */
0
},
{ /* XfwfOptionButton_class part */
0
},
};
WidgetClass xfwfOptionButtonWidgetClass = (WidgetClass) &xfwfOptionButtonClassRec;
/*ARGSUSED*/
#line 127 "OptButton.w"
static void menu_action(self,event,params,num_params)Widget self;XEvent*event;String*params;Cardinal*num_params;
{
    Widget button = XtParent(self);

    if (((XfwfOptionButtonWidget)button)->xfwfLabel.label && strcmp(((XfwfOptionButtonWidget)button)->xfwfLabel.label, params[0]) == 0) return;
    XtVaSetValues(button, XtNlabel, params[0], NULL);
    XtCallCallbackList(button, ((XfwfOptionButtonWidget)button)->xfwfOptionButton.callback, ((XfwfOptionButtonWidget)button)->xfwfLabel.label);
}

static void _resolve_inheritance(class)
WidgetClass class;
{
  XfwfOptionButtonWidgetClass c = (XfwfOptionButtonWidgetClass) class;
  XfwfOptionButtonWidgetClass super;
  if (class == xfwfOptionButtonWidgetClass) return;
  super = (XfwfOptionButtonWidgetClass) c->core_class.superclass;
}
#line 58 "OptButton.w"
/*ARGSUSED*/static void initialize(request,self,args,num_args)Widget  request;Widget self;ArgList  args;Cardinal * num_args;
{
    if (((XfwfOptionButtonWidget)self)->xfwfOptionButton.options != NULL)
	create_menu_string(self);
}
#line 67 "OptButton.w"
/*ARGSUSED*/static Boolean  set_values(old,request,self,args,num_args)Widget  old;Widget  request;Widget self;ArgList  args;Cardinal * num_args;
{
    String s;

    if (((XfwfOptionButtonWidget)old)->xfwfOptionButton.options != ((XfwfOptionButtonWidget)self)->xfwfOptionButton.options)
	create_menu_string(self);
    return False;
}
