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

  1. //═══════════════════════════════════════════════════════╕
  2. //  Program .....: G_Window                              │
  3. //  CopyRight ...: 1993 National Computer Consultants    │
  4. //                 All rights are reserved.              │
  5. //  Author ......: Greg Rice                             │
  6. //═══════════════════════════════════════════════════════╛
  7.  
  8. //─────────────┐
  9. //  Desktop    │
  10. //─────────────┘
  11.  
  12. #include "inkey.ch"
  13. #include "dbstruct.ch"
  14. #include "g_menu.ch"
  15. #include "mouse.ch"
  16.  
  17.  
  18.  
  19. #define WINDOW_INDEXFILES     1
  20. #define WINDOW_ALIAS          2
  21. #define   WINDOW_FILENAME       1
  22. #define   WINDOW_OBJECT         2
  23. #define   WINDOW_COLOR          3
  24. #define   WINDOW_TROW           4
  25. #define   WINDOW_LCOL           5
  26. #define   WINDOW_BROW           6
  27. #define   WINDOW_RCOL           7
  28. #define WINDOW_VIEWFIELDS     3
  29. #define WINDOW_VIEWSTRUCT     4
  30. #define WINDOW_POSITION       5
  31.  
  32. STATIC window_active  := .f.
  33.  
  34. STATIC title_Color       := 'W+/B'                                         , ;
  35.        message_Color     := 'W+/R'                                         , ;
  36.        desktop_Color     := 'W+/N*'                                        , ;
  37.        desktop_char      := "▒"                                            , ;
  38.        popup_color       := 'W+/RB,W+/B,,W+/RB'                            , ;
  39.        pop_color         := 'GR+/RB,W+/B,,GR+/RB'                          , ;
  40.        bar_color         := 'R/BG,W+/R,,W+/BG,W+/R'                        , ;
  41.        Text_Color        := 'W+/B,W+/R,W+/R,N/G,GR+,G'                     , ;
  42.        letter_color      := 'N+/BG,W+/R,,W+/BG,W+/R'                       , ;
  43.        SaveMode          := NIL                                            , ;
  44.        Current_window    := 1                                              , ;
  45.        v                                                                   , ;
  46.        win_Stack         := {}          // Window sequence
  47.  
  48.  
  49. /*                      W I N D O W   S T R U C T U R E
  50.   *************************************************************************************
  51.  
  52.   Position of Current Row  ─────────────────────────────────────────────────────┐
  53.   Viewing File Structure  ───────────────────────────────────────────────┐      │
  54.   Viewing Field List     ──────────────────────────────────────────┐     │      │
  55.   RightColumn           ─────────────────────────────────────┐     │     │      │
  56.   BottomRow            ───────────────────────────────────┐  │     │     │      │
  57.   LeftColumn          ─────────────────────────────────┐  │  │     │     │      │
  58.   TopRow             ───────────────────────────────┐  │  │  │     │     │      │
  59.   Window Color      ────────────┐                   │  │  │  │     │     │      │
  60.   Assoc. object    ─────────┐   │                   │  │  │  │     │     │      │
  61.   Full File name  ───────┐  │   │                   │  │  │  │     │     │      │
  62.   Index Array    ──┐     │  │   │                   │  │  │  │     │     │      │
  63.                    │     │  │   │                   │  │  │  │     │     │      │
  64.                    v     v  v   v                   v  v  v  v     v     v      v
  65.  
  66.   *************************************************************************************
  67. */
  68. STATIC win := {;
  69.                 { {""}, {'','','W+/B,GR+/RB,,,W+/B'   ,03,01,14,70}, {""}, NIL, {} } ,;
  70.                 { {""}, {'','','N/W,W+/R,,,N/W'       ,04,02,15,71}, {""}, NIL, {} } ,;
  71.                 { {""}, {'','','N/BG,W+/R,,,W+/B'     ,05,03,16,72}, {""}, NIL, {} } ,;
  72.                 { {""}, {'','','N/GR,W+/RB,,,N/BR'    ,06,04,17,73}, {""}, NIL, {} } ,;
  73.                 { {""}, {'','','N/G,R+/RB,,,N/W'      ,07,05,18,74}, {""}, NIL, {} } ,;
  74.                 { {""}, {'','','G+/B,W+/R,,,W+/B'     ,08,06,19,75}, {""}, NIL, {} } ,;
  75.                 { {""}, {'','','GR/W,GR+/RB,,,N/W'    ,09,07,20,76}, {""}, NIL, {} } ,;
  76.                 { {""}, {'','','GR+/B,W+/R,,,W+/B'    ,10,08,21,77}, {""}, NIL, {} } ,;
  77.                 { {""}, {'','','R/W,GR+/RB,,,N/W'     ,11,09,22,78}, {""}, NIL, {} } ,;
  78.                 { {""}, {'','','G+/B,W+/R,,,W+/B'     ,12,10,23,79}, {""}, NIL, {} }  ;
  79.               }
  80.  
  81.  
  82. //
  83. //──────────────────────────────────────────────────────────────────────────────────────
  84. //
  85.  
  86. Function Window_Active(x)
  87. Return( if( x == NIL, window_active, window_active := x ) )
  88.  
  89. Function Win_Stack( x )
  90. Return(;
  91.         if( x == NIL, ;
  92.             win_stack, ;
  93.             win_Stack := x ;
  94.           );
  95.       )
  96.  
  97. Function winStackUpdate( x )
  98.  
  99.    local i
  100.  
  101.    if (i := ascan( win_stack, x )) # 0
  102.      adel( win_stack, i )
  103.      win_stack[len(win_stack)] := x
  104.    else
  105.      aadd( win_stack, x )
  106.    endif
  107.  
  108. Return( NIL )
  109.  
  110.  
  111. Function Windows()
  112. Return( win )
  113.  
  114. Function Title_Color( x )
  115. Return( if( x == NIL, Title_Color, Title_Color := x ) )
  116.  
  117. Function Message_Color( x )
  118. Return( if( x == NIL, Message_Color, Message_Color := x ) )
  119.  
  120. Function DeskTop_Color( x )
  121. Return( if( x == NIL, DeskTop_Color, DeskTop_Color := x ) )
  122.  
  123. Function DeskTop_Char( x )
  124. Return( if( x == NIL, DeskTop_Char, DeskTop_Char := x ) )
  125.  
  126. Function Popup_Color( x )
  127. Return( if( x == NIL, Popup_Color, Popup_Color := x ) )
  128.  
  129. Function Pop_Color( x )
  130. Return( if( x == NIL, Pop_Color, Pop_Color := x ) )
  131.  
  132. Function Bar_Color( x )
  133. Return( if( x == NIL, Bar_Color, Bar_Color := x ) )
  134.  
  135. Function Text_Color( x )
  136. Return( if( x == NIL, Text_Color, Text_Color := x ) )
  137.  
  138. Func Letter_Color( x )
  139. Return( if( x == NIL, Letter_Color, Letter_Color := x ) )
  140.  
  141. Function Current_Window( x )
  142. Return( if( x == NIL, Current_Window, Current_Window := x ) )
  143.  
  144. Function SaveMode( x )
  145. Return( if( x == NIL, SaveMode, SaveMode := x ) )
  146.  
  147. Function WinIndexFiles( x, y )
  148.     x := if( x == NIL, current_window, x )
  149. Return( ;
  150.         if( y == NIL, ;
  151.             y := Win[x,WINDOW_INDEXFILES], ;
  152.             Win[x,WINDOW_INDEXFILES] := y ;
  153.           );
  154.        )
  155.  
  156. Function WinFilename( x, y )
  157.  x := if( x == NIL, current_window, x )
  158. Return(;
  159.         if( y == NIL, ;
  160.             y := Win[x,2,WINDOW_FILENAME], ;
  161.             Win[x,2,WINDOW_FILENAME] := y ;
  162.           );
  163.       )
  164.  
  165. Function WinObj( x, y )
  166.  x := if( x == NIL, Current_Window, x )
  167. Return(;
  168.         if( y == NIL, ;
  169.             y := Win[x,2,WINDOW_OBJECT], ;
  170.             Win[x,2,WINDOW_OBJECT] := y ;
  171.           );
  172.       )
  173.  
  174.  
  175. Function WinVSbar(x)
  176.  x := if( x == NIL, current_window, x )
  177.  v:Update(WinObj( x ):LinePosition)
  178. Return( NIL )
  179.  
  180. Function WinColor( x, y )
  181.  x := if( x == NIL, current_window, x )
  182. Return(;
  183.         if( y == NIL, ;
  184.             y := Win[x,2,WINDOW_COLOR], ;
  185.             Win[x,2,WINDOW_COLOR] := y ;
  186.           );
  187.       )
  188.  
  189. Function WinTop( x, y )
  190.  x := if( x == NIL, current_window, x )
  191. Return(;
  192.         if( y == NIL, ;
  193.             y := Win[x,2,WINDOW_TROW], ;
  194.             Win[x,2,WINDOW_TROW] := y ;
  195.           );
  196.       )
  197.  
  198. Function WinLeft( x, y )
  199.  x := if( x == NIL, current_window, x )
  200. Return(;
  201.         if( y == NIL, ;
  202.             y := Win[x,2,WINDOW_LCOL], ;
  203.             Win[x,2,WINDOW_LCOL] := y ;
  204.           );
  205.       )
  206.  
  207. Function WinBottom( x, y )
  208.  x := if( x == NIL, current_window, x )
  209. Return(;
  210.         if( y == NIL, ;
  211.             y := Win[x,2,WINDOW_BROW], ;
  212.             Win[x,2,WINDOW_BROW] := y ;
  213.           );
  214.       )
  215.  
  216. Function WinRight( x, y )
  217.  x := if( x == NIL, current_window, x )
  218. Return(;
  219.         if( y == NIL, ;
  220.             y := Win[x,2,WINDOW_RCOL], ;
  221.             Win[x,2,WINDOW_RCOL] := y ;
  222.           );
  223.       )
  224.  
  225. Function WinViewFields( x, y )
  226.  x := if( x == NIL, current_window, x )
  227. Return(;
  228.         if( y == NIL, ;
  229.             y := Win[x,WINDOW_VIEWFIELDS], ;
  230.             Win[x,WINDOW_VIEWFIELDS] := y ;
  231.           );
  232.       )
  233.  
  234. Function WinViewStru( x, y )
  235.  x := if( x == NIL, current_window, x )
  236. Return(;
  237.         if( y == NIL, ;
  238.             y := Win[x,WINDOW_VIEWSTRUCT], ;
  239.             Win[x,WINDOW_VIEWSTRUCT] := y ;
  240.           );
  241.       )
  242.  
  243. FUNCTION ColorSetup(x)
  244.  
  245.     local i
  246.  
  247.     if '/M' $ uppe(x) .or. ! isColor()
  248.        Title_color   := 'N/W'
  249.        desktop_color := 'N/N,N/W'
  250.        popup_color   := 'N/W,W+/N,,,N/W'
  251.        bar_color     := 'N/W,W/N,,N+/W,W+/N'
  252.        message_color := 'W+/N'
  253.  
  254.        for i = 1 to 10
  255.          WinColor(i,'W/N,N/W,,,W/N')
  256.        next
  257.  
  258.     endif
  259.  
  260. Return( NIL )
  261.  
  262.  
  263. //───────────────┐
  264. //  Next Window  │
  265. //───────────────┘
  266. Function WinNext()
  267.  
  268.     local nKey, i
  269.  
  270.     nKey := Current_Window()
  271.     DeHighLightWindow(nKey)
  272.     for i = 1 to len(windows())
  273.       nKey++
  274.       if nKey > Len(windows())
  275.         nKey := 1
  276.       endif
  277.       if ! Empty(WinFilename(nKey))
  278.         exit
  279.       endif
  280.     next
  281.     HighLightWindow( nKey )
  282.  
  283. Return( NIL )
  284.  
  285.  
  286. //─────────────────┐
  287. // Previous Window │
  288. //─────────────────┘
  289. Function WinPrev()
  290.  
  291.     local nKey, i
  292.  
  293.     nKey := Current_Window()
  294.     DeHighLightWindow(nKey)
  295.     for i = 1 to len(windows())
  296.       nKey--
  297.       if nKey == 0
  298.         nKey := len(windows())
  299.       endif
  300.       if ! Empty(WinFilename(nKey))
  301.         exit
  302.       endif
  303.     next
  304.     HighLightWindow( nKey )
  305.  
  306. Return( NIL )
  307.  
  308. //───────────────┐
  309. // Resize Window │
  310. //───────────────┘
  311. Function WinResize()
  312.  
  313.     ResizeWindow( WinObj() )
  314.     ShowDesktop()
  315.  
  316. Return( NIL )
  317.  
  318.  
  319.  
  320. Function ZoomIsFull()
  321.  
  322.     local zoom := .f., o := WinObj()
  323.  
  324.  
  325.     if Window_Active()
  326.       if ! ( o:TopRow-4      == WinTop() .and.       ;
  327.              o:LeftColumn-1  == WinLeft() .and.      ;
  328.              o:BottomRow+1   == WinBottom() .and.    ;
  329.              o:RightColumn+1 == WinRight()           ;
  330.            )
  331.          zoom := .t.
  332.       endif
  333.     endif
  334.  
  335. Return( zoom )
  336.  
  337. //───────────────┐
  338. //  Zoom Window  │
  339. //───────────────┘
  340. Function WinZoom()
  341.  
  342.     local o := WinObj()
  343.  
  344.     if ! ZoomIsFull()
  345.       o:TopRow       := 6
  346.       o:LeftColumn   := 1
  347.       o:BottomRow    := maxrow() -2
  348.       o:RightColumn  := maxcol() -1
  349.       HighLightWindow()
  350.  
  351.     else
  352.       o:TopRow       := WinTop()+4
  353.       o:LeftColumn   := WinLeft()+1
  354.       o:BottomRow    := WinBottom()-1
  355.       o:RightColumn  := WinRight()-1
  356.       ShowDeskTop()
  357.  
  358.     endif
  359.  
  360. Return( NIL )
  361.  
  362.  
  363. //───────────────────┐
  364. // Highlight Window  │
  365. //───────────────────┘
  366. Function HighlightWindow( x )
  367.  
  368.     x := if( x == NIL, current_window, x )
  369.     Sele ( x )
  370.     winStackUpdate( x )
  371.     Current_Window( x )
  372.     WindowFrame(WinObj( x ))
  373.     WinObj( x ):RefreshAll()
  374.  
  375. Return( NIL )
  376.  
  377.  
  378. //──────────────────────┐
  379. // De Highlight Window  │
  380. //──────────────────────┘
  381. Function DeHighlightWindow( x )
  382.  
  383.     local TopRow, ;
  384.           LeftColumn, ;
  385.           BottomRow, ;
  386.           RightColumn, ;
  387.           StandardColor, ;
  388.           Window
  389.  
  390.  
  391.     x := if( x == NIL, current_window, x )
  392.     if empty(alias(x))
  393.       Return( NIL )
  394.     endif
  395.  
  396.     Window := WinObj(x)
  397.  
  398.     TopRow        := Window:TopRow -4
  399.     LeftColumn    := Window:LeftColumn -1
  400.     BottomRow     := Window:BottomRow +1
  401.     RightColumn   := Window:RightColumn +1
  402.     StandardColor := Window:StandardColor
  403.  
  404.     Setcolor( StandardColor )
  405.     WinBox(TopRow,LeftColumn,BottomRow,RightColumn,0,'┌─┐│┘─└│', ;
  406.                if(BottomRow==maxrow()-1,.f.,.t.) ;
  407.             )
  408.  
  409.     @ TopRow, LeftColumn+1 say " " + eval( Window:UserSlot[1] ) + ;
  410.                                      "  < Win  " + ;
  411.                                      str(select(),1,0)+" > " ;
  412.                                color Window:InverseColor
  413.  
  414.  
  415.     Window:ShowStatus()
  416.  
  417. Return( NIL )
  418.  
  419.  
  420. //─────────────┐
  421. // Open Desktop│
  422. //─────────────┘
  423. Function OpenDesktop()
  424.  
  425.     local init, i, j
  426.  
  427.  
  428.     win_Stack( {} )
  429.     init := .t.
  430.     j := if(empty(alias()),1,select())
  431.     for i = 1 to len(Windows())
  432.       j++
  433.       if j > Len(windows())
  434.         j := 1
  435.       endif
  436.       if ! empty( alias(j) )
  437.         if ! init
  438.           DeHighLightWindow(Current_Window())
  439.         endif
  440.         OpenWindow(j)
  441.         init := .f.
  442.       endif
  443.     next
  444.  
  445. Return( NIL )
  446.  
  447.  
  448. //──────────────────┐
  449. // Display DeskTop  │
  450. //──────────────────┘
  451. Function ShowDeskTop()
  452.  
  453.     local i, j := Current_Window()
  454.  
  455.  
  456.     ShowBackGround()
  457.     for i = 1 to len(windows())
  458.       j++
  459.       if j > Len(windows())
  460.         j := 1
  461.       endif
  462.       Current_Window( j )
  463.       if ! empty(WinFilename(j))
  464.         HighLightWindow( j )
  465.         if i # len(windows())
  466.           DeHighLightWindow(j)
  467.         endif
  468.       endif
  469.     next
  470.  
  471. Return( NIL )
  472.  
  473. //───────────────┐
  474. // Open Window   │
  475. //───────────────┘
  476. Function OpenWindow(x)
  477.  
  478.     local o, y, Window := WinObj()
  479.  
  480.  
  481.     if x == NIL
  482.       x := Current_window()
  483.     endif
  484.  
  485.     if empty(alias(x))
  486.       Return( NIL )
  487.     endif
  488.  
  489.  
  490.     if ! empty( Window )
  491.       WinTop( , Window:TopRow -4 )
  492.       WinLeft( , Window:LeftColumn -1 )
  493.       WinBottom( , Window:BottomRow +1 )
  494.       WinRight( , Window:RightColumn +1 )
  495.     endif
  496.  
  497.     winStackUpdate( x )
  498.     Current_Window( x )
  499.     Sele (x)
  500.  
  501.  
  502.     Setcolor(WinColor())
  503.     o := dViewDBF():New( WinTop()    +4, ;
  504.                          WinLeft()   +1, ;
  505.                          WinBottom() -1, ;
  506.                          WinRight()  -1  ;
  507.                        )
  508.  
  509.     o:Head      := "═"
  510.     o:HeadSep   := "╤"
  511.     o:ColSep    := "│"
  512.  
  513.     o:UserSlot  :=  {                                               ;
  514.                       { || FileBase(WinFilename(),".DBF") }       , ;
  515.                       NIL                                         , ;
  516.                       NIL                                           ;
  517.                     }
  518.     o:Structure :=  WinViewStru()
  519.     y           := {}
  520.     aeval( WinViewStru(), {|a| aadd(y, a[DBS_NAME]) } )
  521.     o:Headings  := y
  522.  
  523.     WinObj(x, o )
  524.     WindowFrame( o )
  525.  
  526.     WinObj():Activate()
  527.  
  528. Return( o )
  529.  
  530.  
  531. //───────────────────────┐
  532. // Display Window Frame  │
  533. //───────────────────────┘
  534. Function WindowFrame( x )
  535.  
  536.  
  537.     local TopRow        := x:TopRow -4, ;
  538.           LeftColumn    := x:LeftColumn -1, ;
  539.           BottomRow     := x:BottomRow +1, ;
  540.           RightColumn   := x:RightColumn +1, ;
  541.           StandardColor := x:StandardColor
  542.  
  543.  
  544.     Setcolor( StandardColor )
  545.  
  546.     if BottomRow > Maxrow() -1
  547.       TopRow := max( 2, maxrow() - (BottomRow - TopRow) )
  548.       BottomRow := Maxrow() -1
  549.     endif
  550.  
  551.     if RightColumn > Maxcol()
  552.       RightColumn := Maxcol()
  553.     endif
  554.  
  555.  
  556.     x:TopRow      := TopRow +4
  557.     x:LeftColumn  := LeftColumn +1
  558.     x:BottomRow   := BottomRow -1
  559.     x:RightColumn := RightColumn -1
  560.  
  561.     WinBox(TopRow,LeftColumn,BottomRow,RightColumn,0,4, ;
  562.                if(BottomRow==maxrow()-1,.f.,.t.) ;
  563.             )
  564.  
  565.     WinSbar( TopRow, RightColumn, BottomRow, LeftColumn )
  566.  
  567.     @ TopRow, LeftColumn say "[■]"
  568.  
  569.     @ TopRow, LeftColumn + 4 say " " + eval( x:UserSlot[1] ) + ;
  570.                                        "  < Win  " + ;
  571.                                        str(select(),2,0)+" > " ;
  572.                                        color x:InverseColor
  573.  
  574.     if x:Userslot[3] # NIL
  575.       eval( x:UserSlot[3] )
  576.     endif
  577.  
  578.  
  579. Return( NIL )
  580.  
  581.  
  582. //─────────────────┐
  583. // Resize window   │
  584. //─────────────────┘
  585.  
  586. #define R_TOP            1
  587. #define R_TOPLEFT        2
  588. #define R_TOPRIGHT       3
  589. #define R_BOTTOMLEFT     4
  590. #define R_BOTTOMRIGHT    5
  591.  
  592. #define EXT_SHIFT        ( keybd_Stat(0) == 1 .or. keybd_Stat(1) == 1 )
  593.  
  594. STATIC Function ResizeWindow( x )
  595.  
  596.     Local CurrentScreen := Savescreen(02,00,maxrow(),maxcol()), ;
  597.           line1         := savescreen(01,00,01,maxcol()), ;
  598.           TopRow        := x:TopRow -4, ;
  599.           LeftColumn    := x:LeftColumn -1, ;
  600.           BottomRow     := x:BottomRow +1, ;
  601.           RightColumn   := x:RightColumn +1, ;
  602.           OriginalColor := Setcolor(), ;
  603.           ResizeColor   := x:InverseColor , ;
  604.           nKey          := 0, ;
  605.           drag          := .f. , ;
  606.           holdT         := -1, ;
  607.           holdL         := -1, ;
  608.           holdB         := -1, ;
  609.           holdR         := -1, ;
  610.           holdButton    := 0 , ;
  611.           Mouse         := MouseSys(), ;
  612.           row, ;
  613.           col, ;
  614.           drag_who , ;
  615.           xwidth, ;
  616.           xheight, ;
  617.           xOffset
  618.  
  619.  
  620.     row    := Mouse:Row
  621.     col    := Mouse:Column
  622.  
  623.     Setcolor( ResizeColor )
  624.     @1,0
  625.     NccMesg( ;
  626.          ' Move:  '+chr(26)+ space(7) + ;
  627.          'Resize:  Shift '+chr(26)+ space(7) + ;
  628.          'Done:  ─┘', ;
  629.          1, ;
  630.          'Center' ;
  631.         )
  632.  
  633.     WHILE .t.
  634.  
  635.       if ! (                              ;
  636.              holdT == TopRow        .and. ;
  637.              holdL == LeftColumn    .and. ;
  638.              holdB == BottomRow     .and. ;
  639.              holdR == RightColumn         ;
  640.            )
  641.  
  642.         Mouse:Hide()
  643.         Restscreen(02,00,maxrow(),maxcol(),CurrentScreen)
  644.         @ TopRow, LeftColumn, BottomRow, RightColumn  Box '┌─┐│┘─└│'
  645.         Mouse:Show()
  646.  
  647.         holdT :=  TopRow
  648.         holdL :=  LeftColumn
  649.         holdB :=  BottomRow
  650.         holdR :=  RightColumn
  651.  
  652.       endif
  653.  
  654.       xheight := BottomRow - TopRow
  655.       xwidth  := RightColumn - LeftColumn
  656.  
  657.       if Mouse:Button == 0
  658.         if drag
  659.           exit
  660.         endif
  661.         Mouse:MouseRead()
  662.         row := Mouse:Row
  663.         col := Mouse:Column
  664.       endif
  665.  
  666.       if Mouse:Ascii # 0
  667.         nKey := Mouse:Ascii
  668.         Do Case
  669.           Case nKey == K_ESC .or. nKey == K_RETURN
  670.             exit
  671.  
  672.           Case nKey == K_UP .and. ! EXT_SHIFT
  673.              if TopRow > 2
  674.                TopRow--
  675.                BottomRow--
  676.              endif
  677.  
  678.           Case nKey == K_DOWN .and. ! EXT_SHIFT
  679.              if BottomRow < maxrow() -1
  680.                TopRow++
  681.                BottomRow++
  682.              endif
  683.  
  684.           Case nKey == K_LEFT .and. ! EXT_SHIFT
  685.              if LeftColumn > 0
  686.                LeftColumn--
  687.                RightColumn--
  688.              endif
  689.  
  690.           Case nKey == K_RIGHT .and. ! EXT_SHIFT
  691.              if RightColumn < maxcol()
  692.                LeftColumn++
  693.                RightColumn++
  694.              endif
  695.  
  696.             Case nKey == K_UP .or. ( EXT_SHIFT .and. nKey == 56 )
  697.                if BottomRow - 6 > TopRow
  698.                  BottomRow--
  699.                endif
  700.  
  701.             Case nKey == K_DOWN .or. ( EXT_SHIFT .and. nKey == 50 )
  702.                if BottomRow < maxrow() -1
  703.                  BottomRow++
  704.                endif
  705.  
  706.             Case nKey == K_LEFT .or. ( EXT_SHIFT .and. nKey == 52 )
  707.                if RightColumn > LeftColumn + 21
  708.                  RightColumn--
  709.                endif
  710.  
  711.             Case nKey == K_RIGHT .or. ( EXT_SHIFT .and. nKey == 54 )
  712.                if RightColumn < maxcol()
  713.                  RightColumn++
  714.                endif
  715.  
  716.         EndCase
  717.  
  718.       elseif Mouse:Button # LEFT_BUTTON
  719.         nKey := K_RETURN
  720.         exit
  721.  
  722.       elseif Mouse:Button == LEFT_BUTTON
  723.         if drag
  724.           Mouse:Update()
  725.           row := Mouse:Row
  726.           col := Mouse:Column
  727.           Do Case
  728.             Case drag_who == R_TOPLEFT
  729.               if row <= BottomRow - 6 .and. col <= RightColumn - 30 .and. ;
  730.                  row > 1
  731.                 TopRow := max(2,row)
  732.                 LeftColumn := col
  733.               endif
  734.  
  735.             Case drag_who == R_TOPRIGHT
  736.               if row <= BottomRow - 6 .and. col >= LeftColumn + 30 .and. ;
  737.                 row > 1
  738.                 TopRow := max(2,row)
  739.                 RightColumn := col
  740.               endif
  741.  
  742.             Case drag_who == R_BOTTOMLEFT
  743.               if row >= TopRow + 6 .and. col <= RightColumn - 30 .and. ;
  744.                  row < maxrow()
  745.                 BottomRow   := min( row, maxrow()-1 )
  746.                 LeftColumn  := col
  747.               endif
  748.  
  749.             Case drag_who == R_BOTTOMRIGHT
  750.               if row >= TopRow + 6 .and. col >= LeftColumn + 30 .and. ;
  751.                  row < maxrow()
  752.                 BottomRow   := min( row, maxrow()-1 )
  753.                 RightColumn := col
  754.               endif
  755.  
  756.             Case drag_who == R_TOP
  757.               if row <= Maxrow()-1 - xHeight .and. col - xOffset >= 0 .and. ;
  758.                  col - xOffset + xWidth <= maxcol() .and. row > 1
  759.                 TopRow      := row
  760.                 BottomRow   := row + xHeight
  761.                 LeftColumn  := col - xOffset
  762.                 RightColumn := LeftColumn + xWidth
  763.               endif
  764.  
  765.           EndCase
  766.  
  767.         else
  768.           drag := .t.
  769.           if holdButton == 0
  770.             @1,0
  771.             holdButton := LEFT_BUTTON
  772.             if row == TopRow .and. Col # LeftColumn .and. Col # RightColumn
  773.               NccMesg( ;
  774.                    ' Move:  '+chr(26)+ space(7) + ;
  775.                    'Done:  Release Mouse Button', ;
  776.                    1, ;
  777.                    'Center' ;
  778.                   )
  779.             else
  780.               NccMesg( ;
  781.                    ' Resize:  '+chr(26)+ space(7) + ;
  782.                    'Done:  Release Mouse Button', ;
  783.                    1, ;
  784.                    'Center' ;
  785.                   )
  786.             endif
  787.             Mouse:Show()
  788.           endif
  789.           Do Case
  790.             Case row == TopRow .and. col == LeftColumn
  791.               drag_who := R_TOPLEFT
  792.  
  793.             Case row == TopRow .and. col == RightColumn
  794.               drag_who := R_TOPRIGHT
  795.  
  796.             Case row == BottomRow .and. col == LeftColumn
  797.               drag_who := R_BOTTOMLEFT
  798.  
  799.             Case row == BottomRow .and. col == RightColumn
  800.               drag_who := R_BOTTOMRIGHT
  801.  
  802.             Case row == TopRow .and. col >= LeftColumn .and. col <= RightColumn
  803.               drag_who := R_TOP
  804.               xOffset  := Col - Leftcolumn
  805.  
  806.             Otherwise
  807.               exit
  808.  
  809.           endcase
  810.         endif
  811.       elseif Mouse:Button == BOTH_BUTTONS
  812.          exit
  813.       elseif Mouse:Button == RIGHT_BUTTON
  814.          exit
  815.       else
  816.         exit
  817.       endif
  818.  
  819.     ENDDO
  820.  
  821.     Mouse:Hide()
  822.  
  823.     nKey           := Current_Window()
  824.     x:TopRow       := TopRow+4
  825.     x:LeftColumn   := LeftColumn+1
  826.     x:BottomRow    := BottomRow-1
  827.     x:RightColumn  := RightColumn-1
  828.  
  829.     WinTop(nKey, TopRow)
  830.     WinLeft(nKey, LeftColumn)
  831.     WinBottom(nKey, BottomRow)
  832.     WinRight(nKey, RightColumn)
  833.  
  834.     Setcolor( OriginalColor )
  835.     restscreen(01,00,01,maxcol(),line1)
  836.  
  837. Return( NIL )
  838.  
  839.  
  840. //─────────────────────────┐
  841. //    Window NccSbar       │
  842. //─────────────────────────┘
  843.  
  844. Function WinSbar( TopRow, RightColumn, BottomRow, LeftColumn )
  845.  
  846. Local bColor := Setcolor()
  847.  
  848. Setcolor('W+/R')
  849. v :=  NccVBar():New( TopRow+3,RightColumn,BottomRow-1,RightColumn, Lastrec() )
  850. v:Activate()
  851. v:InverseColor := Setcolor('GR+')
  852. v:Update(WinObj():LinePosition)
  853.  
  854. /*
  855. Setcolor('W+/R')
  856. h :=  NccHBar():New( BottomRow,LeftColumn+1,BottomRow,RightColumn-1, Fcount() )
  857. // mFcount := dbstruct()
  858. h:Activate()
  859. h:InverseColor := Setcolor('GR+')
  860. // aeval( dbstruct(), {|a| aadd(mFcount, a[DBS_NAME]) } )
  861. h:Update( FieldPos() )
  862. */
  863.  
  864. Setcolor( bColor )
  865.  
  866. Return( NIL )
  867.  
  868.