MenuEditor.st
changeset 2118 caee73c7b7dd
parent 2113 8e2be2823f9e
child 2122 417dabd716d5
equal deleted inserted replaced
2117:3d456b890124 2118:caee73c7b7dd
  1945     ^ self class aboutImage
  1945     ^ self class aboutImage
  1946 ! !
  1946 ! !
  1947 
  1947 
  1948 !MenuEditor methodsFor:'drag & drop'!
  1948 !MenuEditor methodsFor:'drag & drop'!
  1949 
  1949 
  1950 canDrop:aContext
  1950 canDrop:aDropContext
  1951     "return true, if the DropContext can be dropped into the list of items.
  1951     "return true, if the DropContext can be dropped into the list of items.
  1952      The dropable objects are already validated by: #dropEnter:"
  1952      The dropable objects are already validated by: #dropEnter:"
  1953 
  1953 
  1954     ^ (dropOverLine notNil and:[dropOverLine ~~ 0])
  1954     ^ (dropOverLine notNil and:[dropOverLine ~~ 0])
       
  1955 
       
  1956     "Modified: / 13-10-2006 / 16:03:47 / cg"
  1955 !
  1957 !
  1956 
  1958 
  1957 changeDropLineTo:aLineOrNil in:aContext
  1959 changeDropLineTo:aLineOrNil in:aContext
  1958     "the over dropLine changed; redraw drop indication stuff
  1960     "the over dropLine changed; redraw drop indication stuff
  1959     "
  1961     "
  1990         listOfItemsView paint:(Color black).
  1992         listOfItemsView paint:(Color black).
  1991         listOfItemsView displayLineFromX:x0 y:y0 toX:x1 y:y0.
  1993         listOfItemsView displayLineFromX:x0 y:y0 toX:x1 y:y0.
  1992     ].
  1994     ].
  1993 !
  1995 !
  1994 
  1996 
  1995 doDrop:aContext
  1997 doDrop:aDropContext
  1996     "drop the dropContext into the hierachical list of items
  1998     "drop the dropContext into the hierachical list of items
  1997     "
  1999     "
  1998     |done item|
  2000     |done item|
  1999 
  2001 
  2000     dropOverLine ifNil:[^ false ].      "/ context not valid to me ...
  2002     dropOverLine ifNil:[^ false ].      "/ context not valid to me ...
  2001 
  2003 
  2002     item := listOfItems at:dropOverLine ifAbsent:nil.
  2004     item := listOfItems at:dropOverLine ifAbsent:nil.
  2003     self dropLeave:aContext.
  2005     self dropLeave:aDropContext.
  2004     item ifNil:[^ false].
  2006     item ifNil:[^ false].
  2005 
  2007 
  2006     selectionHolder setValue:(Array with:item).
  2008     selectionHolder setValue:(Array with:item).
  2007 
  2009 
  2008     done := false.
  2010     done := false.
  2009 
  2011 
  2010     self addAndSelectValueOf:[
  2012     self addAndSelectValueOf:[
  2011         done := true.
  2013         done := true.
  2012         aContext dropObjects collect:[:el| Item menuItem:(el theObject) ]
  2014         aDropContext dropObjects collect:[:el| Item menuItem:(el theObject) ]
  2013     ].
  2015     ].
  2014     ^ done
  2016     ^ done
  2015 !
  2017 
  2016 
  2018     "Modified: / 13-10-2006 / 16:03:54 / cg"
  2017 dropEnter:aContext
  2019 !
       
  2020 
       
  2021 dropEnter:aDropContext
  2018     "a drop operation enters my widget; validate dropable objects.
  2022     "a drop operation enters my widget; validate dropable objects.
  2019      If the objects are not dropable, dropOverLine is set to nil,
  2023      If the objects are not dropable, dropOverLine is set to nil,
  2020      otherwise to 0 (can drop the contents but not).
  2024      otherwise to 0 (can drop the contents but not).
  2021     "
  2025     "
  2022     |objects|
  2026     |objects|
  2025 
  2029 
  2026     self enablingCommitButtonsHolder value ifTrue:[
  2030     self enablingCommitButtonsHolder value ifTrue:[
  2027         "/ current editing spec is modified (couldn't accept operation)
  2031         "/ current editing spec is modified (couldn't accept operation)
  2028         ^ self
  2032         ^ self
  2029     ].
  2033     ].
  2030     objects := aContext dropObjects.
  2034     objects := aDropContext dropObjects.
  2031     objects isEmpty ifTrue:[ ^ self ].  "/ nothing to drop ???
  2035     objects isEmpty ifTrue:[ ^ self ].  "/ nothing to drop ???
  2032 
  2036 
  2033     "/ test whether all objects are dropable (kind of MenuItem)
  2037     "/ test whether all objects are dropable (kind of MenuItem)
  2034     (objects conform:[:el | (el theObject askFor:#isMenuItem)]) ifTrue:[
  2038     (objects conform:[:el | (el theObject askFor:#isMenuItem)]) ifTrue:[
  2035         "/ ok, the contents is dropable
  2039         "/ ok, the contents is dropable
  2036         dropOverLine := 0.
  2040         dropOverLine := 0.
  2037     ]
  2041     ]
  2038 
  2042 
  2039     "Modified: / 13-10-2006 / 12:57:06 / cg"
  2043     "Modified: / 13-10-2006 / 16:04:14 / cg"
  2040 !
  2044 !
  2041 
  2045 
  2042 dropLeave:aContext
  2046 dropLeave:aDropContext
  2043     "the widget is leaved; restore drop indications drawn ...
  2047     "the widget is leaved; restore drop indications drawn ...
  2044     "
  2048     "
  2045     self changeDropLineTo:nil in:aContext.
  2049     self changeDropLineTo:nil in:aDropContext.
       
  2050 
       
  2051     "Modified: / 13-10-2006 / 16:03:59 / cg"
  2046 !
  2052 !
  2047 
  2053 
  2048 dropObjects
  2054 dropObjects
  2049     "returns list of DropObjects
  2055     "returns list of DropObjects
  2050     "
  2056     "
  2058         obj displayObject:(el rawLabel).
  2064         obj displayObject:(el rawLabel).
  2059         obj
  2065         obj
  2060     ].
  2066     ].
  2061 !
  2067 !
  2062 
  2068 
  2063 dropOver:aContext
  2069 dropOver:aDropContext
  2064     "called during drag & drop while moving over the widget."
  2070     "called during drag & drop while moving over the widget."
  2065 
  2071 
  2066     |lnNr item|
  2072     |lnNr item|
  2067 
  2073 
  2068     dropOverLine ifNil:[^ self ].       "/ context not valid to me ...
  2074     dropOverLine ifNil:[^ self ].       "/ context not valid to me ...
  2069 
  2075 
  2070     lnNr := listOfItemsView yVisibleToLineNr:(aContext targetPoint y).
  2076     lnNr := listOfItemsView yVisibleToLineNr:(aDropContext targetPoint y).
  2071     item := nil.
  2077     item := nil.
  2072 
  2078 
  2073     lnNr ifNotNil:[
  2079     lnNr ifNotNil:[
  2074         item := listOfItems at:lnNr ifAbsent:nil.
  2080         item := listOfItems at:lnNr ifAbsent:nil.
  2075         item ifNotNil:[
  2081         item ifNotNil:[
  2079         ]
  2085         ]
  2080     ].
  2086     ].
  2081     item ifNil:[ lnNr := 0 ].   "/ not dropable for item
  2087     item ifNil:[ lnNr := 0 ].   "/ not dropable for item
  2082 
  2088 
  2083     "/ redraw drop indication
  2089     "/ redraw drop indication
  2084     self changeDropLineTo:lnNr in:aContext.
  2090     self changeDropLineTo:lnNr in:aDropContext.
       
  2091 
       
  2092     "Modified: / 13-10-2006 / 16:04:05 / cg"
  2085 ! !
  2093 ! !
  2086 
  2094 
  2087 !MenuEditor methodsFor:'event processing'!
  2095 !MenuEditor methodsFor:'event processing'!
  2088 
  2096 
  2089 processEvent:anEvent
  2097 processEvent:anEvent