/*
 * Generated by the ICS builderXcessory (BX).
 *
 *
 * Builder Xcessory 3.0A.
 *
 */
/**************************************************************
 *		INCLUDES
 **************************************************************/
#include <Xm/Xm.h>
#include <Xm/ToggleB.h>
#include <Xm/MessageB.h>
#include <Xm/FontS.h>
#include "fontsel.h"

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#if HAVE_STDINT_H
#include <stdint.h>
#elif HAVE_INTTYPES_H
#include <inttypes.h>
#endif

/**************************************************************
 *		GLOBALS' EXTERNS
 **************************************************************/
extern Widget G_font;
extern XtAppContext app;

void CreateHypeLabel(Widget w, XtPointer client, XtPointer call)
{
    Arg args[2];
    XmString xmstring;

	(void)client;
	(void)call;
    xmstring = XmStringCreateLocalized(
"The Motif Font Selector lets the developer add font selecting capabilities into their applications.\n\
The Font Selector allows the end user to choose particular fonts based on font family, size,\n\
weight, and other advanced criteria from the X Logical Font Description (XFLD).");

    XtSetArg(args[0], XmNalignment, XmALIGNMENT_BEGINNING);
    XtSetArg(args[1], XmNlabelString, xmstring);
    XtSetValues(w, args, 2);
}

void ShowFontValChCB(Widget w, XtPointer client, XtPointer call)
{
    Arg args[1];

	(void)client;
	(void)call;
    XtSetArg(args[0], XmNshowFontName, XmToggleButtonGetState(w));
    XtSetValues(G_font, args, 1);
}

void ExplainCB(Widget w, XtPointer client, XtPointer call)
{
    Arg args[1];
    XmString xmstring=NULL;
    static Widget info = NULL;

	(void)call;
    if (!info) {
	XtSetArg(args[0], XmNtitle, "Explanation");
	info = XmCreateInformationDialog(w, "explain", args, 1);
	XtUnmanageChild(XtNameToWidget(info, "Cancel"));
	XtUnmanageChild(XtNameToWidget(info, "Help"));
    }

    switch ((intptr_t)client) {
    case EXPLAIN_SHOWFONT:
	xmstring = XmStringCreateLocalized(
"The Font Selector widget can display the name of the current font\n\
directly on the widget itself. Press the \"Show Font on Widget\" toggle\n\
button to see this behavior.");
	break;
    case EXPLAIN_CURFONT:
	xmstring = XmStringCreateLocalized(
"Getting and Setting the XmNcurrentFont resource results in obtaining\n\
or setting the current font displayed by the Font Selector widget. Press\n\
the \"Show Current Font...\" button to see the current font displayed in\n\
a separate dialog.");
	break;
    default:
	break;
    }

    XtSetArg(args[0], XmNmessageString, xmstring);
    XtSetValues(info, args, 1);
    XmStringFree(xmstring);
    XtManageChild(info);
}

void ShowCurFont(Widget w, XtPointer client, XtPointer call)
{
    Arg args[1];
    XmString xmstring;
    static Widget info = NULL;
    String fontname;

	(void)client;
	(void)call;
    XtSetArg(args[0], XmNcurrentFont, &fontname);
    XtGetValues(G_font, args, 1);

    if (!info) {
	XtSetArg(args[0], XmNtitle, "Current Font");
	info = XmCreateInformationDialog(w, "explain", args, 1);
	XtUnmanageChild(XtNameToWidget(info, "Cancel"));
	XtUnmanageChild(XtNameToWidget(info, "Help"));
    }

    xmstring = XmStringCreateLocalized(fontname ? fontname : "No Current Font");
    XtSetArg(args[0], XmNmessageString, xmstring);
    XtSetValues(info, args, 1);
    XmStringFree(xmstring);
    XtManageChild(info);
}

void ShowOtherCB(Widget w, XtPointer client, XtPointer call)
{
    Arg args[1];
    XmString xmstring;
    static Widget info = NULL;

	(void)client;
	(void)call;

    if (!info) {
	XtSetArg(args[0], XmNtitle, "Other Resources");
	info = XmCreateInformationDialog(w, "explain", args, 1);
	XtUnmanageChild(XtNameToWidget(info, "Cancel"));
	XtUnmanageChild(XtNameToWidget(info, "Help"));
    }

    xmstring = XmStringCreateLocalized(
"The Font Selector Widget has a few other resources to control its\n\
appearance:\n\
\n\
     Resource - Type - Explanation\n\
\n\
     isoFontsOnly - Boolean - Show only ISO8859-1 fonts\n\
     textRows - Dimension - Number of rows shown in the text widget\n\
     useScaling - Boolean - Controls \"Use Font Scaling\" toggle");

    XtSetArg(args[0], XmNmessageString, xmstring);
    XtSetValues(info, args, 1);
    XmStringFree(xmstring);
    XtManageChild(info);
}

void QuitCB(Widget w, XtPointer client, XtPointer call)
{
	(void)w;
	(void)client;
	(void)call;
    XtAppSetExitFlag(app);
}

