home *** CD-ROM | disk | FTP | other *** search
- //------------------------------------------------------------------------
- //
- // vcrbar.prg
- //
- // Toolbar with VCR style rowset navigation tool buttons.
- // To use:
- /*
- f = new FishBarsForm() // a 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.6 $
- //
- // Copyright (c) 1997, Borland International, Inc. All rights reserved.
- //
- //------------------------------------------------------------------------
-
- parameter FormObj, bLarge
- local t, bNew
- t = null
- 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 := FindInstance("VcrToolbar")
- if ( ( t == null ) or ( not FormObj.mdi ) )
- SET PROCEDURE TO (PROGRAM()) ADDITIVE
- t = new VcrToolbar( bLarge )
- bNew := true
- endif
- t.attach( FormObj )
- endif
-
- return ( bNew )
-
- class VcrToolbar( bLarge ) of Toolbar
- local sBitsize
- sBitsize = IIF( bLarge, "TL_", "TS_" )
-
- this.flat := true
- this.text := "VCR"
- this.onUpdate := class::vcr_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 vcr_onUpdate
- local bAtFirst, bAtLast, bRowset
- 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
- 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
-