UIObjectView.st
author ca
Fri, 14 Feb 1997 16:39:11 +0100
changeset 47 5e4319953a0b
parent 44 cb65ce16c150
child 49 7f58dd5fc836
permissions -rw-r--r--
*** empty log message ***
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
44
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
     1
ObjectView subclass:#UIObjectView
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
     2
	instanceVariableNames:'inputView testMode undoHistory copiedExtent resizedObject
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
     3
		resizeSelector createInWidget createFrame createdObject
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
     4
		createClass'
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
     5
	classVariableNames:''
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
     6
	poolDictionaries:''
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
     7
	category:'Interface-UIPainter'
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
     8
!
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
     9
47
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
    10
Object subclass:#UndoHistory
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
    11
	instanceVariableNames:'history transaction enabled modifiedAction'
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
    12
	classVariableNames:''
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
    13
	poolDictionaries:''
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
    14
	privateIn:UIObjectView
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
    15
!
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
    16
44
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
    17
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
    18
!UIObjectView class methodsFor:'defaults'!
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
    19
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
    20
defaultGrid
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
    21
    ^ 4 @ 4
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
    22
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
    23
!
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
    24
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
    25
gridShown
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
    26
    ^ false
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
    27
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
    28
!
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
    29
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
    30
handleSize
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
    31
    "size of blob drawn for handles"
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
    32
    ^ 4
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
    33
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
    34
!
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
    35
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
    36
hitDelta
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
    37
    ^ 4
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
    38
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
    39
! !
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
    40
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
    41
!UIObjectView methodsFor:'accessing'!
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
    42
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
    43
gridParameters
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
    44
    "used by defineGrid, and in a separate method for
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
    45
     easier redefinition in subclasses. 
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
    46
     Returns the grid parameters in an array of 7 elements,
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
    47
     which control the appearance of the grid-pattern.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
    48
     the elements are:
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
    49
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
    50
        bigStepH        number of pixels horizontally between 2 major steps
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
    51
        bigStepV        number of pixels vertically between 2 major steps
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
    52
        littleStepH     number of pixels horizontally between 2 minor steps
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
    53
        littleStepV     number of pixels vertically between 2 minor steps
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
    54
        gridAlignH      number of pixels for horizontal grid align (pointer snap)
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
    55
        gridAlignV      number of pixels for vertical grid align (pointer snap)
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
    56
        docBounds       true, if document boundary should be shown
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
    57
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
    58
     if littleStepH/V are nil, only bigSteps are drawn.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
    59
    "
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
    60
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
    61
    ^ #(10 10 nil nil 10 10 false)
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
    62
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
    63
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
    64
!
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
    65
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
    66
hideGrid
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
    67
    gridShown ifTrue:[
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
    68
        self withSelectionHiddenDo:[
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
    69
            super hideGrid
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
    70
        ]
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
    71
    ]
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
    72
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
    73
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
    74
!
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
    75
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
    76
showGrid
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
    77
    self withSelectionHiddenDo:[
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
    78
        super showGrid
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
    79
    ]
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
    80
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
    81
    "Modified: 5.9.1995 / 12:47:46 / claus"
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
    82
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
    83
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
    84
!
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
    85
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
    86
testMode
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
    87
    "returns testMode
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
    88
    "
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
    89
    ^ testMode
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
    90
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
    91
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
    92
!
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
    93
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
    94
testMode:aBoolean
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
    95
    "change testMode
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
    96
    "
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
    97
    (aBoolean == testMode) ifFalse:[
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
    98
        testMode := aBoolean.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
    99
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   100
        testMode ifTrue:[
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   101
            self unselect.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   102
            inputView unrealize
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   103
        ] ifFalse:[
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   104
            inputView raise.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   105
            inputView realize
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   106
        ]
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   107
    ]
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   108
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   109
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   110
! !
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   111
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   112
!UIObjectView methodsFor:'cut & paste'!
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   113
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   114
convertForPaste:something
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   115
    Transcript showCR:'convertForPaste'.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   116
    ^ nil
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   117
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   118
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   119
!
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   120
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   121
deleteSelection
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   122
    "delete the selection
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   123
    "
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   124
    undoHistory transactionNamed:'delete' do:[
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   125
        super deleteSelection
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   126
    ].
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   127
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   128
! !
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   129
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   130
!UIObjectView methodsFor:'dragging object move'!
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   131
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   132
doObjectMove:aPoint
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   133
    "move selection
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   134
    "
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   135
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   136
    selection isCollection ifTrue:[^ self].
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   137
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   138
    movedObject isNil ifTrue:[
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   139
        (movedObject := selection) isNil ifTrue:[
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   140
            ^ self
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   141
        ].
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   142
        super unselect.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   143
        moveDelta := aPoint - movedObject computeOrigin.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   144
        self invertOutlineOf:movedObject
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   145
    ].
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   146
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   147
    self moveObject:movedObject to:(aPoint - moveDelta)
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   148
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   149
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   150
!
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   151
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   152
endObjectMove
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   153
    "cleanup after object move"
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   154
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   155
    movedObject notNil ifTrue:[
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   156
        self invertOutlineOf:movedObject.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   157
        self setDefaultActions.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   158
        self select:movedObject.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   159
        movedObject := nil
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   160
    ].
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   161
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   162
    "Modified: 5.9.1995 / 12:20:31 / claus"
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   163
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   164
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   165
!
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   166
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   167
startObjectMove:aView at:aPoint
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   168
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   169
    super startObjectMove:aView at:aPoint.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   170
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   171
    aView notNil ifTrue:[
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   172
        undoHistory transactionNamed:'move' do:[
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   173
            self undoBlockPositionChanged:aView
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   174
        ]
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   175
    ]
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   176
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   177
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   178
!
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   179
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   180
startSelectMoreOrMove:aPoint
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   181
    "add/remove to/from selection"
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   182
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   183
    |anObject|
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   184
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   185
    testMode ifTrue:[^ self].
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   186
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   187
    anObject := self findObjectAtVisible:aPoint.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   188
    anObject notNil ifTrue:[
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   189
        (self isSelected:anObject) ifTrue:[
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   190
            self removeFromSelection:anObject
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   191
        ] ifFalse:[
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   192
            self addToSelection:anObject
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   193
        ]
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   194
    ]
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   195
!
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   196
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   197
startSelectOrMove:aPoint
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   198
    "a button is pressed at a point
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   199
    "
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   200
    |anObject b|
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   201
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   202
    testMode ifTrue:[^ self].
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   203
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   204
    "if there is one selection and point hits handle, start a resize
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   205
    "
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   206
    self singleSelection notNil ifTrue:[
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   207
        b := self whichHandleOf:selection isHitBy:aPoint.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   208
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   209
        (b notNil and:[b ~~ #view]) ifTrue:[
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   210
            ^ self startResizeBorder:b of:selection at:aPoint.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   211
        ]
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   212
    ].
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   213
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   214
    anObject := self findObjectAtVisible:aPoint.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   215
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   216
    "nothing is selected
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   217
    "
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   218
    anObject isNil ifTrue:[
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   219
        ^ self unselect
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   220
    ].
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   221
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   222
    "object not in selection; clear selection and add anObject to selection
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   223
    "
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   224
    (self isSelected:anObject) ifFalse:[
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   225
        super unselect.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   226
        self select:anObject.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   227
    ] ifTrue:[
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   228
        selection isCollection ifTrue:[
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   229
            ^ self removeFromSelection:anObject.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   230
        ]
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   231
    ].
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   232
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   233
    "prepare move operation for an object
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   234
    "
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   235
    motionAction := [:movePoint|
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   236
        (aPoint dist:movePoint) > 2.0 ifTrue:[
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   237
            self startObjectMove:anObject at:aPoint
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   238
        ]
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   239
    ].
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   240
    releaseAction := [self setDefaultActions].
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   241
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   242
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   243
! !
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   244
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   245
!UIObjectView methodsFor:'event handling'!
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   246
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   247
doKeyInput:key
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   248
    ^ self
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   249
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   250
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   251
!
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   252
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   253
elementChanged:aView 
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   254
    "some element has been changed - kludge to force a resizing
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   255
     operation (for child layout recomputation) in its superView"
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   256
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   257
    aView superView sizeChanged:nil.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   258
    self changed:#any.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   259
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   260
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   261
!
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   262
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   263
elementChangedLayout:aView 
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   264
    "some element has been changed - kludge to force a resizing
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   265
     operation (for child layout recomputation) in its superView"
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   266
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   267
    aView superView sizeChanged:nil.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   268
    self changed:#layout.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   269
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   270
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   271
!
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   272
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   273
exposeX:x y:y width:w height:h
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   274
    "handle an expose event from device; redraw selection
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   275
    "
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   276
    super exposeX:x y:y width:w height:h.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   277
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   278
    selection notNil ifTrue:[
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   279
        self selectionDo:[:v | self showSelected:v]
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   280
    ]
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   281
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   282
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   283
!
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   284
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   285
keyPress:key x:x y:y
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   286
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   287
    key == #InspectIt ifTrue:[
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   288
        ^ self inspectSelection
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   289
    ].
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   290
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   291
    (key == #Delete or:[key == #BackSpace]) ifTrue: [
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   292
        selection notNil ifTrue:[
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   293
            self deleteSelection
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   294
        ]
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   295
    ] ifFalse:[
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   296
        keyPressAction notNil ifTrue:[
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   297
            keyPressAction value:key
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   298
        ]
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   299
    ]
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   300
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   301
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   302
!
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   303
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   304
processEvent:anEvent
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   305
    "catch expose events for components, and redraw its handles after
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   306
     the redraw when this happens
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   307
    "
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   308
    |view|
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   309
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   310
    selection notNil ifTrue:[
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   311
        anEvent type == #damage ifTrue:[
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   312
            view := anEvent view.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   313
            (selection == view
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   314
            or:[selection isCollection
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   315
                and:[selection includes:view]]) ifTrue:[
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   316
                    self showSelected:view
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   317
            ]
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   318
        ]
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   319
    ].
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   320
    ^ false.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   321
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   322
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   323
!
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   324
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   325
sizeChanged:how
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   326
    self withSelectionHiddenDo:[
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   327
        super sizeChanged:how
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   328
    ]
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   329
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   330
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   331
! !
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   332
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   333
!UIObjectView methodsFor:'initialization'!
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   334
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   335
initialize
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   336
    super initialize.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   337
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   338
    "funny: since I do not want the created widgets to get pointer
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   339
     events, I put an InputView on top of them, which catches those events
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   340
     and passes them back to me - have to take care, that this inputView
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   341
     is always on top
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   342
    "
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   343
    inputView := InputView origin:0.0@0.0 extent:1.0@1.0 in:self.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   344
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   345
    inputView eventReceiver:self.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   346
    inputView enableButtonEvents.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   347
    inputView enableButtonMotionEvents.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   348
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   349
    undoHistory := UndoHistory new.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   350
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   351
    undoHistory modifiedAction:[:what|
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   352
        self changed:#undoHistory with:what
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   353
    ].
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   354
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   355
    testMode := false.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   356
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   357
    (self class gridShown) ifTrue:[
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   358
        super showGrid
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   359
    ].
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   360
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   361
!
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   362
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   363
realize
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   364
    super realize.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   365
    self windowGroup postEventHook:self
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   366
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   367
! !
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   368
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   369
!UIObjectView methodsFor:'misc'!
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   370
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   371
cursor:aCursor
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   372
    inputView realized ifTrue:[
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   373
        inputView cursor:aCursor
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   374
    ].
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   375
    super cursor:aCursor
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   376
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   377
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   378
!
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   379
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   380
invertOutlineOf:anObject
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   381
    |delta|
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   382
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   383
    self clippedByChildren:false.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   384
    delta := (anObject originRelativeTo:self) - anObject origin.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   385
    self xoring:[
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   386
        self displayRectangle:((anObject origin + delta) extent:anObject extent).
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   387
    ].
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   388
    self clippedByChildren:true.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   389
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   390
    "Modified: 5.9.1995 / 12:25:25 / claus"
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   391
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   392
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   393
!
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   394
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   395
showDragging:something offset:anOffset
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   396
    "drag around a View"
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   397
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   398
    |top|
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   399
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   400
    self forEach:something do:[:anObject |
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   401
        self drawRectangle:((anObject origin + anOffset) extent:(anObject extent))
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   402
    ]
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   403
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   404
! !
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   405
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   406
!UIObjectView methodsFor:'object creation'!
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   407
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   408
doDragCreate:aPoint
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   409
    "do a widget create drag
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   410
    "
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   411
    |p|
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   412
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   413
    p := self alignToGrid:aPoint.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   414
    createFrame corner:(p - (createInWidget originRelativeTo:self)).
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   415
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   416
    (createFrame extent x < 10) ifTrue:[
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   417
        createFrame extent x:10
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   418
    ].
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   419
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   420
    (createFrame extent y < 10) ifTrue:[
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   421
        createFrame extent y:10
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   422
    ].
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   423
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   424
    self invertOutlineOf:createdObject.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   425
    createdObject origin:(createFrame origin) extent:(createFrame extent).
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   426
    self invertOutlineOf:createdObject.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   427
!
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   428
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   429
endCreate
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   430
    "end a widget create drag
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   431
    "
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   432
    self invertOutlineOf:createdObject.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   433
    self cursor:oldCursor.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   434
    inputView raise.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   435
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   436
    createdObject geometryLayout:(createdObject bounds asLayout).
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   437
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   438
    self changed:#tree.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   439
    self select:createdObject.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   440
    createdObject := nil.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   441
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   442
    pressAction   := [:pressPoint | self startSelectOrMove:pressPoint].
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   443
    motionAction  := [:movePoint | true].
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   444
    releaseAction := [ true ].
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   445
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   446
    self cursor:Cursor normal.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   447
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   448
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   449
!
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   450
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   451
initializeCreatedObject:anObject
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   452
    self subclassResponsibility
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   453
!
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   454
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   455
startCreate:aPoint
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   456
    "start a widget create
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   457
    "
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   458
    |props index startPoint|
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   459
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   460
    createClass isNil ifTrue:[
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   461
        ^ self
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   462
    ].
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   463
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   464
    startPoint    := self alignToGrid:aPoint.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   465
    motionAction  := [:movePoint | self doDragCreate:movePoint].
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   466
    releaseAction := [self endCreate].
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   467
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   468
    (selection isNil or:[selection isKindOf:Collection]) ifTrue:[
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   469
        createInWidget := self findObjectIn:self at:aPoint
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   470
    ] ifFalse:[
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   471
        createInWidget := self findObjectIn:selection at:aPoint
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   472
    ].
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   473
    super unselect.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   474
    self select:createInWidget.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   475
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   476
    oldCursor := cursor.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   477
    self cursor:(Cursor leftHand).
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   478
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   479
    createInWidget isNil ifTrue:[
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   480
        createdObject  := createClass in:self.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   481
        createInWidget := self.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   482
    ] ifFalse:[
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   483
        createdObject := createClass new.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   484
        createInWidget addSubView:createdObject.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   485
    ].
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   486
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   487
    createFrame := Rectangle origin:(startPoint - (createInWidget originRelativeTo:self))
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   488
                             corner:startPoint.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   489
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   490
    createdObject origin:(createFrame origin).
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   491
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   492
    undoHistory transactionNamed:'create' do:[
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   493
        self initializeCreatedObject:createdObject.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   494
    ].
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   495
    createdObject realize.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   496
    self invertOutlineOf:createdObject.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   497
! !
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   498
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   499
!UIObjectView methodsFor:'private handles'!
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   500
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   501
handlesOf:aComponent do:aBlock
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   502
    |delta layout vertical horizontal|
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   503
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   504
    layout := aComponent geometryLayout.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   505
    delta  := (aComponent originRelativeTo:self) - aComponent origin.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   506
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   507
    (layout isLayout not or:[layout isLayoutFrame]) ifTrue:[
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   508
        vertical   := self isVerticalResizable:aComponent.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   509
        horizontal := self isHorizontalResizable:aComponent.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   510
    ] ifFalse:[
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   511
        vertical   := false.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   512
        horizontal := false.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   513
    ].
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   514
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   515
    horizontal ifTrue:[
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   516
        aBlock value:(aComponent leftCenter   + delta) value:#left.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   517
        aBlock value:(aComponent rightCenter  + delta) value:#right.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   518
    ].
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   519
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   520
    vertical ifTrue:[
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   521
        aBlock value:(aComponent topCenter    + delta) value:#top.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   522
        aBlock value:(aComponent bottomCenter + delta) value:#bottom.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   523
    ].
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   524
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   525
    (horizontal and:[vertical]) ifTrue:[
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   526
        aBlock value:(aComponent origin     + delta) value:#origin.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   527
        aBlock value:(aComponent corner     + delta) value:#corner.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   528
        aBlock value:(aComponent topRight   + delta) value:#topRight.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   529
        aBlock value:(aComponent bottomLeft + delta) value:#bottomLeft.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   530
    ] ifFalse:[
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   531
        aBlock value:(aComponent origin     + delta) value:#view.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   532
        aBlock value:(aComponent corner     + delta) value:#view.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   533
        aBlock value:(aComponent topRight   + delta) value:#view.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   534
        aBlock value:(aComponent bottomLeft + delta) value:#view.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   535
    ].
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   536
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   537
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   538
!
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   539
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   540
showSelected:aComponent
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   541
    |delta oldPaint|
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   542
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   543
    self paint:Color black. 
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   544
    self clippedByChildren:false. 
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   545
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   546
    self handlesOf:aComponent do:[:pnt :what |
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   547
        what == #view ifTrue:[self displayRectangle:(pnt - (4@4) extent:7@7)]
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   548
                     ifFalse:[self    fillRectangle:(pnt - (4@4) extent:7@7)]
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   549
    ].
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   550
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   551
    self clippedByChildren:true.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   552
    self paint:oldPaint.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   553
!
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   554
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   555
showUnselected:aComponent
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   556
    |delta r oldPaint|
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   557
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   558
    r := aComponent origin extent:8@8.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   559
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   560
    self clippedByChildren:false. 
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   561
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   562
    self handlesOf:aComponent do:[:pnt :what |
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   563
        self clearRectangle:(pnt - (4@4) extent:7@7).
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   564
    ].
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   565
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   566
    self clippedByChildren:true. 
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   567
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   568
    "/ must redraw all components which are affected b the handles
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   569
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   570
    r := (aComponent originRelativeTo:self) - (4@4)
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   571
             extent:(aComponent extent + (4@4)).
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   572
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   573
    subViews do:[:anotherComponent |
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   574
        |absOrg absFrame|
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   575
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   576
        anotherComponent ~~ inputView ifTrue:[
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   577
            absOrg := anotherComponent originRelativeTo:self.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   578
            absFrame := absOrg extent:(anotherComponent extent).
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   579
            (absFrame intersects:r) ifTrue:[
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   580
                anotherComponent withAllSubViewsDo:[:v |
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   581
                    v clear.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   582
                    v exposeX:0 y:0 width:9999 height:9999.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   583
                ]
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   584
            ]
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   585
        ]
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   586
    ]
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   587
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   588
!
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   589
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   590
whichHandleOf:aView isHitBy:aPoint
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   591
    |bounds|
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   592
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   593
    self handlesOf:aView do:[:pnt :what |
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   594
        ((pnt - (4@4) extent:7@7) containsPoint:aPoint) ifTrue:[
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   595
            ^ what
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   596
        ].
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   597
    ].
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   598
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   599
    ^ #view
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   600
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   601
    "Modified: 5.9.1995 / 14:39:34 / claus"
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   602
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   603
! !
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   604
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   605
!UIObjectView methodsFor:'private resizing-subviews'!
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   606
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   607
resize:aView bottom:aPoint
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   608
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   609
    undoHistory disabledTransitionDo:[
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   610
        self shifLayout:aView top:0 bottom:((aPoint y) - (aView computeCorner y))
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   611
    ]
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   612
!
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   613
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   614
resize:aView corner:aPoint
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   615
    |delta|
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   616
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   617
    delta := aPoint - aView computeCorner.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   618
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   619
    undoHistory disabledTransitionDo:[
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   620
        self shifLayout:aView top:0 bottom:(delta y) left:0 right:(delta x)
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   621
    ]
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   622
!
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   623
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   624
resize:aView left:aPoint
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   625
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   626
    undoHistory disabledTransitionDo:[
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   627
        self shifLayout:aView left:((aPoint x) - (aView computeOrigin x)) right:0
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   628
    ]
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   629
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   630
!
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   631
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   632
resize:aView right:aPoint
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   633
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   634
    undoHistory disabledTransitionDo:[
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   635
        self shifLayout:aView left:0 right:((aPoint x) - (aView computeCorner x))
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   636
    ]
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   637
!
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   638
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   639
resize:aView top:aPoint
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   640
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   641
    undoHistory disabledTransitionDo:[
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   642
        self shifLayout:aView top:((aPoint y) - (aView computeOrigin y)) bottom:0
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   643
    ]
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   644
! !
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   645
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   646
!UIObjectView methodsFor:'private shift-layout'!
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   647
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   648
shifLayout:aView left:l right:r
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   649
    "shift layout for a view; in case of an open transaction, the
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   650
     undoAction will be defined
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   651
    "
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   652
    self shifLayout:aView top:0 bottom:0 left:l right:r
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   653
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   654
!
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   655
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   656
shifLayout:aView top:t bottom:b
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   657
    "shift layout for a view; in case of an open transaction, the
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   658
     undoAction will be defined
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   659
    "
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   660
    self shifLayout:aView top:t bottom:b left:0 right:0
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   661
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   662
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   663
!
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   664
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   665
shifLayout:aView top:t bottom:b left:l right:r
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   666
    "shift layout for a view; in case of an open transaction, the
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   667
     undoAction will be defined
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   668
    "
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   669
    |layout|
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   670
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   671
    self undoBlockPositionChanged:aView.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   672
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   673
    layout := aView geometryLayout.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   674
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   675
    layout leftOffset:(layout leftOffset + l)
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   676
            topOffset:(layout topOffset  + t).
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   677
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   678
    layout isLayoutFrame ifTrue:[
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   679
        layout bottomOffset:(layout bottomOffset + b).
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   680
        layout  rightOffset:(layout rightOffset  + r).
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   681
    ].
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   682
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   683
    aView geometryLayout:layout.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   684
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   685
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   686
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   687
! !
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   688
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   689
!UIObjectView methodsFor:'private undo-actions'!
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   690
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   691
undoBlockDimensionChanged:aView
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   692
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   693
    undoHistory isTransactionOpen ifTrue:[
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   694
        |layout|
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   695
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   696
        layout := aView geometryLayout copy.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   697
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   698
        undoHistory addUndoBlock:[
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   699
            aView geometryLayout:layout.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   700
            aView superView sizeChanged:nil.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   701
        ]
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   702
    ]
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   703
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   704
!
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   705
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   706
undoBlockPositionChanged:aView
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   707
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   708
    undoHistory isTransactionOpen ifTrue:[
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   709
        |layout|
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   710
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   711
        layout := aView geometryLayout copy.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   712
        undoHistory addUndoBlock:[aView geometryLayout:layout]
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   713
    ]
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   714
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   715
! !
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   716
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   717
!UIObjectView methodsFor:'searching'!
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   718
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   719
findObjectAt:aPoint
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   720
    "find the origin/corner of the currentWidget"
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   721
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   722
     selection notNil ifTrue:[
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   723
        (selection isKindOf:Collection) ifTrue:[
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   724
            ^ self findObjectIn:(selection first) at:aPoint
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   725
        ].
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   726
        ^ self findObjectIn:selection at:aPoint
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   727
     ].
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   728
     ^ self findObjectIn:self at:aPoint
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   729
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   730
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   731
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   732
!
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   733
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   734
findObjectIn:aView at:aPoint
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   735
    "find the origin/corner of the currentWidget
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   736
    "
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   737
    |relPoint|
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   738
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   739
    aView isNil ifTrue:[^ nil].
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   740
    aView subViews notNil ifTrue:[
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   741
        relPoint := aPoint - (aView originRelativeTo:self).
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   742
        self subviewsOf:aView do:[:aView |
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   743
            |org ext|
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   744
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   745
            (aView isKindOf:InputView) ifFalse:[
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   746
                org := aView computeOrigin.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   747
                ext := aView computeExtent.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   748
                ((org extent:ext) containsPoint:relPoint) ifTrue:[
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   749
                    ^ aView
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   750
                ]
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   751
            ]
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   752
        ]
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   753
    ].
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   754
    (aView == self) ifTrue:[^ nil].
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   755
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   756
    ^ self findObjectIn:(aView superView) at:aPoint
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   757
!
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   758
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   759
whichBorderOf:aView isHitBy:aPoint
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   760
    |p r bw org|
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   761
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   762
    bw := aView borderWidth.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   763
    p := aPoint - (aView superView originRelativeTo:self).
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   764
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   765
    r := Rectangle origin:(aView origin)
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   766
                   extent:(aView width @ bw).
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   767
    (r containsPoint:p) ifTrue:[^ #top:].
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   768
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   769
    r origin:(aView left @ (aView bottom + bw)) extent:(aView width @ bw).
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   770
    (r containsPoint:p) ifTrue:[^ #bottom:].
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   771
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   772
    r top:(aView top).
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   773
    r extent:(bw @ aView height).
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   774
    (r containsPoint:p) ifTrue:[^ #left:].
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   775
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   776
    r origin:((aView right + bw) @ aView top).
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   777
    (r containsPoint:p) ifTrue:[^ #right:].
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   778
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   779
    ^ nil
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   780
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   781
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   782
! !
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   783
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   784
!UIObjectView methodsFor:'selections'!
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   785
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   786
addToSelection:something
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   787
    (testMode or:[something == selection]) ifFalse:[
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   788
        selection ~~ something ifTrue:[
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   789
            super addToSelection:something.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   790
            self changed:#selection.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   791
        ]
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   792
    ]
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   793
!
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   794
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   795
inspectSelection
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   796
    self singleSelectionDo:[:aView |
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   797
        aView inspect
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   798
    ]
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   799
!
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   800
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   801
removeFromSelection:something
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   802
    super removeFromSelection:something.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   803
    self changed:#selection
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   804
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   805
!
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   806
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   807
select:something
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   808
    (testMode or:[something == selection]) ifFalse:[
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   809
        super select:something.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   810
        self changed:#selection
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   811
    ]
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   812
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   813
!
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   814
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   815
selection
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   816
    ^ selection
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   817
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   818
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   819
!
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   820
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   821
selectionFindMinimum:aOneArgBlock
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   822
    "returns the minimum value from the block evaluated on each view
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   823
     in the selection
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   824
    "
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   825
    |min val|
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   826
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   827
    self selectionDo:[:aView|
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   828
        val := aOneArgBlock value:aView.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   829
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   830
        min isNil ifTrue:[min := val]
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   831
                 ifFalse:[min := min min:val]
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   832
    ].
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   833
    ^ min
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   834
!
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   835
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   836
selectionHiddenDo:aBlock
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   837
    "apply block to every object in selection"
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   838
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   839
    self selectionDo:[:aView |
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   840
        self showUnselected:aView.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   841
    ].
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   842
    device flush.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   843
    aBlock value.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   844
    self selectionDo:[:aView |
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   845
        self showSelected:aView
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   846
    ]
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   847
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   848
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   849
!
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   850
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   851
singleSelection
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   852
    "returns single selection or nil
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   853
    "
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   854
    (selection isKindOf:SimpleView) ifTrue:[^ selection]
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   855
                                   ifFalse:[^ nil]
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   856
!
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   857
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   858
singleSelectionDo:aBlock
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   859
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   860
    self singleSelection notNil ifTrue:[
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   861
        aBlock value:selection
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   862
    ]
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   863
!
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   864
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   865
unselect
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   866
    selection notNil ifTrue:[
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   867
        super unselect.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   868
        self changed:#selection
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   869
    ]
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   870
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   871
!
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   872
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   873
withSelectionHiddenDo:aBlock
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   874
    "evaluate aBlock while selection is hidden"
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   875
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   876
    |sel|
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   877
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   878
    selection isNil ifTrue:[
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   879
        aBlock value
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   880
    ] ifFalse:[
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   881
        sel := selection.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   882
        super unselect.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   883
        aBlock value.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   884
        super select:sel
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   885
    ]
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   886
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   887
    "Modified: 6.9.1995 / 01:46:16 / claus"
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   888
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   889
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   890
! !
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   891
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   892
!UIObjectView methodsFor:'testing'!
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   893
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   894
canMove:something
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   895
    ^ true
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   896
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   897
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   898
!
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   899
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   900
isHorizontalResizable:aComponent
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   901
    ^ self subclassResponsibility
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   902
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   903
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   904
!
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   905
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   906
isVerticalResizable:aComponent
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   907
    ^ self subclassResponsibility
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   908
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   909
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   910
! !
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   911
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   912
!UIObjectView methodsFor:'user actions'!
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   913
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   914
createWidgetWithClass:aClass
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   915
    "prepare to create new widgets
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   916
    "
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   917
    createClass := aClass.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   918
    pressAction := [:pressPoint | self startCreate:pressPoint].
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   919
    self cursor:Cursor origin.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   920
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   921
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   922
!
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   923
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   924
undoAction
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   925
    undoHistory notEmpty ifTrue:[
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   926
        self unselect.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   927
        undoHistory undoLast
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   928
    ]
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   929
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   930
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   931
! !
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   932
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   933
!UIObjectView methodsFor:'user actions - dimension'!
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   934
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   935
copyExtent
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   936
    (selection isNil or:[selection isKindOf:Collection]) ifTrue:[
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   937
        ^ self warn:'exactly one element must be selected'.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   938
    ].
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   939
    copiedExtent := selection computeExtent
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   940
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   941
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   942
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   943
!
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   944
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   945
pasteExtent
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   946
    copiedExtent notNil ifTrue:[
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   947
        self transition:'paste extent' dimensionDo:[:v|
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   948
            self resize:v corner:(v computeOrigin + copiedExtent)
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   949
        ]    
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   950
    ]    
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   951
!
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   952
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   953
pasteHeight
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   954
    copiedExtent notNil ifTrue:[
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   955
        self transition:'paste height' dimensionDo:[:v|
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   956
            self resize:v bottom:(v computeOrigin + copiedExtent)
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   957
        ]    
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   958
    ]    
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   959
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   960
!
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   961
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   962
pasteWidth
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   963
    copiedExtent notNil ifTrue:[
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   964
        self transition:'paste width' dimensionDo:[:v|
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   965
            self resize:v right:(v computeOrigin + copiedExtent)
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   966
        ]    
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   967
    ]    
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   968
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   969
!
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   970
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   971
setDimension:aLayout
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   972
    |undoText|
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   973
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   974
    undoText := 'change layout'.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   975
    aLayout isLayout ifTrue:[
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   976
        undoText := 'change to layout frame'.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   977
        aLayout isAlignmentOrigin ifTrue:[
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   978
            undoText := 'change to layout alignOrigin'.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   979
        ] ifFalse:[
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   980
            aLayout isAlignmentOrigin ifTrue:[
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   981
                undoText := 'change to layout origin'.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   982
            ]
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   983
        ]
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   984
    ].
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   985
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   986
    self transition:undoText dimensionDo:[:v| v geometryLayout:(aLayout copy)]    
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   987
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   988
!
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   989
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   990
setToDefaultExtent
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   991
    self transition:'default extent' dimensionDo:[:v|
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   992
        self resize:v corner:(v computeOrigin + (v preferredExtent))
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   993
    ]    
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   994
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   995
!
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   996
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   997
setToDefaultHeight
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   998
    self transition:'default height' dimensionDo:[:v|
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
   999
        self resize:v bottom:(v computeOrigin + (v preferredExtent))
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1000
    ]    
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1001
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1002
!
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1003
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1004
setToDefaultWidth
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1005
    self transition:'default width' dimensionDo:[:v|
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1006
        self resize:v right:(v computeOrigin + (v preferredExtent))
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1007
    ]    
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1008
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1009
!
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1010
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1011
transition:what dimensionDo:aOneArgBlock
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1012
    "change dimension within a transaction for the selected elements by evaluating
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1013
     the block with the argument a view.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1014
    "
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1015
    self selectionHiddenDo:[
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1016
        undoHistory transactionNamed:what do:[
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1017
            self selectionDo:[:aView|
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1018
                self undoBlockDimensionChanged:aView.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1019
                aOneArgBlock value:aView.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1020
                self elementChangedLayout:aView.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1021
            ]
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1022
        ]
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1023
    ]
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1024
! !
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1025
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1026
!UIObjectView methodsFor:'user actions - move'!
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1027
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1028
basicMoveSelectionHorizontal:n
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1029
    "move left:  n < 0
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1030
     move right: n > 0
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1031
    "
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1032
    self selectionHiddenDo:[
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1033
        undoHistory transactionNamed:'move' do:[
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1034
            self selectionDo:[:aView|self shifLayout:aView left:n right:n]
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1035
        ].
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1036
        self changed:#layout
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1037
    ]
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1038
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1039
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1040
!
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1041
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1042
basicMoveSelectionVertical:n
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1043
    "move up:   n < 0
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1044
     move down: n > 0
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1045
    "
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1046
    self selectionHiddenDo:[
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1047
        undoHistory transactionNamed:'move' do:[
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1048
            self selectionDo:[:aView| self shifLayout:aView top:n bottom:n ]
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1049
        ].
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1050
        self changed:#layout
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1051
    ]
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1052
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1053
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1054
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1055
!
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1056
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1057
moveObject:anObject to:aPoint
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1058
    "move anObject to newOrigin, aPoint
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1059
    "
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1060
    |dX dY org delta|
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1061
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1062
    anObject notNil ifTrue:[
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1063
        self invertOutlineOf:anObject.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1064
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1065
        org := anObject computeOrigin.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1066
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1067
        delta := aPoint - org.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1068
        delta := (self alignToGrid:aPoint) - org.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1069
        dX := delta x.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1070
        dY := delta y.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1071
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1072
        undoHistory disabledTransitionDo:[
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1073
            self shifLayout:anObject top:dY bottom:dY left:dX right:dX
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1074
        ].
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1075
        self elementChangedLayout:anObject.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1076
        self invertOutlineOf:anObject.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1077
    ]
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1078
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1079
!
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1080
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1081
moveSelectionDown
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1082
    self moveSelectionDown:1
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1083
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1084
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1085
!
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1086
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1087
moveSelectionDown10
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1088
    self moveSelectionDown:10
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1089
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1090
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1091
!
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1092
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1093
moveSelectionDown:n
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1094
    self basicMoveSelectionVertical:n
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1095
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1096
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1097
!
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1098
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1099
moveSelectionLeft
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1100
    self moveSelectionLeft:1
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1101
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1102
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1103
!
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1104
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1105
moveSelectionLeft10
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1106
    self moveSelectionLeft:10
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1107
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1108
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1109
!
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1110
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1111
moveSelectionLeft:n
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1112
    self basicMoveSelectionHorizontal:(n negated)
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1113
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1114
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1115
!
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1116
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1117
moveSelectionRight
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1118
    self moveSelectionRight:1
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1119
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1120
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1121
!
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1122
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1123
moveSelectionRight10
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1124
    self moveSelectionRight:10
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1125
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1126
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1127
!
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1128
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1129
moveSelectionRight:n
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1130
    self basicMoveSelectionHorizontal:n
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1131
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1132
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1133
!
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1134
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1135
moveSelectionUp
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1136
    self moveSelectionUp:1
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1137
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1138
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1139
!
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1140
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1141
moveSelectionUp10
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1142
    self moveSelectionUp:10
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1143
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1144
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1145
!
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1146
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1147
moveSelectionUp:n
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1148
    self basicMoveSelectionVertical:(n negated)
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1149
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1150
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1151
! !
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1152
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1153
!UIObjectView methodsFor:'user actions - position'!
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1154
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1155
alignSelectionBottom
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1156
    |bmost delta|
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1157
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1158
    self selectionHiddenDo:[
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1159
        bmost := 0.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1160
        self selectionDo:[:v| bmost := bmost max:(v computeCorner y)].
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1161
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1162
        undoHistory transactionNamed:'align' do:[
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1163
            self selectionDo:[:v|
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1164
                (delta := bmost - (v computeCorner y)) ~~ 0 ifTrue:[
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1165
                    self shifLayout:v top:delta bottom:delta
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1166
                ]
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1167
            ]
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1168
        ].
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1169
        self changed:#layout
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1170
    ]
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1171
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1172
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1173
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1174
!
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1175
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1176
alignSelectionCenterHor
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1177
    |counter centerX|
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1178
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1179
    self selectionHiddenDo:[
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1180
        counter := 0.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1181
        centerX := 0.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1182
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1183
        self selectionDo:[:v |
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1184
            centerX := centerX + (v computeCorner x + v computeOrigin x).
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1185
            counter := counter + 1.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1186
        ].
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1187
        centerX := centerX // (counter * 2).
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1188
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1189
        undoHistory transactionNamed:'align' do:[
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1190
            |newX oldX delta|
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1191
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1192
            self selectionDo:[:v|
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1193
                oldX  := v computeOrigin x.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1194
                newX  := centerX - ((v computeCorner x - oldX) // 2).
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1195
                delta := newX - oldX.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1196
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1197
                self shifLayout:v left:delta right:delta
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1198
            ]
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1199
        ].
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1200
        self changed:#layout
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1201
    ]
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1202
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1203
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1204
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1205
!
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1206
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1207
alignSelectionCenterVer
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1208
    |counter centerY|
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1209
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1210
    self selectionHiddenDo:[
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1211
        counter := 0.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1212
        centerY := 0.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1213
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1214
        self selectionDo:[:v |
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1215
            centerY := centerY + (v computeCorner y + v computeOrigin y).
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1216
            counter := counter + 1.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1217
        ].
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1218
        centerY := centerY // (counter * 2).
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1219
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1220
        undoHistory transactionNamed:'align' do:[
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1221
            |newY oldY delta|
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1222
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1223
            self selectionDo:[:v|
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1224
                oldY  := v computeOrigin y.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1225
                newY  := centerY - ((v computeCorner y - oldY) // 2).
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1226
                delta := newY - oldY.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1227
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1228
                self shifLayout:v top:delta bottom:delta
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1229
            ]
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1230
        ].
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1231
        self changed:#layout
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1232
    ]
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1233
!
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1234
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1235
alignSelectionLeft
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1236
    |lmost delta|
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1237
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1238
    self selectionHiddenDo:[
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1239
        lmost := self selectionFindMinimum:[:v| v computeOrigin x].
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1240
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1241
        undoHistory transactionNamed:'align' do:[
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1242
            self selectionDo:[:v|
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1243
                (delta := lmost - (v computeOrigin x)) ~~ 0 ifTrue:[
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1244
                    self shifLayout:v left:delta right:delta
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1245
                ]
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1246
            ]
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1247
        ].
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1248
        self changed:#layout
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1249
    ]
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1250
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1251
!
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1252
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1253
alignSelectionLeftAndRight
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1254
    |lmost rmost|
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1255
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1256
    self selectionHiddenDo:[
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1257
        lmost := self selectionFindMinimum:[:v| v computeOrigin x].
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1258
        rmost := 0.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1259
        self selectionDo:[:v | rmost := rmost max:(v computeCorner x)].
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1260
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1261
        undoHistory transactionNamed:'align' do:[
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1262
            self selectionDo:[:v|
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1263
                self shifLayout:v left:(lmost - (v computeOrigin x))
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1264
                                 right:(rmost - (v computeCorner x))
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1265
            ]
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1266
        ].
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1267
        self changed:#layout
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1268
    ]
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1269
!
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1270
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1271
alignSelectionRight
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1272
    |rmost delta|
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1273
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1274
    self selectionHiddenDo:[
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1275
        rmost := 0.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1276
        self selectionDo:[:v| rmost := rmost max:(v computeCorner x)].
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1277
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1278
        undoHistory transactionNamed:'align' do:[
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1279
            self selectionDo:[:v|
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1280
                (delta := rmost - (v computeCorner x)) ~~ 0 ifTrue:[
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1281
                    self shifLayout:v left:delta right:delta
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1282
                ]
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1283
            ]
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1284
        ].
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1285
        self changed:#layout
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1286
    ]
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1287
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1288
!
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1289
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1290
alignSelectionTop
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1291
    |tmost delta|
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1292
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1293
    self selectionHiddenDo:[
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1294
        tmost := self selectionFindMinimum:[:v| v computeOrigin y].
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1295
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1296
        undoHistory transactionNamed:'align' do:[
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1297
            self selectionDo:[:v||delta|
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1298
                (delta := tmost - (v computeOrigin y)) ~~ 0 ifTrue:[
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1299
                    self shifLayout:v top:delta bottom:delta
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1300
                ]
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1301
            ]
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1302
        ].
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1303
        self changed:#layout
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1304
    ]
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1305
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1306
!
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1307
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1308
alignSelectionTopAndBottom
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1309
    |tmost bmost|
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1310
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1311
    self selectionHiddenDo:[
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1312
        tmost := self selectionFindMinimum:[:v| v computeOrigin y].
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1313
        bmost := 0.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1314
        self selectionDo:[:v| bmost := bmost max:(v computeCorner y)].
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1315
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1316
        undoHistory transactionNamed:'align' do:[
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1317
            self selectionDo:[:v|
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1318
                self shifLayout:v top:(tmost - (v computeOrigin y))
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1319
                               bottom:(bmost - (v computeCorner y))
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1320
            ]
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1321
        ].
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1322
        self changed:#layout
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1323
    ]
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1324
!
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1325
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1326
centerSelection:aOneArgBlockXorY
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1327
    "center selection horizontal or vertical dependant on the block result( x or y).
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1328
     The argument to the block is the point.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1329
    "
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1330
    |superview min max delta val|
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1331
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1332
    self selectionHiddenDo:[
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1333
        max := 0.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1334
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1335
        self selectionDo:[:aView |
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1336
            superview isNil ifTrue:[
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1337
                superview := aView superView
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1338
            ] ifFalse:[
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1339
                (aView superView == superview) ifFalse:[
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1340
                    ^ self notify:'views must have same superview'.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1341
                ]
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1342
            ].
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1343
            val := aOneArgBlockXorY value:(aView computeOrigin).    
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1344
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1345
            min isNil ifTrue:[min := val]
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1346
                     ifFalse:[min := min min:val].
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1347
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1348
            val := aOneArgBlockXorY value:(aView computeCorner).
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1349
            max := max max:val.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1350
        ].
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1351
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1352
        val := aOneArgBlockXorY value:(superview computeExtent).
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1353
        max := (min + val - max) // 2.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1354
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1355
        max == min ifFalse:[
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1356
            delta := max - min.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1357
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1358
            undoHistory transactionNamed:'center' do:[
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1359
                self selectionDo:[:aView|
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1360
                    self shifLayout:aView top:delta bottom:delta]
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1361
            ]
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1362
        ].
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1363
        self changed:#layout
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1364
    ]
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1365
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1366
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1367
!
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1368
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1369
centerSelectionHor
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1370
    "center selection horizontal
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1371
    "
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1372
    self centerSelection:[:aPoint| aPoint x]
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1373
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1374
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1375
!
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1376
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1377
centerSelectionVer
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1378
    "center selection vertical
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1379
    "
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1380
    self centerSelection:[:aPoint| aPoint y]
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1381
!
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1382
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1383
spreadSelectionHor
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1384
    |sumWidths min max viewsInOrder topsInOrder count space|
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1385
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1386
    (selection isKindOf:Collection) ifFalse:[^ self].
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1387
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1388
    self selectionHiddenDo:[
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1389
        count := 0.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1390
        sumWidths := 0.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1391
        max := 0.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1392
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1393
        self selectionDo:[:aView |
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1394
            sumWidths := sumWidths + aView width.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1395
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1396
            min isNil ifTrue:[min := aView left]
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1397
                     ifFalse:[min := min min:(aView left)].
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1398
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1399
            max := max max:(aView right).
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1400
            count := count + 1
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1401
        ].
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1402
        viewsInOrder := Array withAll:selection.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1403
        topsInOrder  := viewsInOrder collect:[:aView | aView left].
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1404
        topsInOrder sortWith:viewsInOrder.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1405
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1406
        space := (((max - min) - sumWidths) / (count - 1)) rounded asInteger.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1407
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1408
        undoHistory transactionNamed:'spread' do:[
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1409
            viewsInOrder do:[:aView | 
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1410
                |delta|
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1411
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1412
                delta := min - aView computeOrigin x.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1413
                self shifLayout:aView left:delta right:delta.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1414
                min := min + aView computeExtent x + space
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1415
            ]
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1416
        ].
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1417
        self changed:#layout
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1418
    ]
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1419
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1420
!
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1421
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1422
spreadSelectionVer
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1423
    |sumHeights min max viewsInOrder topsInOrder count space|
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1424
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1425
    (selection isKindOf:Collection) ifFalse:[^ self].
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1426
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1427
    self selectionHiddenDo:[
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1428
        count := 0.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1429
        sumHeights := 0.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1430
        max := 0.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1431
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1432
        self selectionDo:[:aView |
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1433
            sumHeights := sumHeights + aView height.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1434
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1435
            min isNil ifTrue:[min := aView top]
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1436
                     ifFalse:[min := min min:(aView top)].
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1437
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1438
            max   := max max:(aView bottom).
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1439
            count := count + 1
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1440
        ].
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1441
        viewsInOrder := Array withAll:selection.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1442
        topsInOrder  := viewsInOrder collect:[:aView|aView top].
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1443
        topsInOrder sortWith:viewsInOrder.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1444
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1445
        space := (((max - min) - sumHeights) / (count - 1)) rounded asInteger.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1446
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1447
        undoHistory transactionNamed:'spread' do:[
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1448
            viewsInOrder do:[:aView||delta|
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1449
                delta := min - aView computeOrigin y.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1450
                self shifLayout:aView top:delta bottom:delta.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1451
                min := min + aView height + space
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1452
            ]
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1453
        ].
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1454
        self changed:#layout
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1455
    ]
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1456
! !
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1457
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1458
!UIObjectView methodsFor:'user actions - resize'!
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1459
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1460
doDragResize:aPoint
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1461
    "do a widget resize drag"
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1462
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1463
    |p|
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1464
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1465
    self invertOutlineOf:resizedObject.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1466
    p := (self alignToGrid:aPoint) - (resizedObject container originRelativeTo:self).
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1467
    self perform:('x' , resizeSelector , ':') asSymbol with:p.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1468
    resizedObject geometryLayout:(resizedObject geometryLayout).
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1469
    self invertOutlineOf:resizedObject
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1470
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1471
    "Modified: 5.9.1995 / 17:11:46 / claus"
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1472
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1473
!
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1474
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1475
endResize
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1476
    "cleanup after object resize"
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1477
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1478
    self invertOutlineOf:resizedObject.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1479
    self setDefaultActions.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1480
    self select:resizedObject.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1481
    resizedObject := nil
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1482
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1483
    "Modified: 5.9.1995 / 17:11:17 / claus"
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1484
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1485
!
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1486
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1487
startResizeBorder:b of:selection at:aPoint
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1488
    "resize selected view
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1489
    "
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1490
    resizedObject := self singleSelection.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1491
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1492
    resizedObject notNil ifTrue:[
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1493
        resizeSelector := b.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1494
        super unselect.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1495
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1496
        undoHistory transactionNamed:'extent' do:[
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1497
            self undoBlockDimensionChanged:resizedObject.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1498
        ].
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1499
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1500
        motionAction := [:movePoint | self doDragResize:movePoint].
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1501
        releaseAction := [self endResize].
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1502
        self invertOutlineOf:resizedObject
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1503
    ]
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1504
!
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1505
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1506
xbottom:aPoint
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1507
    self resize:resizedObject bottom:aPoint
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1508
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1509
!
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1510
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1511
xbottomLeft:aPoint
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1512
    self resize:resizedObject   left:aPoint.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1513
    self resize:resizedObject bottom:aPoint.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1514
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1515
!
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1516
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1517
xcorner:aPoint
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1518
    self resize:resizedObject corner:aPoint.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1519
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1520
!
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1521
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1522
xleft:aPoint
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1523
    self resize:resizedObject left:aPoint
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1524
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1525
!
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1526
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1527
xorigin:aPoint
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1528
    self resize:resizedObject left:aPoint.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1529
    self resize:resizedObject  top:aPoint.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1530
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1531
!
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1532
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1533
xright:aPoint
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1534
    self resize:resizedObject right:aPoint
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1535
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1536
!
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1537
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1538
xtop:aPoint
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1539
    self resize:resizedObject top:aPoint
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1540
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1541
!
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1542
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1543
xtopRight:aPoint
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1544
    self resize:resizedObject right:aPoint.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1545
    self resize:resizedObject   top:aPoint.
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1546
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1547
! !
cb65ce16c150 intitial checkin
ca
parents:
diff changeset
  1548
47
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
  1549
!UIObjectView::UndoHistory class methodsFor:'constants'!
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
  1550
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
  1551
maxHistorySize
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
  1552
    "returns maximum size of history before removing oldest
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
  1553
     record
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
  1554
    "
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
  1555
    ^ 50
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
  1556
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
  1557
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
  1558
! !
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
  1559
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
  1560
!UIObjectView::UndoHistory class methodsFor:'instance creation'!
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
  1561
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
  1562
new
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
  1563
    ^ self basicNew initialize
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
  1564
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
  1565
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
  1566
! !
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
  1567
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
  1568
!UIObjectView::UndoHistory methodsFor:'accessing'!
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
  1569
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
  1570
modifiedAction:aBlockWithOneArg
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
  1571
    "the block is evaluated whenever the history changed; the argument to the
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
  1572
     block is the newest transaction identifier retrived from 'openTransaction'
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
  1573
    "
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
  1574
    modifiedAction := aBlockWithOneArg
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
  1575
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
  1576
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
  1577
! !
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
  1578
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
  1579
!UIObjectView::UndoHistory methodsFor:'initialization'!
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
  1580
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
  1581
initialize
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
  1582
    super initialize.
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
  1583
    self  reinitialize.
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
  1584
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
  1585
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
  1586
!
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
  1587
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
  1588
reinitialize
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
  1589
    "reinitialize all attributes
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
  1590
    "
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
  1591
    history := OrderedCollection new.
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
  1592
    transaction := nil.
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
  1593
    enabled := true.
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
  1594
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
  1595
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
  1596
! !
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
  1597
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
  1598
!UIObjectView::UndoHistory methodsFor:'notifications'!
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
  1599
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
  1600
modified
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
  1601
    "raise notification; history changed
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
  1602
    "
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
  1603
    modifiedAction notNil ifTrue:[
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
  1604
        |what|
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
  1605
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
  1606
        history isEmpty ifTrue:[what := nil]
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
  1607
                       ifFalse:[what := history last first].
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
  1608
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
  1609
        modifiedAction value:what
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
  1610
    ]
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
  1611
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
  1612
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
  1613
! !
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
  1614
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
  1615
!UIObjectView::UndoHistory methodsFor:'testing'!
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
  1616
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
  1617
isEmpty
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
  1618
    "returns true if undo history is empty
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
  1619
    "
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
  1620
    ^ history isEmpty
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
  1621
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
  1622
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
  1623
!
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
  1624
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
  1625
isTransactionOpen
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
  1626
    ^ (enabled and:[transaction notNil])
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
  1627
!
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
  1628
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
  1629
notEmpty
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
  1630
    "returns true if undo history is not empty
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
  1631
    "
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
  1632
    ^ history notEmpty
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
  1633
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
  1634
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
  1635
! !
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
  1636
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
  1637
!UIObjectView::UndoHistory methodsFor:'transaction'!
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
  1638
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
  1639
addUndoBlock:anUndoBlock
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
  1640
    "undo block to restore changes; add block to current transaction
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
  1641
    "
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
  1642
    enabled ifTrue:[
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
  1643
        transaction isNil ifTrue:[
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
  1644
            "no existing transaction
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
  1645
            "
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
  1646
            self halt
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
  1647
        ] ifFalse:[
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
  1648
            (transaction at:2) add:anUndoBlock
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
  1649
        ]
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
  1650
    ]
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
  1651
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
  1652
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
  1653
!
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
  1654
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
  1655
closeTransaction
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
  1656
    "close current transaction
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
  1657
    "
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
  1658
    self isTransactionOpen ifTrue:[
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
  1659
        transaction last isEmpty ifTrue:[
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
  1660
            "empty undo transaction
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
  1661
            "
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
  1662
            transaction := nil
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
  1663
        ] ifFalse:[
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
  1664
            history addLast:transaction.
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
  1665
            transaction := nil.
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
  1666
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
  1667
            history size > (self class maxHistorySize) ifTrue:[
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
  1668
                history removeFirst
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
  1669
            ].
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
  1670
            self modified
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
  1671
        ]
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
  1672
    ]
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
  1673
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
  1674
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
  1675
!
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
  1676
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
  1677
disabledTransitionDo:aBlock
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
  1678
    "disable transitions during evaluating the block
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
  1679
    "
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
  1680
    |oldState|
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
  1681
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
  1682
    oldState := enabled.
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
  1683
    enabled  := false.
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
  1684
    aBlock value.
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
  1685
    enabled  := oldState.
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
  1686
!
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
  1687
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
  1688
openTransaction:what
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
  1689
    "open a new transaction
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
  1690
    "
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
  1691
    enabled ifTrue:[
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
  1692
        transaction notNil ifTrue:[
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
  1693
            "transaction within transaction
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
  1694
            "
5e4319953a0b *** empty log message ***
ca
parents: 44
diff changeset
  1695
            self halt.
5e4319953a0b *** empty log message ***
ca
parents: 44