(3)

NAME
XfwfMenuBar

DESCRIPTION
The MenuBar widget is a special kind of RowCol widget. It assumes that all its children are PullDown buttons or other widgets that pop up a menu. (But nothing will break if they are not.) By default, the children are arranged in a row, wrapping to the next row if the width is not enough for all of them. But other arrangements are possible, see the resources of the XfwfRowCol(3) widget. The MenuBar attaches itself to the popup callback of the menu shell that is popped up by the children, and inserts itself in the list of pointer grabs that Xt maintains. This is necessary to be able to drag the mouse from one menu into another, popping down the first one and popping up the second. If you use a RowCol widget instead of a MenuBar, you will find that switching from one menu to the next involves releasing the mouse and then pressing it again. To find the menu shell, the children are asked for their popup resource. PullDown buttons have this resource, others may not. The MenuBar widget introduces no new resources.

  Public variables
XfwfMenuBar
Name | Class | Type | Default

XtNframeType
     frameType = XfwfRaised
    XfwfRowCol
    Name | Class | Type | Default
    XtNstoreByRow | XtCStoreByRow | Boolean | True
    XtNrows | XtCRows | Cardinal | 0
    XtNcolumns | XtCColumns | Cardinal | 0
    XtNspacing | XtCSpacing | Cardinal | 3
    XtNalignment | XtCAlignment | Alignment | XfwfTopLeft
    XfwfBoard
    Name | Class | Type | Default
    XtNabs_x | XtCAbs_x | Int | 0
    XtNrel_x | XtCRel_x | Float | "0.0"
    XtNabs_y | XtCAbs_y | Int | 0
    XtNrel_y | XtCRel_y | Float | "0.0"
    XtNabs_width | XtCAbs_width | Int | 0
    XtNrel_width | XtCRel_width | Float | "1.0"
    XtNabs_height | XtCAbs_height | Int | 0
    XtNrel_height | XtCRel_height | Float | "1.0"
    XtNhunit | XtCHunit | Float | "1.0"
    XtNvunit | XtCVunit | Float | "1.0"
    XtNlocation | XtCLocation | String | NULL
    XfwfFrame
    Name | Class | Type | Default
    XtNcursor | XtCCursor | Cursor | None
    XtNframeType | XtCFrameType | FrameType | XfwfRaised
    XtNframeWidth | XtCFrameWidth | Dimension | 0
    XtNframeOffset | XtCFrameOffset | Dimension | 0
    XtNshadowScheme | XtCShadowScheme | ShadowScheme | XfwfAuto
    XtNlightColor | XtCLightColor | Pixel | XtDefaultBackground
    XtNdarkColor | XtCDarkColor | Pixel | XtDefaultForeground
    XtNlightStipple | XtCLightStipple | Bitmap | NULL
    XtNdarkStipple | XtCDarkStipple | Bitmap | NULL
    XfwfCommon
    Name | Class | Type | Default
    XtNtraversalOn | XtCTraversalOn | Boolean | True
    XtNhighlightThickness | XtCHighlightThickness | Dimension | 2
    XtNhighlightColor | XtCHighlightColor | Pixel | XtDefaultForeground
    XtNhighlightPixmap | XtCHighlightPixmap | Pixmap | None
    XtNnextTop | XtCNextTop | Callback | NULL
    XtNuserData | XtCUserData | Pointer | NULL
    Composite
    Name | Class | Type | Default
    XtNchildren | XtCChildren | WidgetList | NULL
    insertPosition | XtCInsertPosition | XTOrderProc | NULL
    numChildren | XtCNumChildren | Cardinal | 0
    Core
    Name | Class | Type | Default
    XtNx | XtCX | Position | 0
    XtNy | XtCY | Position | 0
    XtNwidth | XtCWidth | Dimension | 0
    XtNheight | XtCHeight | Dimension | 0
    borderWidth | XtCBorderWidth | Dimension | 0
    XtNcolormap | XtCColormap | Colormap | NULL
    XtNdepth | XtCDepth | Int | 0
    destroyCallback | XtCDestroyCallback | XTCallbackList | NULL
    XtNsensitive | XtCSensitive | Boolean | True
    XtNtranslations | XtCTranslations | XTTranslations | NULL
    ancestorSensitive | XtCAncestorSensitive | Boolean | False
    accelerators | XtCAccelerators | XTTranslations | NULL
    borderColor | XtCBorderColor | Pixel | 0
    borderPixmap | XtCBorderPixmap | Pixmap | NULL
    background | XtCBackground | Pixel | 0
    backgroundPixmap | XtCBackgroundPixmap | Pixmap | NULL
    mappedWhenManaged | XtCMappedWhenManaged | Boolean | True
    XtNscreen | XtCScreen | Screen * | NULL

  Translations
Since the MenuBar widget adds itself to the list of cascaded pop ups that is maintained by Xt, it will receive pointer events when a menu is popped up. If the event is a button release, the menu will have to be popped down.
<Btn1Up>: menu_popdown()

  Actions

menu_popdown
    The menu_popdown action calls XtPopdown for the current menu, if there is one.
    void menu_popdown($, XEvent* event, String* params, Cardinal* num_params)
    {
        if ($current_menu != NULL) {
    	XtPopdown($current_menu);
    	$current_menu = NULL;
        }
    }

Importss
For the definition of XtNpopup we need the header file for the PullDown widget.
incl
 <Xfwf/PullDown.h>
incl
 <stdio.h>

  Private variables
When the menu_callback function is called, it tries to get the ID of the popped up widget. If it succeeds, the ID is stored in a private variable, so that the widget can be popped down again, if another menu pops up.
Widget  current_menu

  Methods
The current_menu variable is intialized to NULL by the initialize method.
initialize(Widget  request, $, ArgList  args, Cardinal * num_args)
{
    $current_menu = NULL;
}
When a new child is added, it is added normally by the superclass's method, but then a callback is added for the activate of the child and the popdownCallback of the child's menu. This callback is defined in the Shell widget. The child's menu is named popup in Pulldown buttons, thus it will only work for them or their subclasses.
insert_child(Widget  child)
{
    Widget popup = NULL;
    #insert_child(child);
    XtVaGetValues(child, XtNpopup, popup, NULL);
    if (popup) {
	XtAddCallback(child, XtNactivate, menu_popup_cb, $);
	XtAddCallback(popup, XtNpopdownCallback, menu_popdown_cb, $);
    }
}

Utilities
char  rcsid[] = "$Ident$"
The callback menu_popup_cb is attached to the activate callback of a (PullDown) button. The menu_popup_cb routine establishes a new grab, overriding the one exerted by the menu, and adds the MenuBar widget in the list of cascaded menus that is maintained by Xt. This will ensure that pointer events continue to arrive at the MenuBar widget.
menu_popup_cb(Widget  w, XtPointer  client_data, XtPointer  call_data)
{
    Widget $ = (Widget) client_data, menu = NULL;
    Cursor cursor;
    XtVaGetValues(w, XtNpopup, menu, NULL);
    if (menu  $current_menu == menu) return;	/* Already popped up */
    if ($current_menu) XtPopdown($current_menu);
    $current_menu = menu;
    XtVaGetValues(w, XtNmenuCursor, cursor, NULL);
    XtGrabPointer($, True, EnterWindowMask | LeaveWindowMask |
		  ButtonPressMask | ButtonReleaseMask, GrabModeAsync,
		  GrabModeAsync, None, cursor, CurrentTime);
    XtAddGrab($, True, False);
}
When a menu is popped down again,the menu_popdown_cb function will be called. It removes the MenuBarwidget from the cascade list and resets current_menu to NULL.
menu_popdown_cb(Widget  w, XtPointer  client_data, XtPointer  call_data)
{
    Widget $ = (Widget) client_data;
    $current_menu = NULL;
    /* XtRemoveGrab($); */
    XtUngrabPointer($, CurrentTime);
}