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

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

/* ARGSUSED */
void
CreateHypeLabel(w, client, call)
Widget w;
XtPointer client;
XtPointer call;
{
    Arg args[5];
    Cardinal argcnt;
    XmString xmstring;

    xmstring = XmStringCreateLtoR(
"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).",
				  XmSTRING_DEFAULT_CHARSET);
    argcnt = 0;
    XtSetArg(args[argcnt], XmNalignment, XmALIGNMENT_BEGINNING); argcnt++;
    XtSetArg(args[argcnt], XmNlabelString, xmstring); argcnt++;
    XtSetValues(w, args, argcnt);
}

/* ARGSUSED */
void
ShowFontValChCB(w, client, call)
Widget w;
XtPointer client;
XtPointer call;
{
    Arg args[5];
    Cardinal argcnt;

    argcnt = 0;
    XtSetArg(args[argcnt], XmNshowFontName, XmToggleButtonGetState(w)); 
    argcnt++;
    XtSetValues(G_font, args, argcnt);
}

/* ARGSUSED */
void
ExplainCB(w, client, call)
Widget w;
XtPointer client;
XtPointer call;
{
    Arg args[5];
    Cardinal argcnt;
    XmString xmstring=NULL;
    static Widget info = NULL;
    int explain = (int) client;

    if (info == NULL) {
	Widget temp;

	argcnt = 0;
	XtSetArg(args[argcnt], XmNtitle, "Explanation"); argcnt++;
	info = XmCreateInformationDialog(w, "explain", args, argcnt);

	temp = XmMessageBoxGetChild(info, XmDIALOG_CANCEL_BUTTON);
	XtUnmanageChild(temp);
	temp = XmMessageBoxGetChild(info, XmDIALOG_HELP_BUTTON);
	XtUnmanageChild(temp);
    }

    switch (explain) {
    case EXPLAIN_SHOWFONT:
	xmstring = XmStringCreateLtoR(
"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.",
				      XmSTRING_DEFAULT_CHARSET);
	break;
    case EXPLAIN_CURFONT:
	xmstring = XmStringCreateLtoR(
"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.",
				      XmSTRING_DEFAULT_CHARSET);
	break;
    default:
	break;
    }

    argcnt = 0;
    XtSetArg(args[argcnt], XmNmessageString, xmstring); argcnt++;
    XtSetValues(info, args, argcnt);

    XmStringFree(xmstring);

    XtManageChild(info);
}

/* ARGSUSED */
void
ShowCurFont(w, client, call)
Widget w;
XtPointer client;
XtPointer call;
{
    Arg args[5];
    Cardinal argcnt;
    XmString xmstring;
    static Widget info = NULL;
    String fontname;

    argcnt = 0;
    XtSetArg(args[argcnt], XmNcurrentFont, &fontname); argcnt++;
    XtGetValues(G_font, args, argcnt);

    if (info == NULL) {
	Widget temp;

	argcnt = 0;
	XtSetArg(args[argcnt], XmNtitle, "Current Font"); argcnt++;
	info = XmCreateInformationDialog(w, "explain", args, argcnt);

	temp = XmMessageBoxGetChild(info, XmDIALOG_CANCEL_BUTTON);
	XtUnmanageChild(temp);
	temp = XmMessageBoxGetChild(info, XmDIALOG_HELP_BUTTON);
	XtUnmanageChild(temp);
    }

    if (fontname == NULL)
	xmstring = XmStringCreateSimple("No Current Font");
    else
	xmstring = XmStringCreateSimple(fontname);

    argcnt = 0;
    XtSetArg(args[argcnt], XmNmessageString, xmstring); argcnt++;
    XtSetValues(info, args, argcnt);

    XmStringFree(xmstring);
    XtManageChild(info);
}

/* ARGSUSED */
void
ShowOtherCB(w, client, call)
Widget w;
XtPointer client;
XtPointer call;
{
    Arg args[5];
    Cardinal argcnt;
    XmString xmstring;
    static Widget info = NULL;

    if (info == NULL) {
	Widget temp;

	argcnt = 0;
	XtSetArg(args[argcnt], XmNtitle, "Other Resources"); argcnt++;
	info = XmCreateInformationDialog(w, "explain", args, argcnt);

	temp = XmMessageBoxGetChild(info, XmDIALOG_CANCEL_BUTTON);
	XtUnmanageChild(temp);
	temp = XmMessageBoxGetChild(info, XmDIALOG_HELP_BUTTON);
	XtUnmanageChild(temp);
    }

    xmstring = XmStringCreateLtoR(
"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",
				  XmSTRING_DEFAULT_CHARSET);

    argcnt = 0;
    XtSetArg(args[argcnt], XmNmessageString, xmstring); argcnt++;
    XtSetValues(info, args, argcnt);

    XmStringFree(xmstring);

    XtManageChild(info);
}

/* ARGSUSED */
void
QuitCB(w, client, call)
Widget w;
XtPointer client;
XtPointer call;
{
    exit(0);
}
