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