home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 8 / FreshFishVol8-CD1.bin / new / util / batch / dosreqtools / dosextensions / requestersrc / rtscreenmoderequest.c < prev   
C/C++ Source or Header  |  1994-11-16  |  8KB  |  245 lines

  1.  
  2. #include <dos/dos.h>
  3. #include <dos/rdargs.h>
  4. #include <clib/dos_protos.h>
  5. #include <stdio.h>
  6. #include <string.h>
  7. #include <exec/lists.h>
  8.  
  9. #include <libraries/reqtools.h>
  10.  
  11. #include <functions.h>
  12.  
  13. static char version_string[] = "$VER: rtScreenModeRequest 2.3 (16.11.94)";
  14.  
  15. char MyExtHelp[] =
  16. "\n"
  17. "Usage: rtScreenModeRequest\n"
  18. "\n"
  19. " TITLE,OVERSCANGAD/S,AUTOSCROLLGAD/S,SIZEGADS/S,DEPTHGAD/S,NONSTDMODES/S,\n"
  20. " GUIMODES/S,HEIGHT/N/K,OKTEXT/K,MINWIDTH/N/K,MAXWIDTH/N/K,MINHEIGHT/N/K,\n"
  21. " MAXHEIGHT/N/K,MINDEPTH/N/K,MAXDEPTH/N/K,PROPERTYFLAGS/N/K,PROPERTYMASK/N/K,\n"
  22. " POSITION=POS/K,TOPOFFSET=TOP/N/K,LEFTOFFSET=LEFT/N/K,PUBSCREEN/K\n" 
  23. "\n"
  24. "  TITLE        <text> - Title text for requester window.\n"
  25. "  OVERSCANGAD         - Add an overscan gadget to the requester.\n"
  26. "  AUTOSCROLLGAD       - Add an autoscroll checkbox gadget to the requester.\n"
  27. "  SIZEGADS            - Add width and height gadgets to the requester.\n"
  28. "  DEPTHGAD            - Add a depth slider gadget to the requester.\n"
  29. "  NONSTDMODES         - Include all modes. Unless set, rtScreenModeRequest\n"
  30. "                        will exclude nonstandard modes. (presently HAM and\n"
  31. "                        EHB (ExtraHalfBrite))\n"
  32. "  GUIMODES            - Get screen mode to open a user interface screen in.\n"
  33. "  HEIGHT        <num> - Suggested height of screenmode requester window.\n"
  34. "  OKTEXT       <text> - Replacement text for \"Ok\" gadget, max 6 chars.\n"
  35. "  MINWIDTH      <num> - The minimum display width allowed.\n"
  36. "  MAXWIDTH      <num> - The maximum display width allowed.\n"
  37. "  MINHEIGHT     <num> - The minimum display height allowed.\n"
  38. "  MAXHEIGHT     <num> - The maximum display height allowed.\n"
  39. "  MINDEPTH      <num> - The minimum display depth allowed.\n"
  40. "  MAXDEPTH      <num> - The maximum display depth allowed.\n"
  41. "  PROPERTYFLAGS <num> - A mode must have these property flags to be included.\n"
  42. "  PROPERTYMASK  <num> - Mask to apply to PropertyFlags to determine which bits\n"
  43. "                        to consider.\n"
  44. "  POSITION   <pos> - Open requester window at <pos>.  Permissible values are:\n"
  45. " >or POS             CENTERSCR, TOPLEFTSCR, CENTERWIN, TOPLEFTWIN, POINTER.\n"
  46. "  TOPOFFSET  <num> - Offset position relative to above.\n"
  47. " >or TOP\n"
  48. "  LEFFTOFFSET <num>- Offset position relative to above.\n"
  49. " >or LEFT\n"
  50. "  PUBSCREEN <screen> - Public screen name.\n";
  51.  
  52. #define TEMPLATE "TITLE/A,OVERSCANGAD/S,AUTOSCROLLGAD/S,SIZEGADS/S,DEPTHGAD/S,NONSTDMODES/S,GUIMODES/S,HEIGHT/N/K,OKTEXT/K,MINWIDTH/N/K,MAXWIDTH/N/K,MINHEIGHT/N/K,MAXHEIGHT/N/K,MINDEPTH/N/K,MAXDEPTH/N/K,PROPERTYFLAGS/N/K,PROPERTYMASK/N/K,POSITION=POS/K,TOPOFFSET=TOP/N/K,LEFTOFFSET=LEFT/N/K,PUBSCREEN/K"
  53.  
  54.  
  55. #define OPT_TITLE 0
  56. #define OPT_OVERSCANGAD 1
  57. #define OPT_AUTOSCROLLGAD 2
  58. #define OPT_SIZEGADS 3
  59. #define OPT_DEPTHGAD 4
  60. #define OPT_NONSTDMODES 5
  61. #define OPT_GUIMODES 6
  62. #define OPT_HEIGHT 7
  63. #define OPT_OKTEXT 8
  64. #define OPT_MINWIDTH 9
  65. #define OPT_MAXWIDTH 10
  66. #define OPT_MINHEIGHT 11
  67. #define OPT_MAXHEIGHT 12
  68. #define OPT_MINDEPTH 13
  69. #define OPT_MAXDEPTH 14
  70. #define OPT_PROPERTYFLAGS 15
  71. #define OPT_PROPERTYMASK 16
  72. #define OPT_POSITION 17
  73. #define OPT_TOPOFFSET 18
  74. #define OPT_LEFTOFFSET 19
  75. #define OPT_PUBSCREEN 20
  76. #define OPT_COUNT 21
  77.  
  78. struct Library *ReqToolsBase;
  79.  
  80. int
  81. main (int argc, char **argv)
  82. {
  83.   int retval = 0;
  84.  
  85.   if (argc)
  86.     {
  87.       if ((argc == 2) && (stricmp (argv[1], "HELP") == 0))
  88.     {
  89.       fprintf (stdout, "%s", MyExtHelp);
  90.     }
  91.       else
  92.     {
  93.       /* My custom RDArgs */
  94.       struct RDArgs *myrda;
  95.  
  96.       /* Need to ask DOS for a RDArgs structure */
  97.       if (myrda = (struct RDArgs *) AllocDosObject (DOS_RDARGS, NULL))
  98.         {
  99.           /*
  100.            * The array of LONGs where ReadArgs() will store the data from
  101.            * the command line arguments.  C guarantees that all the array
  102.            * entries will be set to zero.
  103.            */
  104.           LONG *result[OPT_COUNT] =
  105.           {NULL};
  106.  
  107.           /* parse my command line */
  108.           if (ReadArgs (TEMPLATE, result, myrda))
  109.         {
  110.           if (ReqToolsBase = (struct Library *) OpenLibrary ("reqtools.library", LIBRARY_MINIMUM))
  111.             {
  112.               struct rtReqInfo *requester;
  113.  
  114.               if (requester = (struct rtReqInfo *) rtAllocRequest (RT_SCREENMODEREQ, NULL))
  115.             {
  116.               ULONG myRTSC_Flags = 0;
  117.               /*
  118.                * Take care of requester positioning -
  119.                * These flags common to most rt requesters
  120.                */
  121.               if (stricmp (result[OPT_POSITION], "CENTERSCR") == 0)
  122.                 requester->ReqPos = REQPOS_CENTERSCR;
  123.               else if (stricmp (result[OPT_POSITION], "TOPLEFTSCR") == 0)
  124.                 requester->ReqPos = REQPOS_TOPLEFTSCR;
  125.               else if (stricmp (result[OPT_POSITION], "CENTERWIN") == 0)
  126.                 requester->ReqPos = REQPOS_CENTERWIN;
  127.               else if (stricmp (result[OPT_POSITION], "TOPLEFTWIN") == 0)
  128.                 requester->ReqPos = REQPOS_TOPLEFTWIN;
  129.               else
  130.                 requester->ReqPos = REQPOS_POINTER;
  131.  
  132.               myRTSC_Flags =
  133.                 ((result[OPT_OVERSCANGAD]) ? SCREQF_OVERSCANGAD : NULL) |
  134.                 ((result[OPT_AUTOSCROLLGAD]) ? SCREQF_AUTOSCROLLGAD : NULL) |
  135.                 ((result[OPT_SIZEGADS]) ? SCREQF_SIZEGADS : NULL) |
  136.                 ((result[OPT_DEPTHGAD]) ? SCREQF_DEPTHGAD : NULL) |
  137.                 ((result[OPT_NONSTDMODES]) ? SCREQF_NONSTDMODES : NULL) |
  138.                 ((result[OPT_GUIMODES]) ? SCREQF_GUIMODES : NULL);
  139.  
  140.               {
  141.                 struct Process *process = (struct Process *) FindTask (NULL);
  142.                 APTR windowptr = process->pr_WindowPtr;
  143.  
  144.                 /*
  145.                  * Tags will be used to take care ofattributes not directly
  146.                  * settable in the rtReqInfo structure
  147.                  */
  148.  
  149.                 retval = rtScreenModeRequest (requester, (result[OPT_TITLE]) ? result[OPT_TITLE] : NULL,
  150.  
  151.                    (myRTSC_Flags) ? RTSC_Flags : TAG_IGNORE,
  152.                               myRTSC_Flags,
  153.  
  154.                 (result[OPT_HEIGHT]) ? RTSC_Height : TAG_IGNORE,
  155.                             *result[OPT_HEIGHT],
  156.                 (result[OPT_OKTEXT]) ? RTSC_OkText : TAG_IGNORE,
  157.                               result[OPT_OKTEXT],
  158.                               (result[OPT_MINWIDTH]) ? RTSC_MinWidth : TAG_IGNORE,
  159.                               *result[OPT_MINWIDTH],
  160.                               (result[OPT_MAXWIDTH]) ? RTSC_MaxWidth : TAG_IGNORE,
  161.                               *result[OPT_MAXWIDTH],
  162.                               (result[OPT_MINHEIGHT]) ? RTSC_MinHeight : TAG_IGNORE,
  163.                              *result[OPT_MINHEIGHT],
  164.                               (result[OPT_MAXHEIGHT]) ? RTSC_MaxHeight : TAG_IGNORE,
  165.                              *result[OPT_MAXHEIGHT],
  166.                               (result[OPT_MINDEPTH]) ? RTSC_MinDepth : TAG_IGNORE,
  167.                               *result[OPT_MINDEPTH],
  168.                               (result[OPT_MAXDEPTH]) ? RTSC_MaxDepth : TAG_IGNORE,
  169.                               *result[OPT_MAXDEPTH],
  170.                               (result[OPT_PROPERTYFLAGS]) ? RTSC_PropertyFlags : TAG_IGNORE,
  171.                          *result[OPT_PROPERTYFLAGS],
  172.                               (result[OPT_PROPERTYMASK]) ? RTSC_PropertyMask : TAG_IGNORE,
  173.                           *result[OPT_PROPERTYMASK],
  174.  
  175.  
  176.                 /*
  177.                  * Finally,
  178.                  * set some more general tags shared by most requesters
  179.                  */
  180.                               RT_Underscore, '_',
  181.                               (result[OPT_TOPOFFSET]) ? RT_TopOffset : TAG_IGNORE,
  182.                              *result[OPT_TOPOFFSET],
  183.                               (result[OPT_LEFTOFFSET]) ? RT_LeftOffset : TAG_IGNORE,
  184.                             *result[OPT_LEFTOFFSET],
  185.                 (windowptr) ? RT_Window : TAG_IGNORE,
  186.                 windowptr,
  187.                               (result[OPT_PUBSCREEN]) ? RT_PubScrName : TAG_IGNORE,
  188.                               result[OPT_PUBSCREEN],
  189.                               TAG_END);
  190.  
  191.               }
  192.               rtFreeRequest (requester);
  193.             }
  194.               else
  195.             {
  196.               /* Unable to allocate request structure */
  197.               retval = 20;
  198.             }
  199.               CloseLibrary (ReqToolsBase);
  200.             }
  201.           else
  202.             {
  203.               /* Unable to open reqtools.library */
  204.               fprintf (stderr, "rtScreenModeRequest: Unable to open reqtools.library.\n");
  205.               retval = 20;
  206.             }
  207.           FreeArgs (myrda);
  208.         }
  209.           else
  210.         {
  211.           /*
  212.            * Something went wrong in the parse
  213.            */
  214.  
  215.           if (result[OPT_TITLE] == NULL)
  216.             {
  217.               fprintf (stderr, "rtScreenModeRequest: Required argument missing.\n");
  218.             }
  219.           else
  220.             {
  221.               /* something else is wrong */
  222.               fprintf (stderr, "rtScreenModeRequest: Command syntax error.\n");
  223.             }
  224.  
  225.           fprintf (stderr, "Try - rtScreenModeRequest help.\n");
  226.  
  227.           retval = 20;
  228.         }
  229.           FreeDosObject (DOS_RDARGS, myrda);
  230.         }
  231.       else
  232.         {
  233.           /* Unable to alloc readargs structure */
  234.           retval = 20;
  235.         }
  236.     }
  237.     }
  238.   else
  239.     {
  240.       /* launched from workbench */
  241.     }
  242.  
  243.   return (retval);
  244. }
  245.