/* Generated by wbuild from "MenuBar.w"
** (generator version $Revision: 1.17 $ of $Date: 92/12/07 19:32:00 $)
*/
#include <X11/IntrinsicP.h>
#include <X11/StringDefs.h>
#line 136 "MenuBar.w"
#include <Xfwf/PullDown.h>
#line 137 "MenuBar.w"
#include <stdio.h>
#include <Xfwf/MenuBarP.h>
#line 83 "MenuBar.w"
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
);
#line 45 "MenuBar.w"
static void initialize(
#if NeedFunctionPrototypes
Widget ,Widget,ArgList ,Cardinal *
#endif
);
#line 57 "MenuBar.w"
static void insert_child(
#if NeedFunctionPrototypes
Widget 
#endif
);
#line 93 "MenuBar.w"
static char  rcsid[] = "$Ident$";
#line 102 "MenuBar.w"
static void menu_popup_cb(
#if NeedFunctionPrototypes
Widget ,XtPointer ,XtPointer 
#endif
);
#line 122 "MenuBar.w"
static void menu_popdown_cb(
#if NeedFunctionPrototypes
Widget ,XtPointer ,XtPointer 
#endif
);
#line 102 "MenuBar.w"
/*ARGSUSED*/static void menu_popup_cb(w,client_data,call_data)Widget  w;XtPointer  client_data;XtPointer  call_data;
{
    Widget self = (Widget) client_data, menu = NULL;
    Cursor cursor;

    XtVaGetValues(w, XtNpopup, &menu, NULL);
    if (menu && ((XfwfMenuBarWidget)self)->xfwfMenuBar.current_menu == menu) return;	/* Already popped up */
    if (((XfwfMenuBarWidget)self)->xfwfMenuBar.current_menu) XtPopdown(((XfwfMenuBarWidget)self)->xfwfMenuBar.current_menu);
    ((XfwfMenuBarWidget)self)->xfwfMenuBar.current_menu = menu;
    XtVaGetValues(w, XtNmenuCursor, &cursor, NULL);
    XtGrabPointer(self, True, EnterWindowMask | LeaveWindowMask |
		  ButtonPressMask | ButtonReleaseMask, GrabModeAsync,
		  GrabModeAsync, None, cursor, CurrentTime);
    XtAddGrab(self, True, False);
}
#line 122 "MenuBar.w"
/*ARGSUSED*/static void menu_popdown_cb(w,client_data,call_data)Widget  w;XtPointer  client_data;XtPointer  call_data;
{
    Widget self = (Widget) client_data;

    ((XfwfMenuBarWidget)self)->xfwfMenuBar.current_menu = NULL;
    /* XtRemoveGrab($); */
    XtUngrabPointer(self, CurrentTime);
}

static XtResource resources[] = {
#line 29 "MenuBar.w"
{XtNframeType,XtCFrameType,XtRFrameType,sizeof(((XfwfMenuBarRec*)NULL)->xfwfFrame.frameType),XtOffsetOf(XfwfMenuBarRec,xfwfFrame.frameType),XtRImmediate,(XtPointer)XfwfRaised },
};

XfwfMenuBarClassRec xfwfMenuBarClassRec = {
{ /* core_class part */
(WidgetClass) &xfwfRowColClassRec,
"XfwfMenuBar",
sizeof(XfwfMenuBarRec),
NULL,
_resolve_inheritance,
FALSE,
initialize,
NULL,
XtInheritRealize,
actionsList,
1,
resources,
1,
NULLQUARK,
False ,
FALSE ,
False ,
False ,
NULL,
XtInheritResize,
XtInheritExpose,
NULL,
NULL,
XtInheritSetValuesAlmost,
NULL,
XtInheritAcceptFocus,
XtVersion,
NULL,
defaultTranslations,
XtInheritQueryGeometry,
XtInheritDisplayAccelerator,
NULL 
},
{ /* composite_class part */
XtInheritGeometryManager,
XtInheritChangeManaged,
insert_child,
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 */
0
},
{ /* XfwfMenuBar_class part */
0
},
};
WidgetClass xfwfMenuBarWidgetClass = (WidgetClass) &xfwfMenuBarClassRec;
/*ARGSUSED*/
#line 83 "MenuBar.w"
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;
  if (class == xfwfMenuBarWidgetClass) return;
  super = (XfwfMenuBarWidgetClass) c->core_class.superclass;
}
#line 45 "MenuBar.w"
/*ARGSUSED*/static void initialize(request,self,args,num_args)Widget  request;Widget self;ArgList  args;Cardinal * num_args;
{
    ((XfwfMenuBarWidget)self)->xfwfMenuBar.current_menu = NULL;
}
#line 57 "MenuBar.w"
/*ARGSUSED*/static void insert_child(child)Widget  child;
{ Widget self = XtParent(child); {
    Widget popup = NULL;

    xfwfRowColClassRec.composite_class.insert_child(child);
    XtVaGetValues(child, XtNpopup, &popup, NULL);
    if (popup) {
	XtAddCallback(child, XtNactivate, menu_popup_cb, self);
	XtAddCallback(popup, XtNpopdownCallback, menu_popdown_cb, self);
    }
}
}
