home *** CD-ROM | disk | FTP | other *** search
/ Fish 'n' More 2 / fishmore-publicdomainlibraryvol.ii1991xetec.iso / fish / programming / intuitioned / strgad.c < prev   
C/C++ Source or Header  |  1990-10-10  |  13KB  |  325 lines

  1. /*-----------------------------------------------------------
  2. --      Name: StrGad.c
  3. --    Author: Intuition Ed 
  4. --      Date: Wed Sep  5
  5. --      Task: 
  6. ------------------------------------------------------------/*
  7.  
  8.  
  9. /*-------------------
  10. --  Include   :    --
  11. -------------------*/
  12.  
  13. #include <intuition/intuition.h>
  14.  
  15.  
  16. /*-------------------
  17. --  Define   :     --
  18. -------------------*/
  19.  
  20. /*
  21.  This is a stringgadget demo
  22.  to show Intuition Ed's possibilities.
  23.  It's written by the complete vesion of Intuition Ed.
  24. */
  25.  
  26.  
  27. #define STRGAD4_GAD        0
  28. #define STRGAD3_GAD        1
  29. #define STRGAD2_GAD        2
  30. #define STRGAD1_GAD        3
  31.  
  32. /*-------------------
  33. --   Functions  :  --
  34. -------------------*/
  35.  
  36. void                   Open_All() ;
  37. void                   Close_All();
  38.  
  39. /*-------------------
  40. --  extern         --
  41. --  Variables  :   --
  42. -------------------*/
  43.  
  44. struct IntuitionBase  *IntuitionBase;
  45. struct Window         *Window1;
  46.  
  47. UBYTE StrGad4Buffer[21] = "-.-.-.-.-.-.";
  48. UBYTE StrGad4UndoBuffer[21];
  49.  
  50. UBYTE StrGad3Buffer[21] = "-.-.-.-.-.-.";
  51. UBYTE StrGad3UndoBuffer[21];
  52.  
  53. UBYTE StrGad2Buffer[301] = "This demo program is written by Intuition Ed with my inputs.";
  54. UBYTE StrGad2UndoBuffer[301];
  55.  
  56. UBYTE StrGad1Buffer[301] = "You  need the entire version of Intuition Ed to create gadgets.";
  57. UBYTE StrGad1UndoBuffer[301];
  58.  
  59. /*-------------------
  60. --  Structures  :  --
  61. -------------------*/
  62.  
  63.  
  64. SHORT Border3Pairs [] =
  65. {
  66.   -1,-1,  -1,12,  145,12,  145,-1,  -1,-1,
  67. };
  68.  
  69. struct Border Border3 =
  70. {
  71.   -1, -1,                                 /* LeftEdge , TopEdge        */
  72.    3,  0,                                 /* FrontPen , BackPen        */
  73.  JAM1,                                    /* Draw Mode                 */
  74.    5,                                     /* Count                     */
  75.  Border3Pairs ,                           /* * X Y                     */
  76.  NULL,                                    /* Last Border               */
  77. };
  78.  
  79. struct StringInfo StrGad4StringInfo =
  80. {
  81.  StrGad4Buffer,                           /* Buffer                    */
  82.  StrGad4UndoBuffer,                       /* UndoBuffer                */
  83.    0,                                     /* BufferPos                 */
  84.   21,                                     /* BufferSize                */
  85.    0,  0,                                 /* DispPos , UndoPos         */
  86.    0,                                     /* Numchars                  */
  87.    0,                                     /* DispCount                 */
  88.    0,  0,                                 /* CLeft , CTop              */
  89.  NULL,                                    /* LayerPtr                  */
  90.  NULL,                                    /* LongInt                   */
  91.  NULL,                                    /* AltKeyMap                 */
  92. };
  93.  
  94. struct Gadget StrGad4 =
  95. {
  96.  NULL,                                    /* Last Gadget               */
  97.  175, 60,                                 /* LeftEdge , TopEdge        */
  98.  145, 12,                                 /* Width , Height            */
  99.  GADGHCOMP,                               /* Flags                     */
  100.  STRINGRIGHT,                             /* Activation                */
  101.  STRGADGET,                               /* Gadget Type               */
  102.  (APTR)&Border3,                          /* Gadget Render             */
  103.  NULL,                                    /* No Selected Render        */
  104.  NULL,                                    /* No Gadget Text            */
  105.  NULL,                                    /* Mutual Exclude            */
  106.  (APTR)&StrGad4StringInfo,                /* Special Info              */
  107.  STRGAD4_GAD,                             /* Gadget ID                 */
  108.  NULL,                                    /* User Data                 */
  109. };
  110.  
  111. struct StringInfo StrGad3StringInfo =
  112. {
  113.  StrGad3Buffer,                           /* Buffer                    */
  114.  StrGad3UndoBuffer,                       /* UndoBuffer                */
  115.    0,                                     /* BufferPos                 */
  116.   21,                                     /* BufferSize                */
  117.    0,  0,                                 /* DispPos , UndoPos         */
  118.    0,                                     /* Numchars                  */
  119.    0,                                     /* DispCount                 */
  120.    0,  0,                                 /* CLeft , CTop              */
  121.  NULL,                                    /* LayerPtr                  */
  122.  NULL,                                    /* LongInt                   */
  123.  NULL,                                    /* AltKeyMap                 */
  124. };
  125.  
  126. struct Gadget StrGad3 =
  127. {
  128.  &StrGad4,                                /* Next Gadget               */
  129.   10, 60,                                 /* LeftEdge , TopEdge        */
  130.  145, 12,                                 /* Width , Height            */
  131.  GADGHCOMP,                               /* Flags                     */
  132.  NULL,                                    /* Activation                */
  133.  STRGADGET,                               /* Gadget Type               */
  134.  (APTR)&Border3,                          /* Gadget Render             */
  135.  NULL,                                    /* No Selected Render        */
  136.  NULL,                                    /* No Gadget Text            */
  137.  NULL,                                    /* Mutual Exclude            */
  138.  (APTR)&StrGad3StringInfo,                /* Special Info              */
  139.  STRGAD3_GAD,                             /* Gadget ID                 */
  140.  NULL,                                    /* User Data                 */
  141. };
  142.  
  143. SHORT Border2Pairs [] =
  144. {
  145.   -1,-1,  -1,12,  300,12,  300,-1,  -1,-1,
  146. };
  147.  
  148. struct Border Border2 =
  149. {
  150.   -1, -1,                                 /* LeftEdge , TopEdge        */
  151.    2,  0,                                 /* FrontPen , BackPen        */
  152.  JAM1,                                    /* Draw Mode                 */
  153.    5,                                     /* Count                     */
  154.  Border2Pairs ,                           /* * X Y                     */
  155.  NULL,                                    /* Last Border               */
  156. };
  157.  
  158. struct StringInfo StrGad2StringInfo =
  159. {
  160.  StrGad2Buffer,                           /* Buffer                    */
  161.  StrGad2UndoBuffer,                       /* UndoBuffer                */
  162.   38,                                     /* BufferPos                 */
  163.  301,                                     /* BufferSize                */
  164.    0,  0,                                 /* DispPos , UndoPos         */
  165.    0,                                     /* Numchars                  */
  166.    0,                                     /* DispCount                 */
  167.    0,  0,                                 /* CLeft , CTop              */
  168.  NULL,                                    /* LayerPtr                  */
  169.  NULL,                                    /* LongInt                   */
  170.  NULL,                                    /* AltKeyMap                 */
  171. };
  172.  
  173. struct Gadget StrGad2 =
  174. {
  175.  &StrGad3,                                /* Next Gadget               */
  176.   20, 40,                                 /* LeftEdge , TopEdge        */
  177.  300, 12,                                 /* Width , Height            */
  178.  GADGHCOMP,                               /* Flags                     */
  179.  STRINGCENTER,                            /* Activation                */
  180.  STRGADGET,                               /* Gadget Type               */
  181.  (APTR)&Border2,                          /* Gadget Render             */
  182.  NULL,                                    /* No Selected Render        */
  183.  NULL,                                    /* No Gadget Text            */
  184.  NULL,                                    /* Mutual Exclude            */
  185.  (APTR)&StrGad2StringInfo,                /* Special Info              */
  186.  STRGAD2_GAD,                             /* Gadget ID                 */
  187.  NULL,                                    /* User Data                 */
  188. };
  189.  
  190. SHORT Border1Pairs [] =
  191. {
  192.   -1,-1,  -1,12,  300,12,  300,-1,  -1,-1,
  193. };
  194.  
  195. struct Border Border1 =
  196. {
  197.   -1, -1,                                 /* LeftEdge , TopEdge        */
  198.    1,  0,                                 /* FrontPen , BackPen        */
  199.  JAM1,                                    /* Draw Mode                 */
  200.    5,                                     /* Count                     */
  201.  Border1Pairs ,                           /* * X Y                     */
  202.  NULL,                                    /* Last Border               */
  203. };
  204.  
  205. struct StringInfo StrGad1StringInfo =
  206. {
  207.  StrGad1Buffer,                           /* Buffer                    */
  208.  StrGad1UndoBuffer,                       /* UndoBuffer                */
  209.   38,                                     /* BufferPos                 */
  210.  301,                                     /* BufferSize                */
  211.    0,  0,                                 /* DispPos , UndoPos         */
  212.    0,                                     /* Numchars                  */
  213.    0,                                     /* DispCount                 */
  214.    0,  0,                                 /* CLeft , CTop              */
  215.  NULL,                                    /* LayerPtr                  */
  216.  NULL,                                    /* LongInt                   */
  217.  NULL,                                    /* AltKeyMap                 */
  218. };
  219.  
  220. struct Gadget StrGad1 =
  221. {
  222.  &StrGad2,                                /* Next Gadget               */
  223.   10, 20,                                 /* LeftEdge , TopEdge        */
  224.  300, 12,                                 /* Width , Height            */
  225.  GADGHCOMP,                               /* Flags                     */
  226.  STRINGCENTER,                            /* Activation                */
  227.  STRGADGET,                               /* Gadget Type               */
  228.  (APTR)&Border1,                          /* Gadget Render             */
  229.  NULL,                                    /* No Selected Render        */
  230.  NULL,                                    /* No Gadget Text            */
  231.  NULL,                                    /* Mutual Exclude            */
  232.  (APTR)&StrGad1StringInfo,                /* Special Info              */
  233.  STRGAD1_GAD,                             /* Gadget ID                 */
  234.  NULL,                                    /* User Data                 */
  235. };
  236.  
  237. /*-  NewWindow  :   ---
  238. ---  Window1        -*/
  239.  
  240. struct NewWindow NewWindow1 =
  241. {
  242.   50, 50,                                 /* LeftEdge , TopEdge        */
  243.  350, 80,                                 /* Width , Height            */
  244.    0,  1,                                 /* DetailPen , BlockPen      */
  245.  NULL,                                    /* IDCMP Flags               */
  246.  WINDOWSIZING                             /* Flags                     */
  247.  | WINDOWDRAG | WINDOWDEPTH | SMART_REFRESH | ACTIVATE,
  248.  &StrGad1,                                /* First Gadget              */
  249.  NULL,                                    /* Check Mark                */
  250.  (UBYTE *) "String gadget example :",     /* Title                     */
  251.  NULL,                                    /* Screen                    */
  252.  NULL,                                    /* BitMap                    */
  253.  100, 20,                                 /* MinWidth , MinHeight      */
  254.  640,256,                                 /* MaxWidth , MaxHeight      */
  255.  WBENCHSCREEN,                            /* ScreenType                */
  256. };
  257.  
  258. /*-----------------------------------------------------------
  259. --  Functionname: main
  260. --  Required variables
  261. --              :  --
  262. --   Returnvalue:  --
  263. --        Remark: Calls Open_All and Close_All.
  264. ------------------------------------------------------------*/
  265.  
  266. void main()
  267. {
  268. Open_All();
  269. Delay(1000L);
  270. Close_All();
  271. }
  272.  
  273. /*-----------------------------------------------------------
  274. --  Functionname: Open_All
  275. --          Task: Opens Intuitionlibrary
  276. --                and structures.
  277. --  Required variables
  278. --              :  --
  279. --   Returnvalue:  --
  280. --        Remark: Calls Close_All in case of difficulties.
  281. ------------------------------------------------------------*/
  282.  
  283.  
  284. void Open_All()
  285. {
  286.  void                 *OpenLibrary();
  287.  struct Window        *OpenWindow();
  288.  
  289.  if (NOT(IntuitionBase = (struct IntuitionBase *)
  290.        OpenLibrary ("intuition.library", 0L)))
  291.  {
  292.   printf("No Intuition Library !!");
  293.   Close_All();
  294.   exit(FALSE);
  295.  }
  296.  
  297.  if (NOT(Window1 = (struct Window *)
  298.        OpenWindow (&NewWindow1 )))
  299.  {
  300.   printf("Can't open Window1 -  WB-Window .\n");
  301.   Close_All();
  302.   exit(FALSE);
  303.  }
  304.  
  305. }
  306.  
  307. /*-----------------------------------------------------------
  308. --  Functionname: Close_All
  309. --          Task: Closes Intuitionlibrary
  310. --                and structures.
  311. --  Required variables
  312. --              :  --
  313. --   Returnvalue:  --
  314. --        Remark:  --
  315. ------------------------------------------------------------*/
  316.  
  317. void Close_All()
  318. {
  319.  void                  CloseWindow();
  320.  void                  CloseLibrary();
  321.  
  322.  if (Window1)   CloseWindow (Window1) ;
  323.  if (IntuitionBase)     CloseLibrary(IntuitionBase);
  324. }
  325.