home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1994 #1 / monster.zip / monster / CLIPPER / NCCLIB.ZIP / NCCVIEW.ZIP / G_MAIN.PRG < prev    next >
Text File  |  1993-11-10  |  8KB  |  285 lines

  1. //═══════════════════════════════════════════════════════╕
  2. //  Program .....: G_Main                                │
  3. //  CopyRight ...: 1993 National Computer Consultants    │
  4. //                 All rights are reserved.              │
  5. //  Author ......: Greg Rice                             │
  6. //═══════════════════════════════════════════════════════╛
  7.  
  8. #include "g_menu.ch"
  9. #include "inkey.ch"
  10. #include "g_event.ch"
  11. #include "Mouse.ch"
  12.  
  13.  
  14. Function Main(p1,p2,p3,p4,p5)
  15.  
  16.     local oldblink   := SetBlink( .f. )                            , ;
  17.           Event      := 0                                          , ;
  18.           nKey       := 0                                          , ;
  19.           vTemp      := NIL                                        , ;
  20.           Bar                                                      , ;
  21.           Mouse                                                    , ;
  22.           mForce                                                   , ;
  23.           i
  24.  
  25.  
  26.     Set Wrap On
  27.     Set Score Off
  28.     SetCancel( .f. )
  29.  
  30.  
  31.     i := GETENV("USE")
  32.     IF ! empty(i)
  33.       p5 := '@'+i
  34.  
  35.     END
  36.  
  37.     ParamPlace(p1)
  38.     ParamPlace(p2)
  39.     ParamPlace(p3)
  40.     ParamPlace(p4)
  41.     ParamPlace(p5)
  42.  
  43.     IF ".INI" $ uppe(DosParamList(5))
  44.       config()
  45.     END
  46.  
  47.     SaveMode( DisplayMode( ) )
  48.     if ! Empty( dosParamList(3) )
  49.       DisplayMode( dosParamList(3) )
  50.     endif
  51.     ColorSetup(dosParamList(3))
  52.  
  53.  
  54.     if '/C1' $ uppe(dosparamlist(3))
  55.       bar_color( 'N/BG*,GR+/RB')
  56.     elseif '/C2' $ uppe(dosparamlist(3))
  57.       bar_color( 'N/W*,R+/BG*')
  58.     elseif '/C3' $ uppe(dosparamlist(3))
  59.       bar_color( 'W+/B*,G+/N')
  60.     elseif '/C4' $ uppe(dosparamlist(3))
  61.       bar_color( 'N/G*, GR+/GR')
  62.     endif
  63.  
  64.  
  65.  
  66.     set cursor off
  67.     messageSet()
  68.     scroll()
  69.     SetColor( "W+/B" )
  70.     @0,0
  71.     NccMesg( 'NccViews Version 1.0', 0, 'center' )
  72.     @0,1 say cDate( date() )
  73.     @0,maxcol()-7 say clock( 'on' )
  74.     setColor( 'B/W')
  75.     @12,00 say 'Initializing... Shareware version'
  76.     SetColor( bar_color() )
  77.     Bar := MenuSys()
  78.  
  79.  
  80.     @maxrow(),00
  81.     set color to
  82.  
  83.     Showbackground()
  84.     Bar:Display()
  85.     Mouse := MouseSys()
  86.     Mouse:Activate()
  87.     Mouse:Hide()
  88.  
  89.     vTemp := ''
  90.     if ! Empty( dosParamList(1) )
  91.       vTemp :=  vTemp + 'F1' + dosParamList(1) + Chr( K_ENTER )
  92.     endif
  93.     if ! Empty( dosParamList(2) )
  94.       vTemp := vTemp + 'I' + dosParamList(2) + Chr( K_ENTER )
  95.     endif
  96.     if ! Empty( dosParamList(4) )
  97.       vTemp := vTemp + 'V' + subs(dosParamList(4),2) + Chr( K_ENTER )
  98.     endif
  99.  
  100.     if Empty( vTemp )
  101.       Bar:MenusActive := .t.
  102.       Bar:BarChoice( 2, .f. )
  103.       Bar:MenuChoice( 1, .f. )
  104.       mForce := .t.
  105.     else
  106.       Keyboard vTemp
  107.       mForce := .f.
  108.     endif
  109.  
  110.  
  111.     While Event # ev_SysExit                   //  Process while ! request to
  112.                                                //  terminate
  113.        if RedisplayBar()
  114.           RedisplayBar(.f.)
  115.          Bar:Display()
  116.        endif
  117.                                                //
  118.        Event := 0                              //
  119.        if Window_Active()                      //
  120.          Mouse:Hide()                          //
  121.          WinObj():Stabilize()                  //
  122.          Mouse:Show()                          //
  123.        endif                                   //
  124.                                                //
  125.  
  126.        if ! Empty(WinObj())
  127.          nKey := ( WinObj():UserSlot[2] == NIL )
  128.          MenuSys():PromptActive( VIEW_VERT, nKey )
  129.          MenuSys():PromptActive( VIEW_HORI, (! nKey) )
  130.        endif
  131.  
  132.        if ! mForce
  133.          Mouse:MouseRead()                     //  Get Event
  134.          nKey := Mouse:Ascii                   //
  135.        else
  136.          nKey := NIL
  137.          mForce := .f.
  138.        endif
  139.  
  140.        if nKey == NIL .or. nKey # 0            //
  141.          vTemp := Bar:Activate(nKey)           //  nKey
  142.          if vTemp # 0                          //  if Menu Action taken
  143.            Event := MenuEvent( vTemp )         //    Translate Menu event
  144.            nKey := vTemp                       //    nKey := Menu key
  145.          endif                                 //
  146.        else                                    //
  147.          nKey := Bar:Activate()                //  Test if mouse activates bar
  148.          if nKey # 0                           //
  149.            Event := MenuEvent( nKey )          //    Translate Menu event
  150.          endif                                 //
  151.        endif                                   //    redisplay menu bar
  152.                                                //
  153.        if Event == 0                           //
  154.          if Mouse:Button # 0                   //
  155.            Event := MouseEvent()               //    Translate Mouse event
  156.          endif                                 //
  157.        endif                                   //
  158.                                                //
  159.        if Event == 0                           //
  160.          Event := KeyboardEvent( nKey )        //    Translate Keyboard event
  161.        endif                                   //
  162.                                                //
  163.        EventProcess( Event )                   //   Event Processing
  164.                                                //
  165.     enddo                                      //
  166.  
  167.     clock( 'off' )
  168.     mouse:Hide()
  169.     Bar:Hide()
  170.     SetBlink( oldblink )
  171.     ResetDisplayMode( SaveMode() )
  172.     Set Color to
  173.     scroll(1,0)
  174.     setpos( (maxrow()/2) -1,0 )
  175.     qout( "" )
  176.     Set Cursor on
  177.  
  178. Return( NIL )
  179.  
  180.  
  181. //──────────────┐
  182. //  Set Message │
  183. //──────────────┘
  184. Function messageSet()
  185.  
  186.     Set message to maxrow()
  187.  
  188. Return( NIL )
  189.  
  190.  
  191. //────────────────────────────────────┐
  192. // System flag: Request bar redisplay │
  193. //────────────────────────────────────┘
  194. Function RedisplayBar( x )
  195.   static bar := .f.
  196.  
  197. Return( if( x == NIL, bar, bar := x ) )
  198.  
  199. //─────────────────────┐
  200. // Set up display size │
  201. //─────────────────────┘
  202. STATIC Function DisplayMode( ScreenMode )
  203.  
  204.     LOCAL CurrentMode := maxrow()+1
  205.  
  206.     scroll()
  207.     if ScreenMode # NIL
  208.       if '/43' $ ScreenMode
  209.         setmode(43,maxcol()+1)
  210.       elseif '/50' $ ScreenMode
  211.         setmode(50,maxcol()+1)
  212.       elseif '/25' $ ScreenMode
  213.         setmode(25,maxcol()+1)
  214.       endif
  215.     endif
  216.  
  217. Return( CurrentMode )
  218.  
  219.  
  220. //───────────────┐
  221. // Reset Display │
  222. //───────────────┘
  223. STATIC Function ResetDisplayMode( ScreenMode )
  224.  
  225.     if ScreenMode # NIL
  226.       if ScreenMode == 43
  227.         setmode(43,maxcol()+1)
  228.       elseif ScreenMode == 50
  229.         setmode(50,maxcol()+1)
  230.       elseif ScreenMode == 25
  231.         setmode(25,maxcol()+1)
  232.       endif
  233.     endif
  234.  
  235. Return( NIL )
  236.  
  237.  
  238. //─────────────┐
  239. //  Background │
  240. //─────────────┘
  241. Function Showbackground()
  242.  
  243.     local sColor := SetColor( desktop_color() )
  244.  
  245.  
  246.     WinBox( 2,0,maxrow()-1,maxcol(),, repl(DeskTop_char(),9) )
  247.     @maxrow(),00  say space( maxcol()+1 ) color message_color()
  248.     SetColor( sColor )
  249.  
  250. Return( NIL )
  251.  
  252.  
  253. Function MenuSys()
  254.  
  255.     static menusys := NIL
  256.  
  257.  
  258.     if menusys == NIL
  259.       MenuSys := g_menu()
  260.     endif
  261.  
  262. Return( menusys )
  263.  
  264.  
  265. Function GrayBar()
  266.  
  267.     local o := MenuSys()
  268.  
  269.  
  270.     aeval( o:Prompts, { |x| x:active := .f. } )
  271.     o:Display()
  272.  
  273. Return( NIL )
  274.  
  275.  
  276. Function UnGrayBar()
  277.  
  278.     local o := MenuSys()
  279.  
  280.     aeval( o:Prompts, { |x| x:active := .t. } )
  281.  
  282.     o:Display()
  283.  
  284. Return( NIL )
  285.