UIGalleryView.st
author Claus Gittinger <cg@exept.de>
Wed, 28 Apr 1999 09:57:39 +0200
changeset 1118 ebecbe5d4b6b
parent 1113 aec10e7dbe80
child 1120 230fe13c4e51
permissions -rw-r--r--
checkin from browser
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
181
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
     1
"
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
     2
 COPYRIGHT (c) 1997 by Claus Gittinger / eXept Software AG
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
     3
              All Rights Reserved
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
     4
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
     5
 This software is furnished under a license and may be used
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
     6
 only in accordance with the terms of that license and with the
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
     8
 be provided or otherwise made available to, or used by, any
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
     9
 other person.  No title to or ownership of the software is
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
    10
 hereby transferred.
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
    11
"
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
    12
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
    13
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
    14
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
    15
NoteBookView subclass:#UIGalleryView
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
    16
	instanceVariableNames:'majorKey minorKeys minorKeysHolder'
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
    17
	classVariableNames:''
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
    18
	poolDictionaries:''
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
    19
	category:'Interface-UIPainter'
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
    20
!
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
    21
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
    22
View subclass:#Canvas
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
    23
	instanceVariableNames:'dragMode clientSpecHolder inputView selection specification
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
    24
		lastClickPoint menuSelector raiseMenuSelector uiBuilder'
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
    25
	classVariableNames:''
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
    26
	poolDictionaries:''
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
    27
	privateIn:UIGalleryView
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
    28
!
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
    29
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
    30
DropObject subclass:#DropSpec
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
    31
	instanceVariableNames:''
247
b4d3f54f2128 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 240
diff changeset
    32
	classVariableNames:''
181
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
    33
	poolDictionaries:''
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
    34
	privateIn:UIGalleryView::Canvas
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
    35
!
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
    36
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
    37
!UIGalleryView class methodsFor:'documentation'!
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
    38
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
    39
copyright
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
    40
"
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
    41
 COPYRIGHT (c) 1997 by Claus Gittinger / eXept Software AG
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
    42
              All Rights Reserved
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
    43
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
    44
 This software is furnished under a license and may be used
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
    45
 only in accordance with the terms of that license and with the
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
    46
 inclusion of the above copyright notice.   This software may not
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
    47
 be provided or otherwise made available to, or used by, any
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
    48
 other person.  No title to or ownership of the software is
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
    49
 hereby transferred.
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
    50
"
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
    51
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
    52
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
    53
!
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
    54
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
    55
documentation
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
    56
"
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
    57
    implements a selection panel, keeping widgets which could be placed
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
    58
    into other components by drag & drop or copy @ paste. The objects
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
    59
    which are draged/droped must be kind of UISpecification's.
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
    60
    The UISelectionPanel used by the UIPainter is implemented in this way.
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
    61
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
    62
    [author:]
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
    63
        Claus Gittinger
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
    64
        Claus Atzkern
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
    65
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
    66
    [see also:]
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
    67
        UIPainter
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
    68
        UISelectionPanel
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
    69
"
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
    70
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
    71
!
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
    72
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
    73
examples
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
    74
"
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
    75
    opens a gallery
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
    76
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
    77
                                                                        [exBegin]
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
    78
    |top sel|
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
    79
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
    80
    top := StandardSystemView new label:'gallery'; extent:500@300.
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
    81
    sel := UIGalleryView origin:0.0 @ 0.0 corner:1.0 @ 1.0 in:top.
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
    82
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
    83
    sel labels:#(    'Buttons'
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
    84
                     'Panels'
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
    85
                     'Text'
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
    86
                   ).
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
    87
191
2f66509899a0 change standart to standard
ca
parents: 181
diff changeset
    88
    sel minorKeys:#( #standardButtonToggle
2f66509899a0 change standart to standard
ca
parents: 181
diff changeset
    89
                     #standardPanels
2f66509899a0 change standart to standard
ca
parents: 181
diff changeset
    90
                     #standardText
181
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
    91
                   ).
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
    92
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
    93
    sel majorKey:UISelectionPanel.
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
    94
    top open.
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
    95
                                                                        [exEnd]
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
    96
"
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
    97
! !
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
    98
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
    99
!UIGalleryView methodsFor:'accessing'!
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   100
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   101
builder
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   102
    "get the builder used to setup a window from a specification (or nil in case
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   103
     of using a new builder)
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   104
    "
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   105
  ^ canvas builder
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   106
!
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   107
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   108
builder:aBuilderOrNil
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   109
    "set the builder used to setup a window from a specification (or nil in case
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   110
     of using a new builder)
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   111
    "
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   112
    canvas builder:aBuilderOrNil
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   113
!
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   114
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   115
canvas:aCanvas
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   116
    ^ self
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   117
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   118
!
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   119
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   120
labels:listOfLabels minorKeys:listOfMinorKeys majorKey:aMajorKey
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   121
    "setup for labels, selectors and class provider
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   122
    "
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   123
    self labels:listOfLabels.
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   124
    minorKeys := listOfMinorKeys.
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   125
    majorKey  := aMajorKey.
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   126
!
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   127
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   128
majorKey
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   129
    "get the class providing the window specifications
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   130
    "
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   131
  ^ majorKey
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   132
!
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   133
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   134
majorKey:aKey
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   135
    "get the class providing the window specifications
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   136
    "
335
9f048ededd7d resolveName:
ca
parents: 331
diff changeset
   137
    |appl|
9f048ededd7d resolveName:
ca
parents: 331
diff changeset
   138
9f048ededd7d resolveName:
ca
parents: 331
diff changeset
   139
    appl := self application.
9f048ededd7d resolveName:
ca
parents: 331
diff changeset
   140
9f048ededd7d resolveName:
ca
parents: 331
diff changeset
   141
    appl notNil ifTrue:[
9f048ededd7d resolveName:
ca
parents: 331
diff changeset
   142
        majorKey := appl resolveName:aKey
9f048ededd7d resolveName:
ca
parents: 331
diff changeset
   143
    ] ifFalse:[
9f048ededd7d resolveName:
ca
parents: 331
diff changeset
   144
        majorKey := Smalltalk resolveName:aKey inClass:self class
9f048ededd7d resolveName:
ca
parents: 331
diff changeset
   145
    ].
181
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   146
    self selection:nil
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   147
!
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   148
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   149
minorKeys
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   150
    "get the list of selector keys
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   151
    "
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   152
  ^ minorKeys
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   153
!
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   154
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   155
minorKeys:aListOfSelectors
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   156
    "set the list of selectors
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   157
    "
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   158
    minorKeys := aListOfSelectors.
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   159
    tabRaw selection:nil.
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   160
! !
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   161
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   162
!UIGalleryView methodsFor:'accessing holders'!
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   163
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   164
clientSpecHolder
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   165
    "get the holder which keeps the current selection or in case of
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   166
     no selection the specification under the cursor
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   167
    "
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   168
  ^ canvas clientSpecHolder
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   169
!
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   170
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   171
clientSpecHolder:aHolder
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   172
    "set the holder which keeps the current selection or in case of
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   173
     no selection the specification under the cursor
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   174
    "
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   175
    canvas clientSpecHolder:aHolder
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   176
!
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   177
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   178
menuSelector
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   179
    ^ canvas menuSelector
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   180
!
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   181
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   182
menuSelector:aSelector
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   183
    ^ canvas menuSelector:aSelector
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   184
!
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   185
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   186
minorKeysHolder
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   187
    "get the holder keeping the minor keys; the selectors to access
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   188
     specifications from a class associated with the majorKey.
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   189
    "
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   190
  ^ minorKeysHolder
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   191
!
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   192
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   193
minorKeysHolder:aValueHolder
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   194
    "set the holder keeping the minor keys; the selectors to access
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   195
     specifications from a class associated with the majorKey.
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   196
    "
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   197
    minorKeysHolder notNil ifTrue:[
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   198
        minorKeysHolder removeDependent:self. 
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   199
    ].
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   200
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   201
    (minorKeysHolder := aValueHolder) notNil ifTrue:[
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   202
        minorKeysHolder addDependent:self.
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   203
    ].
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   204
    self minorKeys:(minorKeysHolder value)
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   205
! !
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   206
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   207
!UIGalleryView methodsFor:'change & update'!
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   208
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   209
selectionChangedTo:something
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   210
    "selection changed
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   211
    "
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   212
    |specification selector selection application|
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   213
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   214
    selection := tabRaw listIndexOf:something.
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   215
683
648ba2c8536e whenever selection changed; reread minorKeys from
ca
parents: 661
diff changeset
   216
    minorKeysHolder notNil ifTrue:[
648ba2c8536e whenever selection changed; reread minorKeys from
ca
parents: 661
diff changeset
   217
        minorKeys := minorKeysHolder value.
648ba2c8536e whenever selection changed; reread minorKeys from
ca
parents: 661
diff changeset
   218
    ].
181
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   219
    (selection notNil and:[minorKeys size >= selection]) ifTrue:[
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   220
        selector := minorKeys at:selection.
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   221
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   222
        (majorKey respondsTo:selector) ifTrue:[
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   223
            specification := majorKey perform:selector
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   224
        ] ifFalse:[
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   225
            (application := self application) notNil ifTrue:[
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   226
                Object messageNotUnderstoodSignal handle:[:ex|
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   227
                    (application class respondsTo:selector) ifTrue:[
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   228
                        specification := application class perform:selector
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   229
                    ]
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   230
                ] do:[
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   231
                    specification := application aspectFor:selector
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   232
                ]
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   233
            ]
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   234
        ]
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   235
    ].
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   236
    canvas specification:specification.
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   237
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   238
!
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   239
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   240
update
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   241
    self selectionChangedTo:(tabRaw selection).
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   242
!
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   243
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   244
update:something with:aParameter from:changedObject
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   245
    "one of my models changed its value
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   246
    "
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   247
    changedObject == minorKeysHolder ifTrue:[
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   248
        ^ self minorKeys:( minorKeysHolder value)
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   249
    ].
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   250
    super update:something with:aParameter from:changedObject.
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   251
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   252
! !
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   253
1113
aec10e7dbe80 category change
Claus Gittinger <cg@exept.de>
parents: 1040
diff changeset
   254
!UIGalleryView methodsFor:'initialize / release'!
181
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   255
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   256
destroy
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   257
    minorKeysHolder notNil ifTrue:[
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   258
        minorKeysHolder removeDependent:self. 
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   259
        minorKeysHolder := nil.
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   260
    ].
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   261
    super destroy.
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   262
!
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   263
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   264
initialize
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   265
    "setup default attributes
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   266
    "
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   267
    canvas := Canvas.
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   268
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   269
    super initialize.
683
648ba2c8536e whenever selection changed; reread minorKeys from
ca
parents: 661
diff changeset
   270
181
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   271
    tabRaw action:[:something| self selectionChangedTo:something ].
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   272
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   273
! !
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   274
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   275
!UIGalleryView::Canvas methodsFor:'accessing'!
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   276
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   277
builder
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   278
    "get the builder used to setup a window from a specification (or nil in case
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   279
     of using a new builder)
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   280
    "
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   281
  ^ uiBuilder
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   282
!
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   283
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   284
builder:something
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   285
    "set the builder used to setup a window from a specification (or nil in case
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   286
     of using a new builder)
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   287
    "
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   288
    uiBuilder := something.
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   289
!
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   290
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   291
clientSpecHolder
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   292
    "get the holder which keeps the current selection or in case of
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   293
     no selection the specification under the cursor
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   294
    "
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   295
    ^ clientSpecHolder
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   296
!
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   297
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   298
clientSpecHolder:aHolder
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   299
    "set the holder which keeps the current selection or in case of
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   300
     no selection the specification under the cursor
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   301
    "
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   302
    (clientSpecHolder := aHolder) notNil ifTrue:[
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   303
        clientSpecHolder value:selection
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   304
    ].
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   305
!
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   306
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   307
menuSelector
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   308
    "return the value of the instance variable 'menuSelector' (automatically generated)"
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   309
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   310
    ^ menuSelector!
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   311
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   312
menuSelector:something
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   313
    "set the value of the instance variable 'menuSelector' (automatically generated)"
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   314
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   315
    menuSelector := something.!
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   316
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   317
specification
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   318
    "get current specification
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   319
    "
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   320
   ^ specification
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   321
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   322
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   323
!
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   324
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   325
specification:aSpecOrSpecArray
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   326
    "set a new specification
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   327
    "
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   328
    |builder|
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   329
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   330
    self selection:nil.
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   331
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   332
    self subViews copy do:[:aSubView|
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   333
        aSubView ~~ inputView ifTrue:[
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   334
            aSubView destroy
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   335
        ]
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   336
    ].
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   337
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   338
    aSpecOrSpecArray notNil ifTrue:[
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   339
        specification := UISpecification from:aSpecOrSpecArray.
205
1188254dcbfc bug fix:
ca
parents: 191
diff changeset
   340
1188254dcbfc bug fix:
ca
parents: 191
diff changeset
   341
        (specification respondsTo:#buildViewFor:in:) ifFalse:[
1188254dcbfc bug fix:
ca
parents: 191
diff changeset
   342
            specification := nil.
1188254dcbfc bug fix:
ca
parents: 191
diff changeset
   343
          ^ self
1188254dcbfc bug fix:
ca
parents: 191
diff changeset
   344
        ].
396
e15b7b5bb81b checkin from browser
ca
parents: 335
diff changeset
   345
        (builder := uiBuilder) isNil ifTrue:[
720
7f228c9cde2e show default widgets for the UISelectionPanel
tz
parents: 683
diff changeset
   346
            builder := UIBuilder new isEditing:true.
7f228c9cde2e show default widgets for the UISelectionPanel
tz
parents: 683
diff changeset
   347
            builder showDefaults:true.
396
e15b7b5bb81b checkin from browser
ca
parents: 335
diff changeset
   348
        ].
e15b7b5bb81b checkin from browser
ca
parents: 335
diff changeset
   349
181
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   350
        specification buildViewFor:builder in:self.
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   351
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   352
        subViews do:[:v|
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   353
            (v ~~ inputView and:[(self findSpecFor:v) notNil]) ifTrue:[
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   354
                v borderWidth:1.
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   355
            ]
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   356
        ].
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   357
        self shown ifTrue:[
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   358
            self realizeAllSubViews.
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   359
            inputView raise
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   360
        ]
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   361
    ] ifFalse:[
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   362
        specification := nil
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   363
    ]
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   364
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   365
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   366
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   367
! !
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   368
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   369
!UIGalleryView::Canvas methodsFor:'building'!
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   370
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   371
buildSpecFrom:aSpec
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   372
    "build spec out of spec
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   373
    "
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   374
    |spec comp coll|
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   375
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   376
    (aSpec notNil and:[aSpec canUIDrag]) ifFalse:[
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   377
        ^ nil
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   378
    ].
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   379
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   380
    spec := aSpec copy.
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   381
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   382
    (aSpec class supportsSubComponents and:[aSpec component notNil]) ifFalse:[
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   383
        ^ spec
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   384
    ].
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   385
    comp := aSpec component.
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   386
    spec component:nil.
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   387
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   388
    comp canUIDrag ifFalse:[
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   389
      ^ spec
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   390
    ].
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   391
    coll := OrderedCollection new.
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   392
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   393
    comp do:[:anEntry||spc|
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   394
        (spc := self buildSpecFrom:anEntry) notNil ifTrue:[
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   395
            coll add:spc
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   396
        ]
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   397
    ].
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   398
    coll isEmpty ifTrue:[
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   399
      ^ spec
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   400
    ].
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   401
    comp := comp copy.
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   402
    comp collection:coll.
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   403
    spec component:comp.
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   404
  ^ spec
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   405
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   406
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   407
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   408
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   409
! !
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   410
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   411
!UIGalleryView::Canvas methodsFor:'drag & drop'!
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   412
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   413
startDrag
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   414
    "start drag of selection
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   415
    "
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   416
    |dragObj spec name|
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   417
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   418
    spec := self findSpecFor:selection.
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   419
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   420
    spec notNil ifTrue:[
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   421
        spec := self buildSpecFrom:spec.
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   422
        name := spec className asString.
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   423
        name := name copyFrom:1 to:(name size - ('Spec' size) + 1). 
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   424
        name at:1 put:(name at:1) asLowercase.
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   425
        name at:(name size) put:$1.
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   426
        spec name:name.
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   427
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   428
        self showUnselected.
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   429
        dragObj := DropSpec for:selection specification:spec.
994
29bfed6efe87 dont reselect after startDrag.
Claus Gittinger <cg@exept.de>
parents: 897
diff changeset
   430
        "/ self showSelected.
181
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   431
        DragAndDropManager startDrag:dragObj from:inputView.
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   432
    ]
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   433
278
5b7dfe33b497 drag & drop offset
Claus Gittinger <cg@exept.de>
parents: 247
diff changeset
   434
!
5b7dfe33b497 drag & drop offset
Claus Gittinger <cg@exept.de>
parents: 247
diff changeset
   435
5b7dfe33b497 drag & drop offset
Claus Gittinger <cg@exept.de>
parents: 247
diff changeset
   436
startDragWithOffset:offs
5b7dfe33b497 drag & drop offset
Claus Gittinger <cg@exept.de>
parents: 247
diff changeset
   437
    "start drag of selection
5b7dfe33b497 drag & drop offset
Claus Gittinger <cg@exept.de>
parents: 247
diff changeset
   438
    "
720
7f228c9cde2e show default widgets for the UISelectionPanel
tz
parents: 683
diff changeset
   439
    |dragObj spec o|
278
5b7dfe33b497 drag & drop offset
Claus Gittinger <cg@exept.de>
parents: 247
diff changeset
   440
5b7dfe33b497 drag & drop offset
Claus Gittinger <cg@exept.de>
parents: 247
diff changeset
   441
    spec := self findSpecFor:selection.
5b7dfe33b497 drag & drop offset
Claus Gittinger <cg@exept.de>
parents: 247
diff changeset
   442
5b7dfe33b497 drag & drop offset
Claus Gittinger <cg@exept.de>
parents: 247
diff changeset
   443
    spec notNil ifTrue:[
5b7dfe33b497 drag & drop offset
Claus Gittinger <cg@exept.de>
parents: 247
diff changeset
   444
        spec := self buildSpecFrom:spec.
720
7f228c9cde2e show default widgets for the UISelectionPanel
tz
parents: 683
diff changeset
   445
        spec name:(spec copy userFriendlyName, $1).
278
5b7dfe33b497 drag & drop offset
Claus Gittinger <cg@exept.de>
parents: 247
diff changeset
   446
5b7dfe33b497 drag & drop offset
Claus Gittinger <cg@exept.de>
parents: 247
diff changeset
   447
        self showUnselected.
5b7dfe33b497 drag & drop offset
Claus Gittinger <cg@exept.de>
parents: 247
diff changeset
   448
        dragObj := DropSpec for:selection specification:spec.
994
29bfed6efe87 dont reselect after startDrag.
Claus Gittinger <cg@exept.de>
parents: 897
diff changeset
   449
        "/ self showSelected.
278
5b7dfe33b497 drag & drop offset
Claus Gittinger <cg@exept.de>
parents: 247
diff changeset
   450
5b7dfe33b497 drag & drop offset
Claus Gittinger <cg@exept.de>
parents: 247
diff changeset
   451
        o := lastClickPoint - selection origin.
5b7dfe33b497 drag & drop offset
Claus Gittinger <cg@exept.de>
parents: 247
diff changeset
   452
5b7dfe33b497 drag & drop offset
Claus Gittinger <cg@exept.de>
parents: 247
diff changeset
   453
        DragAndDropManager 
5b7dfe33b497 drag & drop offset
Claus Gittinger <cg@exept.de>
parents: 247
diff changeset
   454
            startDrag:dragObj 
5b7dfe33b497 drag & drop offset
Claus Gittinger <cg@exept.de>
parents: 247
diff changeset
   455
            from:inputView
5b7dfe33b497 drag & drop offset
Claus Gittinger <cg@exept.de>
parents: 247
diff changeset
   456
            offset:o.
5b7dfe33b497 drag & drop offset
Claus Gittinger <cg@exept.de>
parents: 247
diff changeset
   457
    ]
5b7dfe33b497 drag & drop offset
Claus Gittinger <cg@exept.de>
parents: 247
diff changeset
   458
5b7dfe33b497 drag & drop offset
Claus Gittinger <cg@exept.de>
parents: 247
diff changeset
   459
    "Created: 11.8.1997 / 00:44:17 / cg"
5b7dfe33b497 drag & drop offset
Claus Gittinger <cg@exept.de>
parents: 247
diff changeset
   460
    "Modified: 11.8.1997 / 00:48:35 / cg"
181
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   461
! !
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   462
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   463
!UIGalleryView::Canvas methodsFor:'event handling'!
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   464
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   465
buttonMotion:state x:x y:y
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   466
    "start a drag on selection
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   467
    "
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   468
    |sensor|
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   469
289
7bbe22b39d9b check state for 0 during button motion
ca
parents: 278
diff changeset
   470
    (state ~~ 0 and:[lastClickPoint notNil and:[selection notNil]]) ifTrue:[
181
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   471
        sensor := self sensor.
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   472
        sensor anyButtonPressed ifTrue:[
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   473
            (lastClickPoint dist:(x@y)) > 10.0 ifTrue:[
278
5b7dfe33b497 drag & drop offset
Claus Gittinger <cg@exept.de>
parents: 247
diff changeset
   474
                ^ self startDragWithOffset:(x@y) - lastClickPoint
181
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   475
            ]
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   476
        ]
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   477
    ]
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   478
!
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   479
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   480
buttonPress:button x:x y:y
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   481
    "change selection
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   482
    "
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   483
    |application|
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   484
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   485
    button == 1 ifTrue:[
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   486
        lastClickPoint := Point x:x y:y.
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   487
        self selection:(self findObjectAtX:x y:y).
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   488
    ]  ifFalse:[
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   489
        lastClickPoint := nil.
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   490
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   491
        (menuSelector notNil and:[(application := self application) notNil]) ifTrue:[
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   492
            Object messageNotUnderstoodSignal handle:[:ex|
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   493
            ] do:[
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   494
                application aspectFor:menuSelector
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   495
            ]
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   496
        ]
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   497
    ]
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   498
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   499
!
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   500
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   501
exposeX:x y:y width:w height:h
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   502
    "handle an expose event from device; redraw selection
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   503
    "
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   504
    super exposeX:x y:y width:w height:h.
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   505
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   506
    (selection notNil and:[self sensor hasExposeEventFor:selection]) ifFalse:[
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   507
        self showSelected.
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   508
    ].
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   509
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   510
897
43f9bdc12ae4 make certain inputView is on top when restarting from a snapshot
Claus Gittinger <cg@exept.de>
parents: 806
diff changeset
   511
!
43f9bdc12ae4 make certain inputView is on top when restarting from a snapshot
Claus Gittinger <cg@exept.de>
parents: 806
diff changeset
   512
43f9bdc12ae4 make certain inputView is on top when restarting from a snapshot
Claus Gittinger <cg@exept.de>
parents: 806
diff changeset
   513
mapped
43f9bdc12ae4 make certain inputView is on top when restarting from a snapshot
Claus Gittinger <cg@exept.de>
parents: 806
diff changeset
   514
    "make certain that the input view is on top.
43f9bdc12ae4 make certain inputView is on top when restarting from a snapshot
Claus Gittinger <cg@exept.de>
parents: 806
diff changeset
   515
    "
43f9bdc12ae4 make certain inputView is on top when restarting from a snapshot
Claus Gittinger <cg@exept.de>
parents: 806
diff changeset
   516
    super mapped.
43f9bdc12ae4 make certain inputView is on top when restarting from a snapshot
Claus Gittinger <cg@exept.de>
parents: 806
diff changeset
   517
    inputView raise.
43f9bdc12ae4 make certain inputView is on top when restarting from a snapshot
Claus Gittinger <cg@exept.de>
parents: 806
diff changeset
   518
43f9bdc12ae4 make certain inputView is on top when restarting from a snapshot
Claus Gittinger <cg@exept.de>
parents: 806
diff changeset
   519
    "Modified: / 20.7.1998 / 18:10:48 / cg"
43f9bdc12ae4 make certain inputView is on top when restarting from a snapshot
Claus Gittinger <cg@exept.de>
parents: 806
diff changeset
   520
    "Created: / 20.7.1998 / 18:12:35 / cg"
181
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   521
! !
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   522
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   523
!UIGalleryView::Canvas methodsFor:'initialization'!
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   524
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   525
initialize
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   526
    super initialize.
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   527
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   528
    inputView := InputView origin:0.0@0.0 extent:1.0@1.0 in:self.
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   529
    inputView eventReceiver:self.
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   530
    inputView enableButtonEvents.
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   531
    inputView enableButtonMotionEvents.
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   532
    inputView enableMotionEvents.
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   533
897
43f9bdc12ae4 make certain inputView is on top when restarting from a snapshot
Claus Gittinger <cg@exept.de>
parents: 806
diff changeset
   534
    "Modified: / 20.7.1998 / 18:12:38 / cg"
181
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   535
! !
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   536
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   537
!UIGalleryView::Canvas methodsFor:'searching'!
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   538
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   539
findObjectAtX:x y:y
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   540
    "find the origin/corner of the currentWidget
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   541
    "
239
ce46eb6f92a5 do not clobber the global named DisplayObject - shame on ca.
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   542
    |point id p|
181
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   543
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   544
    point := Point x:x y:y.
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   545
    id    := inputView id.
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   546
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   547
    subViews do:[:v|
239
ce46eb6f92a5 do not clobber the global named DisplayObject - shame on ca.
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   548
	|pX pY|
ce46eb6f92a5 do not clobber the global named DisplayObject - shame on ca.
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   549
181
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   550
        v ~~ inputView ifTrue:[
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   551
            p := device translatePoint:point from:id to:(v id).
239
ce46eb6f92a5 do not clobber the global named DisplayObject - shame on ca.
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   552
	    pX := p x.
ce46eb6f92a5 do not clobber the global named DisplayObject - shame on ca.
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   553
	    pY := p y.
ce46eb6f92a5 do not clobber the global named DisplayObject - shame on ca.
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   554
            (     pX >= 0 and:[pX <= v width
ce46eb6f92a5 do not clobber the global named DisplayObject - shame on ca.
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   555
             and:[pY >= 0 and:[pY <= v height
181
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   556
             and:[(self findSpecFor:v) notNil]]]]
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   557
            ) ifTrue:[
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   558
                ^ v
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   559
            ]
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   560
        ]
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   561
    ].
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   562
  ^ nil
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   563
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   564
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   565
!
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   566
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   567
findSpecFor:anObject
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   568
    "returns subspec assigned to instance or nil
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   569
    "
239
ce46eb6f92a5 do not clobber the global named DisplayObject - shame on ca.
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   570
    |name|
181
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   571
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   572
    anObject notNil ifTrue:[
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   573
        name := anObject name.
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   574
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   575
        specification do:[:aSpec|
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   576
            aSpec name = name ifTrue:[
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   577
                aSpec canUIDrag ifTrue:[^ aSpec]
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   578
                               ifFalse:[^ nil]
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   579
            ]
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   580
        ]
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   581
    ].
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   582
    ^ nil
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   583
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   584
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   585
! !
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   586
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   587
!UIGalleryView::Canvas methodsFor:'selection'!
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   588
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   589
handlesOf:aComponent do:aOneArgBlock
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   590
    "evaluate the block on each handle; the argument to the block
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   591
     is a rectangle
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   592
    "
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   593
    aComponent notNil ifTrue:[
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   594
        aOneArgBlock value:(aComponent origin       - (2@2) extent:6@6).
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   595
        aOneArgBlock value:(aComponent corner       - (1@1) extent:6@6).
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   596
        aOneArgBlock value:(aComponent topRight     - (1@2) extent:6@6).
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   597
        aOneArgBlock value:(aComponent bottomLeft   - (2@1) extent:6@6).
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   598
        aOneArgBlock value:(aComponent leftCenter   - (2@0) extent:6@6).
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   599
        aOneArgBlock value:(aComponent rightCenter  - (1@0) extent:6@6).
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   600
        aOneArgBlock value:(aComponent topCenter    - (0@2) extent:6@6).
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   601
        aOneArgBlock value:(aComponent bottomCenter - (0@1) extent:6@6).
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   602
    ]
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   603
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   604
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   605
!
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   606
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   607
selection:anObject
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   608
    "selection changed
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   609
    "
239
ce46eb6f92a5 do not clobber the global named DisplayObject - shame on ca.
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   610
    |spec|
181
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   611
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   612
    selection ~~ anObject ifTrue:[
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   613
        self showUnselected.
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   614
        spec := self findSpecFor:anObject.
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   615
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   616
        spec notNil ifTrue:[
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   617
            selection := anObject.
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   618
            self showSelected
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   619
        ] ifFalse:[
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   620
            selection := nil
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   621
        ].
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   622
        clientSpecHolder notNil ifTrue:[
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   623
            clientSpecHolder value:spec
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   624
        ]
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   625
    ]
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   626
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   627
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   628
!
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   629
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   630
showSelected
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   631
    "show selected
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   632
    "
994
29bfed6efe87 dont reselect after startDrag.
Claus Gittinger <cg@exept.de>
parents: 897
diff changeset
   633
    shown ifFalse:[^ self].
181
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   634
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   635
    selection notNil ifTrue:[
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   636
        self clippedByChildren:false.
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   637
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   638
        self handlesOf:selection do:[:aRectangle|
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   639
            self fillRectangle:aRectangle
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   640
        ].
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   641
        self clippedByChildren:true.
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   642
    ].
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   643
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   644
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   645
!
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   646
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   647
showUnselected
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   648
    "show unselected
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   649
    "
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   650
    |r currSel|
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   651
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   652
    (currSel := selection) isNil ifTrue:[
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   653
        ^ self
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   654
    ].
994
29bfed6efe87 dont reselect after startDrag.
Claus Gittinger <cg@exept.de>
parents: 897
diff changeset
   655
    shown ifFalse:[^ self].
181
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   656
    selection := nil.
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   657
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   658
    self clippedByChildren:false.
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   659
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   660
    self handlesOf:currSel do:[:aRectangle|
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   661
        self clearRectangle:aRectangle
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   662
    ].
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   663
    self clippedByChildren:true.
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   664
    r := currSel bounds.
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   665
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   666
    subViews do:[:sv|
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   667
        |absOrg absFrame|
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   668
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   669
        sv ~~ inputView ifTrue:[
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   670
            (sv bounds intersects:r) ifTrue:[
1040
01ccc289d112 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1017
diff changeset
   671
                "/ sv borderColor:(Color gray:5).
181
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   672
                sv borderColor:(Color black).
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   673
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   674
                sv withAllSubViewsDo:[:v|
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   675
                    v fill:v viewBackground.
1017
4bfffe913f94 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 994
diff changeset
   676
                    v exposeX:0 y:0 width:v width height:v height.
181
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   677
                ]
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   678
            ]
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   679
        ]
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   680
    ].
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   681
    selection := currSel.
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   682
1017
4bfffe913f94 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 994
diff changeset
   683
    "Modified: / 9.11.1998 / 12:49:57 / cg"
181
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   684
! !
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   685
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   686
!UIGalleryView::Canvas::DropSpec class methodsFor:'instance creation'!
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   687
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   688
for:aView specification:aSpec
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   689
    "create drop object for a view derived from a specification
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   690
    "
806
4faf081e981d add displayObject for dragging
ca
parents: 720
diff changeset
   691
    |point extent root device inst displayObject|
181
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   692
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   693
    device := aView device.
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   694
    root   := device rootView.
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   695
    extent := aView extent.
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   696
    point  := device translatePoint:0@0 from:(aView id) to:(root id).
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   697
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   698
    (point x > 0 and:[point y > 0]) ifTrue:[
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   699
        point := point + extent.
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   700
        (point x < root width and:[point y < root height]) ifTrue:[
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   701
            aView topView raise.
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   702
            device sync.
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   703
            aView invalidate.
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   704
            aView windowGroup processExposeEvents.
806
4faf081e981d add displayObject for dragging
ca
parents: 720
diff changeset
   705
            displayObject := Image fromView:aView grab:false.
181
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   706
        ]
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   707
    ].
806
4faf081e981d add displayObject for dragging
ca
parents: 720
diff changeset
   708
    displayObject isNil ifTrue:[
4faf081e981d add displayObject for dragging
ca
parents: 720
diff changeset
   709
        displayObject := Form extent:extent depth:1.
4faf081e981d add displayObject for dragging
ca
parents: 720
diff changeset
   710
        displayObject colorMap:(Array with:Color white with:Color black).
4faf081e981d add displayObject for dragging
ca
parents: 720
diff changeset
   711
        displayObject fill:(Color colorId:0).
4faf081e981d add displayObject for dragging
ca
parents: 720
diff changeset
   712
        displayObject paint:(Color colorId:1).
4faf081e981d add displayObject for dragging
ca
parents: 720
diff changeset
   713
        displayObject displayRectangleX:0 y:0 width:aView extent x height:aView extent y.
181
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   714
    ].
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   715
    aSpec class == UISubSpecification ifTrue:[
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   716
        aSpec layout:(LayoutOrigin fromPoint:0@0)
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   717
    ].
240
3f0dfabbb14d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 239
diff changeset
   718
806
4faf081e981d add displayObject for dragging
ca
parents: 720
diff changeset
   719
    inst := self new.
4faf081e981d add displayObject for dragging
ca
parents: 720
diff changeset
   720
    inst displayObject:displayObject.
4faf081e981d add displayObject for dragging
ca
parents: 720
diff changeset
   721
    inst theObject:aSpec.
4faf081e981d add displayObject for dragging
ca
parents: 720
diff changeset
   722
  ^ inst.
181
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   723
! !
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   724
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   725
!UIGalleryView class methodsFor:'documentation'!
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   726
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   727
version
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   728
    ^ '$Header$'
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   729
! !