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

  1. //------------------------------------------------------------------------
  2. //
  3. //  clipbar.prg
  4. //
  5. //  Toolbar with clipboard tool buttons.
  6. //  To use:
  7. /* 
  8.      f = new FishBarsForm()  
  9.      DO clipbar.prg WITH f
  10. */
  11. //  
  12. //  Visual dBASE Samples Group
  13. //
  14. //  $Revision:   1.5  $
  15. //
  16. //  Copyright (c) 1997, Borland International, Inc. All rights reserved.    
  17. //
  18. //------------------------------------------------------------------------  
  19.  
  20.    parameter FormObj, bLarge
  21.    local t, bNew
  22.    t    = null
  23.    bNew = false
  24.  
  25.    if ( PCOUNT() == 0 )
  26.        MSGBOX("To attach this toolbar to a form use: " + ;
  27.               CHR(13) + CHR(13) + ;
  28.              "DO " + PROGRAM() + " WITH <form reference>","Alert")
  29.    else
  30.       t := FindInstance("ClipToolbar")
  31.       if ( ( t == null ) or ( not FormObj.mdi ) )
  32.          SET PROCEDURE TO (PROGRAM()) ADDITIVE
  33.          t = new ClipToolbar( bLarge )
  34.          bNew := true
  35.       endif
  36.       t.attach( FormObj )  
  37.     endif
  38.  
  39. return ( bNew )
  40.  
  41. class ClipToolbar( bLarge ) of Toolbar
  42.    local sBitsize
  43.    sBitsize = IIF( bLarge, "TL_", "TS_" )
  44.  
  45.    this.flat     := true
  46.    this.text     := "Clipboard"
  47.    this.onUpdate := class::clip_onUpdate
  48.  
  49.    this.tCut = new ToolButton( this )
  50.    with ( this.tCut )
  51.         bitmap   := "RESOURCE " + sBitsize + "CUT"
  52.         speedTip := "Cut"
  53.         onClick  := class::tCut_onClick
  54.    endwith
  55.  
  56.    this.tCopy = new ToolButton( this )
  57.    with ( this.tCopy )  
  58.         bitmap   := "RESOURCE " + sBitsize + "COPY"
  59.         speedTip := "Copy"
  60.         onClick  := class::tCopy_onClick
  61.    endwith
  62.  
  63.    this.tPaste = new ToolButton( this )
  64.    with ( this.tPaste )
  65.         bitmap   := "RESOURCE " + sBitsize + "PASTE"
  66.         speedTip := "Paste"
  67.         onClick  := class::tPaste_onClick
  68.    endwith 
  69.  
  70.    function clip_onUpdate
  71.       local bClip
  72.       bClip = false
  73.       if ( TYPE("this.form.activeControl") == "O" )
  74.          bClip := ( TYPE("this.form.activeControl.copy") == "FP" )
  75.          with ( this )
  76.             tCut.enabled   := TYPE("this.form.activeControl.cut") == "FP"
  77.             tCopy.enabled  := TYPE("this.form.activeControl.copy" ) == "FP"
  78.             tPaste.enabled := TYPE("this.form.activeControl.paste") == "FP"
  79.          endwith
  80.       else
  81.          with ( this )
  82.             tCut.enabled   := false
  83.             tCopy.enabled  := false
  84.             tPaste.enabled := false
  85.          endwith
  86.       endif
  87.    return ( bClip )
  88.   
  89.    function tCut_onClick
  90.    return ( this.parent.form.activeControl.cut() )
  91.  
  92.    function tCopy_onClick
  93.    return ( this.parent.form.activeControl.copy() )
  94.  
  95.    function tPaste_onClick
  96.    return ( this.parent.form.activeControl.paste() )
  97.  
  98. endclass
  99.