UIObjectView.st
changeset 2481 b8999543e2b4
parent 2422 d85ddb9b2355
child 2482 62831852b487
equal deleted inserted replaced
2480:6effcbfba4e3 2481:b8999543e2b4
  1286 
  1286 
  1287     (size ~~ 0 or:[coll isNil]) ifTrue:[^ size].
  1287     (size ~~ 0 or:[coll isNil]) ifTrue:[^ size].
  1288   ^ 1
  1288   ^ 1
  1289 !
  1289 !
  1290 
  1290 
       
  1291 resizableSelection
       
  1292     "checks whether the selection is not empty and all selected instances
       
  1293      can be resized. If true the selection is returned otherwise nil
       
  1294     "
       
  1295     |coll|
       
  1296 
       
  1297     self hasSelection ifTrue:[
       
  1298         coll := self selection.        
       
  1299         (self canResize:coll) ifTrue:[
       
  1300             ^ coll
       
  1301         ]
       
  1302     ].
       
  1303     ^ nil
       
  1304 !
       
  1305 
  1291 selectNextUpInHierarchy
  1306 selectNextUpInHierarchy
  1292     self halt:#ca.
  1307     self halt:#ca.
  1293 !
  1308 !
  1294 
  1309 
  1295 selection:newSelection
  1310 selection:newSelection
  1435 
  1450 
  1436     "/ compute relative origin starting from border left@top
  1451     "/ compute relative origin starting from border left@top
  1437     relOrgX := relOrg x - bwWidth.
  1452     relOrgX := relOrg x - bwWidth.
  1438     relOrgY := relOrg y - bwWidth.
  1453     relOrgY := relOrg y - bwWidth.
  1439     width   := aView width  + bwWidth + bwWidth.
  1454     width   := aView width  + bwWidth + bwWidth.
  1440     height  := aView height + bwWidth + bwWidth.
  1455     height  := aView height + bwWidth + bwWid
  1441 
       
  1442     size to:1 by:-1 do:[:anIndex|
       
  1443         damage := theDamages at:anIndex.
       
  1444 
       
  1445         "/ compute the rectangle into the view
       
  1446         y := damage top  - relOrgY.
       
  1447         x := damage left - relOrgX.
       
  1448         w := damage width.
       
  1449         h := damage height.
       
  1450 
       
  1451         isRepaired := true.
       
  1452 
       
  1453         x     < 0      ifTrue:[ w := w + x. x := 0. isRepaired := false ].
       
  1454         y     < 0      ifTrue:[ h := h + y. y := 0. isRepaired := false ].
       
  1455         x + w > width  ifTrue:[ w := width  - x.    isRepaired := false ].
       
  1456         y + h > height ifTrue:[ h := height - y.    isRepaired := false ].
       
  1457 
       
  1458         (w > 0 and:[h > 0]) ifTrue:[
       
  1459             bwWidth ~~ 0 ifTrue:[
       
  1460                 color isNil ifTrue:[
       
  1461                     "/ must force redraw of border
       
  1462                     color := aView borderColor.
       
  1463                     aView borderColor:(Color colorId:1).
       
  1464                     aView borderColor:color.
       
  1465                 ].
       
  1466                 w := w - bwWidth.
       
  1467                 h := h - bwWidth.
       
  1468 
       
  1469                 (x := x - bwWidth) < 0 ifTrue:[w := w + x. x := 0].
       
  1470                 (y := y - bwWidth) < 0 ifTrue:[h := h + y. y := 0].
       
  1471 
       
  1472                 (w > 0 and:[h > 0])  ifFalse:[w := 0].
       
  1473             ].
       
  1474 
       
  1475             w > 0 ifTrue:[
       
  1476                 aView clearRectangleX:x y:y width:w height:h.
       
  1477                 aView exposeX:x y:y width:w height:h
       
  1478             ].
       
  1479             isRepaired ifTrue:[ theDamages removeIndex:anIndex ].
       
  1480         ]
       
  1481     ].
       
  1482 !
  1456 !
  1483 
  1457 
  1484 selection
  1458 selection
  1485     "returns the current selection
  1459     "returns the current selection
  1486     "
  1460     "
  2175     "align selection to the left/right of the first object in the selection; in case
  2149     "align selection to the left/right of the first object in the selection; in case
  2176      of one selection the object is aligned to the left/right of its superview
  2150      of one selection the object is aligned to the left/right of its superview
  2177     "
  2151     "
  2178     |lmost rmost sel|
  2152     |lmost rmost sel|
  2179 
  2153 
  2180     (sel := self moveableSelection) notNil ifTrue:[
  2154     (sel := self resizableSelection) notNil ifTrue:[
  2181         self withSelectionHiddenDo:[
  2155         self withSelectionHiddenDo:[
  2182             self numberOfSelections > 1 ifTrue:[
  2156             self numberOfSelections > 1 ifTrue:[
  2183                 lmost := (sel first) computeOrigin x.
  2157                 lmost := (sel first) computeOrigin x.
  2184                 rmost := (sel first) computeCorner x.
  2158                 rmost := (sel first) computeCorner x.
  2185 
  2159 
  2186                 self transaction:#alignLeftRight selectionDo:[:aView|
  2160                 self transaction:#alignLeftRight selectionDo:[:aView|
  2187                     |layout|
  2161                     |layout|
  2188                     layout := self class asLayoutFrameFromView:aView.
  2162 
  2189 
  2163                     aView superView isLayoutWrapper ifTrue:[
  2190                     layout notNil ifTrue:[
  2164                         "change size only"
  2191                         self createUndoLayout:aView.
  2165                         self createUndoLayout:aView.
  2192                         aView geometryLayout:layout.
  2166                         aView width:sel first width.
  2193 
  2167                         self elementChangedSize:aView
  2194                         undoHistory withoutTransactionDo:[
  2168                     ] ifFalse:[
  2195                             self shiftLayout:aView left:(lmost - (aView computeOrigin x))
  2169                         layout := self class asLayoutFrameFromView:aView.
  2196                                                   right:(rmost - (aView computeCorner x)).
  2170 
       
  2171                         layout notNil ifTrue:[
       
  2172                             self createUndoLayout:aView.
       
  2173                             aView geometryLayout:layout.
       
  2174 
       
  2175                             undoHistory withoutTransactionDo:[
       
  2176                                 self shiftLayout:aView left:(lmost - (aView computeOrigin x))
       
  2177                                                       right:(rmost - (aView computeCorner x)).
       
  2178                             ].
       
  2179                             self elementChangedSize:aView
  2197                         ].
  2180                         ].
  2198                         self elementChangedSize:aView
  2181                     ].
  2199                     ]
       
  2200                 ]
  2182                 ]
  2201             ] ifFalse:[
  2183             ] ifFalse:[
  2202                 self extentToFrame:#LeftRight do:[:aLayout|
  2184                 self extentToFrame:#LeftRight do:[:aLayout|
  2203                     aLayout leftFraction:0.0 offset:0.
  2185                     aLayout leftFraction:0.0 offset:0.
  2204                     aLayout rightFraction:1.0 offset:0.
  2186                     aLayout rightFraction:1.0 offset:0.
  2271     "align selection to the top/bottom of the first object in the selection; in case
  2253     "align selection to the top/bottom of the first object in the selection; in case
  2272      of one selection the object is aligned to the top/bottom of its superview
  2254      of one selection the object is aligned to the top/bottom of its superview
  2273     "
  2255     "
  2274     |tmost bmost sel|
  2256     |tmost bmost sel|
  2275 
  2257 
  2276     (sel := self moveableSelection) notNil ifTrue:[
  2258     (sel := self resizableSelection) notNil ifTrue:[
  2277         self withSelectionHiddenDo:[
  2259         self withSelectionHiddenDo:[
  2278             self numberOfSelections > 1 ifTrue:[
  2260             self numberOfSelections > 1 ifTrue:[
  2279                 tmost := (sel first) computeOrigin y.
  2261                 tmost := (sel first) computeOrigin y.
  2280                 bmost := (sel first) computeCorner y.
  2262                 bmost := (sel first) computeCorner y.
  2281 
  2263 
  2282                 self transaction:#alignTopBottom selectionDo:[:aView|
  2264                 self transaction:#alignTopBottom selectionDo:[:aView|
  2283                     |layout|
  2265                     |layout|
  2284                     layout := self class asLayoutFrameFromView:aView.
  2266                     aView superView isLayoutWrapper ifTrue:[
  2285 
  2267                         "change size only"
  2286                     layout notNil ifTrue:[
       
  2287                         self createUndoLayout:aView.
  2268                         self createUndoLayout:aView.
  2288                         aView geometryLayout:layout.
  2269                         aView height:sel first height.
  2289 
  2270                         self elementChangedSize:aView
  2290                         undoHistory withoutTransactionDo:[
  2271                     ] ifFalse:[
  2291                             self shiftLayout:aView top:(tmost - (aView computeOrigin y))
  2272                         layout := self class asLayoutFrameFromView:aView.
  2292                                                 bottom:(bmost - (aView computeCorner y)).
  2273 
       
  2274                         layout notNil ifTrue:[
       
  2275                             self createUndoLayout:aView.
       
  2276                             aView geometryLayout:layout.
       
  2277 
       
  2278                             undoHistory withoutTransactionDo:[
       
  2279                                 self shiftLayout:aView top:(tmost - (aView computeOrigin y))
       
  2280                                                     bottom:(bmost - (aView computeCorner y)).
       
  2281                             ].
       
  2282                             self elementChangedSize:aView
  2293                         ].
  2283                         ].
  2294                         self elementChangedSize:aView
  2284                     ].
  2295                     ]
       
  2296                 ]
  2285                 ]
  2297             ] ifFalse:[
  2286             ] ifFalse:[
  2298                 self extentToFrame:#TopBottom do:[:aLayout|
  2287                 self extentToFrame:#TopBottom do:[:aLayout|
  2299                     aLayout topOffset:0.
  2288                     aLayout topOffset:0.
  2300                     aLayout topFraction:0.0.
  2289                     aLayout topFraction:0.0.