home *** CD-ROM | disk | FTP | other *** search
/ PC World 1997 November / PCWorld_1997-11_cd.bin / software / programy / komix / DATA.Z / ctrlpnlvie.tcl < prev    next >
Text File  |  1996-05-29  |  2KB  |  98 lines

  1. #---------------------------------------------------------------------------
  2. #
  3. #      (c)     Westmount Technology    1994
  4. #
  5. #      File:           @(#)ctrlpnlvie.tcl    1.4
  6. #      Author:         <generated>
  7. #      Description:
  8. #---------------------------------------------------------------------------
  9. # SccsId = @(#)ctrlpnlvie.tcl    1.4   16 Nov 1995 Copyright 1994 Westmount Technology
  10.  
  11. # Start user added include file section
  12. # End user added include file section
  13.  
  14.  
  15. Class CtrlPnlView : {BrowsView} {
  16.     constructor
  17.     method destructor
  18.     method dropEvent
  19.     method reIndex
  20. }
  21.  
  22. constructor CtrlPnlView {class this name} {
  23.     set this [BrowsView::constructor $class $this $name]
  24.     # Start constructor user section
  25.     $this destinationSet "CONTROLPANELENTRY dropEvent"
  26.     # End constructor user section
  27.     return $this
  28. }
  29.  
  30. method CtrlPnlView::destructor {this} {
  31.     # Start destructor user section
  32.     # End destructor user section
  33. }
  34.  
  35. method CtrlPnlView::dropEvent {this droppedObject srcIsDst droppedAfterObject droppedForObject} {
  36.  
  37.  
  38.     if {$srcIsDst == 0} {
  39.         wmtkmessage "Drag & drop between tools is not supported (yet)"
  40.         return
  41.     }
  42.  
  43.     set objSet [$this objectSet]
  44.  
  45.     # remove the dropped object from the list
  46.     foreach obj $objSet {
  47.         if {$obj != $droppedObject} {
  48.             lappend woObjSet $obj
  49.         }
  50.     }
  51.  
  52.     # replace the dropped object in the list
  53.     if { $droppedAfterObject == ""} {
  54.         set wObjSet "$droppedObject $woObjSet"
  55.     } else {
  56.         foreach obj $woObjSet {
  57.             lappend wObjSet $obj
  58.             if {$obj == $droppedAfterObject} {
  59.                 lappend wObjSet $droppedObject
  60.             }
  61.         }
  62.     }
  63.  
  64.     set index 0
  65.     foreach obj $wObjSet { 
  66.         $obj index $index
  67.         incr index
  68.     }
  69.  
  70.     $this sort -command "CtrlPnlView::sort"
  71. }
  72.  
  73. method CtrlPnlView::reIndex {this} {
  74.  
  75.     set index 0
  76.     foreach obj [$this objectSet] {
  77.         $obj index $index
  78.         incr index
  79.     }
  80. }
  81.  
  82. proc CtrlPnlView::sort {objA objB} {
  83.  
  84.     set idxA [$objA index]
  85.     set idxB [$objB index]
  86.  
  87.     if {$idxA > $idxB} {
  88.         return 1
  89.     } elseif {$idxB > $idxA} {
  90.         return -1
  91.     } else {
  92.         return 0
  93.     }
  94. }
  95.  
  96. # Do not delete this line -- regeneration end marker
  97.  
  98.