home *** CD-ROM | disk | FTP | other *** search
- //------------------------------------------------------------------------
- //
- // fdatabar.prg
- //
- // Toolbar for the SDI table oriented forms of the Fleet application.
- // This toolbar is similar to the VCRBAR.PRG sample that you can use
- // for MDI forms.
- //
- // To use:
- /*
- f = new AircraftForm() // an SDI form with a defined rowset
- DO vcrbar.prg WITH f // for small tool buttons
- DO vcrbar.prg WITH f, true // for large tool buttons
- */
- //
- // Visual dBASE Samples Group
- //
- // $Revision: 1.1 $
- //
- // Copyright (c) 1997, Borland International, Inc. All rights reserved.
- //
- //------------------------------------------------------------------------
-
- parameter FormObj, bLarge
- local t, bNew
- bNew = false
-
- if ( PCOUNT() == 0 )
- MSGBOX("To attach this toolbar to a form use: " + ;
- CHR(13) + CHR(13) + ;
- "DO " + PROGRAM() + " WITH <form reference>","Alert")
- else
- t = new FleetDatabar( bLarge )
- t.attach( FormObj )
- bNew := true
- endif
-
- return ( bNew )
-
- class FleetDataBar( bLarge ) of Toolbar
- local sBitsize
- sBitsize = IIF( bLarge, "TL_", "TS_" )
-
- this.flat := true
- this.text := "Fleet DataBar"
- this.onUpdate := class::databar_onUpdate
-
- this.tFirst = new ToolButton( this )
- with ( this.tFirst )
- bitmap := "RESOURCE " + sBitsize + "FIRST"
- speedTip := "First Row"
- onClick := class::tFirst_onClick
- endwith
-
- this.tPrev = new ToolButton( this )
- with ( this.tPrev )
- bitmap := "RESOURCE " + sBitsize + "PREV"
- speedTip := "Previous Row"
- onClick := class::tPrev_onClick
- endwith
-
- this.tNext = new ToolButton( this )
- with ( this.tNext )
- bitmap := "RESOURCE " + sBitsize + "NEXT"
- speedTip := "Next Row"
- onClick := class::tNext_onClick
- endwith
-
- this.tLast = new ToolButton( this )
- with ( this.tLast )
- bitmap := "RESOURCE " + sBitsize + "LAST"
- speedTip := "Last Row"
- onClick := class::tLast_onClick
- endwith
-
- function databar_onUpdate
- local bAtFirst, bAtLast, bRowset
- private typeCheck
- bRowset = false
- if ( TYPE("this.form") == "O" )
- bRowset := ( TYPE("this.form.rowset") == "O" )
- if ( bRowset )
- bAtFirst = this.form.rowset.atFirst()
- bAtLast = this.form.rowset.atLast()
- with ( this )
- tFirst.enabled := ( not bAtFirst )
- tPrev.enabled := ( not bAtFirst )
- tNext.enabled := ( not bAtLast )
- tLast.enabled := ( not bAtLast )
- endwith
- endif
- else
- with ( this )
- tFirst.enabled := false
- tPrev.enabled := false
- tNext.enabled := false
- tLast.enabled := false
- endwith
- endif
- return ( bRowset )
-
- function tFirst_onClick
- return ( this.parent.form.rowset.first() )
-
- function tPrev_onClick
- local bPrev
- bPrev = this.parent.form.rowset.next( -1 )
- if ( not bPrev )
- this.parent.form.rowset.next()
- endif
- return ( bPrev )
-
- function tNext_onClick
- local bNext
- bNext = this.parent.form.rowset.next()
- if ( not bNext )
- this.parent.form.rowset.next( -1 )
- endif
- return ( bNext )
-
- function tLast_onClick
- return ( this.parent.form.rowset.last() )
-
- endclass
-