UIGalleryView.st
author Claus Gittinger <cg@exept.de>
Mon, 28 Jul 1997 16:05:49 +0200
changeset 263 25f080e1217f
parent 247 b4d3f54f2128
child 278 5b7dfe33b497
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
    "
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   137
    (majorKey := aKey) notNil ifTrue:[
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   138
        aKey isBehavior ifFalse:[
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   139
            majorKey := Smalltalk at:aKey asSymbol
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   140
        ]
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   141
    ].
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   142
    self selection:nil
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   143
!
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   144
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   145
minorKeys
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   146
    "get the list of selector keys
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   147
    "
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   148
  ^ minorKeys
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   149
!
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   150
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   151
minorKeys:aListOfSelectors
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   152
    "set the list of selectors
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   153
    "
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   154
    minorKeys := aListOfSelectors.
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   155
    tabRaw selection:nil.
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   156
! !
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   157
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   158
!UIGalleryView methodsFor:'accessing holders'!
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   159
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   160
clientSpecHolder
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   161
    "get the holder which keeps the current selection or in case of
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   162
     no selection the specification under the cursor
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   163
    "
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   164
  ^ canvas clientSpecHolder
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   165
!
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   166
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   167
clientSpecHolder:aHolder
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   168
    "set the holder which keeps the current selection or in case of
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   169
     no selection the specification under the cursor
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   170
    "
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   171
    canvas clientSpecHolder:aHolder
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   172
!
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   173
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   174
menuSelector
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   175
    ^ canvas menuSelector
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:aSelector
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   179
    ^ canvas menuSelector:aSelector
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   180
!
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   181
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   182
minorKeysHolder
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   183
    "get the holder keeping the minor keys; the selectors to access
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   184
     specifications from a class associated with the majorKey.
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
!
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   188
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   189
minorKeysHolder:aValueHolder
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   190
    "set the holder keeping the minor keys; the selectors to access
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   191
     specifications from a class associated with the majorKey.
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   192
    "
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   193
    minorKeysHolder notNil ifTrue:[
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   194
        minorKeysHolder removeDependent:self. 
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   195
    ].
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   196
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   197
    (minorKeysHolder := aValueHolder) notNil ifTrue:[
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   198
        minorKeysHolder addDependent:self.
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   199
    ].
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   200
    self minorKeys:(minorKeysHolder value)
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   201
! !
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   202
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   203
!UIGalleryView methodsFor:'change & update'!
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   204
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   205
selectionChangedTo:something
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   206
    "selection changed
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   207
    "
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   208
    |specification selector selection application|
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   209
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   210
    selection := tabRaw listIndexOf:something.
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   211
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   212
    (selection notNil and:[minorKeys size >= selection]) ifTrue:[
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   213
        selector := minorKeys at:selection.
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   214
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   215
        (majorKey respondsTo:selector) ifTrue:[
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   216
            specification := majorKey perform:selector
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   217
        ] ifFalse:[
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   218
            (application := self application) notNil ifTrue:[
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   219
                Object messageNotUnderstoodSignal handle:[:ex|
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   220
                    (application class respondsTo:selector) ifTrue:[
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   221
                        specification := application class perform:selector
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   222
                    ]
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   223
                ] do:[
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   224
                    specification := application aspectFor:selector
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   225
                ]
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   226
            ]
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   227
        ]
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   228
    ].
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   229
    canvas specification:specification.
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   230
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   231
!
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   232
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   233
update
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   234
    self selectionChangedTo:(tabRaw selection).
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   235
!
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   236
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   237
update:something with:aParameter from:changedObject
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   238
    "one of my models changed its value
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   239
    "
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   240
    changedObject == minorKeysHolder ifTrue:[
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   241
        ^ self minorKeys:( minorKeysHolder value)
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   242
    ].
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   243
    super update:something with:aParameter from:changedObject.
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   244
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   245
! !
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   246
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   247
!UIGalleryView methodsFor:'initialization'!
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   248
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   249
destroy
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   250
    minorKeysHolder notNil ifTrue:[
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   251
        minorKeysHolder removeDependent:self. 
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   252
        minorKeysHolder := nil.
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   253
    ].
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   254
    super destroy.
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   255
!
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   256
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   257
initialize
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   258
    "setup default attributes
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   259
    "
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   260
    canvas := Canvas.
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   261
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   262
    super initialize.
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   263
    tabRaw action:[:something| self selectionChangedTo:something ].
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   264
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   265
! !
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   266
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   267
!UIGalleryView::Canvas methodsFor:'accessing'!
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   268
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   269
builder
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   270
    "get the builder used to setup a window from a specification (or nil in case
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   271
     of using a new builder)
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   272
    "
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   273
  ^ uiBuilder
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   274
!
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   275
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   276
builder:something
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   277
    "set the builder used to setup a window from a specification (or nil in case
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   278
     of using a new builder)
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   279
    "
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   280
    uiBuilder := something.
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   281
!
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   282
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   283
clientSpecHolder
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   284
    "get the holder which keeps the current selection or in case of
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   285
     no selection the specification under the cursor
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   286
    "
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   287
    ^ clientSpecHolder
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   288
!
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   289
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   290
clientSpecHolder:aHolder
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   291
    "set the holder which keeps the current selection or in case of
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   292
     no selection the specification under the cursor
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   293
    "
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   294
    (clientSpecHolder := aHolder) notNil ifTrue:[
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   295
        clientSpecHolder value:selection
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   296
    ].
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   297
!
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   298
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   299
menuSelector
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   300
    "return the value of the instance variable 'menuSelector' (automatically generated)"
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   301
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   302
    ^ menuSelector!
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   303
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   304
menuSelector:something
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   305
    "set the value of the instance variable 'menuSelector' (automatically generated)"
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   306
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   307
    menuSelector := something.!
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   308
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   309
specification
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   310
    "get current specification
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   311
    "
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   312
   ^ specification
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   313
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   314
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   315
!
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   316
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   317
specification:aSpecOrSpecArray
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   318
    "set a new specification
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   319
    "
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   320
    |builder|
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   321
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   322
    self selection:nil.
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   323
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   324
    self subViews copy do:[:aSubView|
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   325
        aSubView ~~ inputView ifTrue:[
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   326
            aSubView destroy
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   327
        ]
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   328
    ].
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   329
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   330
    aSpecOrSpecArray notNil ifTrue:[
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   331
        specification := UISpecification from:aSpecOrSpecArray.
205
1188254dcbfc bug fix:
ca
parents: 191
diff changeset
   332
1188254dcbfc bug fix:
ca
parents: 191
diff changeset
   333
        (specification respondsTo:#buildViewFor:in:) ifFalse:[
1188254dcbfc bug fix:
ca
parents: 191
diff changeset
   334
            specification := nil.
1188254dcbfc bug fix:
ca
parents: 191
diff changeset
   335
          ^ self
1188254dcbfc bug fix:
ca
parents: 191
diff changeset
   336
        ].
181
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   337
        builder := uiBuilder ? UIBuilder new.
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   338
        specification buildViewFor:builder in:self.
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   339
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   340
        subViews do:[:v|
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   341
            (v ~~ inputView and:[(self findSpecFor:v) notNil]) ifTrue:[
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   342
                v borderWidth:1.
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   343
            ]
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   344
        ].
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   345
        self shown ifTrue:[
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   346
            self realizeAllSubViews.
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   347
            inputView raise
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   348
        ]
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   349
    ] ifFalse:[
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   350
        specification := nil
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   351
    ]
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   352
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   353
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   354
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   355
! !
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   356
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   357
!UIGalleryView::Canvas methodsFor:'building'!
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   358
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   359
buildSpecFrom:aSpec
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   360
    "build spec out of spec
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   361
    "
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   362
    |spec comp coll|
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   363
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   364
    (aSpec notNil and:[aSpec canUIDrag]) ifFalse:[
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   365
        ^ nil
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   366
    ].
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   367
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   368
    spec := aSpec copy.
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   369
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   370
    (aSpec class supportsSubComponents and:[aSpec component notNil]) ifFalse:[
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   371
        ^ spec
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   372
    ].
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   373
    comp := aSpec component.
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   374
    spec component:nil.
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   375
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   376
    comp canUIDrag ifFalse:[
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   377
      ^ spec
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   378
    ].
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   379
    coll := OrderedCollection new.
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   380
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   381
    comp do:[:anEntry||spc|
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   382
        (spc := self buildSpecFrom:anEntry) notNil ifTrue:[
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   383
            coll add:spc
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   384
        ]
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   385
    ].
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   386
    coll isEmpty ifTrue:[
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   387
      ^ spec
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   388
    ].
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   389
    comp := comp copy.
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   390
    comp collection:coll.
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   391
    spec component:comp.
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   392
  ^ spec
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   393
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   394
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   395
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   396
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   397
! !
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   398
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   399
!UIGalleryView::Canvas methodsFor:'drag & drop'!
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   400
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   401
startDrag
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   402
    "start drag of selection
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   403
    "
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   404
    |dragObj spec name|
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   405
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   406
    spec := self findSpecFor:selection.
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   407
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   408
    spec notNil ifTrue:[
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   409
        spec := self buildSpecFrom:spec.
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   410
        name := spec className asString.
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   411
        name := name copyFrom:1 to:(name size - ('Spec' size) + 1). 
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   412
        name at:1 put:(name at:1) asLowercase.
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   413
        name at:(name size) put:$1.
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   414
        spec name:name.
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   415
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   416
        self showUnselected.
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   417
        dragObj := DropSpec for:selection specification:spec.
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   418
        self showSelected.
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   419
        DragAndDropManager startDrag:dragObj from:inputView.
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   420
    ]
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   421
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   422
! !
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   423
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   424
!UIGalleryView::Canvas methodsFor:'event handling'!
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   425
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   426
buttonMotion:state x:x y:y
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   427
    "start a drag on selection
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   428
    "
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   429
    |sensor|
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   430
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   431
    (lastClickPoint notNil and:[selection notNil]) ifTrue:[
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   432
        sensor := self sensor.
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   433
        sensor anyButtonPressed ifTrue:[
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   434
            (lastClickPoint dist:(x@y)) > 10.0 ifTrue:[
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   435
                ^ self startDrag
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   436
            ]
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   437
        ]
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   438
    ]
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   439
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   440
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   441
!
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   442
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   443
buttonPress:button x:x y:y
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   444
    "change selection
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   445
    "
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   446
    |application|
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   447
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   448
    button == 1 ifTrue:[
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   449
        lastClickPoint := Point x:x y:y.
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   450
        self selection:(self findObjectAtX:x y:y).
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   451
    ]  ifFalse:[
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   452
        lastClickPoint := nil.
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   453
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   454
        (menuSelector notNil and:[(application := self application) notNil]) ifTrue:[
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   455
            Object messageNotUnderstoodSignal handle:[:ex|
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   456
            ] do:[
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   457
                application aspectFor:menuSelector
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   458
            ]
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   459
        ]
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   460
    ]
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   461
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   462
!
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   463
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   464
exposeX:x y:y width:w height:h
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   465
    "handle an expose event from device; redraw selection
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   466
    "
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   467
    super exposeX:x y:y width:w height:h.
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   468
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   469
    (selection notNil and:[self sensor hasExposeEventFor:selection]) ifFalse:[
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   470
        self showSelected.
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   471
    ].
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   472
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   473
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   474
! !
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   475
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   476
!UIGalleryView::Canvas methodsFor:'initialization'!
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   477
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   478
initialize
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   479
    super initialize.
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   480
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   481
    inputView := InputView origin:0.0@0.0 extent:1.0@1.0 in:self.
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   482
    inputView eventReceiver:self.
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   483
    inputView enableButtonEvents.
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   484
    inputView enableButtonMotionEvents.
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   485
    inputView enableMotionEvents.
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   486
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   487
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   488
! !
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   489
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   490
!UIGalleryView::Canvas methodsFor:'searching'!
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   491
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   492
findObjectAtX:x y:y
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   493
    "find the origin/corner of the currentWidget
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   494
    "
239
ce46eb6f92a5 do not clobber the global named DisplayObject - shame on ca.
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   495
    |point id p|
181
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   496
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   497
    point := Point x:x y:y.
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   498
    id    := inputView id.
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   499
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   500
    subViews do:[:v|
239
ce46eb6f92a5 do not clobber the global named DisplayObject - shame on ca.
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   501
	|pX pY|
ce46eb6f92a5 do not clobber the global named DisplayObject - shame on ca.
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   502
181
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   503
        v ~~ inputView ifTrue:[
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   504
            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
   505
	    pX := p x.
ce46eb6f92a5 do not clobber the global named DisplayObject - shame on ca.
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   506
	    pY := p y.
ce46eb6f92a5 do not clobber the global named DisplayObject - shame on ca.
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   507
            (     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
   508
             and:[pY >= 0 and:[pY <= v height
181
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   509
             and:[(self findSpecFor:v) notNil]]]]
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   510
            ) ifTrue:[
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   511
                ^ v
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   512
            ]
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   513
        ]
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   514
    ].
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   515
  ^ nil
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   516
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   517
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   518
!
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   519
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   520
findSpecFor:anObject
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   521
    "returns subspec assigned to instance or nil
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   522
    "
239
ce46eb6f92a5 do not clobber the global named DisplayObject - shame on ca.
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   523
    |name|
181
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   524
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   525
    anObject notNil ifTrue:[
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   526
        name := anObject name.
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   527
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   528
        specification do:[:aSpec|
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   529
            aSpec name = name ifTrue:[
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   530
                aSpec canUIDrag ifTrue:[^ aSpec]
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   531
                               ifFalse:[^ nil]
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   532
            ]
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   533
        ]
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   534
    ].
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   535
    ^ nil
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   536
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   537
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   538
! !
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   539
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   540
!UIGalleryView::Canvas methodsFor:'selection'!
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   541
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   542
handlesOf:aComponent do:aOneArgBlock
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   543
    "evaluate the block on each handle; the argument to the block
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   544
     is a rectangle
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   545
    "
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   546
    aComponent notNil ifTrue:[
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   547
        aOneArgBlock value:(aComponent origin       - (2@2) extent:6@6).
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   548
        aOneArgBlock value:(aComponent corner       - (1@1) extent:6@6).
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   549
        aOneArgBlock value:(aComponent topRight     - (1@2) extent:6@6).
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   550
        aOneArgBlock value:(aComponent bottomLeft   - (2@1) extent:6@6).
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   551
        aOneArgBlock value:(aComponent leftCenter   - (2@0) extent:6@6).
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   552
        aOneArgBlock value:(aComponent rightCenter  - (1@0) extent:6@6).
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   553
        aOneArgBlock value:(aComponent topCenter    - (0@2) extent:6@6).
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   554
        aOneArgBlock value:(aComponent bottomCenter - (0@1) extent:6@6).
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   555
    ]
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   556
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   557
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   558
!
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   559
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   560
selection:anObject
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   561
    "selection changed
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   562
    "
239
ce46eb6f92a5 do not clobber the global named DisplayObject - shame on ca.
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   563
    |spec|
181
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   564
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   565
    selection ~~ anObject ifTrue:[
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   566
        self showUnselected.
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   567
        spec := self findSpecFor:anObject.
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   568
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   569
        spec notNil ifTrue:[
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   570
            selection := anObject.
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   571
            self showSelected
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   572
        ] ifFalse:[
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   573
            selection := nil
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   574
        ].
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   575
        clientSpecHolder notNil ifTrue:[
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   576
            clientSpecHolder value:spec
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   577
        ]
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   578
    ]
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
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   583
showSelected
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   584
    "show selected
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   585
    "
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   586
    self shown ifFalse:[^ self].
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   587
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   588
    selection notNil ifTrue:[
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   589
        self clippedByChildren:false.
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   590
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   591
        self handlesOf:selection do:[:aRectangle|
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   592
            self fillRectangle:aRectangle
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   593
        ].
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   594
        self clippedByChildren:true.
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   595
    ].
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   596
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   597
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   598
!
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   599
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   600
showUnselected
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   601
    "show unselected
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   602
    "
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   603
    |r currSel|
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   604
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   605
    (currSel := selection) isNil ifTrue:[
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   606
        ^ self
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   607
    ].
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   608
    selection := nil.
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   609
    self shown ifFalse:[^ self].
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   610
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   611
    self clippedByChildren:false.
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   612
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   613
    self handlesOf:currSel do:[:aRectangle|
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   614
        self clearRectangle:aRectangle
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   615
    ].
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   616
    self clippedByChildren:true.
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   617
    r := currSel bounds.
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   618
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   619
    subViews do:[:sv|
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   620
        |absOrg absFrame|
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   621
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   622
        sv ~~ inputView ifTrue:[
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   623
            (sv bounds intersects:r) ifTrue:[
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   624
                sv borderColor:(Color gray:5).
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   625
                sv borderColor:(Color black).
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   626
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   627
                sv withAllSubViewsDo:[:v|
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   628
                    v fill:v viewBackground.
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   629
                    v exposeX:0 y:0 width:9999 height:9999.
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   630
                ]
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   631
            ]
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   632
        ]
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   633
    ].
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   634
    selection := currSel.
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   635
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   636
! !
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   637
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   638
!UIGalleryView::Canvas::DropSpec class methodsFor:'instance creation'!
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   639
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   640
for:aView specification:aSpec
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   641
    "create drop object for a view derived from a specification
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   642
    "
240
3f0dfabbb14d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 239
diff changeset
   643
    |point extent root device|
181
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   644
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   645
    device := aView device.
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   646
    root   := device rootView.
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   647
    extent := aView extent.
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   648
    point  := device translatePoint:0@0 from:(aView id) to:(root id).
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   649
240
3f0dfabbb14d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 239
diff changeset
   650
    DisplayObject := nil.
181
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   651
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   652
    (point x > 0 and:[point y > 0]) ifTrue:[
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   653
        point := point + extent.
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   654
        (point x < root width and:[point y < root height]) ifTrue:[
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   655
            aView topView raise.
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   656
            device sync.
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   657
            aView invalidate.
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   658
            aView windowGroup processExposeEvents.
240
3f0dfabbb14d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 239
diff changeset
   659
            DisplayObject := Image fromView:aView grab:false.
181
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   660
        ]
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   661
    ].
240
3f0dfabbb14d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 239
diff changeset
   662
    DisplayObject isNil ifTrue:[
3f0dfabbb14d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 239
diff changeset
   663
        DisplayObject := Form extent:extent depth:1.
3f0dfabbb14d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 239
diff changeset
   664
        DisplayObject colorMap:(Array with:Color white with:Color black).
3f0dfabbb14d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 239
diff changeset
   665
        DisplayObject fill:(Color colorId:0).
3f0dfabbb14d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 239
diff changeset
   666
        DisplayObject paint:(Color colorId:1).
3f0dfabbb14d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 239
diff changeset
   667
        DisplayObject displayRectangleX:0 y:0 width:aView extent x height:aView extent y.
181
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   668
    ].
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   669
    aSpec class == UISubSpecification ifTrue:[
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   670
        aSpec layout:(LayoutOrigin fromPoint:0@0)
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   671
    ].
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   672
  ^ self new theObject:aSpec
240
3f0dfabbb14d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 239
diff changeset
   673
3f0dfabbb14d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 239
diff changeset
   674
    "Modified: 26.7.1997 / 20:27:40 / cg"
181
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   675
! !
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   676
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   677
!UIGalleryView class methodsFor:'documentation'!
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   678
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   679
version
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   680
    ^ '$Header$'
e0a85c343cb7 intitial checkin
ca
parents:
diff changeset
   681
! !