home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 568b.lha / PowerSource_v3.0 / source.lzh / source / con.c < prev    next >
C/C++ Source or Header  |  1991-09-15  |  7KB  |  220 lines

  1. /*----------------------------------------------------------------------*
  2.    con.c version 3.0 -  © Copyright 1990-91 Jaba Development
  3.  
  4.    Author : Jan van den Baard
  5.    Purpose: startup configuration window
  6.  *----------------------------------------------------------------------*/
  7.  
  8. /*
  9.  * configuration window gadgets e.c.t.
  10.  */
  11. static SHORT WPairs[] =
  12.  { 2,1,246,1,246,97,2,97,2,1 };
  13. static SHORT WPairs1[] =
  14.  { 2,1,246,1,246,12,2,12,2,1 };
  15.  
  16. static struct Border WBorder1 =
  17.  { 0,0,0,0,JAM1,5,WPairs1,NULL };
  18. static struct Border WBorder =
  19.  { 0,0,0,0,JAM1,5,WPairs,&WBorder1 };
  20.  
  21. static struct IntuiText WText2 =
  22.  { 0,1,JAM2,10,3,NULL,(UBYTE *)"Please specify",NULL };
  23. static struct IntuiText WText1 =
  24.  { 0,1,JAM2,67,40,NULL,(UBYTE *)"Screen depth :",&WText2 };
  25. static struct IntuiText WText =
  26.  { 0,1,JAM2,54,15,NULL,(UBYTE *)"Edit gadgets for :",&WText1 };
  27.  
  28. static SHORT WBPairs[] =
  29.  { 0,0,234,0,234,12,0,12,0,0 };
  30. static struct Border WBBorder =
  31.  { -1,-1,0,0,JAM1,5,WBPairs,NULL };
  32. static struct IntuiText WBText =
  33.  { 0,1,JAM2,79,2,NULL,(UBYTE *)"WORKBENCH",NULL };
  34. static struct Gadget WB =
  35.  { NULL,7,66,233,11,SELECTED,GADGIMMEDIATE+TOGGLESELECT,BOOLGADGET,
  36.    (APTR)&WBBorder,NULL,&WBText,31L,NULL,9,NULL };
  37.  
  38. static SHORT OKIDOKIPairs[] =
  39.  { 0,0,114,0,114,12,0,12,0,0 };
  40. static struct Border OKIDOKIBorder =
  41.  { -1,-1,0,0,JAM1,5,OKIDOKIPairs,NULL };
  42.  
  43. static struct IntuiText OKIDOKIText =
  44.  { 0,1,JAM2,49,2,NULL,(UBYTE *)"OK",NULL };
  45. static struct Gadget OKIDOKI =
  46.  { &WB,7,82,113,11,NULL,RELVERIFY,BOOLGADGET,
  47.    (APTR)&OKIDOKIBorder,NULL,&OKIDOKIText,NULL,NULL,8,NULL };
  48.  
  49. static struct IntuiText CNCText =
  50.  { 0,1,JAM2,33,2,NULL,(UBYTE *)"CANCEL",NULL };
  51. static struct Gadget CNC =
  52.  { &OKIDOKI,127,82,113,11,NULL,RELVERIFY,BOOLGADGET,
  53.    (APTR)&OKIDOKIBorder,NULL,&CNCText,NULL,NULL,7,NULL };
  54.  
  55. static SHORT DPairs[] =
  56.  { 0,0,29,0,29,12,0,12,0,0 };
  57. static struct Border DBorder =
  58.  { -1,-1,0,0,JAM1,5,DPairs,NULL };
  59.  
  60. static struct IntuiText D5Text =
  61.  { 0,1,JAM2,10,2,NULL,(UBYTE *)"5",NULL };
  62. static struct Gadget D5 =
  63.  { &CNC,212,50,28,11,NULL,GADGIMMEDIATE+TOGGLESELECT,BOOLGADGET,
  64.    (APTR)&DBorder,NULL,&D5Text,143L,NULL,6,NULL };
  65.  
  66. static struct IntuiText D4Text =
  67.  { 0,1,JAM2,10,2,NULL,(UBYTE *)"4",NULL };
  68. static struct Gadget D4 =
  69.  { &D5,160,50,28,11,NULL,GADGIMMEDIATE+TOGGLESELECT,BOOLGADGET,
  70.    (APTR)&DBorder,NULL,&D4Text,151L,NULL,5,NULL };
  71.  
  72. static struct IntuiText D3Text =
  73.  { 0,1,JAM2,10,2,NULL,(UBYTE *)"3",NULL };
  74. static struct Gadget D3 =
  75.  { &D4,108,50,28,11,NULL,GADGIMMEDIATE+TOGGLESELECT,BOOLGADGET,
  76.    (APTR)&DBorder,NULL,&D3Text,155L,NULL,4,NULL };
  77.  
  78. static struct IntuiText D2Text =
  79.  { 0,1,JAM2,10,2,NULL,(UBYTE *)"2",NULL };
  80. static struct Gadget D2 =
  81.  { &D3,58,50,28,11,NULL,GADGIMMEDIATE+TOGGLESELECT,BOOLGADGET,
  82.    (APTR)&DBorder,NULL,&D2Text,157L,NULL,3,NULL };
  83.  
  84. static struct IntuiText D1Text =
  85.  { 0,1,JAM2,10,2,NULL,(UBYTE *)"1",NULL };
  86. static struct Gadget D1 =
  87.  { &D2,7,50,28,11,NULL,GADGIMMEDIATE+TOGGLESELECT,BOOLGADGET,
  88.    (APTR)&DBorder,NULL,&D1Text,158L,NULL,2,NULL };
  89.  
  90. static SHORT WRPairs[] =
  91.  { 0,0,114,0,114,12,0,12,0,0 };
  92. static struct Border WRBorder =
  93.  { -1,-1,0,0,JAM1,5,WRPairs,NULL };
  94.  
  95. static struct IntuiText REQText =
  96.  { 0,1,JAM2,19,2,NULL,(UBYTE *)"REQUESTER",NULL };
  97. static struct Gadget REQ =
  98.  { &D1,127,25,113,11,NULL,GADGIMMEDIATE+TOGGLESELECT,BOOLGADGET,
  99.    (APTR)&WRBorder,NULL,&REQText,1L,NULL,1,NULL };
  100.  
  101. static struct IntuiText WNDText =
  102.  { 0,1,JAM2,33,2,NULL,(UBYTE *)"WINDOW",NULL };
  103. static struct Gadget WND =
  104.  { &REQ,7,25,113,11,SELECTED,GADGIMMEDIATE+TOGGLESELECT,BOOLGADGET,
  105.    (APTR)&WRBorder,NULL,&WNDText,2L,NULL,0,NULL };
  106.  
  107. static struct NewWindow nw_conf =
  108.  { 197,60,249,99,3,2,GADGETUP+GADGETDOWN,ACTIVATE+RMBTRAP+NOCAREREFRESH+BORDERLESS,
  109.    NULL,NULL,NULL,NULL,NULL,0,0,0,0,WBENCHSCREEN };
  110.  
  111. /*
  112.  * static data
  113.  */
  114. static struct Window *w;
  115. static UWORD          gad_id;
  116.  
  117. /*
  118.  * globals
  119.  */
  120. extern struct Gadget    *Gadget;
  121. extern struct Screen    *MainScreen;
  122. extern struct NewWindow  nw_main;
  123. extern BOOL              REQUESTER;
  124. extern BOOL              WBSCREEN;
  125. extern USHORT            DEPTH, Code;
  126. extern ULONG             Class;
  127. extern char              wdt[80],wlb[MAXLABEL];
  128.  
  129. /*
  130.  * open the configuration window
  131.  */
  132. LONG get_config(custom)
  133.     ULONG custom;
  134. {
  135.     if(custom) {
  136.         nw_conf.LeftEdge = (MainScreen->Width >> 1) - 124;
  137.         nw_conf.TopEdge  = (MainScreen->Height >> 1) - 49;
  138.         nw_conf.Screen   = MainScreen;
  139.         nw_conf.Type     = CUSTOMSCREEN;
  140.     } else {
  141.         nw_conf.LeftEdge = 197;
  142.         nw_conf.TopEdge  = 60;
  143.         nw_conf.Screen   = NULL;
  144.         nw_conf.Type     = WBENCHSCREEN;
  145.     }
  146.  
  147.     if(NOT(w = OpenWindow(&nw_conf)))
  148.         close_up("   - ERROR: Can't open the configurations window !");
  149.  
  150.     draw(w,&WND,&WBorder,&WText);
  151.  
  152.     if(custom) {
  153.         disable_window();
  154.         buisy();
  155.         DeSelectGList(w,&WND,NULL,-1L);
  156.         if(WBSCREEN)        SelectGadget(w,&WB,NULL);
  157.         else if(DEPTH == 1) SelectGadget(w,&D1,NULL);
  158.         else if(DEPTH == 2) SelectGadget(w,&D2,NULL);
  159.         else if(DEPTH == 3) SelectGadget(w,&D3,NULL);
  160.         else if(DEPTH == 4) SelectGadget(w,&D4,NULL);
  161.         else                SelectGadget(w,&D5,NULL);
  162.  
  163.         if(REQUESTER)       SelectGadget(w,&REQ,NULL);
  164.         else                SelectGadget(w,&WND,NULL);
  165.     }
  166.  
  167.     do {
  168.         Wait(1 << w->UserPort->mp_SigBit);
  169.         while(read_msg(w)) {
  170.             gad_id    = Gadget->GadgetID;
  171.             switch(gad_id) {
  172.                 case 9:
  173.                 case 6:
  174.                 case 5:
  175.                 case 4:
  176.                 case 3:
  177.                 case 2: MutualExclude(w,Gadget,&D1,NULL);
  178.                         SelectGadget(w,Gadget,NULL);
  179.                         break;
  180.                 case 1:
  181.                 case 0: MutualExclude(w,Gadget,&WND,NULL);
  182.                         SelectGadget(w,Gadget,NULL);
  183.                         break;
  184.             }
  185.         }
  186.     } while((gad_id != 7)&&(gad_id != 8));
  187.     CloseWindow(w);
  188.  
  189.     if(gad_id == 8) {
  190.         if(SelectTest(&WND)) {
  191.             REQUESTER = FALSE;
  192.             nw_main.Flags = FLAGS_NM;
  193.             strcpy((char *)&wdt,"Work Window");
  194.             strcpy((char *)&wlb,"new_window");
  195.         } else {
  196.             REQUESTER = TRUE;
  197.             nw_main.Flags  = FLAGS_RQ;
  198.             strcpy((char *)&wdt,"Requester");
  199.             strcpy((char *)&wlb,"requester");
  200.         }
  201.         if(SelectTest(&D1))      { DEPTH = 1; WBSCREEN = FALSE; }
  202.         else if(SelectTest(&D2)) { DEPTH = 2; WBSCREEN = FALSE; }
  203.         else if(SelectTest(&D3)) { DEPTH = 3; WBSCREEN = FALSE; }
  204.         else if(SelectTest(&D4)) { DEPTH = 4; WBSCREEN = FALSE; }
  205.         else if(SelectTest(&WB)) { DEPTH = 2; WBSCREEN = TRUE;  }
  206.         else                     { DEPTH = 5; WBSCREEN = FALSE; }
  207.         if(custom) {
  208.             enable_window();
  209.             ok();
  210.         }
  211.         return TRUE;
  212.     }
  213.     if(custom) {
  214.         enable_window();
  215.         ok();
  216.         return FALSE;
  217.     }
  218.     close_up("    - BYE BYE......");
  219. }
  220.