home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 8 / FreshFishVol8-CD1.bin / new / util / wb / startwindow / source / startwindow.c < prev    next >
C/C++ Source or Header  |  1994-11-02  |  17KB  |  602 lines

  1. /*
  2.  *  Source machine generated by GadToolsBox V2.0b
  3.  *  which is (c) Copyright 1991-1993 Jaba Development
  4.  *
  5.  *  GUI Designed by : -- Heinz Reinert --
  6.  */
  7. #include <exec/types.h>
  8. #include <string.h>
  9. #include <intuition/intuition.h>
  10. #include <intuition/classes.h>
  11. #include <intuition/classusr.h>
  12. #include <intuition/imageclass.h>
  13. #include <intuition/gadgetclass.h>
  14. #include <libraries/gadtools.h>
  15. #include <graphics/displayinfo.h>
  16. #include <graphics/GfxBase.h>
  17. #include <clib/exec_protos.h>
  18. #include <clib/intuition_protos.h>
  19. #include <clib/gadtools_protos.h>
  20. #include <clib/graphics_protos.h>
  21. #include <clib/utility_protos.h>
  22. #include <proto/intuition.h>
  23. #include <proto/graphics.h>
  24. #include <proto/exec.h>
  25. #include <proto/dos.h>
  26. #include <proto/gadtools.h>
  27. #include <exec/memory.h>
  28.  
  29.  
  30. /***************************************/
  31. #define GetString( g )      ((( struct StringInfo * )g->SpecialInfo )->Buffer  )
  32. #define GetNumber( g )      ((( struct StringInfo * )g->SpecialInfo )->LongInt )
  33.  
  34. #define GD_list                                0
  35. #define GD_gadtxt                              1
  36. #define GD_command                             2
  37. #define GD_command2                            3
  38. #define GD_new                                 4
  39. #define GD_del                                 5
  40. #define GD_start                               6
  41. #define GD_save                                7
  42. #define GD_req                                 8
  43.  
  44. #define GDX_list                               0
  45. #define GDX_gadtxt                             1
  46. #define GDX_command                            2
  47. #define GDX_command2                           3
  48. #define GDX_new                                4
  49. #define GDX_del                                5
  50. #define GDX_start                              6
  51. #define GDX_save                               7
  52. #define GDX_req                                8
  53.  
  54. #define Project0_CNT 9
  55. UBYTE *vers = "\0$VER: StartWindow 2";
  56.  
  57. extern struct IntuitionBase *IntuitionBase;
  58. extern struct Library       *GadToolsBase;
  59.  
  60. extern struct Screen        *Scr;
  61. extern UBYTE                 *PubScreenName;
  62. extern APTR                  VisualInfo;
  63. extern struct Window        *Project0Wnd;
  64. extern struct Gadget        *Project0GList;
  65. extern struct Gadget        *Project0Gadgets[9];
  66. extern UWORD                 Project0Left;
  67. extern UWORD                 Project0Top;
  68. extern UWORD                 Project0Width;
  69. extern UWORD                 Project0Height;
  70. extern UBYTE                *Project0Wdt;
  71. extern struct TextAttr       topaz8;
  72. extern UWORD                 Project0GTypes[];
  73. extern struct NewGadget      Project0NGad[];
  74. extern ULONG                 Project0GTags[];
  75.  
  76.  
  77. extern int SetupScreen( void );
  78. extern void CloseDownScreen( void );
  79. extern int OpenProject0Window( void );
  80. extern void CloseProject0Window( void );
  81.  
  82. /***************************************/
  83.  
  84. struct Screen         *Scr = NULL;
  85. UBYTE                 *PubScreenName = NULL;
  86. APTR                   VisualInfo = NULL;
  87. struct Window         *Project0Wnd = NULL;
  88. struct Gadget         *Project0GList = NULL;
  89. struct Gadget         *Project0Gadgets[9];
  90. UWORD                  Project0Left = 440;
  91. UWORD                  Project0Top = 10;
  92. UWORD                  Project0Width = 190;
  93. UWORD                  Project0Height = 0;
  94. UBYTE                 *Project0Wdt = (UBYTE *)"StartWindow2";
  95.  
  96. struct TextAttr topaz8 = {
  97.         ( STRPTR )"topaz.font", 8, 0x00, 0x01 };
  98.  
  99. UWORD Project0GTypes[] = {
  100.         LISTVIEW_KIND,
  101.         STRING_KIND,
  102.         STRING_KIND,
  103.         STRING_KIND,
  104.         BUTTON_KIND,
  105.         BUTTON_KIND,
  106.         BUTTON_KIND,
  107.         BUTTON_KIND,
  108.         BUTTON_KIND
  109. };
  110.  
  111. struct NewGadget Project0NGad[] = {
  112.         4, 2, 161, 88, NULL, NULL, GD_list, 0, NULL, NULL,
  113.         4, 86, 138, 12, NULL, NULL, GD_gadtxt, 0, NULL, NULL,
  114.         4, 98, 161, 12, NULL, NULL, GD_command, 0, NULL, NULL,
  115.         4, 110, 161, 12, NULL, NULL, GD_command2, 0, NULL, NULL,
  116.         4, 122, 54, 11, (UBYTE *)"NEW", NULL, GD_new, PLACETEXT_IN, NULL, NULL,
  117.         114, 122, 51, 11, (UBYTE *)"DEL", NULL, GD_del, PLACETEXT_IN, NULL, NULL,
  118.         4, 133, 161, 13, (UBYTE *)"RUN", NULL, GD_start, PLACETEXT_IN, NULL, NULL,
  119.         59, 122, 54, 11, (UBYTE *)"SAVE", NULL, GD_save, PLACETEXT_IN, NULL, NULL,
  120.         142, 86, 23, 12, (UBYTE *)"R", NULL, GD_req, PLACETEXT_IN, NULL, NULL
  121. };
  122.  
  123. ULONG Project0GTags[] = {
  124.         (TAG_DONE),
  125.         (GTST_MaxChars), 256, (TAG_DONE),
  126.         (GTST_MaxChars), 256, (TAG_DONE),
  127.         (GTST_MaxChars), 256, (TAG_DONE),
  128.         (TAG_DONE),
  129.         (TAG_DONE),
  130.         (TAG_DONE),
  131.         (TAG_DONE),
  132.         (TAG_DONE)
  133. };
  134.  
  135. int SetupScreen( void )
  136. {
  137.         if ( ! ( Scr = LockPubScreen( PubScreenName )))
  138.                 return( 1L );
  139.  
  140.         if ( ! ( VisualInfo = GetVisualInfo( Scr, TAG_DONE )))
  141.                 return( 2L );
  142.  
  143.         return( 0L );
  144. }
  145.  
  146. void CloseDownScreen( void )
  147. {
  148.         if ( VisualInfo ) {
  149.                 FreeVisualInfo( VisualInfo );
  150.                 VisualInfo = NULL;
  151.         }
  152.  
  153.         if ( Scr        ) {
  154.                 UnlockPubScreen( NULL, Scr );
  155.                 Scr = NULL;
  156.         }
  157. }
  158.  
  159. int OpenProject0Window( void )
  160. {
  161.         struct NewGadget        ng;
  162.         struct Gadget   *g;
  163.         UWORD           lc, tc;
  164.         UWORD           offx = Scr->WBorLeft, offy = Scr->WBorTop + Scr->RastPort.TxHeight + 1;
  165.  
  166.         if ( ! ( g = CreateContext( &Project0GList )))
  167.                 return( 1L );
  168.  
  169.         for( lc = 0, tc = 0; lc < Project0_CNT; lc++ ) {
  170.  
  171.                 CopyMem((char * )&Project0NGad[ lc ], (char * )&ng, (long)sizeof( struct NewGadget ));
  172.  
  173.                 ng.ng_VisualInfo = VisualInfo;
  174.                 ng.ng_TextAttr   = &topaz8;
  175.                 ng.ng_LeftEdge  += offx;
  176.                 ng.ng_TopEdge   += offy;
  177.  
  178.                 Project0Gadgets[ lc ] = g = CreateGadgetA((ULONG)Project0GTypes[ lc ], g, &ng, ( struct TagItem * )&Project0GTags[ tc ] );
  179.  
  180.                 while( Project0GTags[ tc ] ) tc += 2;
  181.                 tc++;
  182.  
  183.                 if ( NOT g )
  184.                         return( 2L );
  185.         }
  186.  
  187.         if ( ! ( Project0Wnd = OpenWindowTags( NULL,
  188.                                 WA_Left,        Project0Left,
  189.                                 WA_Top,         Project0Top,
  190.                                 WA_Width,       Project0Width,
  191.                                 WA_Height,      Project0Height + offy,
  192.                                 WA_IDCMP,       LISTVIEWIDCMP|STRINGIDCMP|BUTTONIDCMP|IDCMP_CLOSEWINDOW|IDCMP_REFRESHWINDOW,
  193.                                 WA_Flags,       WFLG_SIZEGADGET|WFLG_DRAGBAR|WFLG_DEPTHGADGET|WFLG_CLOSEGADGET|WFLG_SMART_REFRESH,
  194.                                 WA_Gadgets,     Project0GList,
  195.                                 WA_Title,       Project0Wdt,
  196.                                 WA_ScreenTitle, "StartWindow2 Heinz Reinert 1994",
  197.                                 WA_PubScreen,   Scr,
  198.                                 WA_MinWidth,    190,
  199.                                 WA_MinHeight,   160,
  200.                                 WA_MaxWidth,    190,
  201.                                 WA_MaxHeight,   160,
  202.                                 TAG_DONE )))
  203.         return( 4L );
  204.  
  205.         GT_RefreshWindow( Project0Wnd, NULL );
  206.  
  207.         return( 0L );
  208. }
  209.  
  210. void CloseProject0Window( void )
  211. {
  212.         if ( Project0Wnd        ) {
  213.                 CloseWindow( Project0Wnd );
  214.                 Project0Wnd = NULL;
  215.         }
  216.  
  217.         if ( Project0GList      ) {
  218.                 FreeGadgets( Project0GList );
  219.                 Project0GList = NULL;
  220.         }
  221. }
  222.  
  223. /*********************************************/
  224. /* Main Program Part */
  225.  
  226.  
  227. /* Structur for Data-Entries */
  228.  
  229. struct PRJ {
  230.  
  231.     char    Name[0];
  232.  
  233.     char    gadtxt[20];
  234.     char    command[75];
  235.     char    command2[75];
  236.     USHORT  new;
  237.     USHORT  del;
  238.     USHORT  save;
  239.     USHORT  req;
  240.     USHORT  start;
  241. };
  242.  
  243. struct PRJnode {
  244.         struct  Node n;
  245.         struct  PRJ d;
  246. };
  247.  
  248. /* PRJ-Nodes are in this List */
  249.  
  250. struct List prjlist;
  251.  
  252. /* The actual Entry */
  253.  
  254. struct PRJnode *currentprj;
  255.  
  256. /* String-Gadgets */
  257.  
  258. void gt_SetString( struct Gadget        *gad,
  259.                                    struct Window        *w,
  260.                                    char