/* Generated by wbuild from "MenuBar.w"
** (generator version $Revision: 2.0 $ of $Date: 93/07/06 16:08:04 $)
*/
#include <X11/IntrinsicP.h>
#include <X11/StringDefs.h>
/* #include "PullDown.h" */
#include <X11/Shell.h>
#include <stdio.h>
#include "MenuBarP.h"
static void menu_popdown(
#if NeedFunctionPrototypes
Widget,XEvent*,String*,Cardinal*
#endif
);

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

static char defaultTranslations[] = "\
<Btn1Up>: menu_popdown() \n\
";
static void _resolve_inheritance(
#if NeedFunctionPrototypes
WidgetClass
#endif
);
static void initialize(
#if NeedFunctionPrototypes
Widget ,Widget,ArgList ,Cardinal *
#endif
);
static void process_menu(
#if NeedFunctionPrototypes
Widget,Widget ,Cursor 
#endif
);
static void popdown_cb(
#if NeedFunctionPrototypes
Widget ,XtPointer ,XtPointer 
#endif
);
/*ARGSUSED*/static void popdown_cb(menu,client_data,call_data)Widget  menu;XtPointer  client_data;XtPointer  call_data;
{
    Widget self = (Widget) client_data;

    XtRemoveCallback(menu, XtNpopdownCallback, popdown_cb, self);
/*
    XtUngrabKey(menu, AnyKey, AnyModifier);
    XtUngrabButton(menu, AnyButton, AnyModifier);
    XtRemoveGrab($);
*/
    ((XfwfMenuBarWidget)self)->xfwfMenuBar.current_menu = NULL;
}

static XtResource resources[] = {
{XtNframeType,XtCFrameType,XtRFrameType,sizeof(((XfwfMenuBarRec*)NULL)->xfwfFrame.frameType),XtOffsetOf(XfwfMenuBarRec,xfwfFrame.frameType),XtRImmediate,(XtPointer)XfwfRaised },
{XtNtraversalOn,XtCTraversalOn,XtRBoolean,sizeof(((XfwfMenuBarRec*)NULL)->xfwfCommon.traversalOn),XtOffsetOf(XfwfMenuBarRec,xfwfCommon.traversalOn),XtRImmediate,(XtPointer)False },
};

XfwfMenuBarClassRec xfwfMenuBarClassRec = {
{ /* core_class part */
(WidgetClass) &xfwfRowColClassRec,
"XfwfMenuBar",
sizeof(XfwfMenuBarRec),
NULL,
_resolve_inheritance,
FALSE,
initialize,
NULL,
XtInheritRealize,
actionsList,
1,
resources,
2,
NULLQUARK,
False ,
FALSE ,
False ,
False ,
NULL,
XtInheritResize,
XtInheritExpose,
NULL,
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,
},
{ /* XfwfRowCol_class part */
XtInherit_layout,
},
{ /* XfwfMenuBar_class part */
process_menu,
},
};
WidgetClass xfwfMenuBarWidgetClass = (WidgetClass) &xfwfMenuBarClassRec;
/*ARGSUSED*/
static void menu_popdown(self,event,params,num_params)Widget self;XEvent*event;String*params;Cardinal*num_params;
{
    if (((XfwfMenuBarWidget)self)->xfwfMenuBar.current_menu != NULL) {
	XtPopdown(((XfwfMenuBarWidget)self)->xfwfMenuBar.current_menu);
	((XfwfMenuBarWidget)self)->xfwfMenuBar.current_menu = NULL;
    }
}

static void _resolve_inheritance(class)
WidgetClass class;
{
  XfwfMenuBarWidgetClass c = (XfwfMenuBarWidgetClass) class;
  XfwfMenuBarWidgetClass super;
  static CompositeClassExtensionRec extension_rec = {
    NULL, NULLQUARK, XtCompositeExtensionVersion,
    sizeof(CompositeClassExtensionRec), True};
  CompositeClassExtensionRec *ext;
  ext = (XtPointer)XtMalloc(sizeof(*ext));
  *ext = extension_rec;
  ext->next_extension = c->composite_class.extension;
  c->composite_class.extension = ext;
  if (class == xfwfMenuBarWidgetClass) return;
  super = (XfwfMenuBarWidgetClass)class->core_class.superclass;
  if (c->xfwfMenuBar_class.process_menu == XtInherit_process_menu)
    c->xfwfMenuBar_class.process_menu = super->xfwfMenuBar_class.process_menu;
}
/*ARGSUSED*/static void initialize(request,self,args,num_args)Widget  request;Widget self;ArgList  args;Cardinal * num_args;
{
    ((XfwfMenuBarWidget)self)->xfwfMenuBar.current_menu = NULL;
}
/*ARGSUSED*/static void process_menu(self,menu,cursor)Widget self;Widget  menu;Cursor  cursor;
{
    if (menu == ((XfwfMenuBarWidget)self)->xfwfMenuBar.current_menu) return;
    if (((XfwfMenuBarWidget)self)->xfwfMenuBar.current_menu) XtPopdown(((XfwfMenuBarWidget)self)->xfwfMenuBar.current_menu);
    XtAddGrab(self, True, False);
/*
    XtGrabButton(menu, AnyButton, AnyModifier, True, ButtonPressMask |
		 ButtonReleaseMask | EnterWindowMask | LeaveWindowMask
		 | PointerMotionMask, GrabModeAsync, GrabModeAsync,
		 None, cursor);
    XtGrabKey(menu, AnyKey, AnyModifier, True, GrabModeAsync,
	      GrabModeAsync);
*/
    XtAddCallback(menu, XtNpopdownCallback, popdown_cb, self);
    ((XfwfMenuBarWidget)self)->xfwfMenuBar.current_menu = menu;
    XtPopup(menu, XtGrabNonexclusive);
}
/*ARGSUSED*/Boolean  XfwfCallProcessMenu(self,menu,cursor)Widget self;Widget  menu;Cursor  cursor;
{
    if (XtIsSubclass(self, xfwfMenuBarWidgetClass) && ((XfwfMenuBarWidgetClass)self->core.widget_class)->xfwfMenuBar_class.process_menu) {
	((XfwfMenuBarWidgetClass)self->core.widget_class)->xfwfMenuBar_class.process_menu(self, menu, cursor);
	return True;
    } else
	return False;
}
