home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / Programming / Misc / TRSICAT.LZX / CATS_CD2_TRSI / Reference_Library / lib_examples / fontreq.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-08-21  |  2.8 KB  |  92 lines

  1. ;/* fontreq.c - Execute me to compile me with Lattice 5.10
  2. LC -b1 -cfistq -v -y -j73 fontreq.c
  3. Blink FROM LIB:c.o,fontreq.o TO fontreq LIBRARY LIB:LC.lib,LIB:Amiga.lib
  4. quit
  5. **
  6. ** The following example illustrates how to use a font requester.
  7. */
  8.  
  9. #include <exec/types.h>
  10. #include <libraries/asl.h>
  11.  
  12. #include <clib/asl_protos.h>
  13. #include <clib/exec_protos.h>
  14.  
  15. #include <stdio.h>
  16.  
  17. #ifdef LATTICE
  18. int CXBRK(void)     { return(0); }  /* Disable Lattice CTRL/C handling */
  19. void chkabort(void) { return; }     /* really */
  20. #endif
  21.  
  22. UBYTE *vers = "$VER: fontreq 37.0";
  23.  
  24. struct Library *AslBase = NULL;
  25.  
  26. /* Our replacement strings for the "mode" cycle gadget.  The
  27. ** first string is the cycle gadget's label.  The other strings
  28. ** are the actual strings that will appear on the cycle gadget.
  29. */
  30. UBYTE *modelist[] =
  31. {
  32.     "RKM Modes",
  33.     "Mode 0",
  34.     "Mode 1",
  35.     "Mode 2",
  36.     "Mode 3",
  37.     "Mode 4",
  38.     NULL
  39. };
  40.  
  41.  
  42. void main(int argc, char **argv)
  43. {
  44.     struct FontRequester *fr;
  45.  
  46.     if (AslBase = OpenLibrary("asl.library", 37L))
  47.     {
  48.         if (fr = (struct FontRequester *)
  49.             AllocAslRequestTags(ASL_FontRequest,
  50.                 /* tell the requester to use my custom mode names */
  51.                 ASL_ModeList, modelist,
  52.  
  53.                 /* Supply initial values for requester */
  54.                 ASL_FontName, (ULONG)"topaz.font",
  55.                 ASL_FontHeight, 11L,
  56.                 ASL_FontStyles, FSF_BOLD | FSF_ITALIC,
  57.                 ASL_FrontPen,  0x00L,
  58.                 ASL_BackPen,   0x01L,
  59.  
  60.                 /* Only display font sizes between 8 and 14, inclusive. */
  61.                 ASL_MinHeight, 8L,
  62.                 ASL_MaxHeight, 14L,
  63.  
  64.                 /* Give all the gadgetry, but only display fixed width fonts */
  65.                 ASL_FuncFlags, FONF_FRONTCOLOR | FONF_BACKCOLOR |
  66.                     FONF_DRAWMODE | FONF_STYLES | FONF_FIXEDWIDTH,
  67.                 TAG_DONE))
  68.         {
  69.             /* Pop up the requester */
  70.             if (AslRequest(fr, NULL))
  71.             {
  72.                 /* The user selected something,  report their choice */
  73.                 printf("%s\n  YSize = %d  Style = 0x%x   Flags = 0x%x\n"
  74.                        "  FPen = 0x%x   BPen = 0x%x   DrawMode = 0x%x\n",
  75.                                fr->fo_Attr.ta_Name,
  76.                                fr->fo_Attr.ta_YSize,
  77.                                fr->fo_Attr.ta_Style,
  78.                                fr->fo_Attr.ta_Flags,
  79.                                fr->fo_FrontPen,
  80.                                fr->fo_BackPen,
  81.                                fr->fo_DrawMode);
  82.             }
  83.             else
  84.                 /* The user cancelled the requester, or some kind of error
  85.                 ** occurred preventing the requester from opening. */
  86.                 printf("Request Cancelled\n");
  87.             FreeAslRequest(fr);
  88.         }
  89.         CloseLibrary(AslBase);
  90.     }
  91. }
  92.