UIPainterView.st
changeset 2499 11be77599ca9
parent 2494 43400c4e5196
child 2505 2d43dbc0e86c
equal deleted inserted replaced
2498:ca273c14b7bf 2499:11be77599ca9
   293         newSelection := self.
   293         newSelection := self.
   294     ] ifFalse:[
   294     ] ifFalse:[
   295         viewsToRemove size == 1 ifTrue:[
   295         viewsToRemove size == 1 ifTrue:[
   296             |subviews index|
   296             |subviews index|
   297 
   297 
       
   298             newSelection components notEmptyOrNil ifTrue:[ self halt ].
   298             subviews := newSelection subViews.
   299             subviews := newSelection subViews.
   299 
   300 
   300             subviews size > 1 ifTrue:[
   301             subviews size > 1 ifTrue:[
   301                 index := subviews findFirst:[:eachView| eachView isSameOrComponentOf:firstView ].
   302                 index := subviews findFirst:[:eachView| eachView isSameOrComponentOf:firstView ].
   302                 index > 0 ifTrue:[
   303                 index > 0 ifTrue:[
  1614 
  1615 
  1615     "Modified: / 25.10.1997 / 19:22:17 / cg"
  1616     "Modified: / 25.10.1997 / 19:22:17 / cg"
  1616 !
  1617 !
  1617 
  1618 
  1618 generateWindowSpec
  1619 generateWindowSpec
  1619     |spec|
  1620     |spec addToSpec|
  1620 
  1621 
  1621     spec := OrderedCollection new.
  1622     spec := OrderedCollection new.
  1622 
  1623 
  1623     self subViews do:[:aView|
  1624     addToSpec :=
  1624         |vSpec|
  1625         [:aView|
  1625 
  1626             |vSpec|
  1626         "/ care for wrapped views ...
  1627 
  1627         vSpec := self fullSpecFor:aView.
  1628             "/ care for wrapped views ...
  1628         vSpec isNil ifTrue:[
  1629             vSpec := self fullSpecFor:aView.
  1629             aView subViews size == 1 ifTrue:[
  1630             vSpec isNil ifTrue:[
  1630                 vSpec := self fullSpecFor:(aView subViews first).
  1631                 aView subViews size == 1 ifTrue:[
  1631             ]
  1632                     vSpec := self fullSpecFor:(aView subViews first).
  1632         ].
  1633                 ]
  1633         vSpec isNil ifTrue:[
  1634             ].
  1634             self warn:'Oops - could not create spec for some view'
  1635             vSpec isNil ifTrue:[
  1635         ].
  1636                 self warn:'Oops - could not create spec for some view'
  1636         spec add:vSpec
  1637             ].
  1637     ].
  1638             spec add:vSpec
  1638 
  1639         ].
       
  1640 
       
  1641     self subViews do:addToSpec.
       
  1642     self components do:addToSpec.
  1639     spec := treeView generateFullSpecForComponents:spec named:methodName.
  1643     spec := treeView generateFullSpecForComponents:spec named:methodName.
  1640     ^ spec
  1644     ^ spec
  1641 !
  1645 !
  1642 
  1646 
  1643 generateWindowSpecMethodSource
  1647 generateWindowSpecMethodSource
  2035     "show object selected
  2039     "show object selected
  2036     "
  2040     "
  2037     |wasClipped sel hColor bg|
  2041     |wasClipped sel hColor bg|
  2038 
  2042 
  2039     selectionHiddenLevel == 0 ifTrue:[
  2043     selectionHiddenLevel == 0 ifTrue:[
  2040 	sel := treeView selection.
  2044         sel := treeView selection.
  2041 	(sel size > 1 and:
  2045         (sel size > 1 and: [(treeView model list at: sel first) contents view == aComponent])
  2042 	[(treeView model list at: sel first) contents view == aComponent])
  2046         ifTrue: [
  2043 	ifTrue: [
  2047             hColor := handleMasterColor
  2044 	    hColor := handleMasterColor
  2048         ] ifFalse:[
  2045 	] ifFalse:[
  2049             bg := aComponent viewBackground.
  2046 	    bg := aComponent viewBackground.
  2050             bg isColor ifTrue:[
  2047 	    bg isColor ifTrue:[
  2051                 bg brightness < 0.5 ifTrue:[
  2048 		bg brightness < 0.5 ifTrue:[
  2052                     hColor := handleColorWhite
  2049 		    hColor := handleColorWhite
  2053                 ] ifFalse:[
  2050 		] ifFalse:[
  2054                     hColor := handleColorBlack
  2051 		    hColor := handleColorBlack
  2055                 ]
  2052 		]
  2056             ] ifFalse:[
  2053 	    ] ifFalse:[
  2057                 hColor := handleColorBlack
  2054 		hColor := handleColorBlack
  2058             ]
  2055 	    ]
  2059         ].
  2056 	].
  2060 
  2057 
  2061         self paint:hColor.
  2058 	self paint:hColor.
  2062 
  2059 
  2063         (wasClipped := clipChildren) ifTrue:[
  2060 	(wasClipped := clipChildren) ifTrue:[
  2064             self clippedByChildren:(clipChildren := false).
  2061 	    self clippedByChildren:(clipChildren := false).
  2065         ].
  2062 	].
  2066 
  2063 
  2067         self handlesOf:aComponent do:[:aRectangle :what| 
  2064 	self handlesOf:aComponent do:[:aRectangle :what| |l t w h|
  2068             |l t w h|
  2065 	    l := aRectangle left   + 1.
  2069 
  2066 	    t := aRectangle top    + 1.
  2070             l := aRectangle left   + 1.
  2067 	    w := aRectangle width  - 2.
  2071             t := aRectangle top    + 1.
  2068 	    h := aRectangle height - 2.
  2072             w := aRectangle width  - 2.
  2069 
  2073             h := aRectangle height - 2.
  2070 	    what == #view ifTrue:[self displayRectangleX:l y:t width:w height:h]
  2074 
  2071 			 ifFalse:[self fillRectangleX:l y:t width:w height:h]
  2075             what == #view ifTrue:[
  2072 	].
  2076                 self displayRectangleX:l y:t width:w height:h
  2073 
  2077             ] ifFalse:[
  2074 	wasClipped ifTrue:[
  2078                 self fillRectangleX:l y:t width:w height:h
  2075 	    self clippedByChildren:(clipChildren := true).
  2079             ]
  2076 	]
  2080         ].
       
  2081 
       
  2082         wasClipped ifTrue:[
       
  2083             self clippedByChildren:(clipChildren := true).
       
  2084         ]
  2077     ]
  2085     ]
  2078 
  2086 
  2079     "Modified: / 6.12.2001 / 00:00:16 / cg"
  2087     "Modified: / 6.12.2001 / 00:00:16 / cg"
  2080 ! !
  2088 ! !
  2081 
  2089 
  2133 
  2141 
  2134 findObjectAt:aPoint
  2142 findObjectAt:aPoint
  2135     |view prop|
  2143     |view prop|
  2136 
  2144 
  2137     view := super findObjectAt:aPoint.
  2145     view := super findObjectAt:aPoint.
       
  2146     view isNil ifTrue:[^ nil].
       
  2147 
  2138     "/ stupid check, if I know about this view
  2148     "/ stupid check, if I know about this view
  2139     prop := self propertyOfView:view.
  2149     prop := self propertyOfView:view.
  2140     prop notNil ifTrue:[^ prop view].
  2150     prop notNil ifTrue:[^ prop view].
       
  2151 self halt.
  2141     ^ nil
  2152     ^ nil
  2142 !
  2153 !
  2143 
  2154 
  2144 findViewWithId:aViewId
  2155 findViewWithId:aViewId
  2145     "finds view assigned to identifier and returns the view or nil
  2156     "finds view assigned to identifier and returns the view or nil
  2365     ) ifTrue:[
  2376     ) ifTrue:[
  2366         viewPosition := anIndexOrNil.
  2377         viewPosition := anIndexOrNil.
  2367     ].
  2378     ].
  2368 
  2379 
  2369     "/ remember view<->spec associations to tree
  2380     "/ remember view<->spec associations to tree
  2370     aBuilder componentCreationHook:[:aView :aSpec :builder|
  2381     aBuilder 
  2371         |newProperty copyOfSpec nameOfSpec beforeIndex|
  2382         componentCreationHook:[:aView :aSpec :builder|
  2372 
  2383             |newProperty copyOfSpec nameOfSpec beforeIndex|
  2373         (viewPosition notNil and:[aSpecification == aSpec]) ifTrue:[
  2384 
  2374             subviewToRealize := aView.
  2385             (viewPosition notNil and:[aSpecification == aSpec]) ifTrue:[
  2375 
  2386                 subviewToRealize := aView.
  2376             [ (subviewToRealize notNil and:[subviewToRealize superView ~~ aFrame]) ] whileTrue:[
  2387 
  2377                 subviewToRealize := subviewToRealize superView.
  2388                 [ (subviewToRealize notNil and:[subviewToRealize superView ~~ aFrame]) ] whileTrue:[
       
  2389                     subviewToRealize := subviewToRealize superView.
       
  2390                 ].
       
  2391                 subviewToRealize notNil ifTrue:[
       
  2392                     beforeIndex := viewPosition.
       
  2393                     aFrame changeSequenceOrderFor:subviewToRealize to:viewPosition.
       
  2394                 ].
  2378             ].
  2395             ].
  2379             subviewToRealize notNil ifTrue:[
  2396 
  2380                 beforeIndex := viewPosition.
  2397             newProperty := ViewProperty new.
  2381                 aFrame changeSequenceOrderFor:subviewToRealize to:viewPosition.
  2398             copyOfSpec := aSpec copy.
       
  2399             newProperty spec:copyOfSpec.
       
  2400             newProperty view:aView.
       
  2401 
       
  2402             "/ break refs to child-specs
       
  2403             "/ (not needed, as we keep the child info in the view hierarchy)
       
  2404             copyOfSpec class supportsSubComponents ifTrue:[
       
  2405                 copyOfSpec component:nil
  2382             ].
  2406             ].
  2383         ].
  2407 
  2384 
  2408             nameOfSpec := copyOfSpec name.
  2385         newProperty := ViewProperty new.
  2409 
  2386         copyOfSpec := aSpec copy.
  2410             (nameOfSpec isNil or:[(self propertyOfName:nameOfSpec) notNil]) ifTrue:[
  2387         newProperty spec:copyOfSpec.
  2411                 copyOfSpec name:(nameOfSpec := self uniqueNameFor:copyOfSpec)
  2388         newProperty view:aView.
  2412             ].
  2389 
  2413             aView name:nameOfSpec.
  2390         "/ break refs to child-specs
  2414             treeView addProperty:newProperty beforeIndex:beforeIndex.
  2391         "/ (not needed, as we keep the child info in the view hierarchy)
  2415         ].
  2392         copyOfSpec class supportsSubComponents ifTrue:[
  2416 
  2393             copyOfSpec component:nil
       
  2394         ].
       
  2395 
       
  2396         nameOfSpec := copyOfSpec name.
       
  2397 
       
  2398         (nameOfSpec isNil or:[(self propertyOfName:nameOfSpec) notNil]) ifTrue:[
       
  2399             copyOfSpec name:(self uniqueNameFor:copyOfSpec)
       
  2400         ].
       
  2401         treeView addProperty:newProperty beforeIndex:beforeIndex.
       
  2402     ].
       
  2403     newView := aSpecification buildViewWithLayoutFor:aBuilder in:aFrame.
  2417     newView := aSpecification buildViewWithLayoutFor:aBuilder in:aFrame.
  2404 
  2418 
  2405     subviewToRealize notNil ifTrue:[
  2419     subviewToRealize notNil ifTrue:[
  2406         subviewToRealize realize.
  2420         subviewToRealize realize.
  2407 
  2421 
       
  2422         aFrame components notEmptyOrNil ifTrue:[ self halt ].
  2408         aFrame subViews from:(viewPosition + 1 ) do:[:v|
  2423         aFrame subViews from:(viewPosition + 1 ) do:[:v|
  2409             v shown ifTrue:[v raise]
  2424             v shown ifTrue:[v raise]
  2410         ].
  2425         ].
  2411     ].
  2426     ].
  2412     ^ newView
  2427     ^ newView
  2421 
  2436 
  2422     mySpec := self specFor:aView.
  2437     mySpec := self specFor:aView.
  2423 
  2438 
  2424     (mySpec notNil and:[mySpec class supportsSubComponents]) ifTrue:[
  2439     (mySpec notNil and:[mySpec class supportsSubComponents]) ifTrue:[
  2425         (aView subViews notNil) ifTrue:[
  2440         (aView subViews notNil) ifTrue:[
       
  2441             aView components notEmptyOrNil ifTrue:[ self halt ].
  2426             aView subViews do:[:aSubView||spec|
  2442             aView subViews do:[:aSubView||spec|
  2427                 spec := self fullSpecFor:aSubView.
  2443                 spec := self fullSpecFor:aSubView.
  2428                 spec notNil ifTrue:[
  2444                 spec notNil ifTrue:[
  2429                     subSpecs isNil ifTrue:[
  2445                     subSpecs isNil ifTrue:[
  2430                         subSpecs := OrderedCollection new
  2446                         subSpecs := OrderedCollection new
  2537     "update current selected view from specification
  2553     "update current selected view from specification
  2538     "
  2554     "
  2539     |props name|
  2555     |props name|
  2540 
  2556 
  2541     aSpec class == WindowSpec ifTrue:[
  2557     aSpec class == WindowSpec ifTrue:[
  2542 	 ^ treeView canvasSpec:aSpec
  2558          ^ treeView canvasSpec:aSpec
  2543     ].
  2559     ].
  2544 
  2560 
  2545     self singleSelection notNil ifTrue:[
  2561     self singleSelection notNil ifTrue:[
  2546 	self withSelectionHiddenDo:[
  2562         self withSelectionHiddenDo:[
  2547 	    self transaction:#specification selectionDo:[:aView|
  2563             self transaction:#specification selectionDo:[:aView|
  2548 		props   := self propertyOfView:aView.
  2564                 props   := self propertyOfView:aView.
  2549 		name    := (aSpec name) withoutSeparators.
  2565                 name    := (aSpec name) withoutSeparators.
  2550 
  2566 
  2551 		name = props name ifFalse:[
  2567                 (name = props name) ifFalse:[
  2552 		    (self propertyOfName:name) notNil ifTrue:[
  2568                     (self propertyOfName:name) notNil ifTrue:[
  2553 			name := props name
  2569                         name := props name
  2554 		    ]
  2570                     ]
  2555 		].
  2571                 ].
  2556 
  2572 
  2557 		aSpec name:name.
  2573                 aSpec name:name.
  2558 		self createUndoSpecModify:props.
  2574                 self createUndoSpecModify:props.
  2559 		self rebuildView:aView fromSpec:aSpec withBuilder:nil.
  2575                 self rebuildView:aView fromSpec:aSpec withBuilder:nil.
  2560 		props spec:(aSpec copy).
  2576                 props spec:(aSpec copy).
  2561 		treeView propertyChanged:props.
  2577                 treeView propertyChanged:props.
  2562 	    ]
  2578             ]
  2563 	]
  2579         ]
  2564     ]
  2580     ]
  2565 
  2581 
  2566     "Modified: / 30.10.2001 / 13:59:45 / cg"
  2582     "Modified: / 30.10.2001 / 13:59:45 / cg"
  2567 ! !
  2583 ! !
  2568 
  2584