home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 594a.lha / maker_v0.1 / structout.c < prev    next >
C/C++ Source or Header  |  1991-10-18  |  5KB  |  195 lines

  1. #include "global.h"
  2.  
  3. #include <stdio.h>
  4. #include <string.h>
  5. #include <exec/memory.h>
  6. #include <libraries/asl.h>
  7.  
  8. #include <proto/intuition.h>
  9. #include <proto/exec.h>
  10. #include <proto/asl.h>
  11. #include <proto/dos.h>
  12.  
  13.  
  14. void WriteStruct(USHORT code)
  15. {
  16.     LinkNode        *nodePtr;
  17.     GadgetObj    *gadgObj;
  18.     
  19.     USHORT        gadCount = 0,
  20.                     tagCount = 0,
  21.                     stringCount = 0,
  22.                     rectCount = 0,
  23.                     iTextCount = 0,
  24.                     itemNum, totItems;
  25.     short            *newGadgetIndex = 0L,
  26.                     *tagItemIndex = 0L,
  27.                     *stringIndex = 0L,
  28.                     *rectIndex = 0L,
  29.                     *iTextIndex = 0L;
  30.     BOOL            first = TRUE;
  31.     
  32.     totItems = NodeCount( (void **) &gObjList);
  33.     if (!totItems)
  34.         return;
  35.     
  36.     if (    !GetMem( (void **) &newGadgetIndex, (ULONG) totItems * (ULONG) sizeof(short) ) ||
  37.             !GetMem( (void **) &tagItemIndex, (ULONG) totItems * (ULONG) sizeof(short) ) ||
  38.             !GetMem( (void **) &stringIndex, (ULONG) totItems * (ULONG) sizeof(short) ) ||
  39.             !GetMem( (void **) &rectIndex, (ULONG) totItems * (ULONG) sizeof(short) ) ||
  40.             !GetMem( (void **) &iTextIndex, (ULONG) totItems * (ULONG) sizeof(short) ) )
  41.         goto cleanup;
  42.     
  43.     for (itemNum=0; itemNum<totItems; itemNum++)
  44.     {
  45.         newGadgetIndex[itemNum] = -1;
  46.         tagItemIndex[itemNum] = -1;
  47.     }
  48.     
  49.     // first, do the NewGadget structures
  50.  
  51.     for (nodePtr=gObjList, itemNum=0; nodePtr; nodePtr=nodePtr->next, itemNum++)
  52.     {
  53.         if (GetGadgetData(nodePtr, 0L, 0L, 0L, 0L, 0L))
  54.         {
  55.             gadgObj = (GadgetObj *) nodePtr;
  56.             
  57.             newGadgetIndex[itemNum] = gadCount++;
  58.  
  59.             if (first)
  60.             {
  61.                 printf("//  NewGadget structure for all gadgets\n\n");
  62.                 printf("struct NewGadget gResNewGadget[] =\n{\n");
  63.                 first = FALSE;
  64.             }
  65.  
  66. //            printf("// ++++++++++++++++++++++++++++++++\n");
  67.             printf("\t// Item Number %d (type is %s)\n", itemNum, objName[nodePtr->type]);
  68.             printf("\t{\t%3d, %3d, %3d, %3d, \"%s\", 0L, %3d,\n",
  69.                             gadgObj->rect.minX, gadgObj->rect.minY,
  70.                             gadgObj->rect.maxX - gadgObj->rect.minX + 1,
  71.                             gadgObj->rect.maxY - gadgObj->rect.minY + 1,
  72.                             gadgObj->label, itemNum);
  73.             printf("\t\t");
  74.             if (gadgObj->flags == 0)
  75.                 printf("0L, ");
  76.             else
  77.             {
  78.                 if (gadgObj->flags & PLACETEXT_IN)
  79.                     printf("PLACETEXT_IN");
  80.                 else if (gadgObj->flags & PLACETEXT_ABOVE)
  81.                     printf("PLACETEXT_ABOVE");
  82.                 else if (gadgObj->flags & PLACETEXT_RIGHT)
  83.                     printf("PLACETEXT_RIGHT");
  84.                 else if (gadgObj->flags & PLACETEXT_LEFT)
  85.                     printf("PLACETEXT_LEFT");
  86.                 else if (gadgObj->flags & PLACETEXT_BELOW)
  87.                     printf("PLACETEXT_BELOW");
  88.                 
  89.                 printf(", ");
  90.             }
  91.             printf("gVI, 0L },\n");
  92.         }
  93.     }
  94.     
  95.     if (!first)
  96.         printf("};\n\n");
  97.         
  98.     // second, do the tagitem arrays
  99.  
  100.     first = TRUE;
  101.     for (nodePtr=gObjList, itemNum=0; nodePtr; nodePtr=nodePtr->next, itemNum++)
  102.     {
  103.         if (GetGadgetData(nodePtr, 0L, 0L, 0L, 0L, 0L))
  104.         {
  105.             gadgObj = (GadgetObj *) nodePtr;
  106.             
  107.             tagItemIndex[itemNum] = tagCount;
  108.  
  109.             if (first)
  110.             {
  111.                 printf("//  TagItem array for all gadgets\n\n");
  112.                 printf("ULONG gResTags[] =\n{\n");
  113.                 first = FALSE;
  114.             }
  115.  
  116.             printf("\t// Item Number %d (type is %s)\n", itemNum, objName[nodePtr->type]);
  117.             
  118.             switch(nodePtr->type)
  119.             {
  120.                 case OTYPE_Button:
  121.                     PutTF(gadgObj->disable);
  122.                     printf(",\n");
  123.                     tagCount++;
  124.                     break;
  125.                 case OTYPE_Cycle:
  126.                     PutTF(gadgObj->disable);
  127.                     printf(", %d,\n", ( (CycleObj *) gadgObj)->activeItem);
  128.                     tagCount += 2;
  129.                     break;
  130.                 case OTYPE_MX:
  131.                     PutTF(gadgObj->disable);
  132.                     printf(", %d, %d\n", ( (MXObj *) gadgObj)->activeItem,
  133.                                                 ( (MXObj *) gadgObj)->extraSpacing);
  134.                     tagCount += 3;
  135.                     break;
  136.             }
  137.         }
  138.     }
  139.     
  140.     if (!first)
  141.         printf("};\n\n");
  142.         
  143.         
  144.     // now, do the strings
  145.  
  146.     first = TRUE;
  147.     for (nodePtr=gObjList, itemNum=0; nodePtr; nodePtr=nodePtr->next, itemNum++)
  148.     {
  149.         if (nodePtr->type == OTYPE_Cycle || nodePtr->type == OTYPE_MX ||
  150.                 nodePtr->type == OTYPE_ListView)
  151.         {
  152.             gadgObj = (GadgetObj *) nodePtr;
  153.             
  154.             stringIndex[itemNum] = stringCount;
  155.  
  156.             if (first)
  157.             {
  158.                 printf("//  String array for all gadgets\n\n");
  159.                 printf("ULONG gResStrings[] =\n{\n");
  160.                 first = FALSE;
  161.             }
  162.  
  163.             printf("\t// Item Number %d (type is %s)\n", itemNum, objName[nodePtr->type]);
  164.             
  165.             switch(nodePtr->type)
  166.             {
  167.                 case OTYPE_Button:
  168.                     break;
  169.             }
  170.         }
  171.     }
  172.     
  173.     if (!first)
  174.         printf("};\n\n");
  175.         
  176. cleanup:
  177.     if (newGadgetIndex)
  178.         DropMem( (void **) &newGadgetIndex, (ULONG) totItems * (ULONG) sizeof(short) );
  179.     if (tagItemIndex)
  180.         DropMem( (void **) &tagItemIndex, (ULONG) totItems * (ULONG) sizeof(short) );
  181.     if (stringIndex)
  182.         DropMem( (void **) &stringIndex, (ULONG) totItems * (ULONG) sizeof(short) );
  183.     if (iTextIndex)
  184.         DropMem( (void **) &iTextIndex, (ULONG) totItems * (ULONG) sizeof(short) );
  185.     if (rectIndex)
  186.         DropMem( (void **) &rectIndex, (ULONG) totItems * (ULONG) sizeof(short) );
  187.  
  188. }
  189.  
  190. void PutTF(BOOL flag)
  191. {
  192.     printf("%s", flag ? "TRUE" : "FALSE");
  193. }
  194.  
  195.