home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / Visual Database / Visual dBase Pro v7.0 / DATA1.CAB / Sample_dBASE / Fleet / Fdatabar.prg < prev    next >
Encoding:
Text File  |  1997-11-20  |  3.5 KB  |  125 lines

  1. //------------------------------------------------------------------------
  2. //
  3. //  fdatabar.prg
  4. //
  5. //  Toolbar for the SDI table oriented forms of the Fleet application. 
  6. //  This toolbar is similar to the VCRBAR.PRG sample that you can use
  7. //  for MDI forms.
  8. //
  9. //  To use:
  10. /* 
  11.      f = new AircraftForm()     // an SDI form with a defined rowset
  12.      DO vcrbar.prg WITH f       // for small tool buttons
  13.      DO vcrbar.prg WITH f, true // for large tool buttons
  14. */
  15. //  
  16. //  Visual dBASE Samples Group
  17. //
  18. //  $Revision:   1.1  $
  19. //
  20. //  Copyright (c) 1997, Borland International, Inc. All rights reserved.    
  21. //
  22. //------------------------------------------------------------------------  
  23.  
  24.    parameter FormObj, bLarge
  25.    local t, bNew
  26.    bNew = false
  27.  
  28.    if ( PCOUNT() == 0 )
  29.       MSGBOX("To attach this toolbar to a form use: " + ;
  30.               CHR(13) + CHR(13) + ;
  31.              "DO " + PROGRAM() + " WITH <form reference>","Alert")
  32.    else
  33.       t = new FleetDatabar( bLarge )
  34.       t.attach( FormObj ) 
  35.       bNew := true
  36.    endif
  37.  
  38. return ( bNew )
  39.  
  40. class FleetDataBar( bLarge ) of Toolbar
  41.    local sBitsize
  42.    sBitsize = IIF( bLarge, "TL_", "TS_" )
  43.  
  44.    this.flat     := true
  45.    this.text     := "Fleet DataBar"
  46.    this.onUpdate := class::databar_onUpdate
  47.  
  48.    this.tFirst = new ToolButton( this )
  49.    with ( this.tFirst )
  50.         bitmap   := "RESOURCE " + sBitsize + "FIRST"
  51.         speedTip := "First Row"
  52.         onClick  := class::tFirst_onClick
  53.    endwith
  54.  
  55.    this.tPrev = new ToolButton( this )
  56.    with ( this.tPrev )
  57.         bitmap   := "RESOURCE " + sBitsize + "PREV"
  58.         speedTip := "Previous Row"
  59.         onClick  := class::tPrev_onClick
  60.    endwith
  61.    
  62.    this.tNext = new ToolButton( this )
  63.    with ( this.tNext )
  64.         bitmap   := "RESOURCE " + sBitsize + "NEXT"
  65.         speedTip := "Next Row"
  66.         onClick  := class::tNext_onClick
  67.    endwith
  68.  
  69.    this.tLast = new ToolButton( this )
  70.    with ( this.tLast )
  71.         bitmap   := "RESOURCE " + sBitsize + "LAST"
  72.         speedTip := "Last Row"
  73.         onClick  := class::tLast_onClick
  74.    endwith
  75.  
  76.    function databar_onUpdate
  77.       local bAtFirst, bAtLast, bRowset
  78.       private typeCheck
  79.       bRowset = false
  80.       if ( TYPE("this.form") == "O" )
  81.          bRowset := ( TYPE("this.form.rowset") == "O" )
  82.          if ( bRowset )           
  83.             bAtFirst = this.form.rowset.atFirst()
  84.             bAtLast  = this.form.rowset.atLast() 
  85.             with ( this )
  86.                tFirst.enabled := ( not bAtFirst )
  87.                tPrev.enabled  := ( not bAtFirst )
  88.                tNext.enabled  := ( not bAtLast )
  89.                tLast.enabled  := ( not bAtLast )
  90.             endwith
  91.          endif
  92.       else
  93.          with ( this )
  94.             tFirst.enabled := false
  95.             tPrev.enabled  := false
  96.             tNext.enabled  := false
  97.             tLast.enabled  := false
  98.          endwith
  99.       endif         
  100.    return ( bRowset )
  101.  
  102.    function tFirst_onClick
  103.    return ( this.parent.form.rowset.first() )
  104.  
  105.    function tPrev_onClick
  106.        local bPrev
  107.        bPrev = this.parent.form.rowset.next( -1 )
  108.        if ( not bPrev )
  109.           this.parent.form.rowset.next()
  110.        endif
  111.    return ( bPrev )
  112.  
  113.    function tNext_onClick
  114.       local bNext 
  115.       bNext = this.parent.form.rowset.next()
  116.       if ( not bNext )
  117.          this.parent.form.rowset.next( -1 )
  118.       endif
  119.    return ( bNext )
  120.  
  121.    function tLast_onClick
  122.    return ( this.parent.form.rowset.last() )
  123.  
  124. endclass
  125.