UIObjectView.st
author Patrik Svestka <patrik.svestka@gmail.com>
Wed, 14 Nov 2018 12:07:51 +0100
branchjv
changeset 3630 5e718e0a754e
parent 3310 da50428c3763
child 3385 5307c299118d
permissions -rw-r--r--
Issue #239: Fix all Smalltak/X source files to be in unicode (UTF8 without BOM) and prefixed by "{ Encoding: utf8 }" when any unicode character is present

- All source *.st files are now Unicode UTF8 without BOM
Files are in two groups (fileOut works this way in Smalltalk/X):
- containing a unicode character have "{ Encoding: utf8 }" at the header
- ASCII only are without the header
cg@156
     1
"
cg@156
     2
 COPYRIGHT (c) 1995 by eXept Software AG
cg@1120
     3
	      All Rights Reserved
cg@156
     4
cg@156
     5
 This software is furnished under a license and may be used
cg@156
     6
 only in accordance with the terms of that license and with the
cg@156
     7
 inclusion of the above copyright notice.   This software may not
cg@156
     8
 be provided or otherwise made available to, or used by, any
cg@156
     9
 other person.  No title to or ownership of the software is
cg@156
    10
 hereby transferred.
cg@156
    11
"
cg@1399
    12
"{ Package: 'stx:libtool2' }"
cg@1399
    13
cg@3219
    14
"{ NameSpace: Smalltalk }"
cg@3219
    15
cg@60
    16
ObjectView subclass:#UIObjectView
ca@1672
    17
	instanceVariableNames:'saveSelection undoHistory copiedExtent copiedLayout resizeData
ca@1672
    18
		clipChildren selectionHiddenLevel gridParameters
cg@3219
    19
		setOfSuperViewsSizeChanged hasUndoHistoryHolder
cg@3219
    20
		nPixelsForMoveSelection'
cg@2364
    21
	classVariableNames:'CopiedLayout CopiedExtent'
cg@60
    22
	poolDictionaries:''
cg@60
    23
	category:'Interface-UIPainter'
cg@60
    24
!
cg@60
    25
ca@1672
    26
Object subclass:#PostEventHandler
ca@1672
    27
	instanceVariableNames:'onView'
ca@1672
    28
	classVariableNames:''
ca@1672
    29
	poolDictionaries:''
ca@1672
    30
	privateIn:UIObjectView
ca@1672
    31
!
ca@1672
    32
ca@1437
    33
Object subclass:#ResizeData
cg@2536
    34
	instanceVariableNames:'object selector checkForChangeSelector delta'
ca@1437
    35
	classVariableNames:''
ca@1437
    36
	poolDictionaries:''
ca@1437
    37
	privateIn:UIObjectView
ca@1437
    38
!
ca@1437
    39
cg@60
    40
Object subclass:#UndoHistory
ca@134
    41
	instanceVariableNames:'startIdentifier identifier painter history transaction enabled'
cg@60
    42
	classVariableNames:''
cg@60
    43
	poolDictionaries:''
cg@60
    44
	privateIn:UIObjectView
cg@60
    45
!
cg@60
    46
ca@54
    47
Object subclass:#Transaction
ca@134
    48
	instanceVariableNames:'identifier type text actions'
ca@54
    49
	classVariableNames:''
ca@54
    50
	poolDictionaries:''
ca@54
    51
	privateIn:UIObjectView::UndoHistory
ca@54
    52
!
ca@54
    53
ca@128
    54
!UIObjectView class methodsFor:'documentation'!
ca@128
    55
cg@156
    56
copyright
cg@156
    57
"
cg@156
    58
 COPYRIGHT (c) 1995 by eXept Software AG
cg@1120
    59
	      All Rights Reserved
cg@156
    60
cg@156
    61
 This software is furnished under a license and may be used
cg@156
    62
 only in accordance with the terms of that license and with the
cg@156
    63
 inclusion of the above copyright notice.   This software may not
cg@156
    64
 be provided or otherwise made available to, or used by, any
cg@156
    65
 other person.  No title to or ownership of the software is
cg@156
    66
 hereby transferred.
cg@156
    67
"
cg@156
    68
cg@156
    69
cg@156
    70
!
cg@156
    71
ca@128
    72
documentation
ca@128
    73
"
ca@131
    74
    buildIn view used by the UIPainter; it provides all services for creating, deleting
ca@131
    75
    moving and changing layouts of painted components on a canvas.
ca@128
    76
ca@128
    77
    [see also:]
cg@1120
    78
	UIBuilder
cg@1120
    79
	UIPainterView
cg@156
    80
cg@156
    81
    [author:]
cg@1120
    82
	Claus Atzkern
ca@128
    83
"
ca@128
    84
ca@128
    85
! !
cg@60
    86
ca@63
    87
!UIObjectView class methodsFor:'conversion'!
ca@63
    88
ca@63
    89
asLayoutFrameFromView:aView
ca@63
    90
    "convert layout from aView to a frameLayout. On success the frameLayout is
ca@63
    91
     returned otherwise nil
ca@63
    92
    "
ca@68
    93
    |lF lO rF rO tF tO bF bO type layout newLyt|
ca@68
    94
ca@68
    95
    type   := self layoutType:aView.
ca@68
    96
    layout := aView geometryLayout.
ca@68
    97
cg@91
    98
    layout isNil ifTrue:[
cg@1581
    99
        type == #Extent ifTrue:[
cg@1581
   100
            layout := aView bounds asLayout
cg@1581
   101
        ]
cg@91
   102
    ].
cg@91
   103
ca@68
   104
    (type isNil or:[layout isNil]) ifTrue:[
cg@1581
   105
        ^ nil
ca@63
   106
    ].
ca@63
   107
ca@68
   108
    type == #LayoutFrame ifTrue:[
cg@1581
   109
        ^ layout copy
ca@68
   110
    ].
ca@68
   111
ca@68
   112
    layout isLayout ifFalse:[
cg@1581
   113
        type == #Rectangle ifTrue:[
cg@1581
   114
            lO := layout left.
cg@1581
   115
            tO := layout top.
cg@1581
   116
            rO := layout right.
cg@1581
   117
            bO := layout bottom.
cg@1581
   118
        ] ifFalse:[
cg@1581
   119
            lO := layout x.
cg@1581
   120
            tO := layout y.
cg@1581
   121
            rO := lO + aView extent x.
cg@1581
   122
            bO := tO + aView extent y.
cg@1581
   123
        ].
cg@1581
   124
cg@1581
   125
        ^ LayoutFrame 
cg@1581
   126
                leftFraction:0 offset:lO  
cg@1581
   127
                rightFraction:0 offset:rO
cg@1581
   128
                topFraction:0 offset:tO 
cg@1581
   129
                bottomFraction:0 offset:bO
ca@63
   130
    ].
ca@63
   131
ca@68
   132
    lF := layout leftFraction.
ca@68
   133
    lO := layout leftOffset.
ca@68
   134
    tF := layout topFraction.
ca@68
   135
    tO := layout topOffset.
ca@68
   136
    bF := tF.
ca@68
   137
    bO := tO + aView extent y.
ca@68
   138
    rF := lF.
ca@68
   139
    rO := lO + aView extent x.
ca@68
   140
cg@1581
   141
    newLyt := LayoutFrame 
cg@1581
   142
                leftFraction:lF offset:lO  
cg@1581
   143
                rightFraction:rF offset:rO
cg@1581
   144
                topFraction:tF offset:tO 
cg@1581
   145
                bottomFraction:bF offset:bO.
ca@68
   146
ca@68
   147
    (    (type == #AlignmentOrigin)
ca@68
   148
     and:[layout leftAlignmentFraction ~~ 0
ca@68
   149
      or:[layout topAlignmentFraction  ~~ 0]]
ca@68
   150
    ) ifTrue:[
cg@1581
   151
        |svRc prBd dlta|
cg@1581
   152
cg@1581
   153
        svRc := aView superView viewRectangle.
cg@1581
   154
        prBd := aView preferredBounds.
cg@1581
   155
        dlta := (  ((layout rectangleRelativeTo:svRc preferred:prBd) corner)
cg@1581
   156
                 - ((newLyt rectangleRelativeTo:svRc preferred:prBd) corner)
cg@1581
   157
                ) rounded.
cg@1581
   158
cg@1581
   159
        newLyt 
cg@1581
   160
            leftOffset:(lO + dlta x)
cg@1581
   161
            rightOffset:(rO + dlta x)
cg@1581
   162
            topOffset:(tO + dlta y)
cg@1581
   163
            bottomOffset:(bO + dlta y).
ca@68
   164
    ].
ca@68
   165
  ^ newLyt.
cg@91
   166
cg@91
   167
    "Modified: 28.3.1997 / 19:52:48 / cg"
ca@63
   168
! !
ca@63
   169
cg@60
   170
!UIObjectView class methodsFor:'defaults'!
cg@60
   171
cg@60
   172
defaultGrid
cg@60
   173
    ^ 4 @ 4
cg@60
   174
cg@60
   175
!
cg@60
   176
cg@60
   177
gridShown
cg@60
   178
    ^ false
cg@60
   179
cg@60
   180
!
cg@60
   181
cg@60
   182
handleSize
cg@60
   183
    "size of blob drawn for handles"
cg@60
   184
    ^ 4
cg@60
   185
cg@60
   186
!
cg@60
   187
cg@60
   188
hitDelta
cg@60
   189
    ^ 4
cg@60
   190
cg@60
   191
! !
cg@60
   192
ca@175
   193
!UIObjectView class methodsFor:'handles'!
ca@175
   194
cg@2510
   195
handlesOf:aViewOrComponent do:aBlock
ca@175
   196
    |type v h|
ca@175
   197
sv@3143
   198
    (aViewOrComponent isKindOf:(Smalltalk classNamed:#LineSegmentMorph)) ifTrue:[
cg@2510
   199
        aBlock value:(aViewOrComponent startPoint) value:#startPoint.
cg@2510
   200
        aBlock value:(aViewOrComponent endPoint) value:#endPoint.
cg@2510
   201
        ^ self.
cg@2510
   202
    ].
cg@2510
   203
cg@2510
   204
    type := self layoutType:aViewOrComponent.
ca@175
   205
ca@175
   206
    (type == #LayoutFrame or:[type == #Rectangle]) ifTrue:[
cg@2510
   207
        v := self isVerticalResizable:aViewOrComponent.
cg@2510
   208
        h := self isHorizontalResizable:aViewOrComponent.
cg@2501
   209
cg@2501
   210
        h ifTrue:[  
cg@2510
   211
            aBlock value:(aViewOrComponent leftCenter rounded ) value:#left.
cg@2510
   212
            aBlock value:(aViewOrComponent rightCenter rounded) value:#right
cg@2501
   213
        ].
cg@2501
   214
        v ifTrue:[  
cg@2510
   215
            aBlock value:(aViewOrComponent topCenter rounded   ) value:#top.
cg@2510
   216
            aBlock value:(aViewOrComponent bottomCenter rounded) value:#bottom.
cg@2501
   217
        ].
cg@2501
   218
cg@2501
   219
        (h and:[v]) ifTrue:[
cg@2510
   220
            aBlock value:(aViewOrComponent origin    ) value:#origin.
cg@2510
   221
            aBlock value:(aViewOrComponent topRight  ) value:#topRight.
cg@2510
   222
            aBlock value:(aViewOrComponent bottomLeft) value:#bottomLeft.
cg@2510
   223
            aBlock value:(aViewOrComponent corner    ) value:#corner.
cg@2501
   224
            ^ self
cg@2501
   225
        ]
ca@175
   226
    ].
ca@175
   227
cg@2510
   228
    aBlock value:(aViewOrComponent origin    ) value:#view.
cg@2510
   229
    aBlock value:(aViewOrComponent topRight  ) value:#view.
cg@2510
   230
    aBlock value:(aViewOrComponent bottomLeft) value:#view.
ca@175
   231
ca@175
   232
    type == #Extent ifTrue:[
cg@2510
   233
        v := self isVerticalResizable:aViewOrComponent.
cg@2510
   234
        h := self isHorizontalResizable:aViewOrComponent.
cg@2510
   235
cg@2510
   236
        v ifTrue:[ aBlock value:(aViewOrComponent bottomCenter rounded) value:#bottom ].
cg@2510
   237
        h ifTrue:[ aBlock value:(aViewOrComponent rightCenter rounded ) value:#right ].
cg@2501
   238
cg@2501
   239
        (h and:[v]) ifTrue:[
cg@2510
   240
            aBlock value:(aViewOrComponent corner) value:#corner.
cg@2501
   241
            ^ self
cg@2501
   242
        ]
ca@175
   243
    ].
cg@2510
   244
    aBlock value:(aViewOrComponent corner) value:#view.
ca@175
   245
! !
ca@175
   246
ca@61
   247
!UIObjectView class methodsFor:'queries'!
ca@61
   248
ca@175
   249
isHorizontalResizable:aComponent
cg@2510
   250
    "returns true if aComponent is horizontal resizeable
ca@175
   251
    "
ca@175
   252
    (aComponent isKindOf:ScrollBar) ifTrue:[
cg@2510
   253
        ^ aComponent orientation == #horizontal
ca@175
   254
    ].
ca@175
   255
    (aComponent isKindOf:Scroller) ifTrue:[
cg@2510
   256
        ^ aComponent orientation == #horizontal
ca@175
   257
    ].
ca@175
   258
    (aComponent isKindOf:Slider) ifTrue:[
cg@2510
   259
        ^ aComponent orientation == #horizontal
cg@2510
   260
    ].
sv@3143
   261
    (aComponent isKindOf:(Smalltalk classNamed:#LineSegmentMorph)) ifTrue:[
cg@2510
   262
        ^ false
ca@175
   263
    ].
ca@175
   264
    ^ true
ca@175
   265
!
ca@175
   266
ca@175
   267
isVerticalResizable:aComponent
cg@2510
   268
    "returns true if aComponent is vertical resizeable
ca@175
   269
    "
cg@2364
   270
"/    (aComponent isKindOf:EditField) ifTrue:[
cg@2364
   271
"/        ^ false
cg@2364
   272
"/    ].
cg@2364
   273
"/    (aComponent isKindOf:ComboBoxView) ifTrue:[
cg@2364
   274
"/        ^ false
cg@2364
   275
"/    ].
cg@2364
   276
"/    (aComponent isKindOf:CheckBox) ifTrue:[
cg@2364
   277
"/        ^ false
cg@2364
   278
"/    ].
cg@2364
   279
"/    (aComponent isKindOf:ScrollBar) ifTrue:[
cg@2364
   280
"/        ^ aComponent orientation == #vertical
cg@2364
   281
"/    ].
cg@2364
   282
"/    (aComponent isKindOf:Scroller) ifTrue:[
cg@2364
   283
"/        ^ aComponent orientation == #vertical
cg@2364
   284
"/    ].
cg@2364
   285
"/    (aComponent isKindOf:Slider) ifTrue:[
cg@2364
   286
"/        ^ aComponent orientation == #vertical
cg@2364
   287
"/    ].
sv@3143
   288
    (aComponent isKindOf:(Smalltalk classNamed:#LineSegmentMorph)) ifTrue:[
cg@2510
   289
        ^ false
cg@2510
   290
    ].
ca@175
   291
    ^ true
ca@175
   292
!
ca@175
   293
cg@2510
   294
layoutType:aViewOrComponent
cg@2510
   295
    "returns layout type of aView or nil"
cg@2510
   296
ca@113
   297
    |layout spec superView|
ca@113
   298
cg@2510
   299
    aViewOrComponent isNil ifTrue:[ ^ nil ].
sv@3143
   300
    (aViewOrComponent isKindOf:(Smalltalk classNamed:#LineSegmentMorph)) ifTrue:[
cg@2510
   301
        ^ nil
cg@2510
   302
    ].
cg@2510
   303
cg@2510
   304
    layout := aViewOrComponent geometryLayout.
cg@2510
   305
    layout notNil ifTrue:[
cg@2510
   306
        layout isLayout ifTrue:[
cg@2510
   307
            layout isLayoutFrame        ifTrue:[ ^ #LayoutFrame ].
cg@2510
   308
            layout isAlignmentOrigin    ifTrue:[ ^ #AlignmentOrigin ].
cg@2510
   309
            layout isLayoutOrigin       ifTrue:[ ^ #LayoutOrigin ].
cg@2510
   310
        ] ifFalse:[
cg@2510
   311
            layout isRectangle          ifTrue:[ ^ #Rectangle ].
cg@2510
   312
            layout isPoint              ifTrue:[ ^ #Point ].
cg@2510
   313
        ].
cg@2510
   314
    ] ifFalse:[
cg@2510
   315
        (superView := aViewOrComponent superView) notNil ifTrue:[
cg@2510
   316
            spec := superView specClass.
cg@2510
   317
            spec canResizeSubComponents ifTrue:[
cg@2510
   318
                ^ #Extent
cg@2510
   319
            ]
cg@2510
   320
        ]
ca@61
   321
    ].
ca@61
   322
    ^ nil
ca@61
   323
cg@67
   324
    "Modified: 28.2.1997 / 13:02:16 / cg"
ca@61
   325
! !
ca@61
   326
cg@60
   327
!UIObjectView methodsFor:'accessing'!
cg@60
   328
cg@60
   329
gridAlign
ca@61
   330
    "returns state of aligning to grid
ca@61
   331
    "
cg@60
   332
    ^ aligning
cg@60
   333
cg@60
   334
!
cg@60
   335
cg@60
   336
gridAlign:aBool
ca@61
   337
    "change state of aligning to grid
ca@61
   338
    "
cg@60
   339
    aBool ifTrue:[self alignOn]
cg@1120
   340
	 ifFalse:[self alignOff]
cg@60
   341
cg@60
   342
!
cg@60
   343
cg@60
   344
gridParameters
cg@60
   345
    "used by defineGrid, and in a separate method for
cg@60
   346
     easier redefinition in subclasses. 
cg@60
   347
     Returns the grid parameters in an array of 7 elements,
cg@60
   348
     which control the appearance of the grid-pattern.
cg@60
   349
     the elements are:
cg@60
   350
cg@1120
   351
	bigStepH        number of pixels horizontally between 2 major steps
cg@1120
   352
	bigStepV        number of pixels vertically between 2 major steps
cg@1120
   353
	littleStepH     number of pixels horizontally between 2 minor steps
cg@1120
   354
	littleStepV     number of pixels vertically between 2 minor steps
cg@1120
   355
	gridAlignH      number of pixels for horizontal grid align (pointer snap)
cg@1120
   356
	gridAlignV      number of pixels for vertical grid align (pointer snap)
cg@1120
   357
	docBounds       true, if document boundary should be shown
cg@60
   358
cg@60
   359
     if littleStepH/V are nil, only bigSteps are drawn.
cg@60
   360
    "
ca@360
   361
    gridParameters isNil ifTrue:[
cg@1120
   362
	gridParameters := #(10 10 nil nil 10 10 false)
ca@360
   363
    ].
ca@360
   364
    ^ gridParameters
ca@360
   365
ca@360
   366
ca@360
   367
!
ca@360
   368
ca@360
   369
gridParameters:newGridParameters
ca@360
   370
    "used by defineGrid, and in a separate method for
ca@360
   371
     easier redefinition in subclasses. 
ca@360
   372
     Returns the grid parameters in an array of 7 elements,
ca@360
   373
     which control the appearance of the grid-pattern.
ca@360
   374
     the elements are:
ca@360
   375
cg@1120
   376
	bigStepH        number of pixels horizontally between 2 major steps
cg@1120
   377
	bigStepV        number of pixels vertically between 2 major steps
cg@1120
   378
	littleStepH     number of pixels horizontally between 2 minor steps
cg@1120
   379
	littleStepV     number of pixels vertically between 2 minor steps
cg@1120
   380
	gridAlignH      number of pixels for horizontal grid align (pointer snap)
cg@1120
   381
	gridAlignV      number of pixels for vertical grid align (pointer snap)
cg@1120
   382
	docBounds       true, if document boundary should be shown
ca@360
   383
ca@360
   384
     if littleStepH/V are nil, only bigSteps are drawn.
ca@360
   385
    "
ca@360
   386
    newGridParameters size == 7 ifTrue:[
cg@1120
   387
	gridParameters := newGridParameters
ca@360
   388
    ].
cg@60
   389
cg@60
   390
cg@60
   391
!
cg@60
   392
cg@60
   393
gridShown:aBool
ca@61
   394
    "change visibility of grid
ca@61
   395
    "
cg@60
   396
    aBool ifTrue:[self showGrid]
cg@1120
   397
	 ifFalse:[self hideGrid]
cg@60
   398
!
cg@60
   399
cg@60
   400
hideGrid
ca@61
   401
    "hide grid
ca@61
   402
    "
cg@60
   403
    gridShown ifTrue:[
cg@1120
   404
	self withSelectionHiddenDo:[super hideGrid]
cg@60
   405
    ]
cg@60
   406
cg@60
   407
cg@60
   408
!
cg@60
   409
cg@3219
   410
nPixelsForMoveSelection
cg@3219
   411
    ^ nPixelsForMoveSelection
cg@3219
   412
!
cg@3219
   413
cg@3219
   414
nPixelsForMoveSelection:something
cg@3219
   415
    nPixelsForMoveSelection := something.
cg@3219
   416
!
cg@3219
   417
cg@60
   418
showGrid
ca@61
   419
    "show grid
ca@61
   420
    "
ca@61
   421
    self withSelectionHiddenDo:[super showGrid]
ca@119
   422
! !
ca@119
   423
cg@1399
   424
!UIObjectView methodsFor:'accessing-behavior'!
ca@119
   425
sv@1100
   426
enableStateChanged
cg@2364
   427
    "toggle the test mode
ca@119
   428
    "
cg@1102
   429
    self shown ifTrue:[
ca@1672
   430
        enableChannel value ifFalse:[
ca@1672
   431
            saveSelection := selection.
ca@1672
   432
            self hideSelection.
ca@1672
   433
            selection := nil.
ca@1672
   434
        ] ifTrue:[
ca@1672
   435
            selection := saveSelection.
ca@1672
   436
            self showSelection
ca@1672
   437
        ]
ca@119
   438
    ]
ca@119
   439
sv@1100
   440
    "Created: / 30.3.1999 / 16:17:24 / stefan"
sv@1100
   441
!
sv@1100
   442
sv@1100
   443
enabled
sv@1100
   444
    ^ enableChannel value
sv@1100
   445
!
sv@1100
   446
sv@1100
   447
enabled:aState
sv@1100
   448
    "set the modification / test mode
sv@1100
   449
    "
sv@1100
   450
sv@1100
   451
    enableChannel value:aState
sv@1100
   452
sv@1100
   453
    "Modified: / 30.3.1999 / 16:18:12 / stefan"
cg@60
   454
!
cg@60
   455
ca@134
   456
resetModification
cg@1918
   457
    "set modification state to false"
cg@1918
   458
cg@1954
   459
    undoHistory resetModification.
cg@1954
   460
    self undoHistoryChanged.
ca@134
   461
!
ca@134
   462
cg@60
   463
testMode
ca@61
   464
    "returns true if running test
cg@60
   465
    "
ca@119
   466
    ^ enableChannel value not
cg@60
   467
cg@60
   468
cg@60
   469
!
cg@60
   470
cg@60
   471
testMode:aBoolean
ca@61
   472
    "change test mode
cg@60
   473
    "
cg@1102
   474
    enableChannel value:(aBoolean not)
cg@60
   475
! !
cg@60
   476
cg@1954
   477
!UIObjectView methodsFor:'aspects'!
cg@1954
   478
cg@1954
   479
hasUndoHistoryHolder
cg@1954
   480
    hasUndoHistoryHolder isNil ifTrue:[
cg@1954
   481
        hasUndoHistoryHolder := false asValue
cg@1954
   482
    ].
cg@1954
   483
    ^ hasUndoHistoryHolder
cg@1954
   484
! !
cg@1954
   485
cg@60
   486
!UIObjectView methodsFor:'blocked'!
cg@60
   487
cg@60
   488
addObject:anObject
sv@1746
   489
    "add the argument, anObject to the contents - with redraw"
sv@1746
   490
sv@1746
   491
    self shouldNotImplement
cg@60
   492
!
cg@60
   493
cg@60
   494
addObjectWithoutRedraw:anObject
sv@1746
   495
    "add the argument, anObject to the contents - with redraw"
sv@1746
   496
sv@1746
   497
    self shouldNotImplement
cg@60
   498
! !
cg@60
   499
cg@2538
   500
!UIObjectView methodsFor:'enumerating'!
cg@2538
   501
cg@2538
   502
contentsDo:aBlock
cg@2538
   503
    self subViews do:aBlock.
cg@2538
   504
    self components do:aBlock.
cg@2538
   505
! !
cg@2538
   506
cg@60
   507
!UIObjectView methodsFor:'event handling'!
cg@60
   508
werner@1833
   509
doublePressed:pressPoint
werner@1833
   510
!
werner@1833
   511
ca@61
   512
elementChangedSize:aView
cg@2501
   513
    "some element has changed its size; collect them while selectionHiddenLevel is on"
cg@2501
   514
ca@284
   515
    |spv|
ca@284
   516
ca@284
   517
    spv := self findContainerOfView:aView.
ca@284
   518
cg@2501
   519
    aView isView ifFalse:[
cg@2503
   520
"/        spv invalidate.
cg@2501
   521
    ].
cg@2501
   522
cg@2503
   523
"/    spv := self findContainerOfView:aView.
cg@2501
   524
cg@2501
   525
    selectionHiddenLevel ~~ 0 ifTrue:[
cg@2501
   526
        setOfSuperViewsSizeChanged add:spv
cg@2501
   527
    ] ifFalse:[
cg@2501
   528
        spv sizeChanged:nil
cg@2501
   529
    ]
cg@60
   530
!
cg@60
   531
cg@60
   532
keyPress:key x:x y:y
ca@61
   533
    "any key pressed
ca@61
   534
    "
cg@1048
   535
    <resource: #keyboard ( #CursorUp #CursorDown #CursorLeft #CursorRight
werner@1827
   536
                           #Delete #BackSpace #Cut #Copy #Paste #Cmdu #Again) >
cg@1222
   537
cg@1222
   538
    |n sensor|
cg@60
   539
cg@60
   540
    (key == #Cut or:[key == #Delete or:[key == #BackSpace]]) ifTrue: [
cg@1222
   541
        ^ self deleteSelection
cg@60
   542
    ].
werner@1827
   543
    (key = #PreviousPage) ifTrue:[
werner@1827
   544
        self selectNextUpInHierarchy.
werner@1827
   545
    ].
ca@78
   546
    key == #Copy  ifTrue:[ ^ self copySelection].
ca@78
   547
    key == #Paste ifTrue:[ ^ self pasteBuffer].
ca@360
   548
    key == #Cmdu  ifTrue:[ ^ self undoLast ].           "/ #Undo
ca@360
   549
werner@1827
   550
    ( #(CursorUp CursorDown CursorRight CursorLeft)
werner@1827
   551
    includes:key) ifTrue:[
werner@1827
   552
        (sensor := self sensor) isNil ifTrue:[
werner@1827
   553
            n := 1
werner@1827
   554
        ] ifFalse:[
werner@1827
   555
            n := 1 + (sensor compressKeyPressEventsWithKey:key).
werner@1827
   556
            sensor shiftDown ifTrue:[
werner@1827
   557
                n := n * 10.
werner@1827
   558
            ].
cg@1222
   559
        ].
cg@1222
   560
cg@1222
   561
        key == #CursorUp ifTrue:[
cg@1222
   562
            ^ self moveSelectionUp:n
cg@1222
   563
        ].
cg@1222
   564
        key == #CursorDown ifTrue:[
cg@1222
   565
            ^ self moveSelectionDown:n
cg@1222
   566
        ].
cg@1222
   567
        key == #CursorRight ifTrue:[
cg@1222
   568
            ^ self moveSelectionRight:n
cg@1222
   569
        ].
cg@1222
   570
        key == #CursorLeft ifTrue:[
cg@1222
   571
            ^ self moveSelectionLeft:n
cg@1222
   572
        ].
cg@1222
   573
    ].
cg@374
   574
    super keyPress:key x:x y:y
cg@374
   575
cg@1048
   576
    "Modified: / 6.3.1999 / 22:47:48 / cg"
cg@60
   577
!
cg@60
   578
cg@60
   579
processEvent:anEvent
cg@60
   580
    "catch expose events for components, and redraw its handles after
cg@1895
   581
     the redraw when this happens.
cg@1895
   582
     Return true, if I have eaten the event"
cg@1895
   583
cg@2501
   584
    |evView widget p|
ca@1672
   585
ca@1672
   586
    self testMode ifTrue:[^ false].
ca@1672
   587
cg@2555
   588
    anEvent isInputEvent ifFalse:[^ false].
cg@2555
   589
ca@1672
   590
    evView := anEvent view.
cg@2548
   591
    evView isNil ifTrue:[ ^ false].
cg@2548
   592
cg@2501
   593
    (evView == self) ifTrue:[
cg@2501
   594
        "/ new: check for a component to be hit by the event
cg@2554
   595
cg@2501
   596
        components notEmptyOrNil ifTrue:[
cg@2554
   597
            anEvent x notNil ifTrue:[
cg@2554
   598
                p := (anEvent x @ anEvent y).        
cg@2554
   599
                widget := components detect:[:c | c bounds containsPoint:p ] ifNone:nil.
cg@2554
   600
            ].
cg@2501
   601
        ].
cg@2501
   602
        widget isNil ifTrue:[
cg@2501
   603
            ^ false
cg@2501
   604
        ].
cg@2501
   605
    ] ifFalse:[
cg@2501
   606
        widget := evView.
cg@2501
   607
    ].
cg@2501
   608
cg@2501
   609
    (widget isComponentOf:self) ifFalse:[
ca@1672
   610
        ^ false
ca@1672
   611
    ].
cg@2550
   612
cg@2548
   613
    "/ eat most of my events
cg@2548
   614
    anEvent isPointerEnterLeaveEvent ifTrue:[^ true. ^ false].
cg@2548
   615
    anEvent isKeyboardFocusEvent ifTrue:[^ true. ^ false].
cg@2548
   616
cg@2548
   617
    (anEvent isButtonEvent or:[anEvent isKeyEvent]) ifFalse:[ ^ true ].
ca@1672
   618
ca@2203
   619
    anEvent isButtonMotionEvent ifTrue:[
ca@2203
   620
        "/ use current point - layout of underlaying view might change
ca@2203
   621
        "/ and computation dependent on origin is wrong
ca@2203
   622
        p := self sensor mousePoint.
cg@3261
   623
        p := device translatePoint:p fromView:nil toView:self.
ca@2203
   624
    ] ifFalse:[
cg@2501
   625
        p := (anEvent x) @ (anEvent y).
cg@3261
   626
        p := device translatePoint:p fromView:evView toView:self.
ca@2203
   627
    ].
ca@1672
   628
ca@1672
   629
    "/ patch the event
ca@1672
   630
    anEvent x:p x.
ca@1672
   631
    anEvent y:p y.
ca@1672
   632
    anEvent view:self.
cg@60
   633
    ^ false.
cg@60
   634
!
cg@60
   635
cg@624
   636
redrawX:nx y:ny width:nw height:nh
cg@1911
   637
    |redrawFrame|
cg@1911
   638
cg@1911
   639
    redrawFrame := Rectangle left:nx top:ny width:nw height:nh.
cg@2501
   640
    "/ self clearRectangle:redrawFrame.
cg@2501
   641
    super redrawX:nx y:ny width:nw height:nh.
cg@1911
   642
cg@1911
   643
    self selectionDo:[:aComponent |
cg@1911
   644
        |anyHandleToRedraw|
cg@1911
   645
cg@1911
   646
        anyHandleToRedraw := false.
cg@1911
   647
        self handlesOf:aComponent do:[:hRect :typeOfHandle |
cg@1911
   648
            (hRect intersects:redrawFrame) ifTrue:[        
cg@1911
   649
                anyHandleToRedraw := true.
cg@1911
   650
            ].
cg@1911
   651
        ].
cg@1911
   652
        anyHandleToRedraw ifTrue:[
cg@1911
   653
            self showSelected:aComponent
cg@1911
   654
        ]
cg@1911
   655
    ]
cg@2246
   656
cg@2246
   657
    "Modified: / 16-01-2008 / 17:57:09 / cg"
cg@624
   658
!
cg@624
   659
cg@60
   660
sizeChanged:how
ca@61
   661
    "size of a view(s) changed
ca@61
   662
    "
cg@60
   663
    self withSelectionHiddenDo:[
ca@1672
   664
        super sizeChanged:how.
ca@1672
   665
    ].
cg@60
   666
! !
cg@60
   667
cg@60
   668
!UIObjectView methodsFor:'initialization'!
cg@60
   669
cg@60
   670
initialize
ca@61
   671
    "setup attributes
ca@61
   672
    "
cg@60
   673
    super initialize.
cg@60
   674
ca@61
   675
    setOfSuperViewsSizeChanged := IdentitySet new.
cg@60
   676
    self setDefaultActions.
cg@60
   677
cg@1954
   678
    undoHistory := UndoHistory on:self.
cg@1954
   679
sv@1100
   680
    self enableChannel:(true asValue).
ca@119
   681
    clipChildren         := true.
ca@61
   682
    selectionHiddenLevel := 0.
cg@3219
   683
    nPixelsForMoveSelection := 1.
cg@60
   684
cg@60
   685
    (self class gridShown) ifTrue:[
ca@1672
   686
        super showGrid
cg@60
   687
    ].
cg@60
   688
cg@897
   689
    "Modified: / 20.7.1998 / 18:14:51 / cg"
sv@1100
   690
    "Modified: / 30.3.1999 / 16:19:15 / stefan"
cg@60
   691
!
cg@60
   692
ca@284
   693
map
ca@284
   694
    "make the view visible on the screen and in case of a none empty
ca@284
   695
     selection the selection will be shown.
ca@284
   696
    "
ca@284
   697
    super map.
ca@284
   698
    self showSelection.
ca@284
   699
!
ca@284
   700
cg@60
   701
realize
ca@1672
   702
    |windowGroup|
ca@1672
   703
cg@60
   704
    super realize.
ca@1672
   705
    windowGroup := self windowGroup.
ca@1672
   706
    windowGroup  addPreEventHook:self.
ca@1672
   707
    windowGroup addPostEventHook:(PostEventHandler new onView:self).
cg@897
   708
!
cg@897
   709
cg@897
   710
remap
cg@897
   711
    "make the view visible on the screen and in case of a none empty
sv@1746
   712
     selection the selection will be shown"
sv@1746
   713
sv@1746
   714
    self shouldNotImplement
cg@60
   715
! !
cg@60
   716
cg@60
   717
!UIObjectView methodsFor:'misc'!
cg@60
   718
ca@175
   719
invertOutlineOf:something
cg@2501
   720
    "invert outline of an object or collection of objects"
cg@2501
   721
cg@2536
   722
    ^ self.
cg@2536
   723
cg@2536
   724
"/ cg: nope - all done via handles now.
cg@2536
   725
cg@2536
   726
"/    |wasClipped|
cg@2536
   727
"/
cg@2536
   728
"/    (wasClipped := clipChildren) ifTrue:[
cg@2536
   729
"/        self clippedByChildren:(clipChildren := false).
cg@2536
   730
"/    ].
cg@2536
   731
"/
cg@2536
   732
"/    self xoring:[
cg@2536
   733
"/        |p|
cg@2536
   734
"/
cg@2536
   735
"/        something isCollection ifTrue:[
cg@2536
   736
"/            something do:[:v |
cg@2536
   737
"/                p := v originRelativeTo:self.
cg@2536
   738
"/                self displayRectangle:(p extent:v extent).
cg@2536
   739
"/            ].
cg@2536
   740
"/        ] ifFalse:[
cg@2536
   741
"/            p := something originRelativeTo:self.
cg@2536
   742
"/            self displayRectangle:(p extent:something extent).
cg@2536
   743
"/        ]
cg@2536
   744
"/    ].
cg@2536
   745
"/
cg@2536
   746
"/    wasClipped ifTrue:[
cg@2536
   747
"/        self clippedByChildren:(clipChildren := true).
cg@2536
   748
"/    ].
cg@60
   749
!
cg@60
   750
cg@2255
   751
minClosedViewSetFor:setOfViews
cg@2255
   752
    "return the minimum closure for a given set of view;
cg@2255
   753
     That is the minimum set of views which contains the given set of views.
cg@2255
   754
     Concrete: all subviews from setOfViews of which any superView is already in the set
cg@2255
   755
               is excluded from the result"
cg@2255
   756
ca@78
   757
    setOfViews isCollection ifFalse:[
cg@1903
   758
        setOfViews notNil ifTrue:[^ Array with:setOfViews].
cg@1903
   759
        ^ nil
ca@72
   760
    ].
cg@3011
   761
    ^ setOfViews reject:[:aView| (setOfViews contains:[:v | aView isComponentOf:v]) ]
ca@72
   762
!
ca@72
   763
cg@624
   764
redrawObjectsInVisible:redrawFrame
cg@2501
   765
    "my objects are views - they redraw themself.
cg@2501
   766
     - no longer - all non-views MUST be redrawn."
cg@2501
   767
cg@2501
   768
    super redrawObjectsInVisible:redrawFrame.
cg@624
   769
    ^ self
cg@624
   770
!
cg@624
   771
cg@60
   772
setDefaultActions
ca@61
   773
    "set default actions
ca@61
   774
    "
cg@60
   775
    pressAction      := [:pressPoint | self startSelectOrMove:pressPoint].
cg@60
   776
    shiftPressAction := [:pressPoint | self startSelectMoreOrMove:pressPoint].
ca@1861
   777
    ctrlPressAction  := [:pressPoint | self startSelectMoreOrMove:pressPoint].
cg@60
   778
    motionAction     := [:movePoint  | nil].
cg@60
   779
    releaseAction    := [nil].
cg@60
   780
    keyPressAction   := nil.
werner@1827
   781
    doublePressAction   := [:pressPoint | self doublePressed: pressPoint].
cg@60
   782
cg@60
   783
    self cursor:Cursor normal.
cg@60
   784
! !
cg@60
   785
cg@60
   786
!UIObjectView methodsFor:'object moving'!
cg@60
   787
cg@60
   788
doObjectMove:aPoint
cg@2536
   789
    "move movedOject (which is a misnomer - it's actually a collection of objects to move)"
cg@2536
   790
cg@2536
   791
    |anyMove|
cg@2536
   792
cg@2536
   793
    movedObject isEmptyOrNil ifTrue:[^ self].
cg@2536
   794
cg@2536
   795
    anyMove := false.
cg@2536
   796
    "/ to avoid flicker, check if this really involves a move (due to align)
cg@2536
   797
    movedObject keysAndValuesDo:[:i :obj|
cg@2536
   798
        |newOrigin delta|
cg@2536
   799
cg@2536
   800
        newOrigin := (aPoint - (moveDelta at:i)).
cg@2536
   801
        delta := (self alignToGrid:newOrigin) - obj computeOrigin.
cg@2536
   802
        delta ~= (0@0) ifTrue:[ anyMove := true ].
cg@2536
   803
    ].
cg@2536
   804
    anyMove ifFalse:[^ self ].
cg@2536
   805
cg@2536
   806
    self hideSelection.
cg@2536
   807
    self invertOutlineOf:movedObject.
cg@2536
   808
cg@2536
   809
    movedObject keysAndValuesDo:[:i :v|
cg@2536
   810
        self moveObject:v to:(aPoint - (moveDelta at:i)).
cg@2536
   811
    ].
cg@2536
   812
cg@2536
   813
    self invertOutlineOf:movedObject.
cg@2536
   814
    self showSelection.
cg@60
   815
!
cg@60
   816
cg@60
   817
endObjectMove
ca@61
   818
    "cleanup after object(s) move
ca@2205
   819
     send expose to each view - workaround....
ca@61
   820
    "
ca@2205
   821
    |newSel|
ca@2205
   822
ca@2205
   823
    movedObject isNil ifTrue:[^ self].
ca@2205
   824
ca@2205
   825
    movedObject size == 1 ifTrue:[ newSel := movedObject first ]
ca@2205
   826
                         ifFalse:[ newSel := movedObject ].
ca@2205
   827
    movedObject := nil.
ca@2205
   828
cg@2536
   829
"/    self withSelectionHiddenDo:[
cg@2536
   830
"/        self setSelection:newSel withRedraw:false.
cg@2536
   831
"/
cg@2536
   832
"/        components notEmptyOrNil ifTrue:[
cg@2536
   833
"/            self invalidate.
cg@2536
   834
"/        ].
cg@2536
   835
"/        self allSubViewsDo:[:v|
cg@2536
   836
"/            v shown ifTrue:[
cg@2536
   837
"/                v fill:v viewBackground.
cg@2536
   838
"/                v exposeX:0 y:0 width:v width height:v height.
cg@2536
   839
"/            ].
cg@2536
   840
"/        ].
cg@2536
   841
"/    ].
cg@2536
   842
cg@2536
   843
    self setDefaultActions.
cg@2536
   844
    self layoutChanged.
cg@60
   845
!
cg@60
   846
cg@60
   847
moveObject:anObject to:aPoint
cg@2514
   848
    "move anObject to newOrigin, aPoint"
cg@2514
   849
cg@60
   850
    |dX dY org delta|
cg@60
   851
cg@60
   852
    anObject notNil ifTrue:[
cg@1954
   853
        org := anObject computeOrigin.
cg@2849
   854
        org notNil ifTrue:[
cg@2849
   855
            delta := aPoint - org.
cg@2849
   856
            delta := (self alignToGrid:aPoint) - org.
cg@2849
   857
            dX := delta x.
cg@2849
   858
            dY := delta y.
cg@2849
   859
cg@2849
   860
            undoHistory withoutTransactionDo:[
cg@2849
   861
                self shiftLayout:anObject horizontal:dX vertical:dY
cg@2849
   862
            ]
cg@1954
   863
        ]
cg@60
   864
    ]
cg@2849
   865
cg@2849
   866
    "Modified: / 25-07-2011 / 17:27:08 / cg"
cg@60
   867
!
cg@60
   868
cg@60
   869
startObjectMoveAt:aPoint
cg@2501
   870
    "start object(s) move at a point"
cg@2501
   871
ca@128
   872
    self startObjectMove:(self selection) at:aPoint.
ca@128
   873
    movedObject := self selection.
ca@128
   874
ca@128
   875
    movedObject isCollection ifFalse:[
ca@1451
   876
        movedObject := Array with:movedObject
cg@60
   877
    ].
cg@2501
   878
"/    self setSelection:nil withRedraw:true.
cg@2501
   879
cg@2501
   880
    moveDelta := movedObject collect:[:aView | aPoint - aView computeOrigin].
cg@2501
   881
ca@175
   882
    self transaction:#move objects:movedObject do:[:v|self createUndoLayout:v].
ca@175
   883
    self invertOutlineOf:movedObject.
cg@60
   884
!
cg@60
   885
cg@60
   886
startSelectMoreOrMove:aPoint
cg@60
   887
    "add/remove to/from selection"
cg@60
   888
cg@60
   889
    |anObject|
cg@60
   890
ca@119
   891
    self enabled ifFalse:[^ self].
cg@60
   892
cg@60
   893
    anObject := self findObjectAt:aPoint.
cg@60
   894
    anObject notNil ifTrue:[
cg@1120
   895
	(self isSelected:anObject) ifTrue:[
cg@1120
   896
	    self removeFromSelection:anObject
cg@1120
   897
	] ifFalse:[
cg@1120
   898
	    self addToSelection:anObject
cg@1120
   899
	]
cg@60
   900
    ]
cg@60
   901
!
cg@60
   902
cg@60
   903
startSelectOrMove:aPoint
cg@2356
   904
    "a button is pressed at a point; start moving or selecting"
cg@2356
   905
cg@2356
   906
    |selectedView containerOfSelectedView
cg@2501
   907
     clickedView viewOperatedUpon borderHandleSelector pView|
cg@60
   908
ca@119
   909
    self enabled ifFalse:[^ self].
cg@60
   910
cg@2356
   911
    selectedView := self singleSelection.
cg@2364
   912
cg@2364
   913
"/    clickedView := self findObjectAt:aPoint.
cg@2364
   914
"/    (clickedView notNil 
cg@2364
   915
"/    and:[clickedView isComponentOf:selectedView]) ifTrue:[
cg@2364
   916
"/        self unselect.
cg@2364
   917
"/        selectedView := nil.    
cg@2364
   918
"/    ].
cg@60
   919
cg@2501
   920
    "/ if there is already a selection, see if user clicked onto a handle
cg@2501
   921
    "/ then, this may be the start of a resize operation.
cg@2356
   922
    selectedView notNil ifTrue:[
cg@2356
   923
        containerOfSelectedView := self findContainerOfView:selectedView.
cg@2356
   924
cg@2356
   925
        containerOfSelectedView specClass canResizeSubComponents ifTrue:[
cg@2501
   926
            borderHandleSelector := self whichHandleOf:selectedView isHitBy:aPoint.
cg@2501
   927
            (borderHandleSelector notNil and:[borderHandleSelector ~~ #view]) ifTrue:[
cg@2501
   928
                self startResizeBorder:borderHandleSelector.
cg@2356
   929
                ^ self
cg@2356
   930
            ]
cg@2356
   931
        ].
cg@2356
   932
        viewOperatedUpon := selectedView.
cg@2356
   933
cg@3261
   934
        pView := device translatePoint:aPoint fromView:self toView:selectedView superView.
cg@2356
   935
        (selectedView bounds containsPoint:pView) ifFalse:[
cg@2356
   936
            "/ clicked outside the selection
cg@2356
   937
            (self sensor ctrlDown and:[self canChangeLayoutOfView:selectedView]) ifFalse:[
cg@2356
   938
                viewOperatedUpon := nil
cg@2356
   939
            ]
cg@2356
   940
        ]
ca@61
   941
    ].
ca@61
   942
cg@2364
   943
    clickedView := self findObjectAt:aPoint.
cg@2368
   944
    clickedView notNil ifTrue:[
cg@2368
   945
        (clickedView isComponentOf:selectedView) ifTrue:[
cg@2530
   946
            "/ self unselect.
cg@2368
   947
            selectedView := nil.    
cg@2368
   948
            viewOperatedUpon := nil
cg@2368
   949
        ] ifFalse:[
cg@2530
   950
            "/ self unselect.
cg@2368
   951
            selectedView := nil.    
cg@2368
   952
            viewOperatedUpon := clickedView
cg@2368
   953
        ].
cg@2364
   954
    ].
cg@2364
   955
cg@2356
   956
    viewOperatedUpon isNil ifTrue:[
cg@2356
   957
        clickedView isNil ifTrue:[
cg@2538
   958
            "/ clicked outside - start a rectangle drag.
cg@2356
   959
            self select:nil.
cg@2538
   960
            self startRectangleDrag:aPoint.
cg@2356
   961
            ^ self.
cg@2356
   962
        ].
cg@2356
   963
cg@2356
   964
        (self canChangeLayoutOfView:clickedView) ifFalse:[
cg@2356
   965
            self select:clickedView.
cg@2356
   966
            ^ self
cg@2356
   967
        ].
cg@2356
   968
        viewOperatedUpon := clickedView
cg@60
   969
    ].
cg@60
   970
cg@2356
   971
    (self isSelected:viewOperatedUpon) ifFalse:[
cg@2356
   972
        self select:viewOperatedUpon.
cg@2356
   973
    ].
cg@2356
   974
cg@60
   975
    (self numberOfSelections ~~ 1) ifTrue:[
cg@2356
   976
        releaseAction := 
cg@2356
   977
            [
cg@2356
   978
                self setDefaultActions.
cg@2356
   979
                self select:viewOperatedUpon
cg@2356
   980
            ]
cg@60
   981
    ] ifFalse:[
cg@2356
   982
        releaseAction := [self setDefaultActions]
cg@60
   983
    ].
cg@60
   984
cg@2356
   985
    "prepare move operation for an object"
cg@2356
   986
    motionAction := 
cg@2356
   987
        [:movePoint|
cg@2356
   988
            (aPoint dist:movePoint) > 4.0 ifTrue:[
cg@2356
   989
                self startObjectMoveAt:aPoint
cg@2356
   990
            ]
cg@2356
   991
        ].
cg@60
   992
! !
cg@60
   993
cg@60
   994
!UIObjectView methodsFor:'object resize'!
cg@60
   995
cg@60
   996
actionResize:anObject selector:aSelector
cg@2536
   997
    "create and initialize action for resize"
cg@2536
   998
cg@2536
   999
    |delta|
cg@60
  1000
cg@60
  1001
    delta    := anObject container originRelativeTo:self.
cg@543
  1002
    resizeData := ResizeData new
cg@2536
  1003
                        object:anObject 
cg@2536
  1004
                        selector:aSelector
cg@2536
  1005
                        delta:delta.
cg@60
  1006
cg@60
  1007
"can change cursor dependent on vertical/horizontal resizing
cg@60
  1008
"
cg@60
  1009
    oldCursor := cursor.
cg@60
  1010
    self cursor:(Cursor leftHand).
cg@60
  1011
cg@543
  1012
    "Modified: / 2.2.1998 / 13:40:55 / cg"
cg@60
  1013
!
cg@60
  1014
cg@60
  1015
doDragResize:aPoint
cg@2536
  1016
    "do a widget resize drag"
cg@2536
  1017
cg@60
  1018
    |p object|
cg@60
  1019
ca@175
  1020
    object := resizeData object.
cg@2536
  1021
    p := (self alignToGrid:aPoint) - (resizeData delta).
cg@2536
  1022
cg@2536
  1023
    (self resize:object handle:(resizeData selector) to:p check:true) ifFalse:[
cg@2536
  1024
        ^ self  "/ no real change (due to align)
cg@2536
  1025
    ].
cg@60
  1026
cg@2514
  1027
    self hideSelection.
cg@2514
  1028
cg@60
  1029
    self invertOutlineOf:object.
cg@2536
  1030
cg@2536
  1031
    self resize:object handle:(resizeData selector) to:p check:false.
cg@2536
  1032
ca@1451
  1033
    Delay waitForSeconds:0.05.
ca@1451
  1034
    [self sensor hasExposeEventFor:nil] whileTrue:[
ca@1451
  1035
        self windowGroup processExposeEvents
ca@1451
  1036
    ].
ca@1451
  1037
ca@79
  1038
   "/ object geometryLayout:(object geometryLayout).
cg@2501
  1039
    self invertOutlineOf:object.
cg@2501
  1040
cg@2514
  1041
    self showSelection.
cg@60
  1042
!
cg@60
  1043
cg@60
  1044
endResize
cg@2536
  1045
    "cleanup after object resize"
cg@2536
  1046
cg@2536
  1047
    |object savedSelection anyLayoutWrapper anyTransparentBox|
ca@61
  1048
ca@175
  1049
    object := resizeData object.
ca@175
  1050
    resizeData := nil.
ca@61
  1051
cg@2536
  1052
    "/ container objects might want to rearrange their elements after a size change;
cg@2536
  1053
    "/ therefore, we hide the handles while this is possibly done.
cg@2536
  1054
    "/ however, to avoid flicker, we check for containers first.
cg@2536
  1055
    anyLayoutWrapper := anyTransparentBox := false.
cg@2536
  1056
    self forEach:object do:[:aViewOrComponent | 
cg@2536
  1057
        aViewOrComponent isLayoutWrapper ifTrue:[ anyLayoutWrapper := true ].
cg@2536
  1058
        aViewOrComponent isTransparentBox ifTrue:[ anyTransparentBox := true ].
cg@2536
  1059
    ].
cg@2536
  1060
cg@2536
  1061
    (anyLayoutWrapper or:[anyTransparentBox]) ifTrue:[
cg@2536
  1062
cg@2536
  1063
        self invertOutlineOf:object.
cg@2536
  1064
cg@2536
  1065
        "/ temporarily hide the selection, in order to allow the container to move the
cg@2536
  1066
        "/ element around...
cg@2536
  1067
        savedSelection := selection.
cg@2536
  1068
        self setSelection:nil withRedraw:true.
cg@2536
  1069
cg@2536
  1070
        "/ handle any expose events (for subcomponents) before
cg@2536
  1071
        "/ redrawing the handles.
cg@2536
  1072
        self windowGroup processExposeEvents.
cg@2536
  1073
cg@2536
  1074
        self elementChangedSize:object.
cg@2536
  1075
cg@2536
  1076
        "/ handle any expose events (for subcomponents) before
cg@2536
  1077
        "/ redrawing the handles.
cg@2536
  1078
        Delay waitForSeconds:0.05.
cg@2536
  1079
        [self sensor hasExposeEventFor:nil] whileTrue:[
cg@2536
  1080
            self windowGroup processExposeEvents
cg@2536
  1081
        ].
cg@2536
  1082
cg@2536
  1083
        self forEach:savedSelection do:[:aView |
cg@2536
  1084
            self recomputeShapeIfTransparentBox:aView.
cg@2536
  1085
        ].
cg@2536
  1086
cg@2536
  1087
        self setSelection:object withRedraw:true.
cg@2536
  1088
    ].
cg@2536
  1089
cg@2536
  1090
    self layoutChanged.
cg@60
  1091
    self setDefaultActions.
cg@2536
  1092
!
cg@2536
  1093
cg@2536
  1094
layoutChanged
cg@2536
  1095
!
cg@2536
  1096
cg@2536
  1097
resize:aView bottom:aPoint
cg@2536
  1098
    "obsolete: resize a views bottom"
cg@2536
  1099
cg@2536
  1100
    self resize:aView handle:#bottom to:aPoint check:false.
cg@2536
  1101
"/    undoHistory withoutTransactionDo:[
cg@2536
  1102
"/        self shiftLayout:aView top:0 bottom:((aPoint y) - (aView computeCorner y))
cg@2536
  1103
"/    ].
cg@2536
  1104
!
cg@2536
  1105
cg@2536
  1106
resize:aView bottomLeft:aPoint
cg@2536
  1107
    "obsolete: resize a views bottom and left"
cg@2536
  1108
cg@2536
  1109
    self resize:aView handle:#bottomLeft to:aPoint check:false.
cg@2536
  1110
"/    undoHistory withoutTransactionDo:[
cg@2536
  1111
"/        self shiftLayout:aView top:0
cg@2536
  1112
"/                            bottom:((aPoint y) - (aView computeCorner y))
cg@2536
  1113
"/                              left:((aPoint x) - (aView computeOrigin x))
cg@2536
  1114
"/                             right:0
cg@2536
  1115
"/
cg@2536
  1116
"/    ]
cg@2536
  1117
!
cg@2536
  1118
cg@2536
  1119
resize:aView corner:aPoint
cg@2536
  1120
    "obsolete: resize a views corner"
cg@2536
  1121
cg@2536
  1122
    self resize:aView handle:#corner to:aPoint check:false.
cg@2536
  1123
"/    |delta|
cg@2536
  1124
"/
cg@2536
  1125
"/    delta := aPoint - aView computeCorner.
cg@2536
  1126
"/    undoHistory withoutTransactionDo:[
cg@2536
  1127
"/        self shiftLayout:aView top:0 bottom:(delta y) left:0 right:(delta x)
cg@2536
  1128
"/    ]
cg@2536
  1129
!
cg@2536
  1130
cg@2536
  1131
resize:aComponent endPoint:newEndPoint
cg@2536
  1132
    "obsolete: move a component's endPoint"
cg@2536
  1133
cg@2536
  1134
    self resize:aComponent handle:#endPoint to:newEndPoint check:false
cg@2536
  1135
cg@2536
  1136
"/    undoHistory 
cg@2536
  1137
"/        withoutTransactionDo:[
cg@2536
  1138
"/            self shiftLayout:aComponent startPoint:0 endPoint:(newEndPoint - (aComponent endPoint))
cg@2536
  1139
"/        ]
cg@2536
  1140
!
cg@2536
  1141
cg@2536
  1142
resize:aComponent handle:aSymbol to:aPoint check:doCheck
cg@2536
  1143
    "resize a views handle - if doCheck is true, only check if the handle would change
cg@2536
  1144
     (used to avoid flicker, when an aligned move would actually not move anything)"
cg@2536
  1145
cg@2536
  1146
    |newX newY oldBottom oldTop oldLeft oldRight 
cg@2536
  1147
     oldOrigin oldCorner shiftTop shiftBottom shiftLeft shiftRight|
cg@2536
  1148
cg@2536
  1149
    aSymbol == #startPoint ifTrue:[
cg@2536
  1150
        doCheck ifTrue:[
cg@2536
  1151
            ^ aPoint ~= (aComponent startPoint)
cg@2536
  1152
        ].
cg@2536
  1153
        self 
cg@2536
  1154
            shiftLayout:aComponent 
cg@2536
  1155
            startPoint:(aPoint - (aComponent startPoint)) endPoint:0.
cg@2536
  1156
        ^ self.
ca@138
  1157
    ].
cg@2536
  1158
    aSymbol == #endPoint ifTrue:[
cg@2536
  1159
        doCheck ifTrue:[
cg@2536
  1160
            ^ aPoint ~= (aComponent endPoint)
cg@2536
  1161
        ].
cg@2536
  1162
        self 
cg@2536
  1163
            shiftLayout:aComponent 
cg@2536
  1164
            startPoint:0 endPoint:(aPoint - (aComponent endPoint)).
cg@2536
  1165
        ^ self.
werner@1827
  1166
    ].
cg@2536
  1167
cg@2536
  1168
    newX := aPoint x.
cg@2536
  1169
    newY := aPoint y.
cg@2536
  1170
    shiftTop := shiftBottom := shiftLeft := shiftRight := 0.
cg@2536
  1171
cg@2536
  1172
    oldOrigin := aComponent computeOrigin.
cg@2536
  1173
    oldCorner := aComponent computeCorner.
cg@2536
  1174
cg@2536
  1175
    oldTop := oldOrigin y.
cg@2536
  1176
    oldBottom := oldCorner y.
cg@2536
  1177
    oldLeft := oldOrigin x.
cg@2536
  1178
    oldRight := oldCorner x.
cg@2536
  1179
cg@2536
  1180
    aSymbol == #bottom ifTrue:[
cg@2536
  1181
        shiftBottom := newY - oldBottom.
cg@2536
  1182
    ]. 
cg@2536
  1183
    aSymbol == #top ifTrue:[     
cg@2536
  1184
        shiftTop := newY - oldTop.
cg@2536
  1185
    ].
cg@2536
  1186
    aSymbol == #left ifTrue:[
cg@2536
  1187
        shiftLeft := newX - oldLeft.
cg@2536
  1188
    ].
cg@2536
  1189
    aSymbol == #right ifTrue:[
cg@2536
  1190
        shiftRight := newX - oldRight.
cg@2536
  1191
    ].
cg@2536
  1192
    aSymbol == #origin ifTrue:[
cg@2536
  1193
        shiftLeft := newX - oldLeft.
cg@2536
  1194
        shiftTop := newY - oldTop.
cg@2536
  1195
    ].
cg@2536
  1196
    aSymbol == #topRight ifTrue:[
cg@2536
  1197
        shiftRight := newX - oldRight.
cg@2536
  1198
        shiftTop := newY - oldTop.
cg@2536
  1199
    ].
cg@2536
  1200
    aSymbol == #corner ifTrue:[
cg@2536
  1201
        shiftRight := newX - oldRight.
cg@2536
  1202
        shiftBottom := newY - oldBottom.
cg@2536
  1203
    ].
cg@2536
  1204
    aSymbol == #bottomLeft ifTrue:[
cg@2536
  1205
        shiftLeft := newX - oldLeft.
cg@2536
  1206
        shiftBottom := newY - oldBottom.
cg@2536
  1207
    ].
cg@2536
  1208
cg@2536
  1209
    doCheck ifTrue:[
cg@2536
  1210
        ^ (shiftTop ~= 0) or:[ shiftBottom ~= 0 or:[ shiftLeft ~= 0 or:[ shiftRight ~= 0 ]]]
cg@2536
  1211
    ].
cg@2536
  1212
cg@2536
  1213
    undoHistory withoutTransactionDo:[
cg@2536
  1214
        self 
cg@2536
  1215
            shiftLayout:aComponent 
cg@2536
  1216
            top:shiftTop bottom:shiftBottom 
cg@2536
  1217
            left:shiftLeft right:shiftRight
cg@2536
  1218
    ].
cg@60
  1219
!
cg@60
  1220
cg@2536
  1221
resize:aView left:aPoint
cg@2536
  1222
    "obsolete: resize a views left"
cg@2536
  1223
cg@2536
  1224
    self resize:aView handle:#left to:aPoint check:false.
cg@2536
  1225
"/    undoHistory withoutTransactionDo:[
cg@2536
  1226
"/        self shiftLayout:aView left:((aPoint x) - (aView computeOrigin x)) right:0
cg@2536
  1227
"/    ]
cg@2536
  1228
!
cg@2536
  1229
cg@2536
  1230
resize:aView origin:aPoint
cg@2536
  1231
    "obsolete: resize a views origin"
cg@2536
  1232
cg@2536
  1233
    self resize:aView handle:#origin to:aPoint check:false.
cg@2536
  1234
"/    |delta|
cg@2536
  1235
"/
cg@2536
  1236
"/    delta := aPoint - aView computeOrigin.
cg@2536
  1237
"/    undoHistory withoutTransactionDo:[
cg@2536
  1238
"/        self shiftLayout:aView top:(delta y) bottom:0 left:(delta x) right:0
cg@2536
  1239
"/    ]
cg@2536
  1240
!
cg@2536
  1241
cg@2536
  1242
resize:aView right:aPoint
cg@2536
  1243
    "obsolete: resize a views right"
cg@2536
  1244
cg@2536
  1245
    self resize:aView handle:#right to:aPoint check:false.
cg@2536
  1246
"/    undoHistory withoutTransactionDo:[
cg@2536
  1247
"/        self shiftLayout:aView left:0 right:((aPoint x) - (aView computeCorner x))
cg@2536
  1248
"/    ]
cg@2536
  1249
!
cg@2536
  1250
cg@2536
  1251
resize:aComponent startPoint:newStartPoint
cg@2536
  1252
    "obsolete: move a component's startPoint"
cg@2536
  1253
cg@2536
  1254
    self resize:aComponent handle:#startPoint to:newStartPoint check:false
cg@2536
  1255
"/    undoHistory 
cg@2536
  1256
"/        withoutTransactionDo:[
cg@2536
  1257
"/            self shiftLayout:aComponent startPoint:(newStartPoint - (aComponent startPoint)) endPoint:0
cg@2536
  1258
"/        ]
cg@2536
  1259
!
cg@2536
  1260
cg@2536
  1261
resize:aView top:aPoint
cg@2536
  1262
    "obsolete: resize a views top"
cg@2536
  1263
cg@2536
  1264
    self resize:aView handle:#top to:aPoint check:false.
cg@2536
  1265
"/    undoHistory withoutTransactionDo:[
cg@2536
  1266
"/        self shiftLayout:aView 
cg@2536
  1267
"/                top:((aPoint y) - (aView computeOrigin y)) 
cg@2536
  1268
"/                bottom:0
cg@2536
  1269
"/    ]
cg@2536
  1270
!
cg@2536
  1271
cg@2536
  1272
resize:aView topRight:aPoint
cg@2536
  1273
    "obsolete: resize a views top and right"
cg@2536
  1274
cg@2536
  1275
    self resize:aView handle:#topRight to:aPoint check:false.
cg@2536
  1276
"/    undoHistory withoutTransactionDo:[
cg@2536
  1277
"/        self shiftLayout:aView 
cg@2536
  1278
"/                top:((aPoint y) - (aView computeOrigin y))
cg@2536
  1279
"/                bottom:0
cg@2536
  1280
"/                left:0
cg@2536
  1281
"/                right:((aPoint x) - (aView computeCorner x))
cg@2536
  1282
"/    ]
werner@1827
  1283
!
werner@1827
  1284
cg@2501
  1285
startResizeBorder:borderHandleSelector
cg@2501
  1286
    "start resizing the selected view at the given borderHandle"
cg@2501
  1287
cg@60
  1288
    |object|
cg@60
  1289
cg@60
  1290
    object := self singleSelection.
cg@2501
  1291
    self actionResize:object selector:borderHandleSelector.
cg@2501
  1292
cg@2501
  1293
    self 
cg@2501
  1294
        transaction:#resize 
cg@2501
  1295
        selectionDo:[:aView|
cg@2501
  1296
            self createUndoLayout:aView
cg@2501
  1297
        ].
cg@2501
  1298
    "/ self setSelection:nil withRedraw:true.
cg@60
  1299
cg@60
  1300
    motionAction  := [:movePoint | self doDragResize:movePoint].
cg@60
  1301
    releaseAction := [self endResize].
cg@2501
  1302
cg@60
  1303
    self invertOutlineOf:object
cg@60
  1304
! !
cg@60
  1305
cg@1954
  1306
!UIObjectView methodsFor:'private'!
cg@1954
  1307
cg@1954
  1308
undoHistoryChanged
cg@1954
  1309
    self hasUndoHistoryHolder value:(self hasUndoHistory).
cg@1954
  1310
! !
cg@1954
  1311
cg@1714
  1312
!UIObjectView methodsFor:'private-handles'!
cg@60
  1313
ca@175
  1314
handlesOf:aComponent do:aTwoArgAction
cg@2510
  1315
    "perform aTwoArgAction on each handle of a component"
cg@2510
  1316
ca@175
  1317
    |dlt ext|
ca@175
  1318
ca@175
  1319
    dlt := (aComponent originRelativeTo:self) - aComponent origin.
ca@1451
  1320
    dlt := dlt - (4@4).
ca@1451
  1321
    ext := 8@8.
ca@175
  1322
cg@2510
  1323
    self class 
cg@2510
  1324
        handlesOf:aComponent 
cg@2510
  1325
        do:[:pnt :wht |
cg@2510
  1326
            aTwoArgAction value:(pnt + dlt extent:ext) value:wht
cg@2510
  1327
        ]
cg@60
  1328
!
cg@60
  1329
ca@175
  1330
whichHandleOf:aComponent isHitBy:aPoint
cg@2501
  1331
    "returns kind of handle or nil"
cg@2501
  1332
ca@175
  1333
    self handlesOf:aComponent do:[:rectangle :what|
cg@2501
  1334
        (rectangle containsPoint:aPoint) ifTrue:[^ what]
cg@60
  1335
    ].
cg@2501
  1336
    ^ nil
cg@60
  1337
! !
cg@60
  1338
cg@1714
  1339
!UIObjectView methodsFor:'private-resizing subviews'!
cg@60
  1340
werner@1827
  1341
recomputeShapeIfTransparentBox:aView
werner@1829
  1342
    (aView notNil and:[aView isTransparentBox]) ifTrue:[
werner@1827
  1343
        aView computeShape.
werner@1827
  1344
        aView clear; redraw
werner@1827
  1345
    ].
cg@60
  1346
! !
cg@60
  1347
cg@1714
  1348
!UIObjectView methodsFor:'private-shift layout'!
cg@60
  1349
cg@2510
  1350
shiftLayout:aViewOrComponent horizontal:n
cg@2510
  1351
    "shift layout for a view; in case of an open transaction, the undo action is registered"
cg@2510
  1352
cg@2514
  1353
    self shiftLayout:aViewOrComponent horizontal:n vertical:0
cg@2514
  1354
!
cg@2514
  1355
cg@2514
  1356
shiftLayout:aViewOrComponent horizontal:h vertical:v
cg@2514
  1357
    "shift layout for a view; in case of an open transaction, the undo action is registered"
cg@2514
  1358
cg@2514
  1359
    (self specFor:aViewOrComponent) hasLayout ifTrue:[
cg@2514
  1360
        self shiftLayout:aViewOrComponent top:v bottom:v left:h right:h
cg@2510
  1361
    ] ifFalse:[
cg@2514
  1362
        self shiftLayout:aViewOrComponent startPoint:(h @ v) endPoint:(h @ v)
cg@2514
  1363
    ].
cg@2510
  1364
!
cg@2510
  1365
cg@60
  1366
shiftLayout:aView left:l right:r
cg@2510
  1367
    "shift layout for a view; in case of an open transaction, the undo action is registered"
cg@2510
  1368
cg@60
  1369
    self shiftLayout:aView top:0 bottom:0 left:l right:r
cg@60
  1370
!
cg@60
  1371
cg@2510
  1372
shiftLayout:aComponent startPoint:deltaS endPoint:deltaE
cg@2510
  1373
    "shift coordinates; in case of an open transaction, the undo action is registered"
cg@2510
  1374
cg@2510
  1375
    self createUndoStartPointEndPoint:aComponent.
cg@2510
  1376
    aComponent 
cg@2510
  1377
        startPoint:(aComponent startPoint + deltaS)
cg@2510
  1378
        endPoint:(aComponent endPoint + deltaE).
cg@2510
  1379
!
cg@2510
  1380
cg@60
  1381
shiftLayout:aView top:t bottom:b
cg@2510
  1382
    "shift layout for a view; in case of an open transaction, the undo action is registered"
cg@2510
  1383
cg@60
  1384
    self shiftLayout:aView top:t bottom:b left:0 right:0
cg@60
  1385
!
cg@60
  1386
cg@60
  1387
shiftLayout:aView top:t bottom:b left:l right:r
cg@2510
  1388
    "shift layout for a view; in case of an open transaction, the undo action is registered"
cg@2510
  1389
cg@2536
  1390
    |type layout oldExt dX dY|
ca@61
  1391
ca@61
  1392
    type := self class layoutType:aView.
cg@2536
  1393
    type isNil ifTrue:[ ^ self ].
cg@2536
  1394
cg@2536
  1395
    self createUndoLayout:aView.
cg@2536
  1396
cg@2536
  1397
    type == #Extent ifTrue:[
cg@2536
  1398
        oldExt := aView extent.
cg@2536
  1399
        dX := r-l.
cg@2536
  1400
        dY := b-t.
cg@2536
  1401
        aView extent:(oldExt + (dX @ dY)).
cg@2536
  1402
        ^ self 
cg@2536
  1403
    ].
cg@2536
  1404
cg@2536
  1405
    layout := aView geometryLayout copy.
cg@2536
  1406
    layout isLayout ifTrue:[
cg@2536
  1407
        layout leftOffset:(layout leftOffset + l)
cg@2536
  1408
                topOffset:(layout topOffset  + t).
cg@2536
  1409
                
cg@2536
  1410
        type == #LayoutFrame ifTrue:[
sv@3280
  1411
            b ~= 0 ifTrue:[
sv@3280
  1412
                layout bottomOffset:(layout bottomOffset + b).
sv@3280
  1413
            ].
sv@3280
  1414
            r ~= 0 ifTrue:[
sv@3280
  1415
                layout rightOffset:(layout rightOffset  + r).
sv@3280
  1416
            ].
cg@2536
  1417
        ]
cg@2536
  1418
    ] ifFalse:[
cg@2536
  1419
        type == #Rectangle ifTrue:[
cg@2536
  1420
            layout left:(layout left   + l)
cg@2536
  1421
                  right:(layout right  + r)
cg@2536
  1422
                    top:(layout top    + t)
cg@2536
  1423
                 bottom:(layout bottom + b).
cg@2536
  1424
        ] ifFalse:[     "POINT"
cg@2536
  1425
            layout x:(layout x + l) y:(layout y + t).
cg@2536
  1426
        ]
cg@2536
  1427
    ].
cg@2536
  1428
    aView geometryLayout:layout
cg@2510
  1429
!
cg@2510
  1430
cg@2510
  1431
shiftLayout:aViewOrComponent vertical:n
cg@2510
  1432
    "shift layout for a view; in case of an open transaction, the undo action is registered"
cg@2510
  1433
cg@2514
  1434
    self shiftLayout:aViewOrComponent horizontal:0 vertical:n
cg@60
  1435
! !
cg@60
  1436
cg@60
  1437
!UIObjectView methodsFor:'searching'!
cg@60
  1438
cg@60
  1439
findObjectAt:aPoint
sv@3015
  1440
    |componentOrView|
cg@2501
  1441
cg@2501
  1442
    componentOrView := self findObjectAt:aPoint in:self.
cg@2501
  1443
cg@2501
  1444
    componentOrView == self ifTrue:[^ nil].
cg@2501
  1445
    ^ componentOrView.
cg@2501
  1446
cg@2501
  1447
"/ cg: old code, which I do not understand
cg@2501
  1448
"/    point := device translatePoint:aPoint fromView:self toView:rootView.
ca@1672
  1449
"/
cg@2501
  1450
"/    viewId := rootView id.
cg@2501
  1451
"/    [viewId notNil] whileTrue:[
cg@2501
  1452
"/        lastId := viewId.
cg@2501
  1453
"/        viewId := device viewIdFromPoint:point in:lastId. "/ must be rootView coordinate
ca@1672
  1454
"/    ].
ca@1672
  1455
"/
cg@2501
  1456
"/    view := device viewFromId:lastId.
cg@2501
  1457
"/    (view isNil or:[view == self]) ifTrue:[ 
cg@2501
  1458
"/        "/ used to return nil here;
cg@2501
  1459
"/        "/ now support a mix of views and components...
cg@2501
  1460
"/        components notEmptyOrNil ifTrue:[
cg@2501
  1461
"/            component := components detect:[:c | c bounds containsPoint:aPoint] ifNone:nil.
cg@2501
  1462
"/            ^ component
cg@2501
  1463
"/        ].
cg@2501
  1464
"/        ^ nil
ca@1672
  1465
"/    ].
cg@2501
  1466
"/    ^ view
cg@2501
  1467
!
cg@2501
  1468
cg@2501
  1469
findObjectAt:aPoint in:aView
cg@2501
  1470
    |lastHit lastRelPoint view point|
cg@2501
  1471
cg@2501
  1472
    "/ reverse search, to find covering ones first.
cg@2501
  1473
    aView subViews reverseDo:[:aSubView |
cg@2501
  1474
        |innerObject relPoint|
cg@2501
  1475
cg@2501
  1476
        ((aSubView origin extent:aSubView extent) containsPoint:aPoint) ifTrue:[
cg@3261
  1477
            relPoint := device translatePoint:aPoint fromView:aView toView:aSubView.
cg@2501
  1478
            innerObject := self findObjectAt:relPoint in:aSubView.
cg@2501
  1479
            innerObject notNil ifTrue:[ ^ innerObject ].
cg@2501
  1480
            lastHit := aSubView.
cg@2501
  1481
            lastRelPoint := relPoint.
cg@2501
  1482
        ]
cg@2501
  1483
    ].
cg@2501
  1484
    view := lastHit ? aView.
cg@2501
  1485
    point := lastRelPoint ? aPoint.
cg@2501
  1486
cg@2501
  1487
    view components notEmptyOrNil ifTrue:[
cg@2501
  1488
        view components reverseDo:[:eachComponent |
cg@2501
  1489
            (eachComponent frame containsPoint:point) ifTrue:[
cg@2501
  1490
                ^ eachComponent
cg@2501
  1491
            ].
cg@2501
  1492
        ].
cg@2501
  1493
    ].
cg@2501
  1494
    ^ view
cg@60
  1495
! !
cg@60
  1496
cg@60
  1497
!UIObjectView methodsFor:'selections'!
cg@60
  1498
ca@768
  1499
hideSelection
ca@1427
  1500
    "hide the selection - undraw hilights - whatever that is
ca@1427
  1501
    "
cg@2514
  1502
cg@2514
  1503
    super hideSelection.
cg@2514
  1504
    self repairDamage.   
cg@2501
  1505
"/    self showUnselected:selection.
ca@768
  1506
!
ca@768
  1507
ca@128
  1508
moveableSelection
ca@131
  1509
    "checks whether the selection is not empty and all selected instances
ca@131
  1510
     can be moved. If true the selection is returned otherwise nil
ca@128
  1511
    "
ca@128
  1512
    |coll|
ca@128
  1513
ca@128
  1514
    self hasSelection ifTrue:[
cg@2364
  1515
        (self canMove:(coll := self selection)) ifTrue:[
cg@2364
  1516
            ^ coll
cg@2364
  1517
        ]
ca@128
  1518
    ].
cg@2364
  1519
    ^ nil
ca@128
  1520
!
ca@128
  1521
cg@60
  1522
numberOfSelections
ca@131
  1523
    "return the number of selected instances
ca@61
  1524
    "
ca@128
  1525
    |coll size|
ca@128
  1526
ca@128
  1527
    coll := self selection.
ca@128
  1528
    size := coll size.
ca@128
  1529
ca@128
  1530
    (size ~~ 0 or:[coll isNil]) ifTrue:[^ size].
ca@128
  1531
  ^ 1
cg@60
  1532
!
cg@60
  1533
sv@2481
  1534
resizableSelection
sv@2481
  1535
    "checks whether the selection is not empty and all selected instances
sv@2481
  1536
     can be resized. If true the selection is returned otherwise nil
sv@2481
  1537
    "
sv@2481
  1538
    |coll|
sv@2481
  1539
sv@2481
  1540
    self hasSelection ifTrue:[
sv@2481
  1541
        coll := self selection.        
sv@2481
  1542
        (self canResize:coll) ifTrue:[
sv@2481
  1543
            ^ coll
sv@2481
  1544
        ]
sv@2481
  1545
    ].
sv@2481
  1546
    ^ nil
sv@2481
  1547
!
sv@2481
  1548
werner@1827
  1549
selectNextUpInHierarchy
cg@3019
  1550
    self breakPoint:#ca.
werner@1827
  1551
!
werner@1827
  1552
cg@2215
  1553
selection:newSelection
cg@2215
  1554
    "change selection to newSelection"
cg@2215
  1555
cg@2215
  1556
    self select:newSelection
ca@149
  1557
!
ca@149
  1558
ca@128
  1559
selectionDo:aBlock
ca@128
  1560
    "apply block to every selected object
ca@128
  1561
    "
ca@128
  1562
    self forEach:(self selection) do:aBlock
ca@128
  1563
ca@128
  1564
ca@128
  1565
!
ca@128
  1566
ca@61
  1567
showSelection
cg@2501
  1568
    "show the selection - draw handles"
cg@2501
  1569
ca@61
  1570
    selectionHiddenLevel == 0 ifTrue:[
cg@2514
  1571
        super showSelection.
cg@2514
  1572
        self repairDamage.   
cg@60
  1573
    ].
cg@60
  1574
!
cg@60
  1575
cg@60
  1576
singleSelection
sv@2267
  1577
    "checks whether a single element is selected; in this case the element is
sv@2267
  1578
     returned otherwise nil"
sv@2267
  1579
sv@2267
  1580
    |sel|
sv@2267
  1581
sv@2267
  1582
    sel := self selection.
sv@2267
  1583
    sel isCollection ifTrue:[
sv@2267
  1584
        sel := sel size == 1 ifTrue:[sel first] ifFalse:[nil].
cg@60
  1585
    ].
sv@2267
  1586
    ^ sel
cg@60
  1587
!
cg@60
  1588
cg@60
  1589
singleSelectionDo:aBlock
ca@131
  1590
    "checks whether one element is selected; in this case the block
ca@131
  1591
     with argument the selected instance will be processed
ca@61
  1592
    "
cg@60
  1593
    |view|
cg@60
  1594
cg@60
  1595
    (view := self singleSelection) notNil ifTrue:[
cg@1120
  1596
	aBlock value:view
cg@60
  1597
    ]
cg@60
  1598
!
cg@60
  1599
cg@1230
  1600
twoElementSelection
cg@1230
  1601
    "checks whether exactly two elements are selected; 
cg@1230
  1602
     in this case, return the selection collection.
cg@1230
  1603
     otherwise return nil
cg@1230
  1604
    "
cg@1230
  1605
    |coll|
cg@1230
  1606
cg@1230
  1607
    (coll := self selection) isCollection ifFalse:[
cg@1230
  1608
        ^ nil "/ single
cg@1230
  1609
    ].
cg@1230
  1610
cg@1230
  1611
    coll size == 2 ifTrue:[ ^ coll].
cg@1230
  1612
    ^ nil
cg@1230
  1613
!
cg@1230
  1614
cg@60
  1615
unselect
ca@61
  1616
    "clear selection
ca@61
  1617
    "
ca@128
  1618
    self select:nil
cg@60
  1619
!
cg@60
  1620
cg@60
  1621
withSelectionHiddenDo:aBlock
cg@1959
  1622
    "apply block with selection hidden (no handles)"
cg@1959
  1623
ca@78
  1624
    |coll|
ca@78
  1625
ca@138
  1626
    selectionHiddenLevel == 0 ifTrue:[
cg@1555
  1627
        self hideSelection.
sv@3082
  1628
        self flush.
ca@61
  1629
    ].
ca@138
  1630
    selectionHiddenLevel := selectionHiddenLevel + 1.
ca@61
  1631
cg@2516
  1632
    aBlock 
cg@2516
  1633
        ensure:[
cg@2516
  1634
            selectionHiddenLevel == 1 ifTrue:[
cg@2516
  1635
                "/ careful to decrement selectionHiddenLevel AFTER the sizeChanged;
cg@2516
  1636
                "/ otherwise, we get endless recursion here.
cg@2516
  1637
                setOfSuperViewsSizeChanged notEmpty ifTrue:[
cg@2516
  1638
                    coll := self minClosedViewSetFor:setOfSuperViewsSizeChanged.
cg@2516
  1639
                    coll do:[:aView| aView sizeChanged:nil].
cg@2516
  1640
                    setOfSuperViewsSizeChanged := IdentitySet new
cg@2516
  1641
                ].
cg@2516
  1642
                selectionHiddenLevel := selectionHiddenLevel - 1.
cg@2516
  1643
                self showSelection.
cg@2516
  1644
            ] ifFalse:[
cg@2516
  1645
                selectionHiddenLevel := selectionHiddenLevel - 1.
cg@1555
  1646
            ].
cg@1555
  1647
        ]
ca@61
  1648
!
ca@61
  1649
ca@61
  1650
withoutSelectionDo:aBlock
ca@61
  1651
    "evaluate aBlock while selection is nilled
ca@61
  1652
    "
cg@60
  1653
    |sel|
cg@60
  1654
ca@128
  1655
    self hasSelection ifFalse:[
cg@1120
  1656
	aBlock value
ca@128
  1657
    ] ifTrue:[
cg@1120
  1658
	sel := self selection.
cg@1120
  1659
	self setSelection:nil withRedraw:true.
cg@1120
  1660
	aBlock value.
cg@1120
  1661
	self setSelection:sel withRedraw:true.
cg@60
  1662
    ]
cg@60
  1663
cg@60
  1664
cg@60
  1665
! !
cg@60
  1666
cg@1717
  1667
!UIObjectView methodsFor:'selections-basic'!
ca@131
  1668
ca@1427
  1669
recursiveRepair:theDamages startIn:aView
ca@1427
  1670
    "repair all views and contained views, which intersects the damage.
ca@1427
  1671
     !!!! all damages repaired are removed from the list of damages !!!!
ca@1427
  1672
    "
ca@1427
  1673
    |color isRepaired relOrg damage
ca@1427
  1674
     bwWidth    "{ Class:SmallInteger }"
ca@1427
  1675
     x          "{ Class:SmallInteger }"
ca@1427
  1676
     y          "{ Class:SmallInteger }"
ca@1427
  1677
     w          "{ Class:SmallInteger }"
ca@1427
  1678
     h          "{ Class:SmallInteger }"
ca@1427
  1679
     relOrgX    "{ Class:SmallInteger }"
ca@1427
  1680
     relOrgY    "{ Class:SmallInteger }"
ca@1427
  1681
     width      "{ Class:SmallInteger }"
ca@1427
  1682
     height     "{ Class:SmallInteger }"
ca@1427
  1683
     size       "{ Class:SmallInteger }"
ca@1427
  1684
    |
ca@1438
  1685
    aView isInputOnly ifTrue:[^ self ].
ca@1427
  1686
ca@1437
  1687
    (aView shown and:[theDamages notEmpty]) ifFalse:[ ^ self ].
ca@1427
  1688
cg@2513
  1689
    aView components notEmptyOrNil ifTrue:[ 
cg@2513
  1690
        aView invalidate 
cg@2513
  1691
    ].
ca@1427
  1692
    aView subViews notNil ifTrue:[
ca@1427
  1693
        aView subViews reverseDo:[:v| self recursiveRepair:theDamages startIn:v ].
ca@1427
  1694
        theDamages isEmpty ifTrue:[ ^ self ].
ca@1427
  1695
    ].
ca@1427
  1696
ca@1427
  1697
    relOrg  := aView originRelativeTo:self.
ca@1427
  1698
    bwWidth := aView borderWidth.
ca@1427
  1699
    size    := theDamages size.
ca@1427
  1700
ca@1427
  1701
    "/ compute relative origin starting from border left@top
ca@1427
  1702
    relOrgX := relOrg x - bwWidth.
ca@1427
  1703
    relOrgY := relOrg y - bwWidth.
ca@1427
  1704
    width   := aView width  + bwWidth + bwWidth.
sv@2482
  1705
    height  := aView height + bwWidth + bwWidth.
sv@2482
  1706
sv@2482
  1707
    size to:1 by:-1 do:[:anIndex|
sv@2482
  1708
        damage := theDamages at:anIndex.
sv@2482
  1709
sv@2482
  1710
        "/ compute the rectangle into the view
sv@2482
  1711
        y := damage top  - relOrgY.
sv@2482
  1712
        x := damage left - relOrgX.
sv@2482
  1713
        w := damage width.
sv@2482
  1714
        h := damage height.
sv@2482
  1715
sv@2482
  1716
        isRepaired := true.
sv@2482
  1717
sv@2482
  1718
        x     < 0      ifTrue:[ w := w + x. x := 0. isRepaired := false ].
sv@2482
  1719
        y     < 0      ifTrue:[ h := h + y. y := 0. isRepaired := false ].
sv@2482
  1720
        x + w > width  ifTrue:[ w := width  - x.    isRepaired := false ].
sv@2482
  1721
        y + h > height ifTrue:[ h := height - y.    isRepaired := false ].
sv@2482
  1722
sv@2482
  1723
        (w > 0 and:[h > 0]) ifTrue:[
sv@2482
  1724
            bwWidth ~~ 0 ifTrue:[
sv@2482
  1725
                color isNil ifTrue:[
sv@2482
  1726
                    "/ must force redraw of border
cg@3310
  1727
                    "/ color := aView borderColor.
cg@3310
  1728
                    "/ aView borderColor:(Color colorId:1).  "/ kludge to force a redraw
cg@3310
  1729
                    "/ aView borderColor:color.
cg@3310
  1730
                    aView invalidate.
sv@2482
  1731
                ].
sv@2482
  1732
                w := w - bwWidth.
sv@2482
  1733
                h := h - bwWidth.
sv@2482
  1734
sv@2482
  1735
                (x := x - bwWidth) < 0 ifTrue:[w := w + x. x := 0].
sv@2482
  1736
                (y := y - bwWidth) < 0 ifTrue:[h := h + y. y := 0].
sv@2482
  1737
sv@2482
  1738
                (w > 0 and:[h > 0])  ifFalse:[w := 0].
sv@2482
  1739
            ].
sv@2482
  1740
sv@2482
  1741
            w > 0 ifTrue:[
sv@2482
  1742
                aView clearRectangleX:x y:y width:w height:h.
sv@2482
  1743
                aView exposeX:x y:y width:w height:h
sv@2482
  1744
            ].
sv@2482
  1745
            isRepaired ifTrue:[ theDamages removeIndex:anIndex ].
sv@2482
  1746
        ]
sv@2482
  1747
    ].
ca@1427
  1748
!
ca@1427
  1749
ca@131
  1750
selection
ca@131
  1751
    "returns the current selection
ca@131
  1752
    "
cg@2528
  1753
cg@2528
  1754
    "/ Q to ca: why redefine the collection building???
cg@2528
  1755
    ^ super selection.
cg@2528
  1756
ca@131
  1757
    ^ selection
ca@131
  1758
!
ca@131
  1759
cg@2356
  1760
setSelection:newSelection withRedraw:doRedraw
cg@2356
  1761
    "set a new selection without change notifications"
cg@2356
  1762
cg@2356
  1763
    | sel |
cg@2356
  1764
cg@2356
  1765
    (sel := newSelection) == self ifTrue:[
cg@2356
  1766
        sel := nil
cg@2356
  1767
    ].
cg@2356
  1768
cg@2356
  1769
    doRedraw ifTrue:[
cg@2356
  1770
        self hideSelection.
cg@2356
  1771
        selection := sel.
cg@2356
  1772
cg@2356
  1773
        self forEach:selection do:[:aView |
cg@2356
  1774
            |superView|
cg@2356
  1775
cg@2356
  1776
            superView := aView superView. 
cg@2356
  1777
            self recomputeShapeIfTransparentBox:superView.
cg@2356
  1778
        ].
cg@2356
  1779
        self showSelection.
cg@2356
  1780
    ] ifFalse:[
cg@2356
  1781
        selection := sel
cg@2356
  1782
    ]
cg@2356
  1783
!
cg@2356
  1784
ca@1427
  1785
showUnselected:something
cg@2501
  1786
    "show a component or list of components unselected"
cg@2501
  1787
cg@2501
  1788
    |damages oldClipped savedSelection|
ca@1427
  1789
ca@1427
  1790
    (selectionHiddenLevel ~~ 0 or:[something isNil]) ifTrue:[
ca@1427
  1791
        ^ self
ca@1427
  1792
    ].
ca@1438
  1793
ca@1427
  1794
    damages := OrderedCollection new.
ca@1427
  1795
ca@1427
  1796
    self forEach:something do:[:v|
ca@1437
  1797
        self handlesOf:v do:[:aDamage :wht|
ca@1437
  1798
            damages reverseDo:[:el|
ca@1437
  1799
                (el intersects:aDamage) ifTrue:[
ca@1437
  1800
                    damages removeIdentical:el.
ca@1437
  1801
cg@2503
  1802
                    aDamage left:(aDamage left   min:el left) floor
cg@2503
  1803
                           right:(aDamage right  max:el right) ceiling
cg@2503
  1804
                             top:(aDamage top    min:el top) floor
cg@2503
  1805
                          bottom:(aDamage bottom max:el bottom) ceiling
ca@1437
  1806
                ]
ca@1437
  1807
            ].                        
ca@1437
  1808
            damages add:aDamage
ca@1427
  1809
        ]
ca@1427
  1810
    ].
ca@1438
  1811
cg@2501
  1812
    damages do:[:el| self clearRectangle:el. ].
ca@1438
  1813
ca@1438
  1814
    (oldClipped := clipChildren) ifFalse:[
ca@1438
  1815
        self clippedByChildren:(clipChildren := true)
ca@1438
  1816
    ].
ca@1451
  1817
    self subViews reverseDo:[:v| self recursiveRepair:damages startIn:v].
ca@1437
  1818
ca@1427
  1819
    oldClipped ~~ clipChildren ifTrue:[
ca@1427
  1820
        self clippedByChildren:(clipChildren := oldClipped).
ca@1427
  1821
    ].
cg@2501
  1822
sv@3082
  1823
    self flush.
cg@2501
  1824
cg@2501
  1825
    savedSelection := selection.
cg@2501
  1826
    [
cg@2501
  1827
        selection := nil.
cg@2501
  1828
        damages do:[:el| self invalidate:el ].
cg@2501
  1829
        self repairDamage.
cg@2501
  1830
    ] ensure:[
cg@2501
  1831
        selection := savedSelection
cg@2501
  1832
    ].
ca@131
  1833
! !
ca@131
  1834
cg@60
  1835
!UIObjectView methodsFor:'testing'!
cg@60
  1836
ca@128
  1837
hasSelection
ca@284
  1838
    "returns true if any widget is selected
ca@61
  1839
    "
ca@128
  1840
    ^ self numberOfSelections ~~ 0
cg@60
  1841
cg@60
  1842
!
cg@60
  1843
ca@284
  1844
hasSingleSelection
ca@284
  1845
    "returns true if one widget is selected
ca@284
  1846
    "
ca@284
  1847
    ^ self numberOfSelections == 1
ca@284
  1848
ca@284
  1849
!
ca@284
  1850
ca@284
  1851
hasUndoHistory
cg@1918
  1852
    "returns true if undos exists"
cg@1918
  1853
cg@2722
  1854
    ^ undoHistory notEmpty
ca@284
  1855
!
ca@284
  1856
ca@134
  1857
isModified
cg@1918
  1858
    "returns true if painter is modified"
cg@1918
  1859
cg@1918
  1860
    ^ undoHistory isModified
ca@134
  1861
!
ca@134
  1862
ca@128
  1863
isSelected:anObject
ca@128
  1864
    "return true, if the argument, anObject is selected
ca@128
  1865
    "
ca@128
  1866
    anObject notNil ifTrue:[
cg@1120
  1867
	self selectionDo:[:el| el == anObject ifTrue:[^ true]]
ca@128
  1868
    ].
ca@128
  1869
  ^ false
ca@128
  1870
cg@2538
  1871
!
cg@2538
  1872
cg@2538
  1873
object:anObject isContainedIn:aRectangle
cg@2538
  1874
    ^ anObject bounds isContainedIn:aRectangle
cg@60
  1875
! !
cg@60
  1876
cg@60
  1877
!UIObjectView methodsFor:'transaction'!
cg@60
  1878
ca@134
  1879
createUndoLayout:aView
ca@134
  1880
    "prepare undo action for a view changing its layout
ca@134
  1881
    "
ca@134
  1882
    self subclassResponsibility
ca@134
  1883
ca@134
  1884
!
ca@134
  1885
cg@60
  1886
transaction:aType objects:something do:aOneArgBlock
cg@60
  1887
    "opens a transaction and evaluates a block within the transaction; the
cg@60
  1888
     argument to the block is a view from derived from something
cg@60
  1889
    "
cg@60
  1890
    self subclassResponsibility
cg@60
  1891
cg@60
  1892
cg@60
  1893
!
cg@60
  1894
cg@60
  1895
transaction:aType selectionDo:aOneArgBlock
cg@60
  1896
    "opens a transaction and evaluates a block within the transaction; the
cg@60
  1897
     argument to the block is a view from the selection
cg@60
  1898
    "
ca@128
  1899
    self transaction:aType objects:(self selection) do:aOneArgBlock
cg@60
  1900
cg@60
  1901
cg@60
  1902
! !
cg@60
  1903
cg@1715
  1904
!UIObjectView methodsFor:'user actions-dimension'!
cg@60
  1905
cg@60
  1906
copyExtent
cg@2364
  1907
    "copy the extent from the selected object"
cg@2364
  1908
cg@60
  1909
    |object|
cg@60
  1910
cg@60
  1911
    object := self singleSelection.
cg@60
  1912
    object notNil ifTrue:[
cg@2364
  1913
        CopiedExtent := object computeExtent
cg@60
  1914
    ] ifFalse:[
cg@2364
  1915
        self warn:'Exactly one element must be selected!!'.
cg@60
  1916
    ]
cg@60
  1917
!
cg@60
  1918
ca@89
  1919
copyLayout
cg@2364
  1920
    "copy the layout from the selected object"
cg@2364
  1921
ca@89
  1922
    |object|
ca@89
  1923
ca@89
  1924
    object := self singleSelection.
ca@89
  1925
    object notNil ifTrue:[
cg@2364
  1926
        CopiedLayout := object geometryLayout copy
ca@89
  1927
    ] ifFalse:[
cg@2364
  1928
        self warn:'Exactly one element must be selected!!'.
ca@89
  1929
    ]
ca@89
  1930
!
ca@89
  1931
cg@1230
  1932
exchangeLayouts
cg@1230
  1933
    "exchange the layout of two elements 
cg@1230
  1934
     (useful to change the order of radiobuttons or checkBoxes)
cg@1230
  1935
    "
cg@1230
  1936
    |objects l1 l2|
cg@1230
  1937
cg@1230
  1938
    objects := self twoElementSelection.
cg@1230
  1939
cg@1230
  1940
    objects notNil ifTrue:[
cg@1230
  1941
        l1 := (objects at:1) geometryLayout copy.
cg@1230
  1942
        l2 := (objects at:2) geometryLayout copy.
cg@1230
  1943
        self transaction:#exchangeLayout dimensionDo:[:v|
cg@1230
  1944
            v == (objects at:1) ifTrue:[
cg@1230
  1945
                v geometryLayout:(l2 copy)
cg@1230
  1946
            ] ifFalse:[
cg@1230
  1947
                v geometryLayout:(l1 copy).
cg@1230
  1948
            ]
cg@1230
  1949
        ]    
cg@1230
  1950
    ] ifFalse:[    
cg@1230
  1951
        self warn:'exactly two elements must be selected'.
cg@1230
  1952
    ]
cg@1230
  1953
cg@1230
  1954
cg@1230
  1955
cg@1230
  1956
!
cg@1230
  1957
cg@60
  1958
pasteExtent
cg@2364
  1959
    "paste the copied extent to all objects in the selection"
cg@2364
  1960
cg@2398
  1961
    |heightToPaste widthToPaste|
cg@2398
  1962
cg@2364
  1963
    CopiedExtent notNil ifTrue:[
cg@2398
  1964
        widthToPaste := CopiedExtent x.
cg@2398
  1965
        heightToPaste := CopiedExtent y.
cg@2398
  1966
    ] ifFalse:[
cg@2398
  1967
        CopiedLayout notNil ifTrue:[
cg@2398
  1968
            CopiedLayout leftFraction = CopiedLayout rightFraction ifTrue:[
cg@2398
  1969
                CopiedLayout topFraction = CopiedLayout bottomFraction ifTrue:[
cg@2398
  1970
                    widthToPaste := (CopiedLayout rightOffset - CopiedLayout leftOffset). 
cg@2398
  1971
                    heightToPaste := (CopiedLayout bottomOffset - CopiedLayout topOffset). 
cg@2398
  1972
                ]
cg@2398
  1973
            ]
cg@2398
  1974
        ].
cg@2398
  1975
    ].
cg@2398
  1976
cg@2398
  1977
    widthToPaste notNil ifTrue:[
cg@2398
  1978
        heightToPaste notNil ifTrue:[
cg@2398
  1979
            self transaction:#pasteExtent dimensionDo:[:v|
cg@2398
  1980
                self resize:v corner:(v computeOrigin + (widthToPaste@heightToPaste))
cg@2398
  1981
            ]    
cg@2364
  1982
        ]    
cg@60
  1983
    ]    
cg@60
  1984
!
cg@60
  1985
cg@60
  1986
pasteHeight
cg@2364
  1987
    "paste the copied extent's height to all objects in the selection"
cg@2364
  1988
cg@2398
  1989
    |heightToPaste|
cg@2398
  1990
cg@2364
  1991
    CopiedExtent notNil ifTrue:[
cg@2398
  1992
        heightToPaste := CopiedExtent y.
cg@2398
  1993
    ] ifFalse:[
cg@2398
  1994
        CopiedLayout notNil ifTrue:[
cg@2398
  1995
            CopiedLayout topFraction = CopiedLayout bottomFraction ifTrue:[
cg@2398
  1996
                heightToPaste := (CopiedLayout bottomOffset - CopiedLayout topOffset) 
cg@2398
  1997
            ]
cg@2398
  1998
        ].
cg@2398
  1999
    ].
cg@2398
  2000
cg@2398
  2001
    heightToPaste notNil ifTrue:[
cg@2364
  2002
        self transaction:#pasteHeight dimensionDo:[:v|
cg@2398
  2003
            self resize:v bottom:(v computeOrigin + heightToPaste)
cg@2398
  2004
        ].
cg@2398
  2005
    ].    
ca@89
  2006
!
ca@89
  2007
cg@2364
  2008
pasteLayout
cg@2364
  2009
    "paste the layout to all objects in the selection"
cg@2364
  2010
cg@2364
  2011
    CopiedLayout notNil ifTrue:[
cg@2364
  2012
        self transaction:#pasteLayout dimensionDo:[:v|
cg@2364
  2013
            v geometryLayout:(CopiedLayout copy)
cg@2364
  2014
        ]    
cg@2364
  2015
    ]    
cg@2364
  2016
!
cg@2364
  2017
cg@60
  2018
pasteWidth
cg@2364
  2019
    "paste the copied extent's width to all objects in the selection"
cg@2364
  2020
cg@2398
  2021
    |widthToPaste|
cg@2398
  2022
cg@2364
  2023
    CopiedExtent notNil ifTrue:[
cg@2398
  2024
        widthToPaste := CopiedExtent x.
cg@2398
  2025
    ] ifFalse:[
cg@2398
  2026
        CopiedLayout notNil ifTrue:[
cg@2398
  2027
            CopiedLayout leftFraction = CopiedLayout rightFraction ifTrue:[
cg@2398
  2028
                widthToPaste := (CopiedLayout rightOffset - CopiedLayout leftOffset) 
cg@2398
  2029
            ]
cg@2398
  2030
        ].
cg@2398
  2031
    ].
cg@2398
  2032
cg@2398
  2033
    widthToPaste notNil ifTrue:[
cg@2364
  2034
        self transaction:#pasteWidth dimensionDo:[:v|
cg@2398
  2035
            self resize:v right:(v computeOrigin + widthToPaste)
cg@2364
  2036
        ]    
cg@60
  2037
    ]    
cg@60
  2038
!
cg@60
  2039
ca@61
  2040
setExtent:anExtent
ca@61
  2041
    "change extent for all selected objects
ca@61
  2042
    "
ca@134
  2043
    self transaction:#extent dimensionDo:[:v|
cg@1120
  2044
	v geometryLayout:nil.
cg@1120
  2045
	v extent:anExtent.
cg@67
  2046
    ].
cg@67
  2047
cg@67
  2048
    "Modified: 28.2.1997 / 12:49:00 / cg"
ca@61
  2049
!
ca@61
  2050
ca@149
  2051
setLayout:aLayout
ca@149
  2052
    "change layout for all selected objects
ca@149
  2053
    "
ca@149
  2054
    self transaction:#layout dimensionDo:[:v|
cg@2501
  2055
        v geometryLayout:(aLayout copy)
ca@149
  2056
    ].    
ca@149
  2057
!
ca@149
  2058
cg@60
  2059
setToDefaultExtent
ca@61
  2060
    "change extent of all selected views to their default extent
ca@61
  2061
    "
ca@134
  2062
    self transaction:#defaultExtent dimensionDo:[:v|
cg@1120
  2063
	self resize:v corner:(v computeOrigin + (v preferredExtent)).
cg@60
  2064
    ]    
cg@60
  2065
cg@60
  2066
!
cg@60
  2067
cg@60
  2068
setToDefaultHeight
ca@61
  2069
    "change height of all selected views to their default height
ca@61
  2070
    "
ca@134
  2071
    self transaction:#defaultHeight dimensionDo:[:v|
cg@1120
  2072
	self resize:v bottom:(v computeOrigin + (v preferredExtent))
cg@60
  2073
    ]    
cg@60
  2074
cg@60
  2075
!
cg@60
  2076
cg@60
  2077
setToDefaultWidth
ca@61
  2078
    "change width of all selected views to their default width
ca@61
  2079
    "
ca@134
  2080
    self transaction:#defaultWidth dimensionDo:[:v|
cg@1120
  2081
	self resize:v right:(v computeOrigin + (v preferredExtent))
cg@60
  2082
    ]    
cg@60
  2083
cg@60
  2084
!
cg@60
  2085
ca@134
  2086
transaction:aType dimensionDo:aOneArgBlock
cg@60
  2087
    "change dimension within a transaction for the selected elements by evaluating
cg@60
  2088
     the block with the argument a view.
cg@60
  2089
    "
ca@61
  2090
    self withSelectionHiddenDo:[
cg@1120
  2091
	self transaction:aType selectionDo:[:aView|
cg@1120
  2092
	    (self class layoutType:aView) notNil ifTrue:[
cg@1120
  2093
		self createUndoLayout:aView.
cg@1120
  2094
		aOneArgBlock value:aView.
cg@1120
  2095
		self elementChangedSize:aView.
cg@1120
  2096
	    ]
cg@1120
  2097
	]
ca@61
  2098
    ].
ca@225
  2099
    self layoutChanged
ca@61
  2100
ca@61
  2101
! !
ca@61
  2102
cg@1715
  2103
!UIObjectView methodsFor:'user actions-move'!
ca@61
  2104
cg@2394
  2105
moveDo:aOneArgBlock 
cg@2394
  2106
    "perform a move operation (with auto repeat)"
cg@2394
  2107
ca@138
  2108
    |sensor tm|
ca@138
  2109
ca@138
  2110
    self moveableSelection isNil ifTrue:[
cg@2356
  2111
        ^ self
ca@138
  2112
    ].
ca@138
  2113
    sensor := self sensor.
ca@138
  2114
cg@2394
  2115
    tm := ButtonController defaultInitialDelay.
ca@138
  2116
ca@138
  2117
    self withSelectionHiddenDo:[
cg@2356
  2118
        self transaction:#move selectionDo:[:aView|self createUndoLayout:aView].
cg@2356
  2119
cg@2356
  2120
        [
cg@2356
  2121
            self selectionDo:[:aView| aOneArgBlock value:aView ].
cg@2510
  2122
cg@2394
  2123
            sensor leftButtonPressed ifTrue:[
cg@2394
  2124
                self windowGroup processExposeEvents.
cg@2394
  2125
                Delay waitForSeconds:tm.
cg@2394
  2126
                self windowGroup processExposeEvents.
cg@2394
  2127
                tm := ButtonController defaultRepeatDelay.
cg@2394
  2128
                self layoutChanged.
cg@2394
  2129
            ].
cg@2356
  2130
            sensor leftButtonPressed.
cg@2356
  2131
        ] whileTrue.
cg@2356
  2132
cg@2356
  2133
        "/ handle any expose events (for subcomponents) before
cg@2356
  2134
        "/ redrawing the handles.
cg@2356
  2135
        Delay waitForSeconds:0.1.
cg@2394
  2136
        self windowGroup processExposeEvents
ca@138
  2137
    ].
ca@138
  2138
!
ca@138
  2139
ca@113
  2140
moveSelectionDown
ca@61
  2141
    "move selection down
ca@61
  2142
    "
cg@3219
  2143
    self moveSelectionDown:nPixelsForMoveSelection
cg@1222
  2144
!
cg@1222
  2145
cg@1222
  2146
moveSelectionDown:howMany
cg@2510
  2147
    "move selection down (pixelwise or aligned-grid wise)"
cg@2510
  2148
ca@138
  2149
    |gridY n|
ca@138
  2150
ca@138
  2151
    gridAlign notNil ifTrue:[gridY := gridAlign y]
cg@1222
  2152
                    ifFalse:[gridY := 1].
ca@138
  2153
ca@138
  2154
    self moveDo:[:aView|
cg@1222
  2155
        aligning ifTrue:[
cg@1222
  2156
            n := ((aView computeCorner y) \\ gridY).
cg@1222
  2157
cg@1222
  2158
            n ~~ 0 ifTrue:[
cg@1222
  2159
                n := gridY - n + 1.
cg@1222
  2160
            ] ifFalse:[
cg@1222
  2161
                n := gridY
cg@1222
  2162
            ]
cg@1222
  2163
        ] ifFalse:[
cg@2510
  2164
            n := 1.
cg@2510
  2165
            self sensor shiftDown ifTrue:[
cg@2510
  2166
                n := 8.    
cg@2510
  2167
            ].
cg@1222
  2168
        ].
cg@1222
  2169
        n := n * howMany.
cg@2510
  2170
        self shiftLayout:aView vertical:n
cg@60
  2171
    ]
cg@60
  2172
!
cg@60
  2173
ca@113
  2174
moveSelectionLeft
cg@60
  2175
    "move selection left
cg@60
  2176
    "
cg@3219
  2177
    self moveSelectionLeft:nPixelsForMoveSelection
cg@1222
  2178
!
cg@1222
  2179
cg@1222
  2180
moveSelectionLeft:howMany
cg@2510
  2181
    "move selection to the left (pixelwise or aligned-grid wise)"
cg@2510
  2182
ca@113
  2183
    |gridX n|
cg@60
  2184
ca@138
  2185
    gridAlign notNil ifTrue:[gridX := gridAlign x]
cg@1222
  2186
                    ifFalse:[gridX := 1].
ca@138
  2187
ca@138
  2188
    self moveDo:[:aView|
cg@1222
  2189
        aligning ifTrue:[
cg@1222
  2190
            n := ((aView computeOrigin x) \\ gridX).
cg@1222
  2191
            n == 0 ifTrue:[n := gridX].
cg@1222
  2192
        ] ifFalse:[
cg@2538
  2193
            n := 1.
cg@2510
  2194
            self sensor shiftDown ifTrue:[
cg@2538
  2195
                n := 8.    
cg@2510
  2196
            ].
cg@1222
  2197
        ].
cg@1222
  2198
        n := n * howMany.
cg@2538
  2199
        self shiftLayout:aView horizontal:n negated
cg@60
  2200
    ]
cg@60
  2201
!
cg@60
  2202
ca@113
  2203
moveSelectionRight
cg@2356
  2204
    "move the selection to the right"
cg@2356
  2205
cg@3219
  2206
    self moveSelectionRight:nPixelsForMoveSelection
cg@1222
  2207
!
cg@1222
  2208
cg@1222
  2209
moveSelectionRight:howMany
cg@2510
  2210
    "move selection to the right (pixelwise or aligned-grid wise)"
cg@2356
  2211
ca@113
  2212
    |gridX n|
ca@113
  2213
ca@138
  2214
    gridAlign notNil ifTrue:[gridX := gridAlign x]
cg@1222
  2215
                    ifFalse:[gridX := 1].
ca@138
  2216
ca@138
  2217
    self moveDo:[:aView|
cg@1222
  2218
        aligning ifTrue:[
cg@1222
  2219
            n := ((aView computeCorner x) \\ gridX).
cg@2538
  2220
            n == 0 ifTrue:[n := gridX].
cg@1222
  2221
        ] ifFalse:[
cg@2510
  2222
            n := 1.
cg@2510
  2223
            self sensor shiftDown ifTrue:[
cg@2510
  2224
                n := 8.    
cg@2510
  2225
            ].
cg@1222
  2226
        ].
cg@1222
  2227
        n := n * howMany.
cg@2510
  2228
        self shiftLayout:aView horizontal:n
ca@113
  2229
    ]
ca@113
  2230
!
ca@113
  2231
ca@113
  2232
moveSelectionUp
cg@60
  2233
    "move selection up
cg@60
  2234
    "
cg@3219
  2235
    self moveSelectionUp:nPixelsForMoveSelection
cg@1222
  2236
!
cg@1222
  2237
cg@1222
  2238
moveSelectionUp:howMany
cg@2510
  2239
    "move selection up (pixelwise or aligned-grid wise)"
cg@2510
  2240
ca@113
  2241
    |gridY n|
cg@60
  2242
ca@138
  2243
    gridAlign notNil ifTrue:[gridY := gridAlign y]
cg@1222
  2244
                    ifFalse:[gridY := 1].
ca@138
  2245
ca@138
  2246
    self moveDo:[:aView|
cg@1222
  2247
        aligning ifTrue:[
sv@2485
  2248
            n := ((aView computeOrigin y) \\ gridY).
cg@1222
  2249
            n == 0 ifTrue:[n := gridY].
cg@1222
  2250
            n := n negated.
cg@1222
  2251
        ] ifFalse:[
cg@2510
  2252
            n := -1.
cg@2510
  2253
            self sensor shiftDown ifTrue:[
cg@2510
  2254
                n := -8.    
cg@2510
  2255
            ].
cg@1222
  2256
        ].
cg@1222
  2257
        n := n * howMany.
cg@2510
  2258
        self shiftLayout:aView vertical:n
cg@60
  2259
    ]
cg@60
  2260
! !
cg@60
  2261
cg@1715
  2262
!UIObjectView methodsFor:'user actions-position'!
cg@60
  2263
cg@2364
  2264
alignResizeSelectionLeft
cg@2364
  2265
    "resize the selection on the left to align their left edge with the 
cg@2364
  2266
     of the first object in the selection; 
cg@2364
  2267
     in case of a single object selection, the objects left edge is aligned with the left of its superview"
cg@2364
  2268
cg@2364
  2269
    |lmost delta sel|
cg@2364
  2270
cg@2364
  2271
    (sel := self moveableSelection) notNil ifTrue:[
cg@2364
  2272
        self withSelectionHiddenDo:[
cg@2364
  2273
            self numberOfSelections > 1 ifTrue:[
cg@2364
  2274
                lmost := (sel first) computeOrigin x.
cg@2364
  2275
cg@2364
  2276
                self transaction:#alignResizeLeft selectionDo:[:v|
cg@2364
  2277
                    (delta := lmost - (v computeOrigin x)) ~~ 0 ifTrue:[
cg@2364
  2278
                        self shiftLayout:v left:delta right:0
cg@2364
  2279
                    ]
cg@2364
  2280
                ]
cg@2364
  2281
            ] ifFalse:[
cg@2364
  2282
                self extentToFrame:#Left do:[:aLayout|
cg@2364
  2283
                    aLayout leftFraction:0.0 offset:0.
cg@2364
  2284
                ]
cg@2364
  2285
            ]
cg@2364
  2286
        ].
cg@2364
  2287
        self layoutChanged
cg@2364
  2288
    ]
cg@2364
  2289
!
cg@2364
  2290
cg@2364
  2291
alignResizeSelectionRight
cg@2364
  2292
    "align selection to the right of the first object in the selection; 
cg@2364
  2293
     in case of one selection the object is aligned to the right of its superview"
cg@2364
  2294
cg@2364
  2295
    |rmost delta sel|
cg@2364
  2296
cg@2364
  2297
    (sel := self moveableSelection) notNil ifTrue:[
cg@2364
  2298
        self withSelectionHiddenDo:[
cg@2364
  2299
            self numberOfSelections > 1 ifTrue:[
cg@2364
  2300
                rmost := (sel first) computeCorner x.
cg@2364
  2301
cg@2364
  2302
                self transaction:#alignRight selectionDo:[:v|
cg@2364
  2303
                    (delta := rmost - (v computeCorner x)) ~~ 0 ifTrue:[
cg@2364
  2304
                        self shiftLayout:v left:0 right:delta
cg@2364
  2305
                    ]
cg@2364
  2306
                ]
cg@2364
  2307
            ] ifFalse:[
cg@2364
  2308
                self extentToFrame:#Right do:[:aLayout|
cg@2364
  2309
                    aLayout rightOffset:0.
cg@2364
  2310
                    aLayout rightFraction:1.0.
cg@2364
  2311
                ]
cg@2364
  2312
            ]
cg@2364
  2313
        ].
cg@2364
  2314
        self layoutChanged
cg@2364
  2315
    ]
cg@2364
  2316
!
cg@2364
  2317
cg@60
  2318
alignSelectionBottom
ca@61
  2319
    "align selection to the bottom of the first object in the selection; in case
ca@61
  2320
     of one selection the object is aligned to the bottom of its superview
ca@61
  2321
    "
ca@128
  2322
    |bmost delta sel|
ca@128
  2323
ca@128
  2324
    (sel := self moveableSelection) notNil ifTrue:[
cg@1120
  2325
	self withSelectionHiddenDo:[
cg@1120
  2326
	    self numberOfSelections > 1 ifTrue:[
cg@1120
  2327
		bmost := (sel first) computeCorner y.
cg@1120
  2328
cg@1120
  2329
		self transaction:#alignBottom selectionDo:[:v|
cg@1120
  2330
		    (delta := bmost - (v computeCorner y)) ~~ 0 ifTrue:[
cg@1120
  2331
			self shiftLayout:v top:delta bottom:delta.
cg@1120
  2332
		    ]
cg@1120
  2333
		]
cg@1120
  2334
	    ] ifFalse:[
cg@1120
  2335
		self extentToFrame:#Bottom do:[:aLayout|
cg@1120
  2336
		    aLayout bottomOffset:0.
cg@1120
  2337
		    aLayout bottomFraction:1.0
cg@1120
  2338
		]
cg@1120
  2339
	    ]
cg@1120
  2340
	].
cg@1120
  2341
	self layoutChanged
cg@60
  2342
    ]
cg@60
  2343
cg@60
  2344
cg@60
  2345
cg@60
  2346
!
cg@60
  2347
cg@60
  2348
alignSelectionCenterHor
ca@61
  2349
    "align selection to the center/horizontal of the first object in the selection; in case
ca@61
  2350
     of one selection the object is aligned to the center/horizontal of its superview
ca@61
  2351
    "
ca@128
  2352
    |view center sel|
ca@128
  2353
ca@128
  2354
    (sel := self moveableSelection) notNil ifTrue:[
cg@1120
  2355
	self withSelectionHiddenDo:[
cg@1120
  2356
	    view := self singleSelection.
cg@1120
  2357
cg@1120
  2358
	    view notNil ifTrue:[
ca@284
  2359
                
cg@1120
  2360
		view   := self findContainerOfView:view.
cg@1120
  2361
		center := view computeExtent
cg@1120
  2362
	    ] ifFalse:[
cg@1120
  2363
		view   := sel first.
cg@1120
  2364
		center := view computeCorner + view computeOrigin.
cg@1120
  2365
	    ].
cg@1120
  2366
	    center := center x // 2.
cg@1120
  2367
cg@1120
  2368
	    self transaction:#alignCenterHorizontal selectionDo:[:v|
cg@1120
  2369
		|newX oldX delta|
cg@1120
  2370
cg@1120
  2371
		oldX  := v computeOrigin x.
cg@1120
  2372
		newX  := center - ((v computeCorner x - oldX) // 2).
cg@1120
  2373
		delta := newX - oldX.
cg@1120
  2374
cg@1120
  2375
		self shiftLayout:v left:delta right:delta
cg@1120
  2376
	    ]
cg@1120
  2377
	].
cg@1120
  2378
	self layoutChanged
cg@60
  2379
    ]
cg@60
  2380
cg@60
  2381
cg@60
  2382
cg@60
  2383
!
cg@60
  2384
cg@60
  2385
alignSelectionCenterVer
ca@61
  2386
    "align selection to the center/vertical of the first object in the selection; in case
ca@61
  2387
     of one selection the object is aligned to the center/vertical of its superview
ca@61
  2388
    "
ca@128
  2389
    |view center sel|
ca@128
  2390
ca@128
  2391
    (sel := self moveableSelection) notNil ifTrue:[
cg@1120
  2392
	self withSelectionHiddenDo:[
cg@1120
  2393
	    view := self singleSelection.
cg@1120
  2394
cg@1120
  2395
	    view notNil ifTrue:[
cg@1120
  2396
		view   := self findContainerOfView:view.
cg@1120
  2397
		center := view computeExtent
cg@1120
  2398
	    ] ifFalse:[
cg@1120
  2399
		view   := sel first.
cg@1120
  2400
		center := view computeCorner + view computeOrigin.
cg@1120
  2401
	    ].
cg@1120
  2402
	    center := center y // 2.
cg@1120
  2403
cg@1120
  2404
	    self transaction:#alignCenterVertical selectionDo:[:v|
cg@1120
  2405
		|newY oldY delta|
cg@1120
  2406
cg@1120
  2407
		oldY  := v computeOrigin y.
cg@1120
  2408
		newY  := center - ((v computeCorner y - oldY) // 2).
cg@1120
  2409
		delta := newY - oldY.
cg@1120
  2410
cg@1120
  2411
		self shiftLayout:v top:delta bottom:delta
cg@1120
  2412
	    ]
cg@1120
  2413
	].
cg@1120
  2414
	self layoutChanged
cg@60
  2415
    ]
cg@60
  2416
!
cg@60
  2417
cg@60
  2418
alignSelectionLeft
cg@2364
  2419
    "align the selection with the left edge of the first object in the selection.
cg@2364
  2420
     in case of a single object selection, the object is moved to the left of its superview"
cg@2364
  2421
cg@2364
  2422
    |dominantLeft delta sel|
ca@128
  2423
ca@128
  2424
    (sel := self moveableSelection) notNil ifTrue:[
cg@1581
  2425
        self withSelectionHiddenDo:[
cg@2364
  2426
            dominantLeft := (sel first) computeOrigin x.
cg@1581
  2427
            self numberOfSelections > 1 ifTrue:[
cg@1581
  2428
                self transaction:#alignLeft selectionDo:[:v|
cg@2364
  2429
                    (delta := dominantLeft - (v computeOrigin x)) ~~ 0 ifTrue:[
cg@1581
  2430
                        self shiftLayout:v left:delta right:delta
cg@1581
  2431
                    ]
cg@1581
  2432
                ]
cg@1581
  2433
            ] ifFalse:[
cg@2364
  2434
                self transaction:#alignLeft selectionDo:[:v|
cg@2364
  2435
                    self shiftLayout:v left:dominantLeft negated right:dominantLeft negated
cg@2364
  2436
                ].
cg@1581
  2437
            ]
cg@1581
  2438
        ].
cg@1581
  2439
        self layoutChanged
cg@60
  2440
    ]
cg@60
  2441
!
cg@60
  2442
cg@60
  2443
alignSelectionLeftAndRight
ca@61
  2444
    "align selection to the left/right of the first object in the selection; in case
ca@61
  2445
     of one selection the object is aligned to the left/right of its superview
ca@61
  2446
    "
ca@128
  2447
    |lmost rmost sel|
ca@128
  2448
sv@2481
  2449
    (sel := self resizableSelection) notNil ifTrue:[
cg@1581
  2450
        self withSelectionHiddenDo:[
cg@1581
  2451
            self numberOfSelections > 1 ifTrue:[
cg@1581
  2452
                lmost := (sel first) computeOrigin x.
cg@1581
  2453
                rmost := (sel first) computeCorner x.
cg@1581
  2454
cg@1581
  2455
                self transaction:#alignLeftRight selectionDo:[:aView|
cg@1581
  2456
                    |layout|
sv@2481
  2457
sv@2481
  2458
                    aView superView isLayoutWrapper ifTrue:[
sv@2481
  2459
                        "change size only"
cg@1581
  2460
                        self createUndoLayout:aView.
sv@2481
  2461
                        aView width:sel first width.
sv@2481
  2462
                        self elementChangedSize:aView
sv@2481
  2463
                    ] ifFalse:[
sv@2481
  2464
                        layout := self class asLayoutFrameFromView:aView.
sv@2481
  2465
sv@2481
  2466
                        layout notNil ifTrue:[
sv@2481
  2467
                            self createUndoLayout:aView.
sv@2481
  2468
                            aView geometryLayout:layout.
sv@2481
  2469
sv@2481
  2470
                            undoHistory withoutTransactionDo:[
sv@2481
  2471
                                self shiftLayout:aView left:(lmost - (aView computeOrigin x))
sv@2481
  2472
                                                      right:(rmost - (aView computeCorner x)).
sv@2481
  2473
                            ].
sv@2481
  2474
                            self elementChangedSize:aView
cg@1581
  2475
                        ].
sv@2481
  2476
                    ].
cg@1581
  2477
                ]
cg@1581
  2478
            ] ifFalse:[
cg@1581
  2479
                self extentToFrame:#LeftRight do:[:aLayout|
cg@1581
  2480
                    aLayout leftFraction:0.0 offset:0.
cg@1581
  2481
                    aLayout rightFraction:1.0 offset:0.
cg@1581
  2482
                ]
cg@1581
  2483
            ]
cg@1581
  2484
        ].
cg@1581
  2485
        self layoutChanged
ca@61
  2486
    ].
ca@61
  2487
!
ca@61
  2488
ca@61
  2489
alignSelectionRight
ca@61
  2490
    "align selection to the right of the first object in the selection; in case
ca@61
  2491
     of one selection the object is aligned to the right of its superview
ca@61
  2492
    "
cg@2364
  2493
    |dominantRight delta sel|
ca@128
  2494
ca@128
  2495
    (sel := self moveableSelection) notNil ifTrue:[
cg@2364
  2496
        self withSelectionHiddenDo:[
cg@2364
  2497
            dominantRight := (sel first) computeCorner x.
cg@2364
  2498
            self numberOfSelections > 1 ifTrue:[
cg@2364
  2499
                self transaction:#alignRight selectionDo:[:v|
cg@2364
  2500
                    (delta := dominantRight - (v computeCorner x)) ~~ 0 ifTrue:[
cg@2364
  2501
                        self shiftLayout:v left:delta right:delta
cg@2364
  2502
                    ]
cg@2364
  2503
                ]
cg@2364
  2504
            ] ifFalse:[
cg@2364
  2505
                self transaction:#alignRight selectionDo:[:v|
cg@2364
  2506
                    delta := v superView width - dominantRight.
cg@2364
  2507
                    self shiftLayout:v left:delta right:delta
cg@2364
  2508
                ]
cg@2364
  2509
"/                self extentToFrame:#Right do:[:aLayout|
cg@2364
  2510
"/                    aLayout rightOffset:0.
cg@2364
  2511
"/                    aLayout rightFraction:1.0.
cg@2364
  2512
"/                ]
cg@2364
  2513
            ]
cg@2364
  2514
        ].
cg@2364
  2515
        self layoutChanged
cg@60
  2516
    ]
cg@60
  2517
!
cg@60
  2518
cg@60
  2519
alignSelectionTop
ca@61
  2520
    "align selection to the top of the first object in the selection; in case
ca@61
  2521
     of one selection the object is aligned to the top of its superview
ca@61
  2522
    "
ca@128
  2523
    |tmost delta sel|
ca@128
  2524
ca@128
  2525
    (sel := self moveableSelection) notNil ifTrue:[
cg@1120
  2526
	self withSelectionHiddenDo:[
cg@1120
  2527
	    self numberOfSelections > 1 ifTrue:[
cg@1120
  2528
		tmost := (sel first) computeOrigin y.
cg@1120
  2529
cg@1120
  2530
		self transaction:#alignTop selectionDo:[:v|
cg@1120
  2531
		    (delta := tmost - (v computeOrigin y)) ~~ 0 ifTrue:[
cg@1120
  2532
			self shiftLayout:v top:delta bottom:delta
cg@1120
  2533
		    ]
cg@1120
  2534
		]
cg@1120
  2535
	    ] ifFalse:[
cg@1120
  2536
		self extentToFrame:#Top do:[:aLayout|
cg@1120
  2537
		    aLayout topOffset:0.
cg@1120
  2538
		    aLayout topFraction:0.0.
cg@1120
  2539
		]
cg@1120
  2540
	    ]
cg@1120
  2541
	].
cg@1120
  2542
	self layoutChanged
cg@60
  2543
    ]
cg@60
  2544
cg@60
  2545
!
cg@60
  2546
cg@60
  2547
alignSelectionTopAndBottom
ca@61
  2548
    "align selection to the top/bottom of the first object in the selection; in case
ca@61
  2549
     of one selection the object is aligned to the top/bottom of its superview
ca@61
  2550
    "
ca@128
  2551
    |tmost bmost sel|
ca@128
  2552
sv@2481
  2553
    (sel := self resizableSelection) notNil ifTrue:[
cg@1954
  2554
        self withSelectionHiddenDo:[
cg@1954
  2555
            self numberOfSelections > 1 ifTrue:[
cg@1954
  2556
                tmost := (sel first) computeOrigin y.
cg@1954
  2557
                bmost := (sel first) computeCorner y.
cg@1954
  2558
cg@1954
  2559
                self transaction:#alignTopBottom selectionDo:[:aView|
cg@1954
  2560
                    |layout|
sv@2481
  2561
                    aView superView isLayoutWrapper ifTrue:[
sv@2481
  2562
                        "change size only"
cg@1954
  2563
                        self createUndoLayout:aView.
sv@2481
  2564
                        aView height:sel first height.
sv@2481
  2565
                        self elementChangedSize:aView
sv@2481
  2566
                    ] ifFalse:[
sv@2481
  2567
                        layout := self class asLayoutFrameFromView:aView.
sv@2481
  2568
sv@2481
  2569
                        layout notNil ifTrue:[
sv@2481
  2570
                            self createUndoLayout:aView.
sv@2481
  2571
                            aView geometryLayout:layout.
sv@2481
  2572
sv@2481
  2573
                            undoHistory withoutTransactionDo:[
sv@2481
  2574
                                self shiftLayout:aView top:(tmost - (aView computeOrigin y))
sv@2481
  2575
                                                    bottom:(bmost - (aView computeCorner y)).
sv@2481
  2576
                            ].
sv@2481
  2577
                            self elementChangedSize:aView
cg@1954
  2578
                        ].
sv@2481
  2579
                    ].
cg@1954
  2580
                ]
cg@1954
  2581
            ] ifFalse:[
cg@1954
  2582
                self extentToFrame:#TopBottom do:[:aLayout|
cg@1954
  2583
                    aLayout topOffset:0.
cg@1954
  2584
                    aLayout topFraction:0.0.
cg@1954
  2585
                    aLayout bottomOffset:0.
cg@1954
  2586
                    aLayout bottomFraction:1.0.
cg@1954
  2587
                ]
cg@1954
  2588
            ]
cg@1954
  2589
        ].
cg@1954
  2590
        self layoutChanged
cg@60
  2591
    ]
cg@60
  2592
!
cg@60
  2593
cg@60
  2594
centerSelection:aOneArgBlockXorY orientation:orientation
cg@60
  2595
    "center selection horizontal or vertical dependant on the block result( x or y).
cg@60
  2596
     The argument to the block is the point.
cg@60
  2597
    "
cg@60
  2598
    |superview min max delta val|
cg@60
  2599
ca@128
  2600
    (self moveableSelection) isNil ifTrue:[
cg@1120
  2601
	^ self
ca@61
  2602
    ].
ca@61
  2603
ca@61
  2604
    self withSelectionHiddenDo:[
cg@1120
  2605
	max := 0.
cg@1120
  2606
cg@1120
  2607
	self selectionDo:[:aView |
cg@1120
  2608
	    superview isNil ifTrue:[
cg@1120
  2609
		superview := self findContainerOfView:aView
cg@1120
  2610
	    ] ifFalse:[
cg@1120
  2611
		(self findContainerOfView:aView) == superview ifFalse:[
cg@1120
  2612
		    ^ self notify:'views must have same superview'.
cg@1120
  2613
		]
cg@1120
  2614
	    ].
cg@1120
  2615
	    val := aOneArgBlockXorY value:(aView computeOrigin).    
cg@1120
  2616
cg@1120
  2617
	    min isNil ifTrue:[min := val]
cg@1120
  2618
		     ifFalse:[min := min min:val].
cg@1120
  2619
cg@1120
  2620
	    val := aOneArgBlockXorY value:(aView computeCorner).
cg@1120
  2621
	    max := max max:val.
cg@1120
  2622
	].
cg@1120
  2623
cg@1120
  2624
	val := aOneArgBlockXorY value:(superview computeExtent).
cg@1120
  2625
	max := (min + val - max) // 2.
cg@1120
  2626
cg@1120
  2627
	max == min ifFalse:[
cg@1120
  2628
	    |type|
cg@1120
  2629
	    (orientation == #y) ifTrue:[type := #centerVertical]
cg@1120
  2630
			       ifFalse:[type := #centerHorizontal].
cg@1120
  2631
	    delta := max - min.
cg@1120
  2632
cg@1120
  2633
	    self transaction:type selectionDo:[:v|
cg@1120
  2634
		orientation == #y ifTrue:[
cg@1120
  2635
		    self shiftLayout:v top:delta bottom:delta
cg@1120
  2636
		] ifFalse:[
cg@1120
  2637
		    self shiftLayout:v left:delta right:delta
cg@1120
  2638
		]
cg@1120
  2639
	    ]
cg@1120
  2640
	].
cg@1120
  2641
	self layoutChanged
cg@60
  2642
    ]
cg@60
  2643
cg@60
  2644
cg@60
  2645
!
cg@60
  2646
cg@60
  2647
centerSelectionHor
cg@60
  2648
    "center selection horizontal
cg@60
  2649
    "
cg@60
  2650
    self centerSelection:[:aPoint| aPoint x] orientation:#x
cg@60
  2651
cg@60
  2652
cg@60
  2653
!
cg@60
  2654
cg@60
  2655
centerSelectionVer
cg@60
  2656
    "center selection vertical
cg@60
  2657
    "
cg@60
  2658
    self centerSelection:[:aPoint| aPoint y] orientation:#y
cg@60
  2659
!
cg@60
  2660
ca@72
  2661
extentToFrame:toWhat do:aBlock
ca@72
  2662
    "align to frame (Left Right ...) and perform the block on a frameLayout
ca@72
  2663
    "
ca@72
  2664
    |layout type|
ca@72
  2665
ca@72
  2666
    type := ('extent', toWhat asString) asSymbol.
ca@72
  2667
ca@72
  2668
    self transaction:type selectionDo:[:aView|
cg@1120
  2669
	layout := self class asLayoutFrameFromView:aView.
cg@1120
  2670
cg@1120
  2671
	layout notNil ifTrue:[
cg@1120
  2672
	    self createUndoLayout:aView.
cg@1120
  2673
	    aBlock value:layout.
cg@1120
  2674
	    aView geometryLayout:layout.
cg@1120
  2675
	    self elementChangedSize:aView.
cg@1120
  2676
	]
ca@72
  2677
    ]
ca@72
  2678
!
ca@72
  2679
cg@60
  2680
spreadSelectionHor
ca@61
  2681
    "spread multiple selection horizontal
ca@61
  2682
    "
ca@128
  2683
    |sumWidths min max viewsInOrder topsInOrder count space sel|
ca@128
  2684
ca@128
  2685
    sel := self moveableSelection.
ca@128
  2686
ca@128
  2687
    (sel notNil and:[self numberOfSelections > 1]) ifFalse:[
cg@1120
  2688
	^ self
cg@60
  2689
    ].
cg@60
  2690
ca@61
  2691
    self withSelectionHiddenDo:[
cg@1120
  2692
	count := 0.
cg@1120
  2693
	sumWidths := 0.
cg@1120
  2694
	max := 0.
cg@1120
  2695
cg@1120
  2696
	self selectionDo:[:aView |
cg@1120
  2697
	    sumWidths := sumWidths + aView width.
cg@1120
  2698
cg@1120
  2699
	    min isNil ifTrue:[min := aView left]
cg@1120
  2700
		     ifFalse:[min := min min:(aView left)].
cg@1120
  2701
cg@1120
  2702
	    max := max max:(aView right).
cg@1120
  2703
	    count := count + 1
cg@1120
  2704
	].
cg@1120
  2705
	viewsInOrder := Array withAll:sel.
cg@1120
  2706
	topsInOrder  := viewsInOrder collect:[:aView | aView left].
cg@1120
  2707
	topsInOrder sortWith:viewsInOrder.
cg@1120
  2708
cg@1120
  2709
	space := (((max - min) - sumWidths) / (count - 1)) rounded asInteger.
cg@1120
  2710
cg@1120
  2711
	self transaction:#spreadHorizontal objects:viewsInOrder do:[:aView|
cg@1120
  2712
	    |delta|
cg@1120
  2713
cg@1120
  2714
	    delta := min - aView computeOrigin x.
cg@1120
  2715
	    self shiftLayout:aView left:delta right:delta.
cg@1120
  2716
	    min := min + aView computeExtent x + space
cg@1120
  2717
	]
ca@61
  2718
    ].
ca@225
  2719
    self layoutChanged
cg@60
  2720
cg@60
  2721
!
cg@60
  2722
cg@60
  2723
spreadSelectionVer
ca@61
  2724
    "spread multiple selection vertical
ca@61
  2725
    "
ca@128
  2726
    |sumHeights min max viewsInOrder topsInOrder count space sel|
ca@128
  2727
ca@128
  2728
    sel := self moveableSelection.
ca@128
  2729
ca@128
  2730
    (sel notNil and:[self numberOfSelections > 1]) ifFalse:[
cg@1120
  2731
	^ self
cg@60
  2732
    ].
cg@60
  2733
ca@61
  2734
    self withSelectionHiddenDo:[
cg@1120
  2735
	count := 0.
cg@1120
  2736
	sumHeights := 0.
cg@1120
  2737
	max := 0.
cg@1120
  2738
cg@1120
  2739
	self selectionDo:[:aView |
cg@1120
  2740
	    sumHeights := sumHeights + aView height.
cg@1120
  2741
cg@1120
  2742
	    min isNil ifTrue:[min := aView top]
cg@1120
  2743
		     ifFalse:[min := min min:(aView top)].
cg@1120
  2744
cg@1120
  2745
	    max   := max max:(aView bottom).
cg@1120
  2746
	    count := count + 1
cg@1120
  2747
	].
cg@1120
  2748
	viewsInOrder := Array withAll:sel.
cg@1120
  2749
	topsInOrder  := viewsInOrder collect:[:aView|aView top].
cg@1120
  2750
	topsInOrder sortWith:viewsInOrder.
cg@1120
  2751
cg@1120
  2752
	space := (((max - min) - sumHeights) / (count - 1)) rounded asInteger.
cg@1120
  2753
cg@1120
  2754
	self transaction:#spreadVertical objects:viewsInOrder do:[:aView|
cg@1120
  2755
	    |delta|
cg@1120
  2756
cg@1120
  2757
	    delta := min - aView computeOrigin y.
cg@1120
  2758
	    self shiftLayout:aView top:delta bottom:delta.
cg@1120
  2759
	    min := min + aView height + space
cg@1120
  2760
	]
ca@61
  2761
    ].
ca@225
  2762
    self layoutChanged
cg@60
  2763
! !
cg@60
  2764
cg@1715
  2765
!UIObjectView methodsFor:'user actions-undo history'!
cg@60
  2766
ca@72
  2767
enableUndoHistory:aState
cg@1954
  2768
    "enable or disable undo history"
cg@1954
  2769
ca@72
  2770
    undoHistory enabled:aState
ca@72
  2771
!
ca@72
  2772
cg@60
  2773
openUndoMenu
ca@149
  2774
    self select:nil.
ca@138
  2775
    undoHistory openUndoMenu
cg@60
  2776
!
cg@60
  2777
cg@60
  2778
removeUndoHistory
cg@1954
  2779
    "delete total undo history"
cg@1954
  2780
cg@1954
  2781
    undoHistory initializeFor:self.
cg@1954
  2782
    self undoHistoryChanged
cg@60
  2783
!
cg@60
  2784
cg@60
  2785
undoLast
cg@1954
  2786
    "undo last action"
cg@1954
  2787
ca@138
  2788
    |newSel oldSel|
ca@138
  2789
cg@1954
  2790
    undoHistory notEmpty ifTrue:[
cg@1954
  2791
        self hasSelection ifTrue:[
cg@1954
  2792
            oldSel := OrderedCollection new.
cg@1954
  2793
            newSel := OrderedCollection new.
cg@1954
  2794
cg@1954
  2795
            self selectionDo:[:aView||p|
cg@1954
  2796
                (p := self propertyOfView:aView) notNil ifTrue:[
cg@1954
  2797
                    oldSel add:(p identifier)
cg@1954
  2798
                ]
cg@1954
  2799
            ].
cg@1954
  2800
            self setSelection:nil withRedraw:true.
cg@1954
  2801
        ].
cg@1954
  2802
cg@1954
  2803
        self withSelectionHiddenDo:[undoHistory undoLast:1].
cg@1954
  2804
cg@1954
  2805
        oldSel notNil ifTrue:[
cg@1954
  2806
            oldSel do:[:id||v|
cg@1954
  2807
                (v := self findViewWithId:id) notNil ifTrue:[newSel add:v]
cg@1954
  2808
            ].
cg@1954
  2809
            self select:newSel.
cg@1954
  2810
        ].
cg@1954
  2811
        self undoHistoryChanged.
ca@61
  2812
    ].
cg@60
  2813
! !
cg@60
  2814
ca@1672
  2815
!UIObjectView::PostEventHandler methodsFor:'event handling'!
ca@1672
  2816
ca@1672
  2817
processEvent:anEvent
ca@1672
  2818
    |evView|
ca@1672
  2819
ca@1672
  2820
    anEvent isDamage ifTrue:[
ca@1672
  2821
        onView testMode ifFalse:[
ca@1672
  2822
            evView := anEvent view.
ca@1672
  2823
ca@1672
  2824
            (onView isSelected:evView) ifTrue:[
ca@1672
  2825
                onView showSelected:evView.
ca@1672
  2826
            ]
ca@1672
  2827
        ]
ca@1672
  2828
    ].
ca@1672
  2829
    ^ false
ca@1672
  2830
! !
ca@1672
  2831
ca@1672
  2832
!UIObjectView::PostEventHandler methodsFor:'instance creation'!
ca@1672
  2833
ca@1672
  2834
onView:aView
ca@1672
  2835
    onView := aView.
ca@1672
  2836
! !
ca@1672
  2837
ca@1437
  2838
!UIObjectView::ResizeData methodsFor:'accessing'!
ca@1437
  2839
cg@2536
  2840
checkForChangeSelector
cg@2536
  2841
    ^ checkForChangeSelector
cg@2536
  2842
!
cg@2536
  2843
ca@1437
  2844
delta