#include <stdio.h>
#include <X11/Intrinsic.h>
#include <X11/StringDefs.h>
#include <X11/Xaw/Command.h>
#include <X11/Xaw/Paned.h>
#include <X11/Xaw/Box.h>
#include <X11/Xaw/MenuButton.h>
#include <Xfwf/Frame.h>

static XtAppContext app_context;
static Widget toplevel, vp, tester1, tester2, tester3, tester4;
static Widget button1, button2, button3, button4, button5, box4;

static String fallback_resources[] = {
    "FrameT.width: 370",
    "FrameT.height: 280",
    "FrameT*borderWidth: 0",

    "*tester1.frameType: chiseled",
    "*tester1.frameOffset: 10",
    "*tester1.frameWidth: 10",
    "*tester1.background: SteelBlue1",
    "*button1.background: SteelBlue1",
    "*button1.label: 10 pixels wide \"chiseled\" frame",

    "*tester2.frameType: ledged",
    "*tester2.frameOffset: 10",
    "*tester2.frameWidth: 8",
    "*tester2.background: MediumOrchid1",
    "*button2.background: MediumOrchid1",
    "*button2.label: 8 pixels wide \"ledged\" frame",

    "*tester3.frameType: raised",
    "*tester3.frameOffset: 10",
    "*tester3.frameWidth: 6",
    "*tester3.background: OrangeRed1",
    "*button3.background: OrangeRed1",
    "*button3.label: 6 pixels wide \"raised\" frame",

    "*tester4.frameType: sunken",
    "*tester4.frameOffset: 10",
    "*tester4.frameWidth: 4",
    "*tester4.background: VioletRed1",
    "*button4.background: VioletRed3",
    "*button4.label: 4 pixels wide \"sunken\" frame",
    "*button5.background: VioletRed4",
    "*button5.label: iconify the window",

    NULL,
};

static void IconifyShell(widget, clientData, callData)
    Widget widget;
    XtPointer clientData;
    XtPointer callData;
{
    XIconifyWindow(XtDisplay(toplevel), XtWindow(toplevel), 
		   XScreenNumberOfScreen(XtScreen(toplevel)));
}

static void quit(widget, client_data, call_data)
    Widget widget;
    XtPointer client_data, call_data;
{
    exit(0);
}

void main(argc, argv)
    Cardinal argc;
    char *argv[];
{
    toplevel = XtVaAppInitialize(&app_context, "FrameT", NULL, 0,
				  &argc, argv, fallback_resources, NULL);
    XSynchronize(XtDisplay(toplevel), True);
    vp = XtVaCreateManagedWidget
	("pane", panedWidgetClass, toplevel, NULL);
    tester1 = XtVaCreateManagedWidget
	("tester1", xfwfFrameWidgetClass, vp, NULL);
    button1 = XtVaCreateManagedWidget
	("button1", commandWidgetClass, tester1, NULL);
    tester2 = XtVaCreateManagedWidget
	("tester2", xfwfFrameWidgetClass, vp, NULL);
    button2 = XtVaCreateManagedWidget
	("button2", commandWidgetClass, tester2, NULL);
    tester3 = XtVaCreateManagedWidget
	("tester3", xfwfFrameWidgetClass, vp, NULL);
    button3 = XtVaCreateManagedWidget
	("button3", commandWidgetClass, tester3, NULL);
    tester4 = XtVaCreateManagedWidget
	("tester4", xfwfFrameWidgetClass, vp, NULL);
    box4 = XtVaCreateManagedWidget
	("button4", boxWidgetClass, tester4, NULL);
    button4 = XtVaCreateManagedWidget
	("button4", commandWidgetClass, box4, NULL);
    button5 = XtVaCreateManagedWidget
	("button5", commandWidgetClass, box4, NULL);
    XtAddCallback(button1, XtNcallback, quit, NULL);
    XtAddCallback(button2, XtNcallback, quit, NULL);
    XtAddCallback(button3, XtNcallback, quit, NULL);
    XtAddCallback(button4, XtNcallback, quit, NULL);
    XtAddCallback(button5, XtNcallback, IconifyShell, NULL);
    XtRealizeWidget(toplevel);
    XtAppMainLoop(app_context);
}
