home *** CD-ROM | disk | FTP | other *** search
- //------------------------------------------------------------------------
- //
- // clipbar.prg
- //
- // Toolbar with clipboard tool buttons.
- // To use:
- /*
- f = new FishBarsForm()
- DO clipbar.prg WITH f
- */
- //
- // 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("ClipToolbar")
- if ( ( t == null ) or ( not FormObj.mdi ) )
- SET PROCEDURE TO (PROGRAM()) ADDITIVE
- t = new ClipToolbar( bLarge )
- bNew := true
- endif
- t.attach( FormObj )
- endif
-
- return ( bNew )
-
- class ClipToolbar( bLarge ) of Toolbar
- local sBitsize
- sBitsize = IIF( bLarge, "TL_", "TS_" )
-
- this.flat := true
- this.text := "Clipboard"
- this.onUpdate := class::clip_onUpdate
-
- this.tCut = new ToolButton( this )
- with ( this.tCut )
- bitmap := "RESOURCE " + sBitsize + "CUT"
- speedTip := "Cut"
- onClick := class::tCut_onClick
- endwith
-
- this.tCopy = new ToolButton( this )
- with ( this.tCopy )
- bitmap := "RESOURCE " + sBitsize + "COPY"
- speedTip := "Copy"
- onClick := class::tCopy_onClick
- endwith
-
- this.tPaste = new ToolButton( this )
- with ( this.tPaste )
- bitmap := "RESOURCE " + sBitsize + "PASTE"
- speedTip := "Paste"
- onClick := class::tPaste_onClick
- endwith
-
- function clip_onUpdate
- local bClip
- bClip = false
- if ( TYPE("this.form.activeControl") == "O" )
- bClip := ( TYPE("this.form.activeControl.copy") == "FP" )
- with ( this )
- tCut.enabled := TYPE("this.form.activeControl.cut") == "FP"
- tCopy.enabled := TYPE("this.form.activeControl.copy" ) == "FP"
- tPaste.enabled := TYPE("this.form.activeControl.paste") == "FP"
- endwith
- else
- with ( this )
- tCut.enabled := false
- tCopy.enabled := false
- tPaste.enabled := false
- endwith
- endif
- return ( bClip )
-
- function tCut_onClick
- return ( this.parent.form.activeControl.cut() )
-
- function tCopy_onClick
- return ( this.parent.form.activeControl.copy() )
-
- function tPaste_onClick
- return ( this.parent.form.activeControl.paste() )
-
- endclass
-