home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / Programming / C / OTL-MC7.DMS / in.adf / ansicdemo.lha / ANSI-C / Asl / asl.c < prev   
Encoding:
C/C++ Source or Header  |  1994-10-30  |  8.1 KB  |  242 lines

  1. #include <exec/types.h>
  2. #include <exec/memory.h>
  3. #include <intuition/intuition.h>
  4. #include <graphics/displayinfo.h>
  5. #include <dos/dos.h>
  6. #include <dos/rdargs.h>
  7. #include <utility/hooks.h>
  8. #include <libraries/asl.h>
  9. #include <stdio.h>
  10.  
  11. #include <pragma/dos_lib.h>
  12. #include <pragma/exec_lib.h>
  13. #include <pragma/intuition_lib.h>
  14. #include <pragma/asl_lib.h>
  15.  
  16.  
  17. /*****************************************************************************/
  18.  
  19.  
  20. extern struct Library *SysBase;
  21. extern struct Library *DOSBase;
  22.        struct Library *GfxBase;
  23.        struct Library *IntuitionBase;
  24.        struct Library *GadToolsBase;
  25.        struct Library *UtilityBase;
  26.        struct Library *AslBase;
  27.  
  28.  
  29. /*****************************************************************************/
  30.  
  31.  
  32. VOID main(VOID)
  33. {
  34. struct FileRequester       *fr;
  35. struct FontRequester       *fo;
  36. struct ScreenModeRequester *smr;
  37. struct Hook                 modehook;
  38. struct DisplayMode          dmode;
  39. struct DimensionInfo       *di;
  40. struct List                 list;
  41. BOOL                        going;
  42.  
  43.     /* open all basic libraries in case we need 'em later */
  44.     IntuitionBase = OpenLibrary("intuition.library", 37);
  45.     GfxBase       = OpenLibrary("graphics.library", 37);
  46.     GadToolsBase  = OpenLibrary("gadtools.library", 37);
  47.     UtilityBase   = OpenLibrary("utility.library", 37);
  48.     AslBase       = OpenLibrary("asl.library", 38);
  49.  
  50.     /* check if we got everything we need */
  51.     if (IntuitionBase && GfxBase && GadToolsBase && UtilityBase && AslBase)
  52.     {
  53.         going = TRUE;
  54.  
  55.         if (going)
  56.         {
  57.             /* bring up a plain file requester */
  58.             if (fr = ( struct FileRequester *)AllocAslRequestTags(ASL_FileRequest,
  59.                                          TAG_DONE))
  60.             {
  61.                 going = AslRequest(fr,NULL);
  62.  
  63.                 printf("Drawer: [%s]\nFile  : [%s]\n", fr->fr_Drawer, fr->fr_File);
  64.  
  65.                 FreeAslRequest(fr);
  66.             }
  67.         }
  68.  
  69.         if (going)
  70.         {
  71.             /* bring up a directory requester */
  72.             if (fr = ( struct FileRequester *)AllocAslRequestTags(ASL_FileRequest,
  73.                                          ASLFR_DrawersOnly, TRUE,
  74.                                          TAG_DONE))
  75.             {
  76.                 going = AslRequest(fr,NULL);
  77.  
  78.                 printf("Drawer: [%s]\n", fr->fr_Drawer);
  79.  
  80.                 FreeAslRequest(fr);
  81.             }
  82.         }
  83.  
  84.         if (going)
  85.         {
  86.             /* bring up a save mode requester with a pattern gadget, and custom
  87.              * text for the positive and negative action gadgets
  88.              */
  89.             if (fr = ( struct FileRequester *)AllocAslRequestTags(ASL_FileRequest,
  90.                                          ASLFR_DoPatterns,   TRUE,
  91.                                          ASLFR_DoSaveMode,   TRUE,
  92.                                          ASLFR_PositiveText, "Save Me, Please!",
  93.                                          ASLFR_NegativeText, "I'm Not Ready",
  94.                                          TAG_DONE))
  95.             {
  96.                 going = AslRequest(fr,NULL);
  97.  
  98.                 printf("Drawer: [%s]\nFile  : [%s]\n", fr->fr_Drawer, fr->fr_File);
  99.  
  100.                 FreeAslRequest(fr);
  101.             }
  102.         }
  103.  
  104.         if (going)
  105.         {
  106.             /* bring up a plain font requester */
  107.             if (fo = ( struct FontRequester *)AllocAslRequestTags(ASL_FontRequest,
  108.                                          TAG_DONE))
  109.             {
  110.                 going = AslRequest(fo,NULL);
  111.  
  112.                 printf("Font: [%s]\nSize: %ld\n", fo->fo_Attr.ta_Name,fo->fo_Attr.ta_YSize);
  113.  
  114.                 FreeAslRequest(fo);
  115.             }
  116.         }
  117.  
  118.         if (going)
  119.         {
  120.             /* bring up a font requester which allows style selections */
  121.             if (fo = ( struct FontRequester *)AllocAslRequestTags(ASL_FontRequest,
  122.                                          ASLFO_DoStyle,    TRUE,
  123.                                          TAG_DONE))
  124.             {
  125.                 going = AslRequest(fo,NULL);
  126.  
  127.                 printf("Font : [%s]\nSize : %ld\nStyle: %lx\n", fo->fo_Attr.ta_Name,fo->fo_Attr.ta_YSize,fo->fo_Attr.ta_Style);
  128.  
  129.                 FreeAslRequest(fo);
  130.             }
  131.         }
  132.  
  133.         if (going)
  134.         {
  135.             /* bring up a font requester with a front pen selector */
  136.             if (fo = ( struct FontRequester *)AllocAslRequestTags(ASL_FontRequest,
  137.                                          ASLFO_DoFrontPen, TRUE,
  138.                                          TAG_DONE))
  139.             {
  140.                 going = AslRequest(fo,NULL);
  141.  
  142.                 printf("Font     : [%s]\nSize     : %ld\nFront Pen: %lx\n", fo->fo_Attr.ta_Name,fo->fo_Attr.ta_YSize,fo->fo_FrontPen);
  143.  
  144.                 FreeAslRequest(fo);
  145.             }
  146.         }
  147.  
  148.         if (going)
  149.         {
  150.             /* bring up a font requester with front and back pen selectors,
  151.              * and drawing mode selector
  152.              */
  153.             if (fo = ( struct FontRequester *)AllocAslRequestTags(ASL_FontRequest,
  154.                                          ASLFO_DoFrontPen, TRUE,
  155.                                          ASLFO_DoBackPen,  TRUE,
  156.                                          ASLFO_DoDrawMode, TRUE,
  157.                                          TAG_DONE))
  158.             {
  159.                 going = AslRequest(fo,NULL);
  160.  
  161.                 FreeAslRequest(fo);
  162.             }
  163.         }
  164.  
  165.         if (going)
  166.         {
  167.             /* bring up a font requester with everything in it */
  168.             if (fo = ( struct FontRequester *)AllocAslRequestTags(ASL_FontRequest,
  169.                                          ASLFO_DoStyle,    TRUE,
  170.                                          ASLFO_DoFrontPen, TRUE,
  171.                                          ASLFO_DoBackPen,  TRUE,
  172.                                          ASLFO_DoDrawMode, TRUE,
  173.                                          TAG_DONE))
  174.             {
  175.                 going = AslRequest(fo,NULL);
  176.  
  177.                 FreeAslRequest(fo);
  178.             }
  179.         }
  180.  
  181.         if (going)
  182.         {
  183.             /* bring up a plain screen mode requester */
  184.             if (smr = ( struct ScreenModeRequester *)AllocAslRequestTags(ASL_ScreenModeRequest,
  185.                                           TAG_DONE))
  186.             {
  187.                 going = AslRequest(smr,NULL);
  188.  
  189.                 printf("DisplayID: [$%08lx]\n",smr->sm_DisplayID);
  190.  
  191.                 FreeAslRequest(smr);
  192.             }
  193.         }
  194.  
  195.         if (going)
  196.         {
  197.             if (smr = ( struct ScreenModeRequester *)AllocAslRequestTags(ASL_ScreenModeRequest,
  198.                                           ASLSM_DoWidth,        FALSE,
  199.                                           ASLSM_DoHeight,       FALSE,
  200.                                           ASLSM_DoDepth,        TRUE,
  201.                                           ASLSM_DoAutoScroll,   FALSE,
  202.                                           ASLSM_DoOverscanType, TRUE,
  203.                                           TAG_DONE))
  204.             {
  205.                 going = AslRequest(smr,NULL);
  206.  
  207.                 FreeAslRequest(smr);
  208.             }
  209.         }
  210.  
  211.         if (going)
  212.         {
  213.             /* bring up a screen mode requester with more gadgets, that shows
  214.              * every mode available, except dual playfield modes
  215.              */
  216.             if (smr = ( struct ScreenModeRequester *)AllocAslRequestTags(ASL_ScreenModeRequest,
  217.                                           ASLSM_DoWidth,        TRUE,
  218.                                           ASLSM_DoHeight,       TRUE,
  219.                                           ASLSM_DoDepth,        TRUE,
  220.                                           ASLSM_DoAutoScroll,   FALSE,
  221.                                           ASLSM_DoOverscanType, FALSE,
  222.                                           ASLSM_PropertyFlags,  0,
  223.                                           ASLSM_PropertyMask,   DIPF_IS_DUALPF | DIPF_IS_PF2PRI,
  224.                                           TAG_DONE))
  225.             {
  226.                 going = AslRequest(smr,NULL);
  227.  
  228.                 FreeAslRequest(smr);
  229.             }
  230.         }
  231.     }
  232.  
  233.     if (IntuitionBase)  /* this will be always true when under >= V37 */
  234.     {
  235.         CloseLibrary(AslBase);
  236.         CloseLibrary(UtilityBase);
  237.         CloseLibrary(GadToolsBase);
  238.         CloseLibrary(GfxBase);
  239.         CloseLibrary(IntuitionBase);
  240.     }
  241. }
  242.