/* Generated by wbuild from "PullDown.w"
** (generator version $Revision: 1.4 $ of $Date: 1995/08/29 09:46:14 $)
*/
#include <xite/includes.h>
#include <X11/IntrinsicP.h>
#include <X11/StringDefs.h>
#line 294 "PullDown.w"
#include <Xfwf/TextMenu.h>
#line 295 "PullDown.w"
#include <Xfwf/MenuBar.h>
#line 296 "PullDown.w"
#include XITE_STDIO_H
#include <Xfwf/PullDownP.h>
#line 178 "PullDown.w"
static void note(
#if NeedFunctionPrototypes
Widget,XEvent*,String*,Cardinal*
#endif
);
#line 198 "PullDown.w"
static void prepare(
#if NeedFunctionPrototypes
Widget,XEvent*,String*,Cardinal*
#endif
);
#line 210 "PullDown.w"
static void open_menu(
#if NeedFunctionPrototypes
Widget,XEvent*,String*,Cardinal*
#endif
);
#line 226 "PullDown.w"
static void popdown_maybe(
#if NeedFunctionPrototypes
Widget,XEvent*,String*,Cardinal*
#endif
);

static XtActionsRec actionsList[] = {
{"note", note},
{"prepare", prepare},
{"open_menu", open_menu},
{"popdown_maybe", popdown_maybe},
};

static char defaultTranslations[] = "\
<Btn1Down>: prepare() open_menu() \n\
Button1<Enter>: prepare() open_menu() \n\
<Key>Return: prepare() open_menu() \n\
<Btn1Up>: popdown_maybe() \n\
";
static void _resolve_inheritance(
#if NeedFunctionPrototypes
WidgetClass
#endif
);
#line 106 "PullDown.w"
static void class_initialize(
#if NeedFunctionPrototypes
void
#endif
);
#line 120 "PullDown.w"
static void initialize(
#if NeedFunctionPrototypes
Widget ,Widget,ArgList ,Cardinal *
#endif
);
#line 140 "PullDown.w"
static Boolean  set_values(
#if NeedFunctionPrototypes
Widget ,Widget ,Widget,ArgList ,Cardinal *
#endif
);
#line 257 "PullDown.w"
static void create_accelerator(
#if NeedFunctionPrototypes
Widget
#endif
);
#line 273 "PullDown.w"
static void activate_cb(
#if NeedFunctionPrototypes
Widget ,XtPointer ,XtPointer 
#endif
);
#line 285 "PullDown.w"
static void change_cb(
#if NeedFunctionPrototypes
Widget ,XtPointer ,XtPointer 
#endif
);
#line 257 "PullDown.w"
/*ARGSUSED*/static void create_accelerator(self)Widget self;
{
    char s[100];
    XtAccelerators a;

    (void) strcpy(s, ((XfwfPullDownWidget)self)->xfwfPullDown.hotkey);
    (void) strcat(s, ": prepare() open_menu()");
    a = XtParseAcceleratorTable(s);
    XtVaSetValues(self, XtNaccelerators, a, NULL);
}
#line 273 "PullDown.w"
/*ARGSUSED*/static void activate_cb(menu,client_data,call_data)Widget  menu;XtPointer  client_data;XtPointer  call_data;
{
    Widget self = (Widget) client_data;

    XtCallCallbackList(self, ((XfwfPullDownWidget)self)->xfwfButton.activate, call_data);
}
#line 285 "PullDown.w"
/*ARGSUSED*/static void change_cb(menu,client_data,call_data)Widget  menu;XtPointer  client_data;XtPointer  call_data;
{
    Widget self = (Widget) client_data;

    XtCallCallbackList(self, ((XfwfPullDownWidget)self)->xfwfPullDown.changeSelection, call_data);
}

static XtResource resources[] = {
#line 38 "PullDown.w"
{XtNpopup,XtCPopup,XtRWidget,sizeof(((XfwfPullDownRec*)NULL)->xfwfPullDown.popup),XtOffsetOf(XfwfPullDownRec,xfwfPullDown.popup),XtRImmediate,(XtPointer)NULL },
#line 44 "PullDown.w"
{XtNmenu,XtCMenu,XtRString,sizeof(((XfwfPullDownRec*)NULL)->xfwfPullDown.menu),XtOffsetOf(XfwfPullDownRec,xfwfPullDown.menu),XtRImmediate,(XtPointer)NULL },
#line 51 "PullDown.w"
{XtNcascaded,XtCCascaded,XtRBoolean,sizeof(((XfwfPullDownRec*)NULL)->xfwfPullDown.cascaded),XtOffsetOf(XfwfPullDownRec,xfwfPullDown.cascaded),XtRImmediate,(XtPointer)False },
#line 62 "PullDown.w"
{XtNhotkey,XtCHotkey,XtRString,sizeof(((XfwfPullDownRec*)NULL)->xfwfPullDown.hotkey),XtOffsetOf(XfwfPullDownRec,xfwfPullDown.hotkey),XtRImmediate,(XtPointer)NULL },
#line 68 "PullDown.w"
{XtNmenuCursor,XtCMenuCursor,XtRCursor,sizeof(((XfwfPullDownRec*)NULL)->xfwfPullDown.menuCursor),XtOffsetOf(XfwfPullDownRec,xfwfPullDown.menuCursor),XtRString,(XtPointer)"arrow"},
#line 73 "PullDown.w"
{XtNprepare,XtCPrepare,XtRCallback,sizeof(((XfwfPullDownRec*)NULL)->xfwfPullDown.prepare),XtOffsetOf(XfwfPullDownRec,xfwfPullDown.prepare),XtRImmediate,(XtPointer)NULL },
#line 83 "PullDown.w"
{XtNchangeSelection,XtCChangeSelection,XtRCallback,sizeof(((XfwfPullDownRec*)NULL)->xfwfPullDown.changeSelection),XtOffsetOf(XfwfPullDownRec,xfwfPullDown.changeSelection),XtRImmediate,(XtPointer)NULL },
#line 88 "PullDown.w"
{XtNframeWidth,XtCFrameWidth,XtRDimension,sizeof(((XfwfPullDownRec*)NULL)->xfwfFrame.frameWidth),XtOffsetOf(XfwfPullDownRec,xfwfFrame.frameWidth),XtRImmediate,(XtPointer)0 },
#line 92 "PullDown.w"
{XtNshrinkToFit,XtCShrinkToFit,XtRBoolean,sizeof(((XfwfPullDownRec*)NULL)->xfwfLabel.shrinkToFit),XtOffsetOf(XfwfPullDownRec,xfwfLabel.shrinkToFit),XtRImmediate,(XtPointer)True },
};

XfwfPullDownClassRec xfwfPullDownClassRec = {
{ /* core_class part */
(WidgetClass) &xfwfButtonClassRec,
"XfwfPullDown",
sizeof(XfwfPullDownRec),
class_initialize,
_resolve_inheritance,
FALSE,
initialize,
NULL,
XtInheritRealize,
actionsList,
4,
resources,
9,
NULLQUARK,
True ,
XtExposeCompressMultiple ,
True ,
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_total_frame_width,
XtInherit_highlight_border,
XtInherit_unhighlight_border,
XtInherit_would_accept_focus,
XtInherit_traverse,
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
},
};
WidgetClass xfwfPullDownWidgetClass = (WidgetClass) &xfwfPullDownClassRec;
/*ARGSUSED*/
#line 178 "PullDown.w"
static void note(self,event,params,num_params)Widget self;XEvent*event;String*params;Cardinal*num_params;
{
    static String Xeventname[] = {
	"", "", "KeyPress", "KeyRelease", "ButtonPress", "ButtonRelease",
	"MotionNotify", "EnterNotify", "LeaveNotify", "FocusIn",
	"FocusOut", "KeymapNotify", "Expose", "GraphicsExpose",
	"NoExpose", "VisisbilityNotify", "CreateNotify", "DestroyNotify",
	"UnmapNotify", "MapNotify", "MapRequest", "ReparentNotify",
	"ConfigureNotify", "ConfigureRequest", "GravityNotify",
	"ResizeRequest", "CirculateNotify", "CirculateRequest",
	"PropertyNotify", "SelectionClear", "SelectionRequest",
	"SelectionNotify", "ColormapNotify", "ClientMessage",
	"MappingNotify", };
    (void) fprintf(stderr, "%s received %s\n",
		   XtName(self), Xeventname[event->type]);
}

/*ARGSUSED*/
#line 198 "PullDown.w"
static void prepare(self,event,params,num_params)Widget self;XEvent*event;String*params;Cardinal*num_params;
{
    XtCallCallbackList(self, ((XfwfPullDownWidget)self)->xfwfPullDown.prepare, event);
}

/*ARGSUSED*/
#line 210 "PullDown.w"
static void open_menu(self,event,params,num_params)Widget self;XEvent*event;String*params;Cardinal*num_params;
{
    Position x, y;

    if (((XfwfPullDownWidget)self)->xfwfPullDown.popup == NULL) return;
    /* fprintf(stderr, "open_menu \"%s\"\n", XtName($)); */
    XtTranslateCoords(self, 0, ((XfwfPullDownWidget)self)->core.height, &x, &y);
    XtVaSetValues(((XfwfPullDownWidget)self)->xfwfPullDown.popup, XtNx, x, XtNy, y, NULL);
    if (! XfwfCallProcessMenu(XtParent(self), ((XfwfPullDownWidget)self)->xfwfPullDown.popup, ((XfwfPullDownWidget)self)->xfwfPullDown.menuCursor))
	XtPopupSpringLoaded(((XfwfPullDownWidget)self)->xfwfPullDown.popup);
}

/*ARGSUSED*/
#line 226 "PullDown.w"
static void popdown_maybe(self,event,params,num_params)Widget self;XEvent*event;String*params;Cardinal*num_params;
{
    Position x, y;

    switch (event->type) {
    case ButtonRelease:
    case ButtonPress:
	x = event->xbutton.x;
	y = event->xbutton.y;
	break;
    case MotionNotify:
	x = event->xmotion.x;
	y = event->xmotion.y;
	break;
    case EnterNotify:
    case LeaveNotify:
	x = event->xcrossing.x;
	y = event->xcrossing.y;
	break;
    default:
	XtAppWarning(XtWidgetToApplicationContext(self),
		   "Incorrect event for popdown_maybe()");
    }
    if (x < 0 || ((XfwfPullDownWidget)self)->core.width <= x || y < 0 || ((XfwfPullDownWidget)self)->core.height <= y) XtPopdown(((XfwfPullDownWidget)self)->xfwfPullDown.popup);
}

static void _resolve_inheritance(class)
WidgetClass class;
{
  XfwfPullDownWidgetClass c = (XfwfPullDownWidgetClass) class;
  XfwfPullDownWidgetClass super;
  static CompositeClassExtensionRec extension_rec = {
    NULL, NULLQUARK, XtCompositeExtensionVersion,
    sizeof(CompositeClassExtensionRec), True};
  CompositeClassExtensionRec *ext;
  ext = (CompositeClassExtensionRec *)XtMalloc(sizeof(*ext));
  *ext = extension_rec;
  ext->next_extension = c->composite_class.extension;
  c->composite_class.extension = (XtPointer)ext;
  if (class == xfwfPullDownWidgetClass) return;
  super = (XfwfPullDownWidgetClass)class->core_class.superclass;
}
#line 106 "PullDown.w"
/*ARGSUSED*/static void class_initialize()
{
    XtRegisterGrabAction(open_menu, True, ButtonPressMask |
			 ButtonReleaseMask | EnterWindowMask |
			 LeaveWindowMask | PointerMotionMask,
			 GrabModeAsync, GrabModeAsync);
}
#line 120 "PullDown.w"
/*ARGSUSED*/static void initialize(request,self,args,num_args)Widget  request;Widget self;ArgList  args;Cardinal * num_args;
{
    if (((XfwfPullDownWidget)self)->xfwfPullDown.menu) ((XfwfPullDownWidget)self)->xfwfPullDown.menu = XtNewString(((XfwfPullDownWidget)self)->xfwfPullDown.menu);
    if (! ((XfwfPullDownWidget)self)->xfwfPullDown.popup && ((XfwfPullDownWidget)self)->xfwfPullDown.menu) {
	((XfwfPullDownWidget)self)->xfwfPullDown.popup = XtVaCreatePopupShell
	    ("menu", xfwfTextMenuWidgetClass, self, XtNmenu, ((XfwfPullDownWidget)self)->xfwfPullDown.menu, XtNcursor,
	     ((XfwfPullDownWidget)self)->xfwfPullDown.menuCursor, NULL);
	((XfwfPullDownWidget)self)->xfwfPullDown.own_popup = True;
	XtAddCallback(((XfwfPullDownWidget)self)->xfwfPullDown.popup, XtNactivate, activate_cb, self);
	XtAddCallback(((XfwfPullDownWidget)self)->xfwfPullDown.popup, XtNchangeSelection, change_cb, self);
    } else
	((XfwfPullDownWidget)self)->xfwfPullDown.own_popup = False;
    if (! ((XfwfPullDownWidget)self)->xfwfPullDown.popup && ((XfwfPullDownWidget)self)->xfwfPullDown.hotkey) create_accelerator(self);
}
#line 140 "PullDown.w"
/*ARGSUSED*/static Boolean  set_values(old,request,self,args,num_args)Widget  old;Widget  request;Widget self;ArgList  args;Cardinal * num_args;
{
    if (((XfwfPullDownWidget)old)->xfwfPullDown.menu != ((XfwfPullDownWidget)self)->xfwfPullDown.menu) {
	XtFree(((XfwfPullDownWidget)old)->xfwfPullDown.menu);
	((XfwfPullDownWidget)self)->xfwfPullDown.menu = XtNewString(((XfwfPullDownWidget)self)->xfwfPullDown.menu);
    }
    if (((XfwfPullDownWidget)old)->xfwfPullDown.popup != ((XfwfPullDownWidget)self)->xfwfPullDown.popup) {
	if (((XfwfPullDownWidget)self)->xfwfPullDown.own_popup && ((XfwfPullDownWidget)old)->xfwfPullDown.popup) XtDestroyWidget(((XfwfPullDownWidget)old)->xfwfPullDown.popup);
	((XfwfPullDownWidget)self)->xfwfPullDown.own_popup = False;
    } else if (((XfwfPullDownWidget)old)->xfwfPullDown.menu != ((XfwfPullDownWidget)self)->xfwfPullDown.menu) {
	((XfwfPullDownWidget)self)->xfwfPullDown.popup = XtVaCreatePopupShell
	    ("menu", xfwfTextMenuWidgetClass, self, XtNmenu, ((XfwfPullDownWidget)self)->xfwfPullDown.menu, XtNcursor,
	     ((XfwfPullDownWidget)self)->xfwfPullDown.menuCursor, NULL);
	((XfwfPullDownWidget)self)->xfwfPullDown.own_popup = True;
	XtAddCallback(((XfwfPullDownWidget)self)->xfwfPullDown.popup, XtNactivate, activate_cb, self);
	XtAddCallback(((XfwfPullDownWidget)self)->xfwfPullDown.popup, XtNchangeSelection, change_cb, self);
    }
    if (((XfwfPullDownWidget)old)->xfwfPullDown.menuCursor != ((XfwfPullDownWidget)self)->xfwfPullDown.menuCursor)
	if (((XfwfPullDownWidget)self)->xfwfPullDown.popup) XtVaSetValues(((XfwfPullDownWidget)self)->xfwfPullDown.popup, XtNcursor, ((XfwfPullDownWidget)self)->xfwfPullDown.menuCursor, NULL);
    if (((XfwfPullDownWidget)old)->xfwfPullDown.hotkey != ((XfwfPullDownWidget)self)->xfwfPullDown.hotkey)
	create_accelerator(self);
    return False;
}
