home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PASCAL / BABEL2.ZIP / BABEL.VIR < prev    next >
Encoding:
Text File  |  1993-01-01  |  7.6 KB  |  244 lines

  1.    {|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
  2.  
  3.    CHANGE LANGUAGE
  4.  
  5.    |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||}
  6. procedure ChangeLanguage ( NewLanguage : string ) ;
  7.    {===================================================================
  8.    ===================================================================}
  9. procedure Dump ;
  10. begin
  11.    if MenuBox <> NIL then
  12.    begin
  13.       DisposeMenu ( MenuBox^.Menu ) ;
  14.       Dispose ( MenuBox , Done ) ;
  15.       MenuBox                := NIL ;
  16.    end ;
  17.    if MenuBar <> NIL then
  18.    begin
  19.       Application^.Delete ( MenuBar ) ;
  20.       Dispose ( MenuBar , Done ) ;
  21.       MenuBar                := NIL ;
  22.    end ;
  23.    if StatusLine <> NIL then
  24.    begin
  25.       Application^.Delete ( StatusLine ) ;
  26.       Dispose ( StatusLine , Done ) ;
  27.       StatusLine             := NIL ;
  28.    end ;
  29. end ;
  30.    {===================================================================
  31.    ===================================================================}
  32. procedure Place ;
  33. begin
  34.    if PLanguage <> NIL then
  35.       DisposeStr ( PLanguage ) ;
  36.    PLanguage                 := NewStr ( NewLanguage ) ;
  37.    CalcHelp ( PLanguage^ ) ;
  38. {$IFDEF code}
  39. {$ELSE}
  40.    MenuBoxName               := 'MENUBOX_' + PLanguage^ ;
  41.    MenuBarName               := 'MENUBAR_' + PLanguage^ ;
  42.    StatusLineName            := 'STATUSLINE_' + PLanguage^ ;
  43.    HintName                  := 'HINT_' + PLanguage^ ;
  44.    MenuBox                   := PMenuBox ( RezFile^.Get ( MenuBoxName ) ) ;
  45.    Application^.InitMenuBar ;
  46.    Application^.InitStatusLine ;
  47. {$ENDIF}
  48.    if MenuBar <> NIL then
  49.       Application^.Insert ( MenuBar ) ;
  50.    if StatusLine <> NIL then
  51.       Application^.Insert ( StatusLine ) ;
  52.    DefaultHint               := PLanguage^ ;
  53.    if StatusLine <> NIL then
  54.       StatusLine^.DrawView ;
  55.    Message ( Application ,
  56.              evBroadcast ,
  57.              cmCommandSetChanged ,
  58.              NIL ) ;
  59. end ;
  60.    {===================================================================
  61.    ===================================================================}
  62. procedure English ;
  63. begin
  64.    Dump ;
  65. {$IFDEF code}
  66.    MenuBox                   := InitMenuBoxENGLISH ;
  67.    MenuBar                   := InitMenuBarENGLISH ;
  68.    StatusLine                := InitStatusLineENGLISH ;
  69. {$ENDIF}
  70.    Place ;
  71. end ;
  72.    {===================================================================
  73.    ===================================================================}
  74. procedure German ;
  75. begin
  76.    Dump ;
  77. {$IFDEF code}
  78.    MenuBox                   := InitMenuBoxGERMAN ;
  79.    MenuBar                   := InitMenuBarGERMAN ;
  80.    StatusLine                := InitStatusLineGERMAN ;
  81. {$ENDIF}
  82.    Place ;
  83. end ;
  84.    {===================================================================
  85.    ===================================================================}
  86. procedure Spanish ;
  87. begin
  88.    Dump ;
  89. {$IFDEF code}
  90.    MenuBox                   := InitMenuBoxSPANISH ;
  91.    MenuBar                   := InitMenuBarSPANISH ;
  92.    StatusLine                := InitStatusLineSPANISH ;
  93. {$ENDIF}
  94.    Place ;
  95. end ;
  96.    {===================================================================
  97.    ===================================================================}
  98. procedure French ;
  99. begin
  100.    Dump ;
  101. {$IFDEF code}
  102.    MenuBox                   := InitMenuBoxFRENCH ;
  103.    MenuBar                   := InitMenuBarFRENCH ;
  104.    StatusLine                := InitStatusLineFRENCH ;
  105. {$ENDIF}
  106.    Place ;
  107. end ;
  108.    {===================================================================
  109.    ===================================================================}
  110. procedure Dutch ;
  111. begin
  112.    Dump ;
  113. {$IFDEF code}
  114.    MenuBox                   := InitMenuBoxDUTCH ;
  115.    MenuBar                   := InitMenuBarDUTCH ;
  116.    StatusLine                := InitStatusLineDUTCH ;
  117. {$ENDIF}
  118.    Place ;
  119. end ;
  120.    {- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  121.    PROCESS
  122.    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -}
  123. begin
  124.    if NewLanguage = 'GERMAN' then German else
  125.    if NewLanguage = 'SPANISH' then Spanish else
  126.    if NewLanguage = 'FRENCH' then French else
  127.    if NewLanguage = 'DUTCH' then Dutch else
  128.    begin
  129.       NewLanguage := 'ENGLISH' ;
  130.       English ;
  131.    end ;
  132. end ;
  133.    {|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
  134.  
  135.    APPLICATION METHODS
  136.  
  137.    |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||}
  138.    {===================================================================
  139.  
  140.    IDLE
  141.    
  142.    ===================================================================}
  143. procedure TGenericApp.Idle ;
  144. begin
  145.    if CommandSetChanged then
  146.    begin
  147.       if Desktop^.Current = NIL then
  148.          DisableCommands ( [ cmPrint , cmTile , cmCascade ] )
  149.       else
  150.          EnableCommands ( [ cmPrint , cmTile , cmCascade ] ) ;
  151.       if not HiResScreen or ( Screenmode = smMono ) then
  152.          Application^.DisableCommands ( [ cmVideoMode ] ) ;
  153.    end ;
  154.    TApplication.Idle ;
  155. end ;
  156.    {|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
  157.  
  158.    INIT
  159.  
  160.    |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||}
  161.    {===================================================================
  162.  
  163.    PRE
  164.  
  165.    ===================================================================}
  166. procedure TGenericApp.PreInit ;
  167. begin
  168.    VersionCode               := '0.92' ;
  169.    PushScreen ;
  170.    ReserveForData ( 32 * ( 1024 div 16 ) ) ;
  171.    InitBuffers ;
  172.    EDITORS.EditorDialog      := EditorDialog ;
  173.    {- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  174.    Allow access to "ReadOnly" files (else loads blank & overwrites!)
  175.    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -}
  176.    if Lo ( DosVersion ) >= 3 then
  177.       FileMode               := $20     { OPEN Read_Only + Deny_Write }
  178.    else
  179.       FileMode               := $0 ;               { ATTR:  Read_Only }
  180. end ;
  181.    {===================================================================
  182.  
  183.    POST
  184.    
  185.    ===================================================================}
  186. procedure TGenericApp.PostInit ;
  187. begin
  188.    CalcHelp ( 'ENGLISH' ) ;
  189. {$IFDEF code}
  190.    MenuBox                   := InitMenuBoxENGLISH ;
  191. {$ELSE}
  192.    MenuBox                   := PMenuBox ( RezFile^.Get ( MenuBoxName ) ) ;
  193. {$ENDIF}
  194.    if not HiResScreen then
  195.       Application^.DisableCommands ( [ cmVideoMode ] ) ;
  196.    CreateClipboard ;
  197.  
  198.    LoadConfig ;
  199.    if PLanguage <> NIL then
  200.       ChangeLanguage ( PLanguage^ ) ;
  201.  
  202.    LoadDesktopFrom ( Names.DSK ) ;
  203.    if ParamCount > 0 then
  204.    begin
  205.       hdClearDesktop ;
  206.       CommandLineOpen ;
  207.    end ;
  208.    if Desktop^.Current = NIL then
  209.    begin
  210.       OpenEditor ( '' , TRUE ) ;
  211.       ForceEvent ( evCommand , cmAbout ) ;
  212.    end ;
  213. end ;
  214.    {|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
  215.  
  216.    DONE
  217.  
  218.    |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||}
  219.    {===================================================================
  220.  
  221.    PRE
  222.    
  223.    ===================================================================}
  224. procedure TGenericApp.PreDone ;
  225. begin
  226.    SaveDesktopTo ( Names.DSK , 'BABEL.EXE  Multi-Language Editor - Desktop File' ) ;
  227.    SaveConfig ;
  228.    if PLanguage <> NIL then
  229.       DisposeStr ( PLanguage ) ;
  230.    DisposeMenu ( MenuBox^.Menu ) ;
  231.    Dispose ( MenuBox , Done ) ;
  232.    MenuBox                   := NIL ;
  233. end ;
  234.    {===================================================================
  235.  
  236.    POST
  237.  
  238.    ===================================================================}
  239. procedure TGenericApp.PostDone ;
  240. begin
  241.    PopScreen ;
  242.    CopyrightMsg ;
  243. end ;
  244.