home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 357.lha / intuisup_v1.15 / examples / wsmartreq / test.c < prev    next >
C/C++ Source or Header  |  1990-03-10  |  5KB  |  167 lines

  1. #include <intuition/intuisup.h>
  2. #include <clib/macros.h>
  3. #include <proto/all.h>
  4.  
  5. struct   GfxBase        *GfxBase;
  6. struct   IntuitionBase  *IntuitionBase;
  7.  
  8. #ifdef ISUP_RUNTIME
  9. struct   Library  *iSupBase;
  10. #else
  11. struct   Device   *ConsoleDevice;
  12. struct   IOStdReq  ConsoleMsg;
  13. #endif
  14.  
  15. VOID   Resize() {}
  16.  
  17. struct Window  *sr_window;
  18.  
  19. struct IntuiText  Body[3] =
  20.    {
  21.       { 0, 0, JAM1, 0,0, NULL, "This is requester One", &Body[1] },
  22.       { 2, 0, JAM1, 0,0, NULL, "It has 3 text lines", &Body[2] },
  23.       { 3, 0, JAM1, 0,0, NULL, "and 2 string gadgets", NULL }
  24.    };
  25.  
  26. UBYTE Buffer1[40] = "Hi!";
  27. UBYTE Buffer2[10] = "123456789";
  28. UBYTE UBuffer1[40], UBuffer2[10];
  29.  
  30. struct StringInfoList Gad[2] =
  31.    {
  32.       { &Gad[1], { Buffer1, UBuffer1, 0, 40, 0, 0,0,0,0,0,NULL,0L,NULL } },
  33.       { NULL,    { Buffer2, UBuffer2, 0, 10, 0, 0,0,0,0,0,NULL,0L,NULL } }
  34.    };
  35.  
  36. struct SmartReq   sm =
  37.    {
  38.    Body,
  39.    Gad,
  40.    "Ok", "Cancel",
  41.    NULL, NULL,
  42.    Resize,
  43.    NULL
  44.    };
  45.  
  46. struct IntuiText  BBody[5] =
  47.    {
  48.       { 0, 0, JAM1, 0,0, NULL, "This is the second one", &BBody[1] },
  49.       { 0, 0, JAM1, 0,0, NULL, "", &BBody[2] },
  50.       { 0, 0, JAM1, 0,0, NULL, "The text attributes can", &BBody[3] },
  51.       { 0, 0, JAM1, 0,0, NULL, "be controlled for each", &BBody[4] },
  52.       { 2, 0, JAM1, 0,0, NULL, "individual line", NULL }
  53.    };
  54.  
  55. UBYTE BBuffer0[40] = "This is Gadget 1";
  56. UBYTE BBuffer1[40] = "This is Gadget 2";
  57. UBYTE BBuffer2[40] = "This is Gadget 3";
  58. UBYTE BBuffer3[40] = "This is Gadget 4";
  59. UBYTE BBuffer4[40] = "This is Gadget 5";
  60. UBYTE UUBuffer0[40];
  61. UBYTE UUBuffer1[40];
  62. UBYTE UUBuffer2[40];
  63. UBYTE UUBuffer3[40];
  64. UBYTE UUBuffer4[40];
  65.  
  66. struct StringInfoList GGad[10] =
  67.    {
  68.       { &GGad[1], { BBuffer0, UUBuffer0, 0, 40, 0, 0,0,0,0,0,NULL,0L,NULL } },
  69.       { &GGad[2], { BBuffer1, UUBuffer1, 0, 40, 0, 0,0,0,0,0,NULL,0L,NULL } },
  70.       { &GGad[3], { BBuffer2, UUBuffer2, 0, 40, 0, 0,0,0,0,0,NULL,0L,NULL } },
  71.       { &GGad[4], { BBuffer3, UUBuffer3, 0, 40, 0, 0,0,0,0,0,NULL,0L,NULL } },
  72.       { NULL,     { BBuffer4, UUBuffer4, 0, 40, 0, 0,0,0,0,0,NULL,0L,NULL } },
  73.    };
  74.  
  75. struct SmartReq   ssm =
  76.    {
  77.    BBody,
  78.    GGad,
  79.    "Ok", NULL,
  80.    NULL, NULL,
  81.    Resize,
  82.    NULL
  83.    };
  84.  
  85.  
  86. UBYTE buf1[20] = "";
  87. UBYTE buf2[20] = "";
  88. UBYTE buf3[20] = "";
  89.  
  90. static   USHORT   Pattern[7][8] =
  91.    {
  92.       { 0x7b9c, 0xda7b, 0x3327, 0xe5af, 0x5eac, 0xd96a, 0x6b6b, 0x1de7 },
  93.       { 0xeeee, 0xdddd, 0xbbbb, 0x7777, 0xeeee, 0xdddd, 0xbbbb, 0x7777 },
  94.       { 0x7777, 0xbbbb, 0xdddd, 0xeeee, 0x7777, 0xbbbb, 0xdddd, 0xeeee },
  95.       { 0x7777, 0x7777, 0x7777, 0x7777, 0x7777, 0x7777, 0x7777, 0x7777 },
  96.       { 0x6666, 0x9999, 0x6666, 0x9999, 0x6666, 0x9999, 0x6666, 0x9999 },
  97.       { 0x5555, 0x5555, 0x5555, 0x5555, 0x5555, 0x5555, 0x5555, 0x5555 },
  98.       { 0x7b9c, 0xda7b, 0x3327, 0xe5af, 0x5eac, 0xd96a, 0x6b6b, 0x1de7 },
  99.    };
  100.  
  101.  
  102. VOID
  103. Cleanup(err)
  104. BYTE  err;
  105. {
  106. #ifdef ISUP_RUNTIME
  107.       if (iSupBase)      CloseLibrary(iSupBase);
  108. #else
  109.       if (ConsoleDevice) CloseDevice(&ConsoleMsg);
  110. #endif
  111.    if (GfxBase)         CloseLibrary(GfxBase);
  112.    if (IntuitionBase)   CloseLibrary(IntuitionBase);
  113.  
  114.    exit(err);
  115. }
  116.  
  117. VOID
  118. main()
  119. {
  120.    extern struct Window *OpenStdWindow();
  121.  
  122.    if (  !(GfxBase       = (struct Library *)OpenLibrary("graphics.library", 0))
  123.       || !(IntuitionBase = (struct Library *)OpenLibrary("intuition.library", 0))
  124.       || !(DiskfontBase  = (struct Library *)OpenLibrary("diskfont.library", 0))
  125. #ifdef ISUP_RUNTIME
  126.       || !(iSupBase      = (struct Library *)OpenLibrary("isup.library", 0))
  127. #else
  128.       || !(!OpenDevice("console.device", -1, &ConsoleMsg, 0) && (ConsoleDevice=ConsoleMsg.io_Device))
  129. #endif
  130.       ) Cleanup(10);;
  131.  
  132.    if (!(sr_window = OpenStdWindow("WSmartReq example", 0x13, 15,15, 270,113, Pattern[0]))) Cleanup(15);
  133.    WSmartReq(sr_window, &sm);
  134.    CloseStdWindow(sr_window);
  135.  
  136.    if (!(sr_window = OpenStdWindow("WSmartReq example", 0x13, 15,15, 270,179, Pattern[1]))) Cleanup(15);
  137.    WSmartReq(sr_window, &ssm);
  138.    CloseStdWindow(sr_window);
  139.  
  140.  
  141.    if (!(sr_window = OpenStdWindow("WSmartReq example", 0x13, 15,15, 270, 72, Pattern[2]))) Cleanup(15);
  142.    AutoWSmartRequest(sr_window, 2, "Simple text only", "example", 0,
  143.                         "Ok", NULL, Resize, NULL);
  144.    CloseStdWindow(sr_window);
  145.  
  146.    if (!(sr_window = OpenStdWindow("WSmartReq example", 0x13, 15,15, 270, 79, Pattern[3]))) Cleanup(15);
  147.    AutoWSmartRequest(sr_window, 1, "Enter a file name:", 1, buf1, 20, "Ok", NULL, Resize, NULL);
  148.    CloseStdWindow(sr_window);
  149.  
  150.    if (!(sr_window = OpenStdWindow("WSmartReq example", 0x13, 15,15, 270, 63, Pattern[4]))) Cleanup(15);
  151.    AutoWSmartRequest(sr_window, 1, "Software Failure?", 0, "Nope", NULL, Resize, NULL);
  152.    CloseStdWindow(sr_window);
  153.  
  154.    if (!(sr_window = OpenStdWindow("WSmartReq example", 0x13, 15,15, 270,120, Pattern[5]))) Cleanup(15);
  155.    AutoWSmartRequest(sr_window, 2, "Enter string to search,", "replacement, and wildcard",
  156.                          3, buf1, 20, buf2, 20, buf3, 20,
  157.                         "Replace", "Cancel", Resize, NULL);
  158.    CloseStdWindow(sr_window);
  159.  
  160.    if (!(sr_window = OpenStdWindow("WSmartReq example", 0x13, 15,15, 270, 63, Pattern[6]))) Cleanup(15);
  161.    AutoWSmartRequest(sr_window, 1, "Had enough?", 0, "YEAH!", NULL, Resize, NULL);
  162.    CloseStdWindow(sr_window);
  163.  
  164.    Cleanup(0);
  165. }
  166.  
  167.