home *** CD-ROM | disk | FTP | other *** search
/ AMIGA-CD 2 / Amiga-CD - Volume 2.iso / ungepackte_daten / 1992 / 09 / 2 / window-machine / wm_source.ampk / WM_Source2.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-06-01  |  10.8 KB  |  468 lines

  1. /************************************************************************
  2. *
  3. *        Source-Name:    WM_Source2.c
  4. *        Compiler   :    Lattice 5.02
  5. *        Funktion   :    verschiedene-Strukturen erstellen
  6. *        Autor       :    Arno Pichler
  7. *        Besonderes :    wird zu Window-Maschine gelinkt
  8. *
  9. ************************************************************************/
  10.  
  11. #include <WM.h>
  12. #include <MS.h>
  13. #include <MyStructs.h>
  14.  
  15. USHORT MenuSource()
  16. {
  17.     status=0;
  18.     if((Erlaubt & 16)==0) return(0);
  19.     helpM=helpW->MenuStrip;
  20.     if(CodeArt==0)
  21.     {
  22.         while(helpM->Next)
  23.             helpM=helpM->Next;
  24.     }
  25.     while(helpM)
  26.     {
  27.         MU++;
  28.  
  29. /************************************************************************
  30. *        Assembler --- MenuListeNr: ---            
  31. ************************************************************************/
  32.  
  33.         if(CodeArt==1 && status==0)
  34.         {
  35.             MUL++;
  36.             status=1;
  37.             sprintf(Buffer,"%s%s%d:",String[15],String[5],MUL);
  38.             if(LSave()) return(1);
  39.         }
  40.  
  41. /************************************************************************
  42. *        C - Sourcecode MenuItem's ausgeben
  43. ************************************************************************/
  44.  
  45.         if(CodeArt==0)
  46.         {
  47.             if(ItemSource())
  48.                 return(1);
  49.         }
  50.  
  51. /************************************************************************
  52. *        C - struct Menu --- MenuNr --- = {
  53. *         Assembler - Menu --- Nr: ---
  54. ************************************************************************/
  55.  
  56.         StrEnd=0;
  57.         if(CodeArt==0) sprintf(Buffer,"%s%s %s%d",STR,String[15],
  58.                     String[15],MU);
  59.         else sprintf(Buffer,"%s%d",String[15],MU);
  60.         if(CStart()) return(1);
  61.         
  62. /************************************************************************
  63. *        C und Assembler --- Nextes Menu oder NULL ---
  64. ************************************************************************/
  65.  
  66.         if(helpM->Next)
  67.         {
  68.             AssT(2);
  69.             KUnd();
  70.             i=MU-1;
  71.             if(CodeArt) i=MU+1;
  72.             InLeer(15,i);
  73.             if(BuffKom()) return(1);
  74.         }
  75.         else if(Null(1)) return(1);
  76.  
  77. /************************************************************************
  78. *        C und Assembler --- LeftEdge,TopEdge ---
  79. ************************************************************************/
  80.  
  81.         if(Word(helpM->LeftEdge,helpM->TopEdge)) return(1);
  82.  
  83. /************************************************************************
  84. *        C und Assembler --- Width,Height ---
  85. ************************************************************************/
  86.  
  87.         if(Word(helpM->Width,helpM->Height)) return(1);
  88.  
  89. /************************************************************************
  90. *        C und Assembler --- MenuFlags ---
  91. ************************************************************************/
  92.  
  93.         AssT(1);
  94.         if(helpM->Flags)
  95.         {
  96.             InBuff("MENUENABLED");
  97.             if(KomTab()) return(1);
  98.         }
  99.         else if(Null(1)) return(1);
  100.  
  101. /************************************************************************
  102. *            C --- MenuName ---
  103. *            Assembler --- Zeiger auf MenuName ---
  104. ************************************************************************/
  105.  
  106.         AssT(2);
  107.         if(CodeArt)
  108.         {
  109.             sprintf(LEER,"%s%s%d",String[15],String[7],MU);
  110.             BuffLeer();
  111.         }
  112.         else
  113.         {
  114.             if(Compiler) InBuff(CType[2]);
  115.             SetByte(helpM->MName);
  116.         }
  117.         if(KomTab()) return(1);
  118.  
  119. /************************************************************************
  120. *        C und Assembler --- FirstItem ---
  121. ************************************************************************/
  122.  
  123.         AssT(2);
  124.         KUnd();
  125.         if(helpM->FirstItem)
  126.         {
  127.             i=MI;
  128.             if(CodeArt) i++;
  129.             helpJ=helpM->FirstItem;
  130.             MakeName(helpJ->ItemName,i,16);
  131.             if(LSave()) return(1);
  132.         }
  133.         else if(Null(0)) return(1);
  134.         if(CodeArt==0)
  135.         {
  136.             CEnde();
  137.             if(DSave()) return(1);
  138.         }
  139.         else
  140.         {
  141.             HTab();
  142.             AssT(1);
  143.             Nuller(3);
  144.             if(LSave()) return(1);
  145.             sprintf(Buffer,"%s%s%d:",String[15],String[7],MU);
  146.             Tab();
  147.             AssT(0);
  148.             SetByte(helpM->MName);
  149.             KommaNull(3);
  150.             if(DSave()) return(1);
  151.             if(ItemSource()) return(1);
  152.         }
  153.  
  154. /************************************************************************
  155. *            Nextes Menu ermitteln
  156. ************************************************************************/
  157.  
  158.         if(CodeArt) helpM=helpM->Next;
  159.         else helpM=helpM->Parent;
  160.     }
  161.  
  162. /************************************************************************
  163. *        C --- #define MenuListeNr MenuNr ---
  164. ************************************************************************/
  165.  
  166.     if(CodeArt==0)
  167.     {
  168.         MUL++;
  169.         sprintf(Buffer,"%s%s%s%d %s%d",String[6],String[15],
  170.             String[5],MUL,String[15],MU);
  171.         if(DSave()) return(1);
  172.     }
  173.     return(0);
  174. }
  175.  
  176. /************************************************************************
  177. *        MenuItem-Strukturen erstellen
  178. ************************************************************************/
  179.  
  180. USHORT ItemSource()
  181. {
  182.     actI=helpM->FirstItem;
  183.     if(actI==NULL) return(0);
  184.     ok=0;
  185.     if(CodeArt==0)
  186.     {
  187.         while(actI->Next)
  188.             actI=actI->Next;
  189.     }
  190.     while(actI)
  191.     {
  192.         MI++;
  193.         if(SubSource()) return(1);
  194.         helpJ=actI;
  195.         if(ItemQuell(MI,16)) return(1);
  196.         if(CodeArt) actI=actI->Next;
  197.         else actI=actI->Parent;
  198.     }
  199.     return(0);
  200. }
  201.  
  202. /************************************************************************
  203. *        SubItem-Strukturen erstellen
  204. ************************************************************************/
  205.  
  206. USHORT SubSource()
  207. {
  208.     actS=actI->Sub;
  209.     if(actS==NULL) return(0);
  210.     ok=1;
  211.     if(CodeArt==0)
  212.     {
  213.         while(actS->Next)
  214.             actS=actS->Next;
  215.     }
  216.     while(actS)
  217.     {
  218.         SU++;
  219.         helpJ=actS;
  220.         if(ItemQuell(SU,17)) return(1);
  221.         if(CodeArt) actS=actS->Next;
  222.         else actS=actS->Parent;
  223.     }
  224.     return(0);
  225. }
  226.  
  227. USHORT ItemExtra()
  228. {
  229.     if(helpJ->ItemImage)
  230.     {
  231.         if(ImageSource(helpJ->ItemImage,0)) return(1);
  232.         IMG=IM;
  233.     }
  234.     if(helpJ->SelectImage!=NULL && helpJ->ItemImage!=NULL)
  235.     {
  236.         if(ImageSource(helpJ->SelectImage,0)) return(1);
  237.         IMS=IM;
  238.     }
  239.     if(helpJ->ItemText!=NULL && helpJ->ItemImage==NULL)
  240.     {
  241.         if(TextSource(helpJ->ItemText,0)) return(1);
  242.         IT=TX;
  243.     }
  244.     if(helpJ->SelectText!=NULL && helpJ->ItemText!=NULL &&
  245.         helpJ->ItemImage==NULL)
  246.     {
  247.         if(TextSource(helpJ->SelectText,0)) return(1);
  248.         ST=TX;
  249.     }
  250.     return(0);
  251. }
  252.     
  253. /************************************************************************
  254. *        Item-Struktur erstellen ---            
  255. ************************************************************************/
  256.  
  257. USHORT ItemQuell(USHORT q,UBYTE string)
  258. {
  259. /************************************************************************
  260. *    C - struct MenuItem --- ItemName oder ItemNr --- = {
  261. *         Assembler - Item --- Name: oder Nr: ---
  262. ************************************************************************/
  263.  
  264.     if(CodeArt==0)
  265.     {
  266.         if(ItemExtra()) return(1);
  267.         sprintf(Buffer,"%s%s ",STR,String[16]);
  268.     }
  269.     StrEnd=0;
  270.     MakeName(helpJ->ItemName,q,string);
  271.     if(CStart()) return(1);
  272.  
  273. /************************************************************************
  274. *        C und Assembler --- Nextes Item oder NULL ---
  275. ************************************************************************/
  276.  
  277.     if(helpJ->Next)
  278.     {
  279.         AssT(2);
  280.         KUnd();
  281.         i=q-1;
  282.         if(CodeArt) i=q+1;
  283.         MakeName(helpJ->Next->ItemName,i,string);
  284.         if(KomTab()) return(1);
  285.     }
  286.     else if(Null(1)) return(1);
  287.  
  288. /************************************************************************
  289. *        C und Assembler --- LeftEdge,TopEdge ---
  290. ************************************************************************/
  291.  
  292.     if(Word(helpJ->LeftEdge,helpJ->TopEdge)) return(1);
  293.  
  294. /************************************************************************
  295. *        C und Assembler --- Width,Height ---
  296. ************************************************************************/
  297.  
  298.     if(Word(helpJ->Width,helpJ->Height)) return(1);
  299.  
  300. /************************************************************************
  301. *        C und Assembler --- Item-Flags ---
  302. ************************************************************************/
  303.  
  304.     AssT(1);
  305.     d=7;
  306.     if(helpJ->ItemImage!=NULL && helpJ->SelectImage!=NULL) d=4;
  307.     else if(helpJ->ItemText!=NULL && helpJ->SelectText!=NULL) d=4;
  308.     j=0;
  309.     for(i=0; i<d; i++)
  310.     {
  311.         if((helpJ->Flags & MFLAGS[i]) == MFLAGS[i])
  312.         {
  313.             Plus();
  314.             InBuff(MFLAGS1[i]);
  315.         }
  316.     }
  317.     if(helpJ->Command != 0)
  318.     {
  319.         Plus();
  320.         InBuff("COMMSEQ");
  321.     }
  322.     if(helpJ->ItemText!=NULL && helpJ->ItemImage==NULL)
  323.     {
  324.         Plus();
  325.         InBuff("ITEMTEXT");
  326.         if(helpJ->SelectText!=NULL)
  327.         {
  328.             Plus();
  329.             InBuff(DEFS[8]);
  330.         }
  331.     }
  332.     if(helpJ->ItemImage!=NULL && helpJ->SelectImage!=NULL)
  333.     {
  334.         Plus();
  335.         InBuff(DEFS[8]);
  336.     }
  337.     if(j==0)
  338.     {
  339.         if(Null(1)) return(1);
  340.     }
  341.     else if(KomTab()) return(1);
  342.  
  343. /************************************************************************
  344. *            MutualExclude
  345. ************************************************************************/
  346.  
  347.     if(helpJ->Exclude)
  348.     {
  349.         AssT(2);
  350.         HexCode(helpJ->Exclude);
  351.         if(KomTab()) return(1);
  352.     }
  353.     else if(Null(1)) return(1);
  354.  
  355. /************************************************************************
  356. *        C und Assembler --- ItemFill ---
  357. ************************************************************************/
  358.  
  359.     strcpy(LEER,"");
  360.     if(helpJ->ItemText!=NULL && helpJ->ItemImage==NULL)
  361.     {
  362.         if(CodeArt) sprintf(LEER,"I%s%d",String[4],TX+1);
  363.         else sprintf(LEER,"%s&I%s%d",CType[1],String[4],IT);
  364.     }
  365.     if(helpJ->ItemImage)
  366.     {
  367.         if(CodeArt) InLeer(10,IM+1);
  368.         else sprintf(LEER,"%s&%s%d",CType[1],String[10],IMG);
  369.     }
  370.     if(strlen(LEER))
  371.     {
  372.         AssT(2);
  373.         if(BuffKom()) return(1);
  374.     }
  375.     else if(Null(1)) return(1);
  376.  
  377. /************************************************************************
  378. *        C und Assembler --- SelectFill ---
  379. ************************************************************************/
  380.  
  381.     strcpy(LEER,"");
  382.     if(helpJ->SelectText!=NULL && helpJ->ItemText!=NULL &&
  383.         helpJ->ItemImage==NULL)
  384.     {
  385.         if(CodeArt)
  386.         {
  387.             helpT=helpJ->ItemText;
  388.             i=TX+1;
  389.             while(helpT)
  390.             {
  391.                 i++;
  392.                 helpT=helpT->NextText;
  393.             }
  394.             sprintf(LEER,"I%s%d",String[4],i);
  395.         }
  396.         else sprintf(LEER,"%s&I%s%d",CType[1],String[4],ST);
  397.     }
  398.     if(helpJ->SelectImage!=NULL && helpJ->ItemImage!=NULL)
  399.     {
  400.         if(CodeArt) InLeer(10,IM+2);
  401.         else sprintf(LEER,"%s&%s%d",CType[1],String[10],IMS);
  402.     }
  403.     if(strlen(LEER))
  404.     {
  405.         AssT(2);
  406.         if(BuffKom()) return(1);
  407.     }
  408.     else if(Null(1)) return(1);
  409.  
  410. /************************************************************************
  411. *        C und Assembler --- Command ---
  412. ************************************************************************/
  413.  
  414.     AssT(0);
  415.     if(helpJ->Command)
  416.     {
  417.         BType=CodeArt;
  418.         CodeArt=1;
  419.         LEER[0]=helpJ->Command;
  420.         LEER[1]='\0';
  421.         SetByte(LEER);
  422.         CodeArt=BType;
  423.     }
  424.     else Nuller(0);
  425.     KommaNull(0);
  426.     if(KomTab()) return(1);
  427.  
  428. /************************************************************************
  429. *        C und Assembler --- SubItem oder NULL ---
  430. ************************************************************************/
  431.  
  432.     if(helpJ->Sub)
  433.     {
  434.         AssT(2);
  435.         KUnd();
  436.         i=SU;
  437.         if(CodeArt) i++;
  438.         MakeName(helpJ->Sub->ItemName,i,17);
  439.         if(KomTab()) return(1);
  440.     }
  441.     else if(Null(1)) return(1);
  442.  
  443. /************************************************************************
  444. *        C und Assembler --- MENUNULL ---
  445. ************************************************************************/
  446.  
  447.     AssT(1);
  448.     InBuff("MENUNULL");
  449.     if(LSave()) return(1);
  450.     if(CodeArt)
  451.     {
  452.         if(ItemExtra()) return(1);
  453.     }
  454.  
  455. /************************************************************************
  456. *        C - };
  457. ************************************************************************/
  458.  
  459.     else
  460.     {
  461.         CEnde();
  462.         if(DSave()) return(1);
  463.     }
  464.     return(0);
  465. }
  466.  
  467.  
  468.