UIObjectView.st
changeset 1827 691d1471cd3e
parent 1746 bb4f759cf456
child 1829 35409df5492a
equal deleted inserted replaced
1826:25ddfdfe0bf9 1827:691d1471cd3e
   506 
   506 
   507 keyPress:key x:x y:y
   507 keyPress:key x:x y:y
   508     "any key pressed
   508     "any key pressed
   509     "
   509     "
   510     <resource: #keyboard ( #CursorUp #CursorDown #CursorLeft #CursorRight
   510     <resource: #keyboard ( #CursorUp #CursorDown #CursorLeft #CursorRight
   511                            #Delete #BackSpace #Cut #Copy #Paste #Cmdu ) >
   511                            #Delete #BackSpace #Cut #Copy #Paste #Cmdu #Again) >
   512 
   512 
   513     |n sensor|
   513     |n sensor|
   514 
   514 
   515     (key == #Cut or:[key == #Delete or:[key == #BackSpace]]) ifTrue: [
   515     (key == #Cut or:[key == #Delete or:[key == #BackSpace]]) ifTrue: [
   516         ^ self deleteSelection
   516         ^ self deleteSelection
       
   517     ].
       
   518     (key = #PreviousPage) ifTrue:[
       
   519         self selectNextUpInHierarchy.
   517     ].
   520     ].
   518     key == #Copy  ifTrue:[ ^ self copySelection].
   521     key == #Copy  ifTrue:[ ^ self copySelection].
   519     key == #Paste ifTrue:[ ^ self pasteBuffer].
   522     key == #Paste ifTrue:[ ^ self pasteBuffer].
   520     key == #Cmdu  ifTrue:[ ^ self undoLast ].           "/ #Undo
   523     key == #Cmdu  ifTrue:[ ^ self undoLast ].           "/ #Undo
   521 
   524 
   522     (#(CursorUp CursorDown CursorRight CursorLeft) includes:key) ifTrue:[
   525     ( #(CursorUp CursorDown CursorRight CursorLeft)
   523         sensor := self sensor.
   526     includes:key) ifTrue:[
   524         n := 1 + (sensor compressKeyPressEventsWithKey:key).
   527         (sensor := self sensor) isNil ifTrue:[
   525         sensor shiftDown ifTrue:[
   528             n := 1
   526             n := n * 10.
   529         ] ifFalse:[
       
   530             n := 1 + (sensor compressKeyPressEventsWithKey:key).
       
   531             sensor shiftDown ifTrue:[
       
   532                 n := n * 10.
       
   533             ].
   527         ].
   534         ].
   528 
   535 
   529         key == #CursorUp ifTrue:[
   536         key == #CursorUp ifTrue:[
   530             ^ self moveSelectionUp:n
   537             ^ self moveSelectionUp:n
   531         ].
   538         ].
   705     pressAction      := [:pressPoint | self startSelectOrMove:pressPoint].
   712     pressAction      := [:pressPoint | self startSelectOrMove:pressPoint].
   706     shiftPressAction := [:pressPoint | self startSelectMoreOrMove:pressPoint].
   713     shiftPressAction := [:pressPoint | self startSelectMoreOrMove:pressPoint].
   707     motionAction     := [:movePoint  | nil].
   714     motionAction     := [:movePoint  | nil].
   708     releaseAction    := [nil].
   715     releaseAction    := [nil].
   709     keyPressAction   := nil.
   716     keyPressAction   := nil.
       
   717     doublePressAction   := [:pressPoint | self doublePressed: pressPoint].
   710 
   718 
   711     self cursor:Cursor normal.
   719     self cursor:Cursor normal.
   712 
   720 
   713 ! !
   721 ! !
   714 
   722 
   916     [self sensor hasExposeEventFor:nil] whileTrue:[
   924     [self sensor hasExposeEventFor:nil] whileTrue:[
   917         self windowGroup processExposeEvents
   925         self windowGroup processExposeEvents
   918     ].
   926     ].
   919 
   927 
   920     self setSelection:object withRedraw:true.
   928     self setSelection:object withRedraw:true.
       
   929     self forEach:selection do:[:aView |
       
   930         self recomputeShapeIfTransparentBox:aView.
       
   931     ].
   921     self layoutChanged.
   932     self layoutChanged.
       
   933 !
       
   934 
       
   935 layoutChanged
   922 !
   936 !
   923 
   937 
   924 startResizeBorder:b of:selection
   938 startResizeBorder:b of:selection
   925     "resize selected view
   939     "resize selected view
   926     "
   940     "
   963     ].
   977     ].
   964   ^ nil
   978   ^ nil
   965 ! !
   979 ! !
   966 
   980 
   967 !UIObjectView methodsFor:'private-resizing subviews'!
   981 !UIObjectView methodsFor:'private-resizing subviews'!
       
   982 
       
   983 recomputeShapeIfTransparentBox:aView
       
   984     (aView notNil and:[aView isTBox]) ifTrue:[
       
   985         aView computeShape.
       
   986         aView clear; redraw
       
   987     ].
       
   988 !
   968 
   989 
   969 resize:aView bottom:aPoint
   990 resize:aView bottom:aPoint
   970     "resize a views bottom
   991     "resize a views bottom
   971     "
   992     "
   972     undoHistory withoutTransactionDo:[
   993     undoHistory withoutTransactionDo:[
  1187 
  1208 
  1188     (size ~~ 0 or:[coll isNil]) ifTrue:[^ size].
  1209     (size ~~ 0 or:[coll isNil]) ifTrue:[^ size].
  1189   ^ 1
  1210   ^ 1
  1190 !
  1211 !
  1191 
  1212 
       
  1213 selectNextUpInHierarchy
       
  1214     self halt.
       
  1215 !
       
  1216 
  1192 selection:something
  1217 selection:something
  1193     "change selection to something
  1218     "change selection to something
  1194     "
  1219     "
  1195     self select:something
  1220     self select:something
  1196 !
  1221 !
  1296 	aBlock value.
  1321 	aBlock value.
  1297 	self setSelection:sel withRedraw:true.
  1322 	self setSelection:sel withRedraw:true.
  1298     ]
  1323     ]
  1299 
  1324 
  1300 
  1325 
       
  1326 ! !
       
  1327 
       
  1328 !UIObjectView methodsFor:'selections basic'!
       
  1329 
       
  1330 setSelection:aNewSelection withRedraw:doRedraw
       
  1331     "set a new selection without change notifications
       
  1332     "
       
  1333     | sel |
       
  1334 
       
  1335     (sel := aNewSelection) == self ifTrue:[
       
  1336         sel := nil
       
  1337     ].
       
  1338 
       
  1339     doRedraw ifTrue:[
       
  1340         self hideSelection.
       
  1341         selection := sel.
       
  1342 
       
  1343         self forEach:selection do:[:aView |
       
  1344             |superView|
       
  1345 
       
  1346             superView := aView superView. 
       
  1347             self recomputeShapeIfTransparentBox:superView.
       
  1348         ].
       
  1349         self showSelection.
       
  1350     ] ifFalse:[
       
  1351         selection := sel
       
  1352     ]
  1301 ! !
  1353 ! !
  1302 
  1354 
  1303 !UIObjectView methodsFor:'selections-basic'!
  1355 !UIObjectView methodsFor:'selections-basic'!
  1304 
  1356 
  1305 recursiveRepair:theDamages startIn:aView
  1357 recursiveRepair:theDamages startIn:aView
  1383     "returns the current selection
  1435     "returns the current selection
  1384     "
  1436     "
  1385     ^ selection
  1437     ^ selection
  1386 
  1438 
  1387 
  1439 
  1388 !
       
  1389 
       
  1390 setSelection:aNewSelection withRedraw:doRedraw
       
  1391     "set a new selection without change notifications
       
  1392     "
       
  1393     |sel|
       
  1394 
       
  1395     (sel := aNewSelection) == self ifTrue:[
       
  1396 	sel := nil
       
  1397     ].
       
  1398 
       
  1399     doRedraw ifTrue:[
       
  1400 	self hideSelection.
       
  1401 	selection := sel.
       
  1402 	self showSelection
       
  1403     ] ifFalse:[
       
  1404 	selection := sel
       
  1405     ]
       
  1406 !
  1440 !
  1407 
  1441 
  1408 showUnselected:something
  1442 showUnselected:something
  1409     "show a component ot list of components unselected
  1443     "show a component ot list of components unselected
  1410     "
  1444     "