//##ex mcpp:cppc -gs -o fontreq p:pLib/StartCode.o -pc fontreq.c p:pLib/StdIO.o -l pOSxA -l pOSStub -l pOS -l List

/*\
*** 29.01.1997, Michael Christoph, proDAD
*** Example:
*** Tag ASLFO_ModeList, ASLFO_InitialStyle, ASLFO_InitialFrontPen,
***     ASLFO_InitialBackPen, ASLFO_MinHeight, ASLFO_MaxHeight,
***     ASLFO_Flags wird von pOS nicht unterstützt
\*/

#include <exec/types.h>
#include <libraries/asl.h>

#include <clib/asl_protos.h>
#include <clib/exec_protos.h>

#include <stdio.h>

#ifdef __pOS__
#include "p:clib/pExec_protos.h"
#endif

#ifdef LATTICE
int CXBRK(void)     { return(0); }  /* Disable Lattice CTRL/C handling */
void chkabort(void) { return; }     /* really */
#endif

UBYTE *vers = "$VER: fontreq 1.0 (29.01.1997)  (proDAD, Michael Christoph)";

#ifdef __pOS__
struct pOS_pSLBase *gb_PSLBase;
#else
struct Library *AslBase = NULL;
#endif

/* Our replacement strings for the "mode" cycle gadget.  The
** first string is the cycle gadget's label.  The other strings
** are the actual strings that will appear on the cycle gadget.
*/
UBYTE *modelist[] =
{
    "RKM Modes",
    "Mode 0",
    "Mode 1",
    "Mode 2",
    "Mode 3",
    "Mode 4",
    NULL
};


void main(int argc, char **argv)
{
    struct FontRequester *fr;

#ifdef __pOS__
    if(gb_PSLBase=(struct pOS_pSLBase*) pOS_OpenLibrary("psl.library",0))
#else
    if (AslBase = OpenLibrary("asl.library", 37L))
#endif
    {
        if (fr = (struct FontRequester *)
            AllocAslRequestTags(ASL_FontRequest,
#ifdef __pOS__
#else
                /* tell the requester to use my custom mode names */
                ASL_ModeList, modelist,
#endif

                /* Supply initial values for requester */
                ASL_FontName, (ULONG)"topaz.font",
                ASL_FontHeight, 11L,
#ifdef __pOS__
#else
                ASL_FontStyles, FSF_BOLD | FSF_ITALIC,
                ASL_FrontPen,  0x00L,
                ASL_BackPen,   0x01L,

                /* Only display font sizes between 8 and 14, inclusive. */
                ASL_MinHeight, 8L,
                ASL_MaxHeight, 14L,

                /* Give all the gadgetry, but only display fixed width fonts */
                ASL_FuncFlags, FONF_FRONTCOLOR | FONF_BACKCOLOR |
                    FONF_DRAWMODE | FONF_STYLES | FONF_FIXEDWIDTH,
#endif

                TAG_DONE))
        {
            /* Pop up the requester */
            if (AslRequest(fr, NULL))
            {
                /* The user selected something,  report their choice */
                printf("%s\n  YSize = %d  Style = 0x%x   Flags = 0x%x\n"
                       "  FPen = 0x%x   BPen = 0x%x   DrawMode = 0x%x\n",
                               fr->fo_Attr.ta_Name,
                               fr->fo_Attr.ta_YSize,
                               fr->fo_Attr.ta_Style,
                               fr->fo_Attr.ta_Flags,
                               fr->fo_FrontPen,
                               fr->fo_BackPen,
                               fr->fo_DrawMode);
            }
            else
                /* The user cancelled the requester, or some kind of error
                ** occurred preventing the requester from opening. */
                printf("Request Cancelled\n");
            FreeAslRequest(fr);
        }
#ifdef __pOS__
        pOS_CloseLibrary((struct pOS_Library *)gb_PSLBase);
#else
        CloseLibrary(AslBase);
#endif
    }
}
