home *** CD-ROM | disk | FTP | other *** search
- //------------------------------------------------------------------------
- //
- // editbar.prg
- //
- // Toolbar with rowset editing tool buttons.
- // To use:
- /*
- f = new FishBarsForm() // a form with a defined rowset
- DO editbar.prg WITH f // for small tool buttons
- DO editbar.prg WITH f, true // for large tool buttons
- */
- //
- // Visual dBASE Samples Group
- //
- // $Revision: 1.5 $
- //
- // 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("EditToolbar")
- if ( ( t == null ) or ( not FormObj.mdi ) )
- SET PROCEDURE TO (PROGRAM()) ADDITIVE
- t = new EditToolbar( bLarge )
- bNew := true
- endif
- t.attach( FormObj )
- endif
-
- return ( bNew )
-
- class EditToolbar( bLarge ) of Toolbar
- local sBitsize
- sBitsize = IIF( bLarge, "TL_", "TS_" )
-
- this.flat := true
- this.text := "Edit"
- this.onUpdate := class::edit_onUpdate
-
- this.tAppend = new ToolButton( this )
- with ( this.tAppend )
- bitmap := "RESOURCE " + sBitsize + "APPEND"
- speedTip := "Add Row"
- onClick := class::tAppend_onClick
- endwith
-
- this.tDelete = new ToolButton( this )
- with ( this.tDelete )
- bitmap := "RESOURCE " + sBitsize + "DELETE"
- speedTip := "Delete Row"
- onClick := class::tDelete_onClick
- endwith
-
- this.tSave = new ToolButton( this )
- with ( this.tSave )
- bitmap := "RESOURCE " + sBitsize + "SAVE"
- speedTip := "Save Row"
- onClick := class::tSave_onClick
- endwith
-
- this.tAbandon = new ToolButton( this )
- with ( this.tAbandon )
- bitmap := "RESOURCE " + sBitsize + "ABANDON"
- speedTip := "Abandon Row"
- onClick := class::tAbandon_onClick
- endwith
-
- function edit_onUpdate
- LOCAL bRowFound
- bRowFound = ( TYPE("this.form.rowset") == "O" )
- this.tAppend.enabled := bRowFound
- this.tDelete.enabled := bRowFound
- this.tSave.enabled := bRowFound
- this.tAbandon.enabled := bRowFound
- return ( bRowFound )
-
- function tAppend_onClick
- return ( this.parent.form.rowset.beginAppend() )
-
- function tDelete_onClick
- local bDelete, bFirst
- bDelete = false
- bFirst = false
- if ( not this.parent.form.rowset.endOfSet )
- if ( MSGBOX("You are about to delete the current row." ;
- + CHR(13) ;
- + "Click Yes to delete the current row.", ;
- "Alert", ;
- 4) == 6 )
- bFirst := this.parent.form.rowset.atFirst()
- bDelete := this.parent.form.rowset.delete()
- if ( not bFirst )
- this.parent.form.rowset.next(-1)
- endif
- if ( this.parent.form.rowset.endOfSet )
- this.parent.form.rowset.next()
- endif
- endif
- endif
- return ( bDelete )
-
- function tSave_onClick
- return ( this.parent.form.rowset.save() )
-
- function tAbandon_onClick
- return ( this.parent.form.rowset.abandon() )
-
- endclass
-