/* MenuBarT -- test program for the MenuBar widget */

#include <stdio.h>
#include <X11/Intrinsic.h>
#include <X11/StringDefs.h>
#include <Xfwf/Board.h>
#include <Xfwf/Label.h>
#include <Xfwf/MenuBar.h>
#include <Xfwf/PullDown.h>
#include <Xfwf/OptButton.h>

static String fallback_resources[] = {
    "MenuBarT.width: 450",
    "MenuBarT.height: 200",

    /* "*board.frameWidth: 0", */
    /* "*board.frameType: sunken", */
    "*board.highlightThickness: 0",

    "*menubar.location: 0 0 1.0 40",
    "*menubar.frameWidth: 2",
    "*menubar.frameType: raised",
    "*menubar.highlightThickness: 0",

    "*menu1.label: menu 1",
    "*menu1.hotkey: Alt<Key>1",
    "*menu1.menu:\
	(item \"first item\" (action \"first_action()\"))\
	(item \"second item\" (action \"second_action()\"))\
	(item \"quit\" (action \"quit()\"))",
	    
    "*menu2.label: menu 2",
    "*menu2.hotkey: Alt<Key>2",
    "*menu2.menu:\
	(item \"third item\" (action \"third_action()\"))\
	(item \"fourth item\" (action \"fourth_action()\"))",

    "*opt.label: <none>",
    "*opt.options:\
Sunday\\n\
Monday\\n\
Tuesday\\n\
Wednesday\\n\
Thursday\\n\
Friday\\n\
Saturday",

    "*explain.location: 0 40 1.0 1.0-42",
    "*explain.alignment: top left",
    "*explain.frameWidth: 2",
    "*explain.frameType: sunken",
    /* "*explain.highlightThickness: 0", */
    "*explain.label: \
This program shows a menubar with three\\n\
pull-down menus. The third menu is actually\\n\
an option button, i.e., it shows the most\\n\
recently chosen item as its label. None of the\\n\
entries does anything, except for `Quit',\\n\
which stops the program.",

    NULL,
};

static void quit(w, event, params, num_params)
    Widget w;
    XEvent *event;
    String *params;
    Cardinal *num_params;
{
    exit(0);
}

static XtActionsRec actions[] = {
    "quit", quit,
};

static Widget toplevel, board, menubar, menu1, menu2, opt, explain;
static XtAppContext app_context;

int main(argc, argv)
    Cardinal argc;
    String *argv;
{
    toplevel = XtVaAppInitialize
	(&app_context, "MenuBarT", NULL, 0, &argc, argv,
	 fallback_resources, NULL);
    XtAppAddActions(app_context, actions, XtNumber(actions));
    board = XtVaCreateManagedWidget
	("board", xfwfBoardWidgetClass, toplevel, NULL);
    menubar = XtVaCreateManagedWidget
	("menubar", xfwfMenuBarWidgetClass, board, NULL);
    menu1 = XtVaCreateManagedWidget
	("menu1", xfwfPullDownWidgetClass, menubar, NULL);
    menu2 = XtVaCreateManagedWidget
	("menu2", xfwfPullDownWidgetClass, menubar, NULL);
    opt = XtVaCreateManagedWidget
	("opt", xfwfOptionButtonWidgetClass, menubar, NULL);
    explain = XtVaCreateManagedWidget
	("explain", xfwfLabelWidgetClass, board, NULL);
    XtRealizeWidget(toplevel);
    XtAppMainLoop(app_context);
}
