home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / MUI / MUIBuilder22.lha / MUIBuilder / MB / E / sources / GUIFile.e < prev    next >
Encoding:
Text File  |  1995-02-06  |  29.8 KB  |  1,267 lines

  1. OPT MODULE
  2. OPT PREPROCESS
  3.  
  4.  
  5. ->*****
  6. ->** External modules
  7. ->*****
  8. MODULE 'muibuilder' , 'libraries/muibuilder'
  9.  
  10. MODULE '*.config'
  11. MODULE '*Variable'
  12. MODULE '*AuxProcs'
  13.  
  14.  
  15. ->*****
  16. ->** Exception handling
  17. ->*****
  18. RAISE    "OPEN"    IF    Open()        =    NIL    ,
  19.         "OUT"    IF    Fputs()        =    -1    ,
  20.         "OUT"    IF    FputC()        =    -1    ,
  21.         "MEM"    IF    String()    =    NIL
  22.  
  23.  
  24. ->*****
  25. ->** Object definitions
  26. ->*****
  27. EXPORT    OBJECT gui_file
  28.             PRIVATE
  29.                 file                :    LONG
  30.                 number_vars            :    LONG
  31.                 vars                :    PTR TO variable
  32.                 ident_length_max    :    LONG
  33.                 hook_funcs            :    LONG
  34.                 main_object_ident    :    PTR TO CHAR
  35.         ENDOBJECT
  36.  
  37.  
  38. /***********************************
  39. ** Opens the GUI file to generate **
  40. ***********************************/
  41. PROC open( filename : PTR TO CHAR , number_vars , vars : PTR TO variable , ident_length_max ) OF gui_file
  42.  
  43.     DEF i
  44.  
  45.     self.file := Open( filename , NEWFILE )
  46.     self.number_vars := number_vars
  47.     self.vars := vars
  48.     self.ident_length_max := ident_length_max
  49.     self.main_object_ident := vars[ 0 ].ident
  50.     self.hook_funcs := FALSE
  51.  
  52.     FOR i := 0 TO ( number_vars - 1 ) DO IF vars[ i ].type = TYPEVAR_HOOK THEN self.hook_funcs := TRUE
  53.  
  54. ENDPROC
  55.  
  56.  
  57. /************************************
  58. ** Closes the GUI file to generate **
  59. ************************************/
  60. PROC close() OF gui_file
  61.  
  62.     IF self.file THEN Close( self.file )
  63.  
  64. ENDPROC
  65.  
  66.  
  67. /******************************************
  68. ** Write to the GUI file its header part **
  69. ******************************************/
  70. PROC put_header( application , locale ) OF gui_file
  71.  
  72. #ifdef EV30
  73.     Fputs( self.file ,
  74.         'OPT MODULE\n\n\n'                                                                    +
  75.         '/*/////////////////////////////////////////////////////////////////////////////\n'    +
  76.         '///////////////////////////////////////////////////////////// Macro files /////\n'    +
  77.         '///////////////////////////////////////////////////////////////////////////////\n'    +
  78.         'MACROS ''MUI.pma''\n*/\n\n\n'                                                        +
  79.         '->/////////////////////////////////////////////////////////////////////////////\n'    +
  80.         '->////////////////////////////////////////////////////// External modules /////\n'    +
  81.         '->/////////////////////////////////////////////////////////////////////////////\n' +
  82.         'MODULE ''muimaster'' , ''libraries/mui''\n'                                        +
  83.         'MODULE ''tools/boopsi''\n'                                                            +
  84.         'MODULE ''utility/tagitem'''                                                        )
  85. #endif
  86.  
  87. #ifdef EV31
  88.     Fputs( self.file ,
  89.         'OPT MODULE\n'                                                                        +
  90.         'OPT PREPROCESS\n\n\n'                                                                +
  91.         '->/////////////////////////////////////////////////////////////////////////////\n'    +
  92.         '->////////////////////////////////////////////////////// External modules /////\n'    +
  93.         '->/////////////////////////////////////////////////////////////////////////////\n' +
  94.         'MODULE ''muimaster'' , ''libraries/mui''\n'                                        +
  95.         'MODULE ''tools/boopsi''\n'                                                            +
  96.         'MODULE ''utility/tagitem'''                                                        )
  97. #endif
  98.  
  99.     Fputs( self.file , IF ( self.hook_funcs OR application ) THEN ' , ''utility/hooks''\n\n' ELSE '\n\n' )
  100.  
  101.     IF locale THEN Fputs( self.file , 'MODULE ''*Locale''\n\n\n' ) ELSE FputC( self.file , "\n" )
  102.  
  103. ENDPROC
  104.  
  105.  
  106. /*********************************************************
  107. ** Write to the GUI file the definitions of aux objects **
  108. *********************************************************/
  109. PROC put_aux_objects( environment , application ) OF gui_file
  110.  
  111.     DEF i
  112.  
  113.     IF environment
  114.  
  115.         Fputs( self.file ,
  116.             '->/////////////////////////////////////////////////////////////////////////////\n'    +
  117.             '->//////////////////////////////////////////////////// Object definitions /////\n'    +
  118.             '->/////////////////////////////////////////////////////////////////////////////\n' )
  119.  
  120.         IF application THEN    Fputs( self.file ,
  121.                                 'EXPORT OBJECT app_arexx\n'                +
  122.                                 '\tcommands :\tPTR TO mui_command\n'    +
  123.                                 '\terror    :\thook\n'                    +
  124.                                 'ENDOBJECT\n\n'                            )
  125.  
  126.     ENDIF
  127.  
  128.     IF self.hook_funcs
  129.  
  130.         IF environment
  131.  
  132.             Fputs( self.file , 'EXPORT OBJECT ' )
  133.             Fputs( self.file , self.main_object_ident )
  134.             Fputs( self.file , '_display\n' )
  135.  
  136.         ENDIF
  137.  
  138.         FOR i := 0 TO ( self.number_vars - 1 )
  139.  
  140.             IF self.vars[ i ].type = TYPEVAR_HOOK
  141.  
  142.                 FputC( self.file , "\t" )
  143.                 Fputs( self.file , self.vars[ i ].ident )
  144.                 indent_defs( self.file , self.vars[ i ].ident , self.ident_length_max )
  145.                 Fputs( self.file , ' :\thook\n' )
  146.  
  147.             ENDIF
  148.  
  149.         ENDFOR
  150.  
  151.         IF environment THEN Fputs( self.file , 'ENDOBJECT\n\n' ) ELSE FputC( self.file , "\n" )
  152.  
  153.     ENDIF
  154.  
  155. ENDPROC
  156.  
  157.  
  158. /*****************************************************************
  159. ** Write to the GUI file the definition of the generated object **
  160. *****************************************************************/
  161. PROC put_main_object( environment ) OF gui_file
  162.  
  163.     DEF i
  164.  
  165.     IF environment
  166.  
  167.         Fputs( self.file , 'EXPORT OBJECT ' )
  168.         Fputs( self.file , self.main_object_ident )
  169.         Fputs( self.file , '_obj\n' )
  170.  
  171.     ENDIF
  172.  
  173.     FOR i := 0 TO ( self.number_vars - 1 )
  174.  
  175.         IF self.vars[ i ].type = TYPEVAR_PTR
  176.  
  177.             FputC( self.file , "\t" )
  178.             Fputs( self.file , self.vars[ i ].ident )
  179.             indent_defs( self.file , self.vars[ i ].ident , self.ident_length_max )
  180.             Fputs( self.file , ' :\tPTR TO LONG\n' )
  181.  
  182.         ENDIF
  183.  
  184.     ENDFOR
  185.  
  186.     FOR i := 0 TO ( self.number_vars - 1 )
  187.  
  188.         IF ( self.vars[ i ].type = TYPEVAR_INT ) AND ( self.vars[ i ].type = TYPEVAR_BOOL )
  189.  
  190.             FputC( self.file , "\t" )
  191.             Fputs( self.file , self.vars[ i ].ident )
  192.             indent_defs( self.file , self.vars[ i ].ident , self.ident_length_max )
  193.             Fputs( self.file , ' :\tLONG\n' )
  194.  
  195.         ENDIF
  196.  
  197.     ENDFOR
  198.  
  199.     FOR i := 0 TO ( self.number_vars - 1 )
  200.  
  201.         IF self.vars[ i ].type = TYPEVAR_STRING
  202.  
  203.             FputC( self.file , "\t" )
  204.             Fputs( self.file , self.vars[ i ].ident )
  205.             indent_defs( self.file , self.vars[ i ].ident , self.ident_length_max )
  206.             Fputs( self.file , ' :\tPTR TO CHAR\n' )
  207.  
  208.         ENDIF
  209.  
  210.     ENDFOR
  211.  
  212.     FOR i := 0 TO ( self.number_vars - 1 )
  213.  
  214.         IF self.vars[ i ].type = TYPEVAR_TABSTRING
  215.  
  216.             FputC( self.file , "\t" )
  217.             Fputs( self.file , self.vars[ i ].ident )
  218.             indent_defs( self.file , self.vars[ i ].ident , self.ident_length_max )
  219.             Fputs( self.file , ' :\tPTR TO LONG\n' )
  220.  
  221.         ENDIF
  222.  
  223.     ENDFOR
  224.  
  225.     Fputs( self.file , IF environment THEN 'ENDOBJECT\n\n\n' ELSE '\n\n' )
  226.  
  227. ENDPROC
  228.  
  229.  
  230. /***********************************************************************************
  231. ** Write to the GUI file the definitions of the constants used with MUIM_ReturnID **
  232. ***********************************************************************************/
  233. PROC put_constants( environment ) OF gui_file
  234.  
  235.     DEF i , first_constant = TRUE , previous_ident : PTR TO CHAR , offset = 0
  236.  
  237.     FOR i := 0 TO ( self.number_vars - 1 )
  238.  
  239.         IF self.vars[ i ].type = TYPEVAR_IDENT
  240.  
  241.             IF first_constant
  242.  
  243.                 IF environment THEN    Fputs( self.file ,
  244.                                         '->/////////////////////////////////////////////////////////////////////////////\n'    +
  245.                                         '->////////////////////////////////////////////////// Constant definitions /////\n'    +
  246.                                         '->/////////////////////////////////////////////////////////////////////////////\n'    +
  247.                                         'EXPORT ENUM\n'                                                                        )
  248.  
  249.                 FputC( self.file , "\t" )
  250.                 Fputs( self.file , self.vars[ i ].ident )
  251.                 Fputs( self.file , ' = 1' )
  252.                 previous_ident := self.vars[ i ].ident
  253.                 first_constant := FALSE
  254.  
  255.             ELSE
  256.  
  257.                 indent_defs( self.file , previous_ident , self.ident_length_max + offset )
  258.                 Fputs( self.file , ' ,\n\t' )
  259.                 Fputs( self.file , self.vars[ i ].ident )
  260.                 offset := 4
  261.                 previous_ident := self.vars[ i ].ident
  262.  
  263.             ENDIF
  264.  
  265.         ENDIF
  266.  
  267.     ENDFOR
  268.  
  269.     IF first_constant = FALSE THEN Fputs( self.file , '\n\n\n' )
  270.  
  271. ENDPROC
  272.  
  273.  
  274. /********************************************************************************************************
  275. ** Write to the GUI file the definitions of the global variables (external ones used by notifications) **
  276. ********************************************************************************************************/
  277. PROC put_global_vars( environment , locale , catalog_name : PTR TO CHAR ) OF gui_file
  278.  
  279.     DEF i , first_global_var = TRUE
  280.  
  281.     FOR i := 0 TO ( self.number_vars - 1 )
  282.  
  283.         IF self.vars[ i ].type = TYPEVAR_EXTERNAL
  284.  
  285.             IF first_global_var
  286.  
  287.                 IF environment THEN    Fputs( self.file ,
  288.                                         '->/////////////////////////////////////////////////////////////////////////////\n' +
  289.                                         '->/////////////////////////////////////////// Global variable definitions /////\n' +
  290.                                         '->/////////////////////////////////////////////////////////////////////////////\n'    )
  291.  
  292.                 first_global_var := FALSE
  293.  
  294.             ENDIF
  295.  
  296.             Fputs( self.file , 'EXPORT DEF ' )
  297.             Fputs( self.file , self.vars[ i ].ident )
  298.             FputC( self.file , "\n" )
  299.  
  300.         ENDIF
  301.  
  302.     ENDFOR
  303.  
  304.     IF locale
  305.  
  306.         IF first_global_var
  307.  
  308.             IF environment THEN    Fputs( self.file ,
  309.                                     '->/////////////////////////////////////////////////////////////////////////////\n' +
  310.                                     '->/////////////////////////////////////////// Global variable definitions /////\n' +
  311.                                     '->/////////////////////////////////////////////////////////////////////////////\n'    )
  312.  
  313.             first_global_var := FALSE
  314.  
  315.         ELSE
  316.  
  317.             FputC( self.file , "\n" )
  318.  
  319.         ENDIF
  320.  
  321.         Fputs( self.file , 'EXPORT DEF cat : PTR TO ' )
  322.         Fputs( self.file ,  catalog_name )
  323.         FputC( self.file , "\n" )
  324.  
  325.     ENDIF
  326.  
  327.     IF first_global_var = FALSE THEN Fputs( self.file , '\n\n' )
  328.  
  329. ENDPROC
  330.  
  331.  
  332. /*************************************************************
  333. ** Write to the GUI file the declaration of create() method **
  334. *************************************************************/
  335. PROC put_create_declaration( application ) OF gui_file
  336.  
  337.     Fputs( self.file ,
  338.         '->/////////////////////////////////////////////////////////////////////////////\n'    +
  339.         '->/////////// Creates one instance of one object or the whole application /////\n'    +
  340.         '->/////////////////////////////////////////////////////////////////////////////\n'    +
  341.         'PROC create('                                                                        )
  342.  
  343.     IF application
  344.  
  345.         IF self.hook_funcs
  346.  
  347.             Fputs( self.file , ' display : PTR TO ' )
  348.             Fputs( self.file , self.main_object_ident )
  349.             Fputs( self.file , '_display ,\n            ' )
  350.  
  351.         ENDIF
  352.  
  353.         Fputs( self.file ,
  354.             ' icon  = NIL ,\n'                                    +
  355.             '             arexx = NIL : PTR TO app_arexx ,\n'    +
  356.             '             menu  = NIL '                            )
  357.  
  358.     ELSE
  359.  
  360.         IF self.hook_funcs
  361.  
  362.             Fputs( self.file , ' display : PTR TO ' )
  363.             Fputs( self.file , self.main_object_ident )
  364.             Fputs( self.file , '_display ' )
  365.  
  366.         ENDIF
  367.  
  368.     ENDIF
  369.  
  370.     Fputs( self.file , ') OF ' )
  371.     Fputs( self.file , self.main_object_ident )
  372.     Fputs( self.file , '_obj\n\n' )
  373.  
  374. ENDPROC
  375.  
  376.  
  377. /********************************************************************
  378. ** Write to the GUI file the local declarations of create() method **
  379. ********************************************************************/
  380. PROC put_create_local_defs() OF gui_file
  381.  
  382.     DEF i , defs_string[ 70 ] : STRING , local_vars = FALSE
  383.  
  384.     FOR i := 0 TO ( self.number_vars - 1 )
  385.  
  386.         IF self.vars[ i ].type = TYPEVAR_LOCAL_PTR
  387.  
  388.             local_vars := TRUE
  389.  
  390.             IF ( EstrLen( defs_string ) + StrLen ( self.vars[ i ].ident ) ) <= 57
  391.  
  392.                 IF EstrLen( defs_string ) <> 0 THEN StrAdd( defs_string , ' , ' )
  393.                 StrAdd( defs_string , self.vars[ i ].ident )
  394.  
  395.             ELSE
  396.  
  397.                 Fputs( self.file, '\tDEF ' )
  398.                 Fputs( self.file, defs_string )
  399.                 FputC( self.file , "\n" )
  400.                 SetStr( defs_string , 0 )
  401.                 StrAdd( defs_string , self.vars[ i ].ident )
  402.  
  403.             ENDIF
  404.  
  405.         ENDIF
  406.             
  407.     ENDFOR
  408.  
  409.     IF EstrLen( defs_string ) <> 0
  410.  
  411.         Fputs( self.file , '\tDEF ' )
  412.         Fputs( self.file , defs_string )
  413.         FputC( self.file , "\n" )
  414.  
  415.     ENDIF
  416.  
  417.     IF local_vars THEN FputC( self.file , "\n" )
  418.  
  419. ENDPROC
  420.  
  421.  
  422. /********************************************************************
  423. ** Write to the GUI file the local declarations of create() method **
  424. ********************************************************************/
  425. PROC put_create_initialisations( locale , getstring_func : PTR TO CHAR ) OF gui_file
  426.  
  427.     DEF i , j , initialisations = FALSE
  428.     DEF strptr : PTR TO CHAR
  429.  
  430.     FOR i := 0 TO ( self.number_vars - 1 )
  431.  
  432.         IF self.vars[ i ].type = TYPEVAR_STRING
  433.  
  434.             initialisations := TRUE
  435.  
  436.             Fputs( self.file , '\tself.' )
  437.             Fputs( self.file , self.vars[ i ].ident )
  438.             indent_defs( self.file , self.vars[ i ].ident , self.ident_length_max )
  439.             Fputs( self.file , ' := ' )
  440.  
  441.             IF Char( self.vars[ i ].init ) <> 0
  442.  
  443.                 IF locale
  444.  
  445.                     Fputs( self.file , 'cat.' )
  446.                     Fputs( self.file , self.vars[ i ].init )
  447.                     FputC( self.file , "." )
  448.                     Fputs( self.file , getstring_func )
  449.                     Fputs( self.file , '()\n' )
  450.  
  451.                 ELSE
  452.  
  453.                     Fputs( self.file , string_convert( self.vars[ i ].init ) )
  454.                     FputC( self.file , "\n" )
  455.  
  456.                 ENDIF
  457.  
  458.             ELSE
  459.  
  460.                 Fputs( self.file , 'NIL\n' )
  461.  
  462.             ENDIF
  463.  
  464.         ENDIF
  465.  
  466.     ENDFOR
  467.  
  468.     FOR i := 0 TO ( self.number_vars - 1 )
  469.  
  470.         IF self.vars[ i ].type = TYPEVAR_TABSTRING
  471.  
  472.             initialisations := TRUE
  473.  
  474.             Fputs( self.file , '\tself.' )
  475.             Fputs( self.file , self.vars[ i ].ident )
  476.             indent_defs( self.file , self.vars[ i ].ident , self.ident_length_max )
  477.             Fputs( self.file , ' := [\n' )
  478.             strptr := self.vars[ i ].init
  479.  
  480.             FOR j := 1 TO self.vars[ i ].size
  481.  
  482.                 Fputs( self.file , '\t\t' )
  483.  
  484.                 IF locale
  485.  
  486.                     Fputs( self.file , 'cat.' )
  487.                     Fputs( self.file , strptr )
  488.                     FputC( self.file , "." )
  489.                     Fputs( self.file , getstring_func )
  490.                     Fputs( self.file , '() ,\n' )
  491.  
  492.                 ELSE
  493.  
  494.                     Fputs( self.file , string_convert( strptr ) )
  495.                     Fputs( self.file , ' ,\n' )
  496.  
  497.                 ENDIF
  498.  
  499.                 strptr := strptr + StrLen( strptr ) + 1
  500.  
  501.             ENDFOR
  502.  
  503.             Fputs( self.file , '\t\tNIL ]\n' )
  504.  
  505.         ENDIF
  506.  
  507.     ENDFOR
  508.  
  509.     IF initialisations THEN FputC( self.file , "\n" )
  510.  
  511. ENDPROC
  512.  
  513.  
  514. /************************************************
  515. ** Write to the GUI file all the creating code **
  516. ************************************************/
  517. PROC put_code( getstring_func : PTR TO CHAR , muistrings : PTR TO LONG ) OF gui_file
  518.  
  519.     DEF type , code
  520.     DEF indent_level = 1 , func_level = 0
  521.     DEF return = TRUE , objfunction = FALSE , inobj = FALSE
  522.  
  523.     Mb_GetNextCode( {type} , {code} )
  524.  
  525.     WHILE type <> -1
  526.  
  527.         SELECT type
  528.  
  529.             CASE TC_CREATEOBJ
  530.  
  531.                 indent_code( self.file , indent_level , return )
  532.                 Fputs( self.file , muistrings[ Val( code ) ] )
  533.                 Fputs( self.file , ' ,\n' )
  534.                 INC indent_level
  535.                 return := TRUE
  536.                 inobj := TRUE
  537.  
  538.                 IF Val( code ) = 113
  539.  
  540.                     indent_code( self.file , indent_level , return )
  541.                     Fputs( self.file , '( IF icon THEN MUIA_Application_DiskObject ELSE TAG_IGNORE ) , icon ,\n' )
  542.  
  543.                     indent_code( self.file , indent_level , return )
  544.                     Fputs( self.file , '( IF arexx THEN MUIA_Application_Commands ELSE TAG_IGNORE ) , ( IF arexx THEN arexx.commands ELSE NIL ) ,\n' )
  545.  
  546.                     indent_code( self.file , indent_level , return )
  547.                     Fputs( self.file , '( IF arexx THEN MUIA_Application_RexxHook ELSE TAG_IGNORE ) , ( IF arexx THEN arexx.error ELSE NIL ) ,\n' )
  548.  
  549.                     indent_code( self.file , indent_level , return )
  550.                     Fputs( self.file , '( IF menu THEN MUIA_Application_Menu ELSE TAG_IGNORE ) , menu ,\n' )
  551.  
  552.                 ENDIF
  553.  
  554.                 Mb_GetNextCode( {type} , {code} )
  555.  
  556.             CASE TC_ATTRIBUT
  557.  
  558.                 indent_code( self.file , indent_level , return )
  559.                 Fputs( self.file , muistrings[ Val( code ) ] )
  560.                 Fputs( self.file , ' , ')
  561.                 return := FALSE
  562.                 Mb_GetNextCode( {type} , {code} )
  563.  
  564.             CASE TC_END
  565.  
  566.                 DEC indent_level
  567.                 indent_code( self.file , indent_level , return )
  568.                 Fputs( self.file , muistrings[ Val( code ) ] )
  569.                 Fputs( self.file , '\n\n')
  570.                 inobj := FALSE
  571.                 return := TRUE
  572.                 Mb_GetNextCode( {type} , {code} )
  573.  
  574.             CASE TC_FUNCTION
  575.  
  576.                 indent_code( self.file , indent_level , return )
  577.  
  578.                 IF Val( code ) = 673
  579.  
  580.                     FputC( self.file , 34 )
  581.                     Mb_GetNextCode( {type} , {code} )
  582.                     Fputs( self.file , code )
  583.                     Mb_GetNextCode( {type} , {code} )
  584.                     Fputs( self.file , code )
  585.                     Mb_GetNextCode( {type} , {code} )
  586.                     Fputs( self.file , code )
  587.                     Mb_GetNextCode( {type} , {code} )
  588.                     Fputs( self.file , code )
  589.                     Mb_GetNextCode( {type} , {code} )
  590.                     Fputs( self.file , '" ,\n' )
  591.  
  592.                     return := TRUE
  593.  
  594.                 ELSE
  595.  
  596.                     INC func_level
  597.                     Fputs( self.file , muistrings[ Val( code ) ] )
  598.                     Fputs( self.file , '( ' )
  599.                     return := FALSE
  600.  
  601.                 ENDIF
  602.  
  603.                 Mb_GetNextCode( {type} , {code} )
  604.  
  605.             CASE TC_MUIARG_FUNCTION        ->    same as TC_FUNCTION
  606.  
  607.                 indent_code( self.file , indent_level , return )
  608.                 INC func_level
  609.                 Fputs( self.file , muistrings[ Val( code ) ] )
  610.                 Fputs( self.file , '( ' )
  611.                 return := FALSE
  612.                 Mb_GetNextCode( {type} , {code} )
  613.  
  614.             CASE TC_OBJFUNCTION
  615.  
  616.                 indent_code( self.file , indent_level , return )
  617.                 Fputs( self.file , muistrings[ Val( code ) ] )
  618.                 Fputs( self.file , '( ' )
  619.                 INC func_level
  620.                 return := FALSE
  621.                 objfunction := TRUE
  622.                 Mb_GetNextCode( {type} , {code} )
  623.  
  624.             CASE TC_MUIARG_OBJFUNCTION        ->    same as TC_OBJFUNCTION
  625.  
  626.                 indent_code( self.file , indent_level , return )
  627.                 Fputs( self.file , muistrings[ Val( code ) ] )
  628.                 Fputs( self.file , '( ' )
  629.                 INC func_level
  630.                 return := FALSE
  631.                 objfunction := TRUE
  632.                 Mb_GetNextCode( {type} , {code} )
  633.  
  634.             CASE TC_STRING
  635.  
  636.                 indent_code( self.file , indent_level , return )
  637.                 Fputs( self.file , string_convert( code ) )
  638.                 Mb_GetNextCode( {type} , {code} )
  639.  
  640.                 IF func_level > 0
  641.  
  642.                     IF type <> TC_END_FUNCTION THEN Fputs( self.file , ' , ' )
  643.                     return := FALSE
  644.  
  645.                 ELSE
  646.  
  647.                     Fputs( self.file , ' ,\n' )
  648.                     return := TRUE
  649.  
  650.                 ENDIF
  651.  
  652.             CASE TC_INTEGER
  653.  
  654.                 indent_code( self.file , indent_level , return )
  655.                 Fputs( self.file , code )
  656.                 Mb_GetNextCode( {type} , {code} )
  657.  
  658.                 IF func_level > 0
  659.  
  660.                     IF type <> TC_END_FUNCTION THEN Fputs( self.file , ' , ' )
  661.                     return := FALSE
  662.  
  663.                 ELSE
  664.  
  665.                     Fputs( self.file , ' ,\n' )
  666.                     return := TRUE
  667.  
  668.                 ENDIF
  669.  
  670.             CASE TC_CHAR
  671.  
  672.                 indent_code( self.file , indent_level , return )
  673.                 FputC( self.file , 34 )
  674.                 Fputs( self.file , code )
  675.                 Mb_GetNextCode( {type} , {code} )
  676.  
  677.                 IF func_level > 0
  678.  
  679.                     IF type <> TC_END_FUNCTION THEN Fputs( self.file , '" , ') ELSE FputC( self.file , 34 )
  680.                     return := FALSE
  681.  
  682.                 ELSE
  683.  
  684.                     Fputs( self.file , '" ,\n' )
  685.                     return := TRUE
  686.  
  687.                 ENDIF
  688.  
  689.             CASE TC_VAR_AFFECT
  690.  
  691.                 indent_code( self.file , indent_level , return )
  692.  
  693.                 IF self.vars[ Val( code ) ].type <> TYPEVAR_LOCAL_PTR
  694.  
  695.                     Fputs( self.file , 'self.' )
  696.  
  697.                 ENDIF
  698.  
  699.                 Fputs( self.file , self.vars[ Val( code ) ].ident )
  700.                 Fputs( self.file , ' := ')
  701.                 return := FALSE
  702.                 Mb_GetNextCode( {type} , {code} )
  703.  
  704.             CASE TC_VAR_ARG
  705.  
  706.                 indent_code( self.file , indent_level , return )
  707.  
  708.                 IF self.vars[ Val( code ) ].type <> TYPEVAR_LOCAL_PTR
  709.  
  710.                     Fputs( self.file , 'self.' )
  711.  
  712.                 ENDIF
  713.  
  714.                 Fputs( self.file , self.vars[ Val( code ) ].ident )
  715.                 Mb_GetNextCode( {type} , {code} )
  716.  
  717.                 IF func_level > 0
  718.  
  719.                     IF type <> TC_END_FUNCTION THEN Fputs( self.file , ' , ')
  720.                     return := FALSE
  721.  
  722.                 ELSE
  723.  
  724.                     Fputs( self.file , ' ,\n')
  725.                     return := TRUE
  726.  
  727.                 ENDIF
  728.  
  729.             CASE TC_OBJ_ARG        ->    same as TC_VAR_ARG
  730.  
  731.                 indent_code( self.file , indent_level , return )
  732.  
  733.                 IF self.vars[ Val( code ) ].type <> TYPEVAR_LOCAL_PTR
  734.  
  735.                     Fputs( self.file , 'self.' )
  736.  
  737.                 ENDIF
  738.  
  739.                 Fputs( self.file , self.vars[ Val( code ) ].ident )
  740.                 Mb_GetNextCode( {type} , {code} )
  741.  
  742.                 IF func_level > 0
  743.  
  744.                     IF type <> TC_END_FUNCTION THEN Fputs( self.file , ' , ')
  745.                     return := FALSE
  746.  
  747.                 ELSE
  748.  
  749.                     Fputs( self.file , ' ,\n')
  750.                     return := TRUE
  751.  
  752.                 ENDIF
  753.  
  754.             CASE TC_END_FUNCTION
  755.  
  756.                 indent_code( self.file , indent_level , return )
  757.                 DEC func_level
  758.                 Mb_GetNextCode( {type} , {code} )
  759.  
  760.                 IF func_level > 0
  761.  
  762.                     Fputs( self.file , ' )' )
  763.                     IF type <> TC_END_FUNCTION THEN Fputs( self.file , ' ,' )
  764.                     return := FALSE
  765.  
  766.                 ELSE
  767.  
  768.                     Fputs( self.file , IF objfunction THEN ' )\n\n' ELSE ' ) ,\n' )
  769.                     objfunction := FALSE
  770.                     return := TRUE
  771.  
  772.                 ENDIF
  773.  
  774.             CASE TC_BOOL
  775.  
  776.                 indent_code( self.file , indent_level , return )
  777.                 Fputs( self.file , IF Char( code ) = "0" THEN 'FALSE' ELSE 'MUI_TRUE')
  778.                 Mb_GetNextCode( {type} , {code} )
  779.  
  780.                 IF func_level > 0
  781.  
  782.                     IF type <> TC_END_FUNCTION THEN Fputs( self.file , ' , ')
  783.                     return := FALSE
  784.  
  785.                 ELSE
  786.  
  787.                     Fputs( self.file , ' ,\n')
  788.                     return := TRUE
  789.  
  790.                 ENDIF
  791.  
  792.             CASE TC_MUIARG
  793.  
  794.                 indent_code( self.file , indent_level , return )
  795.                 Fputs( self.file , muistrings[ Val( code ) ] )
  796.                 Mb_GetNextCode( {type} , {code} )
  797.  
  798.                 IF func_level > 0
  799.  
  800.                     IF type <> TC_END_FUNCTION THEN Fputs( self.file , ' , ')
  801.                     return := FALSE
  802.  
  803.                 ELSE
  804.  
  805.                     Fputs( self.file , ' ,\n')
  806.                     return := TRUE
  807.  
  808.                 ENDIF
  809.  
  810.             CASE TC_MUIARG_OBJ
  811.  
  812.                 indent_code( self.file , indent_level , return )
  813.                 Fputs( self.file , muistrings[ Val( code ) ] )
  814.                 Mb_GetNextCode( {type} , {code} )
  815.  
  816.                 IF inobj
  817.  
  818.                     Fputs( self.file , ' ,\n' )
  819.                     return := TRUE
  820.  
  821.                 ELSE
  822.  
  823.                     IF func_level > 0
  824.  
  825.                         IF type <> TC_END_FUNCTION THEN Fputs( self.file , ' , ')
  826.                         return := FALSE
  827.  
  828.                     ELSE
  829.  
  830.                         Fputs( self.file , '\n\n')
  831.                         return := TRUE
  832.  
  833.                     ENDIF
  834.  
  835.                 ENDIF
  836.  
  837.             CASE TC_MUIARG_ATTRIBUT        ->    same as TC_MUIARG_OBJ
  838.  
  839.                 indent_code( self.file , indent_level , return )
  840.                 Fputs( self.file , muistrings[ Val( code ) ] )
  841.                 Mb_GetNextCode( {type} , {code} )
  842.  
  843.                 IF inobj
  844.  
  845.                     Fputs( self.file , ' ,\n' )
  846.                     return := TRUE
  847.  
  848.                 ELSE
  849.  
  850.                     IF func_level > 0
  851.  
  852.                         IF type <> TC_END_FUNCTION THEN Fputs( self.file , ' , ')
  853.                         return := FALSE
  854.  
  855.                     ELSE
  856.  
  857.                         Fputs( self.file , '\n\n')
  858.                         return := TRUE
  859.  
  860.                     ENDIF
  861.  
  862.                 ENDIF
  863.  
  864.             CASE TC_EXTERNAL_FUNCTION
  865.  
  866.                 indent_code( self.file , indent_level , return )
  867.                 Fputs( self.file , 'display.' )
  868.                 Fputs( self.file , code )
  869.                 Mb_GetNextCode( {type} , {code} )
  870.  
  871.                 IF func_level > 0
  872.  
  873.                     IF type <> TC_END_FUNCTION THEN Fputs( self.file , ' , ')
  874.                     return := FALSE
  875.  
  876.                 ELSE
  877.  
  878.                     Fputs( self.file , ' ,\n')
  879.                     return := TRUE
  880.  
  881.                 ENDIF
  882.  
  883.             CASE TC_LOCALESTRING
  884.  
  885.                 indent_code( self.file , indent_level , return )
  886.                 Fputs( self.file , 'getMBstring( cat.')
  887.                 Fputs( self.file ,  code )
  888.                 FputC( self.file , "." )
  889.                 Fputs( self.file , getstring_func )
  890.                 Fputs( self.file , '() )' )
  891.                 Mb_GetNextCode( {type} , {code} )
  892.  
  893.                 IF func_level > 0
  894.  
  895.                     IF type<>TC_END_FUNCTION THEN Fputs( self.file , ' , ')
  896.                     return := FALSE
  897.  
  898.                 ELSE
  899.  
  900.                     Fputs( self.file , ' ,\n')
  901.                     return := TRUE
  902.  
  903.                 ENDIF
  904.  
  905.             CASE TC_LOCALECHAR
  906.  
  907.                 indent_code( self.file , indent_level , return )
  908.                 Fputs( self.file , 'Char( cat.')
  909.                 Fputs( self.file ,  code )
  910.                 FputC( self.file , "." )
  911.                 Fputs( self.file , getstring_func )
  912.                 Fputs( self.file , '() )')
  913.                 Mb_GetNextCode( {type} , {code} )
  914.  
  915.                 IF func_level > 0
  916.  
  917.                     IF type<>TC_END_FUNCTION THEN Fputs( self.file , ' , ')
  918.                     return := FALSE
  919.  
  920.                 ELSE
  921.  
  922.                     Fputs( self.file , ' ,\n')
  923.                     return := TRUE
  924.  
  925.                 ENDIF
  926.  
  927.         ENDSELECT
  928.  
  929.     ENDWHILE
  930.  
  931. ENDPROC
  932.  
  933.  
  934. /*****************************************************
  935. ** Write to the GUI file the end of create() method **
  936. *****************************************************/
  937. PROC put_create_end() OF gui_file
  938.  
  939.     Fputs( self.file , 'ENDPROC self.' )
  940.     Fputs( self.file , self.main_object_ident )
  941.     Fputs( self.file , '\n\n\n' )
  942.  
  943. ENDPROC
  944.  
  945.  
  946. /***********************************************
  947. ** Write to the GUI file the dispose() method **
  948. ***********************************************/
  949. PROC put_dispose_method() OF gui_file
  950.  
  951.     Fputs( self.file ,
  952.         '->/////////////////////////////////////////////////////////////////////////////\n'    +
  953.         '->////////////////////////// Disposes the object or the whole application /////\n'    +
  954.         '->/////////////////////////////////////////////////////////////////////////////\n'    +
  955.         'PROC dispose() OF '                                                                )
  956.     Fputs( self.file , self.main_object_ident )
  957.     Fputs( self.file , '_obj IS ( IF self.' )
  958.     Fputs( self.file , self.main_object_ident )
  959.     Fputs( self.file , ' THEN Mui_DisposeObject( self.' )
  960.     Fputs( self.file , self.main_object_ident )
  961.     Fputs( self.file , ' ) ELSE NIL )\n\n\n' )
  962.  
  963. ENDPROC
  964.  
  965.  
  966. /*************************************************************************
  967. ** Write to the GUI file the declaration of init_notifications() method **
  968. *************************************************************************/
  969. PROC put_init_notifications_declaration() OF gui_file
  970.  
  971.     DEF i , comma = FALSE
  972.  
  973.     Fputs( self.file ,
  974.         '->/////////////////////////////////////////////////////////////////////////////\n'    +
  975.         '->/////////////////////// Initializes all the notifications of one object /////\n'    +
  976.         '->/////////////////////////////////////////// or of the whole application /////\n'    +
  977.         '->/////////////////////////////////////////////////////////////////////////////\n'    +
  978.         'PROC init_notifications( '                                                            )
  979.  
  980.     IF self.hook_funcs
  981.  
  982.         Fputs( self.file , 'display : PTR TO ' )
  983.         Fputs( self.file , self.main_object_ident )
  984.         Fputs( self.file , '_display' )
  985.  
  986.         comma := TRUE
  987.  
  988.     ENDIF
  989.  
  990.     FOR i := 0 TO ( self.number_vars - 1 )
  991.  
  992.         IF self.vars[ i ].type = TYPEVAR_EXTERNAL_PTR
  993.  
  994.             IF comma THEN Fputs( self.file , ' , ' ) ELSE comma := TRUE
  995.  
  996.             Fputs( self.file , self.vars[ i ].ident )
  997.  
  998.         ENDIF
  999.  
  1000.     ENDFOR
  1001.  
  1002.     Fputs( self.file , ' ) OF ' )
  1003.     Fputs( self.file , self.main_object_ident )
  1004.     Fputs( self.file , '_obj\n\n' )
  1005.  
  1006. ENDPROC
  1007.  
  1008.  
  1009. /************************************************
  1010. ** Write to the GUI file all the notifications **
  1011. ************************************************/
  1012. PROC put_notifications( muistrings : PTR TO LONG , getstring_func : PTR TO CHAR ) OF gui_file
  1013.  
  1014.     DEF type , code , indent = FALSE , set_func = FALSE
  1015.  
  1016.     Mb_GetNextNotify( {type} , {code} )
  1017.  
  1018.     WHILE ( type <> -1 )
  1019.  
  1020.         IF indent THEN Fputs( self.file , '\t\t' )
  1021.  
  1022.         SELECT type
  1023.  
  1024.             CASE TC_BEGIN_NOTIFICATION
  1025.  
  1026.                 Fputs( self.file , '\tdomethod( self.' )
  1027.                 Fputs( self.file , self.vars[ Val( code ) ].ident )
  1028.                 Fputs( self.file , ' , [\n' )
  1029.                 indent := TRUE
  1030.                 Mb_GetNextNotify( {type} , {code} )
  1031.  
  1032.             CASE TC_END_NOTIFICATION
  1033.  
  1034.                 Fputs( self.file , ' ] )\n\n' )
  1035.                 indent := FALSE
  1036.                 Mb_GetNextNotify( {type} , {code} )
  1037.  
  1038.             CASE TC_FUNCTION
  1039.  
  1040.                 FputC( self.file , "\t" )
  1041.                 Fputs( self.file , muistrings[ Val( code ) ] )
  1042.                 Fputs( self.file , '( ' )
  1043.                 indent := FALSE
  1044.                 IF Val( code ) = 203 /* set function */ THEN set_func := TRUE
  1045.                 Mb_GetNextNotify( {type} , {code} )
  1046.  
  1047.             CASE TC_END_FUNCTION
  1048.  
  1049.                 Fputs( self.file , ' )\n\n' )
  1050.                 indent := FALSE
  1051.                 set_func := FALSE
  1052.                 Mb_GetNextNotify( {type} , {code} )
  1053.  
  1054.             CASE TC_STRING
  1055.  
  1056.                 Fputs( self.file , string_convert( code ) )
  1057.                 Mb_GetNextNotify( {type} , {code} )
  1058.  
  1059.                 IF ( type <> TC_END_FUNCTION ) AND ( type <> TC_END_NOTIFICATION )
  1060.  
  1061.                     indent := TRUE
  1062.                     Fputs( self.file , ' ,\n' )
  1063.  
  1064.                 ELSE
  1065.  
  1066.                     indent := FALSE
  1067.  
  1068.                 ENDIF
  1069.  
  1070.             CASE TC_LOCALESTRING
  1071.  
  1072.                 Fputs( self.file , 'getMBstring( cat.')
  1073.                 Fputs( self.file ,  code )
  1074.                 FputC( self.file , "." )
  1075.                 Fputs( self.file , getstring_func )
  1076.                 Fputs( self.file , '() )' )
  1077.                 Mb_GetNextNotify( {type} , {code} )
  1078.  
  1079.                 IF ( type <> TC_END_FUNCTION ) AND ( type <> TC_END_NOTIFICATION )
  1080.  
  1081.                     indent := TRUE
  1082.                     Fputs( self.file , ' ,\n' )
  1083.  
  1084.                 ELSE
  1085.  
  1086.                     indent := FALSE
  1087.  
  1088.                 ENDIF
  1089.  
  1090.             CASE TC_INTEGER
  1091.  
  1092.                 Fputs( self.file , code )
  1093.                 Mb_GetNextNotify( {type} , {code} )
  1094.  
  1095.                 IF ( type <> TC_END_FUNCTION ) AND ( type <> TC_END_NOTIFICATION )
  1096.  
  1097.                     indent := TRUE
  1098.                     Fputs( self.file , ' ,\n' )
  1099.  
  1100.                 ELSE
  1101.  
  1102.                     indent := FALSE
  1103.  
  1104.                 ENDIF
  1105.  
  1106.             CASE TC_CHAR
  1107.  
  1108.                 FputC( self.file , 34)
  1109.                 Fputs( self.file , code )
  1110.                 FputC( self.file , 34)
  1111.                 Mb_GetNextNotify( {type} , {code} )
  1112.  
  1113.                 IF ( type <> TC_END_FUNCTION ) AND ( type <> TC_END_NOTIFICATION )
  1114.  
  1115.                     indent := TRUE
  1116.                     Fputs( self.file , ' ,\n' )
  1117.  
  1118.                 ELSE
  1119.  
  1120.                     indent := FALSE
  1121.  
  1122.                 ENDIF
  1123.  
  1124.             CASE TC_BOOL
  1125.  
  1126.                 Fputs( self.file , IF Char( code ) = "0" THEN 'FALSE' ELSE 'MUI_TRUE')
  1127.                 Mb_GetNextNotify( {type} , {code} )
  1128.  
  1129.                 IF ( type <> TC_END_FUNCTION ) AND ( type <> TC_END_NOTIFICATION )
  1130.  
  1131.                     indent := TRUE
  1132.                     Fputs( self.file , ' ,\n' )
  1133.  
  1134.                 ELSE
  1135.  
  1136.                     indent := FALSE
  1137.  
  1138.                 ENDIF
  1139.  
  1140.             CASE TC_VAR_ARG
  1141.  
  1142.                 IF self.vars[ Val( code ) ].type <> TYPEVAR_EXTERNAL_PTR THEN Fputs( self.file , 'self.' )
  1143.                 Fputs( self.file , self.vars[ Val( code ) ].ident )
  1144.                 Mb_GetNextNotify( {type} , {code} )
  1145.  
  1146.                 IF set_func
  1147.  
  1148.                     Fputs( self.file , ' ,' )
  1149.                     indent := FALSE
  1150.  
  1151.                 ELSEIF ( type <> TC_END_FUNCTION ) AND ( type <> TC_END_NOTIFICATION )
  1152.  
  1153.                     Fputs( self.file , ' ,\n' )
  1154.                     indent := TRUE
  1155.  
  1156.                 ELSE
  1157.  
  1158.                     indent := FALSE
  1159.  
  1160.                 ENDIF
  1161.  
  1162.             CASE TC_MUIARG
  1163.  
  1164.                 Fputs( self.file , muistrings[ Val( code ) ] )
  1165.                 indent := FALSE
  1166.                 Mb_GetNextNotify( {type} , {code} )
  1167.                 IF ( type <> TC_END_FUNCTION ) AND ( type <> TC_END_NOTIFICATION ) THEN Fputs( self.file , ' , ' )
  1168.  
  1169.             CASE TC_MUIARG_OBJ        ->    same as TC_MUIARG
  1170.  
  1171.                 Fputs( self.file , muistrings[ Val( code ) ] )
  1172.                 indent := FALSE
  1173.                 Mb_GetNextNotify( {type} , {code} )
  1174.                 IF ( type <> TC_END_FUNCTION ) AND ( type <> TC_END_NOTIFICATION ) THEN Fputs( self.file , ' , ' )
  1175.  
  1176.             CASE TC_MUIARG_ATTRIBUT
  1177.  
  1178.                 Fputs( self.file , muistrings[ Val( code ) ] )
  1179.                 Mb_GetNextNotify( {type} , {code} )
  1180.  
  1181.                 IF ( type <> TC_END_FUNCTION ) AND ( type <> TC_END_NOTIFICATION )
  1182.  
  1183.                     indent := TRUE
  1184.                     Fputs( self.file , ' ,\n' )
  1185.  
  1186.                 ELSE
  1187.  
  1188.                     indent := FALSE
  1189.  
  1190.                 ENDIF
  1191.  
  1192.             CASE TC_EXTERNAL_CONSTANT
  1193.  
  1194.                 Fputs( self.file , code )
  1195.                 Mb_GetNextNotify( {type} , {code} )
  1196.  
  1197.                 IF ( type <> TC_END_FUNCTION ) AND ( type <> TC_END_NOTIFICATION )
  1198.  
  1199.                     indent := TRUE
  1200.                     Fputs( self.file , ' ,\n' )
  1201.  
  1202.                 ELSE
  1203.  
  1204.                     indent := FALSE
  1205.  
  1206.                 ENDIF
  1207.  
  1208.             CASE TC_EXTERNAL_FUNCTION
  1209.  
  1210.                 Fputs( self.file , 'display.' )
  1211.                 Fputs( self.file , code )
  1212.  
  1213.                 Mb_GetNextNotify( {type} , {code} )
  1214.  
  1215.                 IF ( type <> TC_END_FUNCTION ) AND ( type <> TC_END_NOTIFICATION )
  1216.  
  1217.                     indent := TRUE
  1218.                     Fputs( self.file , ' ,\n' )
  1219.  
  1220.                 ELSE
  1221.  
  1222.                     indent := FALSE
  1223.  
  1224.                 ENDIF
  1225.  
  1226.             CASE TC_EXTERNAL_VARIABLE
  1227.  
  1228.                 Fputs( self.file , code )
  1229.                 Mb_GetNextNotify( {type} , {code} )
  1230.  
  1231.                 IF ( type <> TC_END_FUNCTION ) AND ( type <> TC_END_NOTIFICATION )
  1232.  
  1233.                     indent := TRUE
  1234.                     Fputs( self.file , ' ,\n' )
  1235.  
  1236.                 ELSE
  1237.  
  1238.                     indent := FALSE
  1239.  
  1240.                 ENDIF
  1241.  
  1242.         ENDSELECT
  1243.  
  1244.     ENDWHILE
  1245.  
  1246. ENDPROC
  1247.  
  1248.  
  1249. /*****************************************************************
  1250. ** Write to the GUI file the end of init_notifications() method **
  1251. *****************************************************************/
  1252. PROC put_init_notifications_end() OF gui_file IS Fputs( self.file , 'ENDPROC\n\n\n' )
  1253.  
  1254.  
  1255. /*************************************************
  1256. ** Write to the GUI file getMBstring() function **
  1257. *************************************************/
  1258. PROC put_aux_funcs() OF gui_file
  1259.  
  1260.     Fputs( self.file ,
  1261.         '->/////////////////////////////////////////////////////////////////////////////\n'                                                        +
  1262.         '->//////////// Special GetString() function for MUIBuilder generated code /////\n'                                                        +
  1263.         '->/////////////////////////////////////////////////////////////////////////////\n'                                                        +
  1264.         'PROC getMBstring( local_string : PTR TO CHAR ) RETURN ( IF local_string[ 1 ] = "\\0" THEN ( local_string + 2 ) ELSE local_string )\n'    )
  1265.  
  1266. ENDPROC
  1267.