UIPainterView.st
author Claus Gittinger <cg@exept.de>
Fri, 14 Sep 2001 18:25:38 +0200
changeset 1491 4249a6a1b252
parent 1474 d2ee565fa32a
child 1494 115ae5972b27
permissions -rw-r--r--
pick with SHIFT-click in the mag-view
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
     1
"
156
b332d7117c40 added copyrights
Claus Gittinger <cg@exept.de>
parents: 154
diff changeset
     2
 COPYRIGHT (c) 1995 by Claus Gittinger / eXept Software AG
b332d7117c40 added copyrights
Claus Gittinger <cg@exept.de>
parents: 154
diff changeset
     3
              All Rights Reserved
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
     4
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
     5
 This software is furnished under a license and may be used
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
     6
 only in accordance with the terms of that license and with the
742
688fd0a0b0fd code generation comment
tz
parents: 723
diff changeset
     7
 inclusion of the above copyright notice. This software may not
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
     8
 be provided or otherwise made available to, or used by, any
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
     9
 other person.  No title to or ownership of the software is
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
    10
 hereby transferred.
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
    11
"
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
    12
1387
65c9df9cb1ad change selection behaviour after delete
ca
parents: 1366
diff changeset
    13
"{ Package: 'stx:libtool2' }"
65c9df9cb1ad change selection behaviour after delete
ca
parents: 1366
diff changeset
    14
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
    15
UIObjectView subclass:#UIPainterView
278
5b7dfe33b497 drag & drop offset
Claus Gittinger <cg@exept.de>
parents: 238
diff changeset
    16
	instanceVariableNames:'treeView listHolder superclassName className methodName
1467
b46624bb6994 use white handles, if the views background color is dark.
Claus Gittinger <cg@exept.de>
parents: 1450
diff changeset
    17
		categoryName handleColorBlack handleColorWhite handleMasterColor'
925
e6ddd46581c3 added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents: 887
diff changeset
    18
	classVariableNames:'HandCursor RedefineAspectMethods AspectsAsInstances'
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
    19
	poolDictionaries:''
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
    20
	category:'Interface-UIPainter'
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
    21
!
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
    22
211
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
    23
Object subclass:#ViewProperty
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
    24
	instanceVariableNames:'view spec identifier'
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
    25
	classVariableNames:'Identifier'
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
    26
	poolDictionaries:''
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
    27
	privateIn:UIPainterView
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
    28
!
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
    29
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
    30
!UIPainterView class methodsFor:'documentation'!
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
    31
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
    32
copyright
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
    33
"
156
b332d7117c40 added copyrights
Claus Gittinger <cg@exept.de>
parents: 154
diff changeset
    34
 COPYRIGHT (c) 1995 by Claus Gittinger / eXept Software AG
b332d7117c40 added copyrights
Claus Gittinger <cg@exept.de>
parents: 154
diff changeset
    35
              All Rights Reserved
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
    36
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
    37
 This software is furnished under a license and may be used
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
    38
 only in accordance with the terms of that license and with the
742
688fd0a0b0fd code generation comment
tz
parents: 723
diff changeset
    39
 inclusion of the above copyright notice. This software may not
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
    40
 be provided or otherwise made available to, or used by, any
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
    41
 other person.  No title to or ownership of the software is
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
    42
 hereby transferred.
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
    43
"
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
    44
!
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
    45
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
    46
documentation
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
    47
"
128
9779b7459a1c selection and update from selection
ca
parents: 121
diff changeset
    48
    buildIn view used by the UIPainter; from this view, the layout of the
9779b7459a1c selection and update from selection
ca
parents: 121
diff changeset
    49
    new application derives from.
9779b7459a1c selection and update from selection
ca
parents: 121
diff changeset
    50
9779b7459a1c selection and update from selection
ca
parents: 121
diff changeset
    51
    [see also:]
9779b7459a1c selection and update from selection
ca
parents: 121
diff changeset
    52
        UIBuilder
9779b7459a1c selection and update from selection
ca
parents: 121
diff changeset
    53
        UIObjectView
156
b332d7117c40 added copyrights
Claus Gittinger <cg@exept.de>
parents: 154
diff changeset
    54
b332d7117c40 added copyrights
Claus Gittinger <cg@exept.de>
parents: 154
diff changeset
    55
    [author:]
b332d7117c40 added copyrights
Claus Gittinger <cg@exept.de>
parents: 154
diff changeset
    56
        Claus Gittinger
b332d7117c40 added copyrights
Claus Gittinger <cg@exept.de>
parents: 154
diff changeset
    57
        Claus Atzkern
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
    58
"
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
    59
! !
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
    60
1225
0aa39cc5f0a3 Initialize class vars.
Stefan Vogel <sv@exept.de>
parents: 1201
diff changeset
    61
!UIPainterView class methodsFor:'initialization'!
0aa39cc5f0a3 Initialize class vars.
Stefan Vogel <sv@exept.de>
parents: 1201
diff changeset
    62
0aa39cc5f0a3 Initialize class vars.
Stefan Vogel <sv@exept.de>
parents: 1201
diff changeset
    63
initialize
0aa39cc5f0a3 Initialize class vars.
Stefan Vogel <sv@exept.de>
parents: 1201
diff changeset
    64
0aa39cc5f0a3 Initialize class vars.
Stefan Vogel <sv@exept.de>
parents: 1201
diff changeset
    65
    AspectsAsInstances := false.
0aa39cc5f0a3 Initialize class vars.
Stefan Vogel <sv@exept.de>
parents: 1201
diff changeset
    66
    RedefineAspectMethods := false.
0aa39cc5f0a3 Initialize class vars.
Stefan Vogel <sv@exept.de>
parents: 1201
diff changeset
    67
0aa39cc5f0a3 Initialize class vars.
Stefan Vogel <sv@exept.de>
parents: 1201
diff changeset
    68
    "Created: / 22.9.1999 / 12:32:31 / stefan"
0aa39cc5f0a3 Initialize class vars.
Stefan Vogel <sv@exept.de>
parents: 1201
diff changeset
    69
! !
0aa39cc5f0a3 Initialize class vars.
Stefan Vogel <sv@exept.de>
parents: 1201
diff changeset
    70
698
5bf234e0e451 redefine methods flag
tz
parents: 662
diff changeset
    71
!UIPainterView class methodsFor:'code generation mode'!
5bf234e0e451 redefine methods flag
tz
parents: 662
diff changeset
    72
925
e6ddd46581c3 added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents: 887
diff changeset
    73
generateAspectsAsInstanceVariables
e6ddd46581c3 added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents: 887
diff changeset
    74
    "if on, aspects are held as instance variables;
e6ddd46581c3 added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents: 887
diff changeset
    75
     if off (the default), they are kept in the bindings dictionary.
e6ddd46581c3 added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents: 887
diff changeset
    76
    "
e6ddd46581c3 added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents: 887
diff changeset
    77
    ^ AspectsAsInstances
e6ddd46581c3 added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents: 887
diff changeset
    78
e6ddd46581c3 added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents: 887
diff changeset
    79
    "Created: / 29.7.1998 / 11:21:38 / cg"
e6ddd46581c3 added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents: 887
diff changeset
    80
    "Modified: / 29.7.1998 / 11:22:01 / cg"
e6ddd46581c3 added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents: 887
diff changeset
    81
!
e6ddd46581c3 added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents: 887
diff changeset
    82
e6ddd46581c3 added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents: 887
diff changeset
    83
generateAspectsAsInstanceVariables:aBoolean
e6ddd46581c3 added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents: 887
diff changeset
    84
    "if on, aspects are held as instance variables;
e6ddd46581c3 added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents: 887
diff changeset
    85
     if off (the default), they are kept in the bindings dictionary.
e6ddd46581c3 added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents: 887
diff changeset
    86
    "
e6ddd46581c3 added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents: 887
diff changeset
    87
    AspectsAsInstances := aBoolean
e6ddd46581c3 added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents: 887
diff changeset
    88
e6ddd46581c3 added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents: 887
diff changeset
    89
    "Created: / 29.7.1998 / 11:21:26 / cg"
e6ddd46581c3 added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents: 887
diff changeset
    90
    "Modified: / 29.7.1998 / 11:22:11 / cg"
e6ddd46581c3 added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents: 887
diff changeset
    91
!
e6ddd46581c3 added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents: 887
diff changeset
    92
742
688fd0a0b0fd code generation comment
tz
parents: 723
diff changeset
    93
redefineAspectMethods
698
5bf234e0e451 redefine methods flag
tz
parents: 662
diff changeset
    94
    "redefine methods yes or no. If a method is defined in super class
5bf234e0e451 redefine methods flag
tz
parents: 662
diff changeset
    95
     should the message be reinstalled ?
5bf234e0e451 redefine methods flag
tz
parents: 662
diff changeset
    96
    "
1225
0aa39cc5f0a3 Initialize class vars.
Stefan Vogel <sv@exept.de>
parents: 1201
diff changeset
    97
    ^ RedefineAspectMethods
698
5bf234e0e451 redefine methods flag
tz
parents: 662
diff changeset
    98
1225
0aa39cc5f0a3 Initialize class vars.
Stefan Vogel <sv@exept.de>
parents: 1201
diff changeset
    99
    "Modified: / 22.9.1999 / 12:33:03 / stefan"
698
5bf234e0e451 redefine methods flag
tz
parents: 662
diff changeset
   100
!
5bf234e0e451 redefine methods flag
tz
parents: 662
diff changeset
   101
742
688fd0a0b0fd code generation comment
tz
parents: 723
diff changeset
   102
redefineAspectMethods:aBoolean
698
5bf234e0e451 redefine methods flag
tz
parents: 662
diff changeset
   103
    "redefine methods yes or no. If a method is defined in super class
5bf234e0e451 redefine methods flag
tz
parents: 662
diff changeset
   104
     should the message be reinstalled ?
5bf234e0e451 redefine methods flag
tz
parents: 662
diff changeset
   105
    "
742
688fd0a0b0fd code generation comment
tz
parents: 723
diff changeset
   106
    RedefineAspectMethods := aBoolean
698
5bf234e0e451 redefine methods flag
tz
parents: 662
diff changeset
   107
5bf234e0e451 redefine methods flag
tz
parents: 662
diff changeset
   108
5bf234e0e451 redefine methods flag
tz
parents: 662
diff changeset
   109
! !
5bf234e0e451 redefine methods flag
tz
parents: 662
diff changeset
   110
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   111
!UIPainterView class methodsFor:'defaults'!
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   112
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   113
defaultMenuMessage   
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   114
    "This message is the default yo be sent to the menuHolder to get a menu
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   115
    "
121
96d6feeeb049 middleButtonMen:
ca
parents: 119
diff changeset
   116
    ^ #showMiddleButtonMenu
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   117
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   118
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   119
! !
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   120
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   121
!UIPainterView methodsFor:'accessing'!
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   122
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   123
application
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   124
    ^ nil
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   125
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   126
    "Modified: 6.9.1995 / 00:46:44 / claus"
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   127
!
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   128
78
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
   129
applicationName
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
   130
    ^ self className
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
   131
!
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
   132
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
   133
applicationName:aName
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
   134
    self className:aName
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
   135
!
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
   136
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   137
className
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   138
    ^ className
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   139
!
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   140
78
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
   141
className:aName
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
   142
    className := aName
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   143
!
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   144
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   145
className:aClassName superclassName:aSuperclassName selector:aSelector
78
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
   146
    className      := aClassName.
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   147
    superclassName := aSuperclassName.
78
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
   148
    methodName     := aSelector.
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   149
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   150
!
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   151
223
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
   152
findInputViewIn:aSuperView
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
   153
    "returns index of input view into superview or nil
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
   154
    "
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
   155
    aSuperView == self ifTrue:[
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
   156
        ^ self subViews findFirst:[:v| v == inputView ]
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
   157
    ].
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
   158
  ^ 0
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
   159
!
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
   160
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
   161
inputView
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
   162
    ^ inputView
111
ca
parents: 103
diff changeset
   163
!
ca
parents: 103
diff changeset
   164
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   165
methodName
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   166
    ^ methodName
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   167
!
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   168
78
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
   169
methodName:aName
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
   170
    methodName := aName
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   171
!
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   172
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   173
selectNames:aStringOrCollection
1031
7ce4b97f2c43 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   174
    |prop coll s n newSel|
7ce4b97f2c43 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   175
7ce4b97f2c43 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   176
    (aStringOrCollection size == 0) ifTrue:[
7ce4b97f2c43 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   177
        newSel := nil.
7ce4b97f2c43 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   178
    ] ifFalse:[
7ce4b97f2c43 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   179
        (s := aStringOrCollection) isString ifFalse:[
7ce4b97f2c43 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   180
            s size == 1 ifTrue:[
7ce4b97f2c43 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   181
                s := s first
7ce4b97f2c43 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   182
            ] ifFalse:[
7ce4b97f2c43 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   183
                coll := OrderedCollection new.
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   184
1031
7ce4b97f2c43 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   185
                s do:[:aName|
7ce4b97f2c43 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   186
                    (prop := self propertyOfName:aName) notNil ifTrue:[
7ce4b97f2c43 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   187
                        coll add:(prop view)
7ce4b97f2c43 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   188
                    ]
7ce4b97f2c43 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   189
                ].
7ce4b97f2c43 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   190
                (n := coll size) == 1 ifTrue:[ 
7ce4b97f2c43 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   191
                    newSel := coll at:1 
7ce4b97f2c43 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   192
                ] ifFalse:[
7ce4b97f2c43 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   193
                    n == 0 ifTrue:[ 
7ce4b97f2c43 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   194
                        newSel := nil
7ce4b97f2c43 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   195
                    ] ifFalse:[
7ce4b97f2c43 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   196
                        newSel := coll
7ce4b97f2c43 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   197
                    ]
7ce4b97f2c43 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   198
                ].
7ce4b97f2c43 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   199
                ^ self select:newSel.
7ce4b97f2c43 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   200
            ]
7ce4b97f2c43 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   201
        ].
7ce4b97f2c43 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   202
7ce4b97f2c43 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   203
        prop := self propertyOfName:s.
7ce4b97f2c43 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   204
        prop isNil ifTrue:[
7ce4b97f2c43 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   205
            newSel := nil
7ce4b97f2c43 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   206
        ] ifFalse:[
7ce4b97f2c43 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   207
            newSel := prop view
7ce4b97f2c43 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   208
        ].
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   209
    ].
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   210
1031
7ce4b97f2c43 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   211
    ^ self select:newSel
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   212
! !
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   213
111
ca
parents: 103
diff changeset
   214
!UIPainterView methodsFor:'change & update'!
ca
parents: 103
diff changeset
   215
223
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
   216
layoutChanged
1445
d2654a3b1e3a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1441
diff changeset
   217
    treeView notNil ifTrue:[
d2654a3b1e3a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1441
diff changeset
   218
        treeView layoutChanged
d2654a3b1e3a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1441
diff changeset
   219
    ]
111
ca
parents: 103
diff changeset
   220
! !
ca
parents: 103
diff changeset
   221
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   222
!UIPainterView methodsFor:'copy & cut & paste'!
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   223
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   224
copySelection
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   225
    "copy the selection into the cut&paste-buffer
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   226
    "
698
5bf234e0e451 redefine methods flag
tz
parents: 662
diff changeset
   227
    |specs coll sel|
5bf234e0e451 redefine methods flag
tz
parents: 662
diff changeset
   228
5bf234e0e451 redefine methods flag
tz
parents: 662
diff changeset
   229
    sel := treeView selection.
71
407d25aca670 checkin from browser
ca
parents: 69
diff changeset
   230
128
9779b7459a1c selection and update from selection
ca
parents: 121
diff changeset
   231
    coll := self minSetOfSuperViews:(self selection).
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   232
71
407d25aca670 checkin from browser
ca
parents: 69
diff changeset
   233
    coll notNil ifTrue:[
776
1df0525eeec9 reuse methods provided by the model
ca
parents: 770
diff changeset
   234
"/        self select:nil.
78
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
   235
        specs := coll collect:[:aView| self fullSpecFor:aView ].
698
5bf234e0e451 redefine methods flag
tz
parents: 662
diff changeset
   236
        self setSelection:specs.
776
1df0525eeec9 reuse methods provided by the model
ca
parents: 770
diff changeset
   237
"/        treeView selection: sel
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   238
    ].
78
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
   239
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
   240
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   241
!
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   242
723
60e8ffac2f38 #deleteSelection in #deleteTotalSelection renamed
tz
parents: 712
diff changeset
   243
deleteSelection
887
79a6e12e1d0f after deleting a widget do select the neighbour then the parent (step 2)
tz
parents: 886
diff changeset
   244
    "delete the selection buffered
79a6e12e1d0f after deleting a widget do select the neighbour then the parent (step 2)
tz
parents: 886
diff changeset
   245
    "
79a6e12e1d0f after deleting a widget do select the neighbour then the parent (step 2)
tz
parents: 886
diff changeset
   246
    self deleteSelectionBuffered: true
79a6e12e1d0f after deleting a widget do select the neighbour then the parent (step 2)
tz
parents: 886
diff changeset
   247
!
79a6e12e1d0f after deleting a widget do select the neighbour then the parent (step 2)
tz
parents: 886
diff changeset
   248
79a6e12e1d0f after deleting a widget do select the neighbour then the parent (step 2)
tz
parents: 886
diff changeset
   249
deleteSelectionBuffered: buffered
698
5bf234e0e451 redefine methods flag
tz
parents: 662
diff changeset
   250
    "cut the selection into the cut&paste-buffer
62
0e8573b4329a so far so good ...
ca
parents: 60
diff changeset
   251
     and open a transaction
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   252
    "
1402
7abc17031163 nil check bug fix
Claus Gittinger <cg@exept.de>
parents: 1388
diff changeset
   253
    |specs coll index oldSelection newSelection treeModel parent children size nd|
71
407d25aca670 checkin from browser
ca
parents: 69
diff changeset
   254
128
9779b7459a1c selection and update from selection
ca
parents: 121
diff changeset
   255
    coll := self minSetOfSuperViews:(self selection).
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   256
78
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
   257
    coll notNil ifTrue:[
238
882be7e03af4 renamed claus instVar (;-)
Claus Gittinger <cg@exept.de>
parents: 231
diff changeset
   258
        treeView cvsEventsDisabledDo:[
1388
c5559ad5c09e change selection behaviour after delete
ca
parents: 1387
diff changeset
   259
            treeModel    := treeView model.
1387
65c9df9cb1ad change selection behaviour after delete
ca
parents: 1366
diff changeset
   260
            oldSelection := treeModel selectedNodes at:1 ifAbsent: nil.
65c9df9cb1ad change selection behaviour after delete
ca
parents: 1366
diff changeset
   261
65c9df9cb1ad change selection behaviour after delete
ca
parents: 1366
diff changeset
   262
            oldSelection notNil ifTrue:[
1388
c5559ad5c09e change selection behaviour after delete
ca
parents: 1387
diff changeset
   263
                children := oldSelection parent children.
c5559ad5c09e change selection behaviour after delete
ca
parents: 1387
diff changeset
   264
                (size := children size) > 1 ifTrue:[
c5559ad5c09e change selection behaviour after delete
ca
parents: 1387
diff changeset
   265
                    index := children identityIndexOf:oldSelection.
c5559ad5c09e change selection behaviour after delete
ca
parents: 1387
diff changeset
   266
                    size == index ifTrue:[
c5559ad5c09e change selection behaviour after delete
ca
parents: 1387
diff changeset
   267
                        index := index - 1
c5559ad5c09e change selection behaviour after delete
ca
parents: 1387
diff changeset
   268
                    ].
c5559ad5c09e change selection behaviour after delete
ca
parents: 1387
diff changeset
   269
                    newSelection := children at:index ifAbsent:1.
c5559ad5c09e change selection behaviour after delete
ca
parents: 1387
diff changeset
   270
                ] ifFalse:[
c5559ad5c09e change selection behaviour after delete
ca
parents: 1387
diff changeset
   271
                    newSelection := oldSelection parent
c5559ad5c09e change selection behaviour after delete
ca
parents: 1387
diff changeset
   272
                ].
c5559ad5c09e change selection behaviour after delete
ca
parents: 1387
diff changeset
   273
                newSelection := treeModel indexOf:newSelection.
1387
65c9df9cb1ad change selection behaviour after delete
ca
parents: 1366
diff changeset
   274
            ] ifFalse:[
1388
c5559ad5c09e change selection behaviour after delete
ca
parents: 1387
diff changeset
   275
                newSelection := 1
886
3c67610b9631 after deleting a widget do select the neighbour then the parent
tz
parents: 858
diff changeset
   276
            ].
1387
65c9df9cb1ad change selection behaviour after delete
ca
parents: 1366
diff changeset
   277
887
79a6e12e1d0f after deleting a widget do select the neighbour then the parent (step 2)
tz
parents: 886
diff changeset
   278
            self hideSelection.
79a6e12e1d0f after deleting a widget do select the neighbour then the parent (step 2)
tz
parents: 886
diff changeset
   279
            selection := nil.
111
ca
parents: 103
diff changeset
   280
            specs := coll collect:[:aView| self fullSpecFor:aView ].
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   281
134
d5ab85ec27fd undo history; keep view identifier
ca
parents: 131
diff changeset
   282
            self withinTransaction:#cut objects:coll do:[
d5ab85ec27fd undo history; keep view identifier
ca
parents: 131
diff changeset
   283
                coll reverseDo:[:aView|
d5ab85ec27fd undo history; keep view identifier
ca
parents: 131
diff changeset
   284
                    self createUndoRemove:aView.
887
79a6e12e1d0f after deleting a widget do select the neighbour then the parent (step 2)
tz
parents: 886
diff changeset
   285
                    self remove:aView.
111
ca
parents: 103
diff changeset
   286
                ]
ca
parents: 103
diff changeset
   287
            ].
1387
65c9df9cb1ad change selection behaviour after delete
ca
parents: 1366
diff changeset
   288
            buffered ifTrue: [self setSelection:specs].
65c9df9cb1ad change selection behaviour after delete
ca
parents: 1366
diff changeset
   289
            treeView selection:nil.
65c9df9cb1ad change selection behaviour after delete
ca
parents: 1366
diff changeset
   290
            treeView selection:(Array with: newSelection).
1402
7abc17031163 nil check bug fix
Claus Gittinger <cg@exept.de>
parents: 1388
diff changeset
   291
            (nd := treeView selectedNode) notNil ifTrue:[
7abc17031163 nil check bug fix
Claus Gittinger <cg@exept.de>
parents: 1388
diff changeset
   292
                self setSelection:nd contents view withRedraw:true.
7abc17031163 nil check bug fix
Claus Gittinger <cg@exept.de>
parents: 1388
diff changeset
   293
            ]
698
5bf234e0e451 redefine methods flag
tz
parents: 662
diff changeset
   294
        ]
5bf234e0e451 redefine methods flag
tz
parents: 662
diff changeset
   295
    ]
5bf234e0e451 redefine methods flag
tz
parents: 662
diff changeset
   296
!
5bf234e0e451 redefine methods flag
tz
parents: 662
diff changeset
   297
723
60e8ffac2f38 #deleteSelection in #deleteTotalSelection renamed
tz
parents: 712
diff changeset
   298
deleteTotalSelection
887
79a6e12e1d0f after deleting a widget do select the neighbour then the parent (step 2)
tz
parents: 886
diff changeset
   299
    "delete the selection
79a6e12e1d0f after deleting a widget do select the neighbour then the parent (step 2)
tz
parents: 886
diff changeset
   300
    "            
79a6e12e1d0f after deleting a widget do select the neighbour then the parent (step 2)
tz
parents: 886
diff changeset
   301
    self deleteSelectionBuffered: false
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   302
!
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   303
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   304
pasteBuffer
62
0e8573b4329a so far so good ...
ca
parents: 60
diff changeset
   305
    "add the objects in the paste-buffer to the object view
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   306
    "
223
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
   307
    |sel|
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
   308
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
   309
    sel := self pasteSpecifications:(self getSelection) keepLayout:false.
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
   310
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
   311
    sel notNil ifTrue:[
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
   312
        self select:sel.
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
   313
    ].
89
35c5711729c2 so far so good
ca
parents: 86
diff changeset
   314
35c5711729c2 so far so good
ca
parents: 86
diff changeset
   315
!
35c5711729c2 so far so good
ca
parents: 86
diff changeset
   316
392
ca
parents: 376
diff changeset
   317
pasteFromClipBoard:aString
ca
parents: 376
diff changeset
   318
    ^ self
ca
parents: 376
diff changeset
   319
ca
parents: 376
diff changeset
   320
ca
parents: 376
diff changeset
   321
!
ca
parents: 376
diff changeset
   322
1338
3c1a528c50db added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   323
pasteKeepingPosition
3c1a528c50db added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   324
    "add the objects in the paste-buffer to the object view; 
3c1a528c50db added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   325
     translate the layout as appropriate, to position the component
3c1a528c50db added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   326
     at the same absolute position (relative to topView) as before
3c1a528c50db added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   327
    "
3c1a528c50db added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   328
    |sel|
3c1a528c50db added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   329
3c1a528c50db added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   330
    sel := self
3c1a528c50db added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   331
        pasteSpecifications:(self getSelection) 
3c1a528c50db added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   332
        keepLayout:true 
3c1a528c50db added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   333
        keepPosition:true 
3c1a528c50db added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   334
        at:nil.
3c1a528c50db added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   335
3c1a528c50db added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   336
    sel notNil ifTrue:[
3c1a528c50db added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   337
        self select:sel.
3c1a528c50db added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   338
    ].
3c1a528c50db added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   339
!
3c1a528c50db added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   340
89
35c5711729c2 so far so good
ca
parents: 86
diff changeset
   341
pasteSpecifications:aSpecificationOrList keepLayout:keepLayout
223
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
   342
    "add the specs to the object view; returns list of pasted components
89
35c5711729c2 so far so good
ca
parents: 86
diff changeset
   343
    "
278
5b7dfe33b497 drag & drop offset
Claus Gittinger <cg@exept.de>
parents: 238
diff changeset
   344
5b7dfe33b497 drag & drop offset
Claus Gittinger <cg@exept.de>
parents: 238
diff changeset
   345
    ^ self
5b7dfe33b497 drag & drop offset
Claus Gittinger <cg@exept.de>
parents: 238
diff changeset
   346
        pasteSpecifications:aSpecificationOrList 
5b7dfe33b497 drag & drop offset
Claus Gittinger <cg@exept.de>
parents: 238
diff changeset
   347
        keepLayout:keepLayout 
5b7dfe33b497 drag & drop offset
Claus Gittinger <cg@exept.de>
parents: 238
diff changeset
   348
        at:nil
5b7dfe33b497 drag & drop offset
Claus Gittinger <cg@exept.de>
parents: 238
diff changeset
   349
5b7dfe33b497 drag & drop offset
Claus Gittinger <cg@exept.de>
parents: 238
diff changeset
   350
    "Modified: 11.8.1997 / 01:00:35 / cg"
5b7dfe33b497 drag & drop offset
Claus Gittinger <cg@exept.de>
parents: 238
diff changeset
   351
!
5b7dfe33b497 drag & drop offset
Claus Gittinger <cg@exept.de>
parents: 238
diff changeset
   352
5b7dfe33b497 drag & drop offset
Claus Gittinger <cg@exept.de>
parents: 238
diff changeset
   353
pasteSpecifications:aSpecificationOrList keepLayout:keepLayout at:aPointOrNil
5b7dfe33b497 drag & drop offset
Claus Gittinger <cg@exept.de>
parents: 238
diff changeset
   354
    "add the specs to the object view; returns list of pasted components
5b7dfe33b497 drag & drop offset
Claus Gittinger <cg@exept.de>
parents: 238
diff changeset
   355
    "
1387
65c9df9cb1ad change selection behaviour after delete
ca
parents: 1366
diff changeset
   356
    ^ self 
1338
3c1a528c50db added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   357
        pasteSpecifications:aSpecificationOrList 
3c1a528c50db added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   358
        keepLayout:keepLayout 
3c1a528c50db added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   359
        keepPosition:false 
3c1a528c50db added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   360
        at:aPointOrNil
3c1a528c50db added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   361
3c1a528c50db added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   362
!
3c1a528c50db added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   363
3c1a528c50db added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   364
pasteSpecifications:aSpecificationOrList keepLayout:keepLayout keepPosition:keepPosition at:aPointOrNil
3c1a528c50db added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   365
    "add the specs to the object view; returns list of pasted components
3c1a528c50db added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   366
    "
312
386932d91a97 paste at a point; first translate the point
ca
parents: 310
diff changeset
   367
    |paste frame pasteOrigin pasteOffset builder newSel bounds|
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   368
89
35c5711729c2 so far so good
ca
parents: 86
diff changeset
   369
    (self canPaste:aSpecificationOrList) ifFalse:[
223
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
   370
        ^ nil
89
35c5711729c2 so far so good
ca
parents: 86
diff changeset
   371
    ].
223
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
   372
776
1df0525eeec9 reuse methods provided by the model
ca
parents: 770
diff changeset
   373
    aSpecificationOrList isCollection ifTrue:[
1df0525eeec9 reuse methods provided by the model
ca
parents: 770
diff changeset
   374
        paste := aSpecificationOrList
1df0525eeec9 reuse methods provided by the model
ca
parents: 770
diff changeset
   375
    ] ifFalse:[
1df0525eeec9 reuse methods provided by the model
ca
parents: 770
diff changeset
   376
        paste := Array with:aSpecificationOrList
1df0525eeec9 reuse methods provided by the model
ca
parents: 770
diff changeset
   377
    ].
1df0525eeec9 reuse methods provided by the model
ca
parents: 770
diff changeset
   378
    (frame := self singleSelection) isNil ifTrue:[
1df0525eeec9 reuse methods provided by the model
ca
parents: 770
diff changeset
   379
        frame := self
1df0525eeec9 reuse methods provided by the model
ca
parents: 770
diff changeset
   380
    ].
1df0525eeec9 reuse methods provided by the model
ca
parents: 770
diff changeset
   381
    self selection:nil.
1df0525eeec9 reuse methods provided by the model
ca
parents: 770
diff changeset
   382
1df0525eeec9 reuse methods provided by the model
ca
parents: 770
diff changeset
   383
    newSel  := OrderedCollection new.
1df0525eeec9 reuse methods provided by the model
ca
parents: 770
diff changeset
   384
    builder := UIBuilder new isEditing:true.
1df0525eeec9 reuse methods provided by the model
ca
parents: 770
diff changeset
   385
1df0525eeec9 reuse methods provided by the model
ca
parents: 770
diff changeset
   386
    className notNil ifTrue:[
1df0525eeec9 reuse methods provided by the model
ca
parents: 770
diff changeset
   387
        builder applicationClass:(self resolveName:className)
1df0525eeec9 reuse methods provided by the model
ca
parents: 770
diff changeset
   388
    ].
1df0525eeec9 reuse methods provided by the model
ca
parents: 770
diff changeset
   389
1338
3c1a528c50db added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   390
    (keepLayout not or:[keepPosition]) ifTrue:[
776
1df0525eeec9 reuse methods provided by the model
ca
parents: 770
diff changeset
   391
        pasteOffset := 0@0.
1df0525eeec9 reuse methods provided by the model
ca
parents: 770
diff changeset
   392
1338
3c1a528c50db added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   393
        keepPosition ifTrue:[
3c1a528c50db added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   394
            pasteOrigin := device translatePoint:0@0
776
1df0525eeec9 reuse methods provided by the model
ca
parents: 770
diff changeset
   395
                                            from:self id
1df0525eeec9 reuse methods provided by the model
ca
parents: 770
diff changeset
   396
                                              to:frame id.
1338
3c1a528c50db added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   397
        ] ifFalse:[
3c1a528c50db added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   398
            aPointOrNil isNil ifTrue:[
3c1a528c50db added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   399
                pasteOrigin := self sensor mousePoint.
3c1a528c50db added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   400
                pasteOrigin := device translatePoint:pasteOrigin
1429
0fb6421a93e9 use rootWindowId (save a message send)
Claus Gittinger <cg@exept.de>
parents: 1427
diff changeset
   401
                                            from:device rootWindowId
1338
3c1a528c50db added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   402
                                              to:frame id.
3c1a528c50db added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   403
            ] ifFalse:[
3c1a528c50db added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   404
                pasteOrigin := device translatePoint:aPointOrNil
3c1a528c50db added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   405
                                                from:self id
3c1a528c50db added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   406
                                                  to:frame id.
3c1a528c50db added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   407
            ]
3c1a528c50db added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   408
        ].
3c1a528c50db added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   409
776
1df0525eeec9 reuse methods provided by the model
ca
parents: 770
diff changeset
   410
        bounds := Rectangle origin:0@0 extent:(frame bounds extent)
1df0525eeec9 reuse methods provided by the model
ca
parents: 770
diff changeset
   411
    ].
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   412
776
1df0525eeec9 reuse methods provided by the model
ca
parents: 770
diff changeset
   413
    paste do:[:aSpec|
1338
3c1a528c50db added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   414
        |view newOrigin|
395
d39076243277 sett UIBuilder isEditing to true
ca
parents: 392
diff changeset
   415
776
1df0525eeec9 reuse methods provided by the model
ca
parents: 770
diff changeset
   416
        view := self addSpec:aSpec builder:builder in:frame.
89
35c5711729c2 so far so good
ca
parents: 86
diff changeset
   417
1338
3c1a528c50db added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   418
        keepPosition ifTrue:[
3c1a528c50db added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   419
            self moveObject:view to:(view origin + pasteOrigin).
3c1a528c50db added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   420
        ] ifFalse:[
3c1a528c50db added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   421
            keepLayout ifFalse:[
3c1a528c50db added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   422
                (bounds containsPoint:pasteOrigin) ifFalse:[
3c1a528c50db added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   423
                    newOrigin := pasteOffset.
3c1a528c50db added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   424
                ] ifTrue:[
3c1a528c50db added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   425
                    newOrigin := pasteOrigin + pasteOffset.
3c1a528c50db added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   426
                ].
3c1a528c50db added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   427
                self moveObject:view to:newOrigin.
3c1a528c50db added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   428
                pasteOffset := pasteOffset + 4
776
1df0525eeec9 reuse methods provided by the model
ca
parents: 770
diff changeset
   429
            ].
312
386932d91a97 paste at a point; first translate the point
ca
parents: 310
diff changeset
   430
        ].
776
1df0525eeec9 reuse methods provided by the model
ca
parents: 770
diff changeset
   431
        view realize.
1df0525eeec9 reuse methods provided by the model
ca
parents: 770
diff changeset
   432
        newSel add:view.
1df0525eeec9 reuse methods provided by the model
ca
parents: 770
diff changeset
   433
    ].
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   434
776
1df0525eeec9 reuse methods provided by the model
ca
parents: 770
diff changeset
   435
    self withinTransaction:#paste objects:newSel do:[
1df0525eeec9 reuse methods provided by the model
ca
parents: 770
diff changeset
   436
        undoHistory addUndoSelector:#undoCreate:
1df0525eeec9 reuse methods provided by the model
ca
parents: 770
diff changeset
   437
                           withArgs:(newSel collect:[:v|(self propertyOfView:v) identifier])
1df0525eeec9 reuse methods provided by the model
ca
parents: 770
diff changeset
   438
    ].
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   439
776
1df0525eeec9 reuse methods provided by the model
ca
parents: 770
diff changeset
   440
    self realizeAllSubViews.
1df0525eeec9 reuse methods provided by the model
ca
parents: 770
diff changeset
   441
    newSel do:[:v| v raise].
1df0525eeec9 reuse methods provided by the model
ca
parents: 770
diff changeset
   442
    inputView raise.
1df0525eeec9 reuse methods provided by the model
ca
parents: 770
diff changeset
   443
    self elementChangedSize:frame.
134
d5ab85ec27fd undo history; keep view identifier
ca
parents: 131
diff changeset
   444
776
1df0525eeec9 reuse methods provided by the model
ca
parents: 770
diff changeset
   445
    newSel size == 1 ifTrue:[newSel := newSel at:1].
223
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
   446
    ^ newSel
89
35c5711729c2 so far so good
ca
parents: 86
diff changeset
   447
!
35c5711729c2 so far so good
ca
parents: 86
diff changeset
   448
35c5711729c2 so far so good
ca
parents: 86
diff changeset
   449
pasteWithLayout
35c5711729c2 so far so good
ca
parents: 86
diff changeset
   450
    "add the objects in the paste-buffer to the object view; don't change the
35c5711729c2 so far so good
ca
parents: 86
diff changeset
   451
     layout
35c5711729c2 so far so good
ca
parents: 86
diff changeset
   452
    "
223
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
   453
    |sel|
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
   454
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
   455
    sel := self pasteSpecifications:(self getSelection) keepLayout:true.
89
35c5711729c2 so far so good
ca
parents: 86
diff changeset
   456
223
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
   457
    sel notNil ifTrue:[
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
   458
        self select:sel.
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
   459
    ].
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   460
! !
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   461
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   462
!UIPainterView methodsFor:'drag & drop'!
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   463
288
675327dd4d7d change drop mechanism:
ca
parents: 285
diff changeset
   464
canDrop:something
675327dd4d7d change drop mechanism:
ca
parents: 285
diff changeset
   465
    "returns true if something can be droped
698
5bf234e0e451 redefine methods flag
tz
parents: 662
diff changeset
   466
    "      
288
675327dd4d7d change drop mechanism:
ca
parents: 285
diff changeset
   467
    (something size == 1 and:[self enabled and:[self numberOfSelections <= 1]]) ifTrue:[
675327dd4d7d change drop mechanism:
ca
parents: 285
diff changeset
   468
      ^ something first theObject isKindOf:UISpecification
223
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
   469
    ].
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
   470
    ^ false
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
   471
!
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
   472
285
d80b3c6a4373 don't use superView instead parent properties derived
ca
parents: 281
diff changeset
   473
canPaste
d80b3c6a4373 don't use superView instead parent properties derived
ca
parents: 281
diff changeset
   474
    "returns true if something to be past exists and can be paste into
d80b3c6a4373 don't use superView instead parent properties derived
ca
parents: 281
diff changeset
   475
     the selection if exists
d80b3c6a4373 don't use superView instead parent properties derived
ca
parents: 281
diff changeset
   476
    "
d80b3c6a4373 don't use superView instead parent properties derived
ca
parents: 281
diff changeset
   477
    ^ self canPaste:(self getSelection)
d80b3c6a4373 don't use superView instead parent properties derived
ca
parents: 281
diff changeset
   478
!
d80b3c6a4373 don't use superView instead parent properties derived
ca
parents: 281
diff changeset
   479
223
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
   480
canPaste:something
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
   481
    "returns true if something could be paste
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
   482
    "
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
   483
    |el size|
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
   484
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
   485
    ((size := self numberOfSelections) <= 1 and:[self enabled]) ifFalse:[
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
   486
        ^ false
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
   487
    ].
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
   488
    something isCollection ifTrue:[something notEmpty ifTrue:[el := something first]]
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
   489
                          ifFalse:[el := something].
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
   490
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
   491
    (el isKindOf:UISpecification) ifFalse:[
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
   492
        ^ false
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
   493
    ].
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
   494
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
   495
    size == 1 ifTrue:[
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
   496
        ^ self canPasteInto:(self singleSelection)
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
   497
    ].
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
   498
  ^ true
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
   499
!
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
   500
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
   501
canPasteInto:aView
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
   502
    "can paste into a view
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
   503
    "
285
d80b3c6a4373 don't use superView instead parent properties derived
ca
parents: 281
diff changeset
   504
    |prop|
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   505
223
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
   506
    aView notNil ifTrue:[
285
d80b3c6a4373 don't use superView instead parent properties derived
ca
parents: 281
diff changeset
   507
        (prop := self propertyRespondsToView:aView) notNil ifTrue:[
d80b3c6a4373 don't use superView instead parent properties derived
ca
parents: 281
diff changeset
   508
            ^ prop spec class supportsSubComponents
d80b3c6a4373 don't use superView instead parent properties derived
ca
parents: 281
diff changeset
   509
        ].
d80b3c6a4373 don't use superView instead parent properties derived
ca
parents: 281
diff changeset
   510
      ^ aView specClass supportsSubComponents.
89
35c5711729c2 so far so good
ca
parents: 86
diff changeset
   511
    ].
35c5711729c2 so far so good
ca
parents: 86
diff changeset
   512
    ^ false
96
73725336b4fe dont paste into scrollable selectionInListViews ...
Claus Gittinger <cg@exept.de>
parents: 89
diff changeset
   513
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   514
!
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   515
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   516
drop:anObjectOrCollection at:aPoint
278
5b7dfe33b497 drag & drop offset
Claus Gittinger <cg@exept.de>
parents: 238
diff changeset
   517
    |spec newSel oldSel dragOffset|
5b7dfe33b497 drag & drop offset
Claus Gittinger <cg@exept.de>
parents: 238
diff changeset
   518
288
675327dd4d7d change drop mechanism:
ca
parents: 285
diff changeset
   519
    self selection notNil ifTrue:[
675327dd4d7d change drop mechanism:
ca
parents: 285
diff changeset
   520
        oldSel := self singleSelection.
675327dd4d7d change drop mechanism:
ca
parents: 285
diff changeset
   521
675327dd4d7d change drop mechanism:
ca
parents: 285
diff changeset
   522
        (self canPasteInto:oldSel) ifFalse:[
675327dd4d7d change drop mechanism:
ca
parents: 285
diff changeset
   523
            oldSel := nil.
675327dd4d7d change drop mechanism:
ca
parents: 285
diff changeset
   524
            self setSelection:nil withRedraw:true
675327dd4d7d change drop mechanism:
ca
parents: 285
diff changeset
   525
        ]
231
75de472d579f check whether selection is a view or a collection
ca
parents: 223
diff changeset
   526
    ].
89
35c5711729c2 so far so good
ca
parents: 86
diff changeset
   527
    spec := (anObjectOrCollection at:1) theObject.
1060
0332a41de5c5 Use #query instead of #raise when invoking QuerySignals
Stefan Vogel <sv@exept.de>
parents: 1058
diff changeset
   528
    dragOffset := DragAndDropManager dragOffsetQuerySignal query.
278
5b7dfe33b497 drag & drop offset
Claus Gittinger <cg@exept.de>
parents: 238
diff changeset
   529
    newSel := self pasteSpecifications:spec keepLayout:false at:aPoint - dragOffset.
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   530
223
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
   531
    oldSel isNil ifTrue:[self select:newSel]
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
   532
                ifFalse:[self select:oldSel]
1060
0332a41de5c5 Use #query instead of #raise when invoking QuerySignals
Stefan Vogel <sv@exept.de>
parents: 1058
diff changeset
   533
0332a41de5c5 Use #query instead of #raise when invoking QuerySignals
Stefan Vogel <sv@exept.de>
parents: 1058
diff changeset
   534
    "Modified: / 18.3.1999 / 18:29:43 / stefan"
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   535
! !
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   536
361
6624bb5d9a1a configuration of grid parameters
ca
parents: 352
diff changeset
   537
!UIPainterView methodsFor:'event handling'!
6624bb5d9a1a configuration of grid parameters
ca
parents: 352
diff changeset
   538
6624bb5d9a1a configuration of grid parameters
ca
parents: 352
diff changeset
   539
keyPress:key x:x y:y view:aView
376
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
   540
    "a delegated keyEvent from aView"
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
   541
361
6624bb5d9a1a configuration of grid parameters
ca
parents: 352
diff changeset
   542
    self keyPress:key x:x y:y
6624bb5d9a1a configuration of grid parameters
ca
parents: 352
diff changeset
   543
376
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
   544
    "Modified: / 31.10.1997 / 20:27:22 / cg"
361
6624bb5d9a1a configuration of grid parameters
ca
parents: 352
diff changeset
   545
!
6624bb5d9a1a configuration of grid parameters
ca
parents: 352
diff changeset
   546
6624bb5d9a1a configuration of grid parameters
ca
parents: 352
diff changeset
   547
keyRelease:key x:x y:y view:aView
376
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
   548
    "a delegated keyEvent from aView"
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
   549
361
6624bb5d9a1a configuration of grid parameters
ca
parents: 352
diff changeset
   550
    self keyRelease:key x:x y:y
6624bb5d9a1a configuration of grid parameters
ca
parents: 352
diff changeset
   551
376
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
   552
    "Modified: / 31.10.1997 / 20:27:32 / cg"
754
04e802a6a920 color master selection in red + grid background colored
tz
parents: 744
diff changeset
   553
!
04e802a6a920 color master selection in red + grid background colored
tz
parents: 744
diff changeset
   554
04e802a6a920 color master selection in red + grid background colored
tz
parents: 744
diff changeset
   555
sizeChanged:how
04e802a6a920 color master selection in red + grid background colored
tz
parents: 744
diff changeset
   556
04e802a6a920 color master selection in red + grid background colored
tz
parents: 744
diff changeset
   557
    super sizeChanged:how. 
04e802a6a920 color master selection in red + grid background colored
tz
parents: 744
diff changeset
   558
04e802a6a920 color master selection in red + grid background colored
tz
parents: 744
diff changeset
   559
    self layoutChanged
361
6624bb5d9a1a configuration of grid parameters
ca
parents: 352
diff changeset
   560
! !
6624bb5d9a1a configuration of grid parameters
ca
parents: 352
diff changeset
   561
78
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
   562
!UIPainterView methodsFor:'generating output'!
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
   563
352
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   564
aspectMethods
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   565
    "extract a list of aspect methods - for browsing"
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   566
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   567
    |cls methods skip selector protoSpec|
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   568
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   569
    className isNil ifTrue:[
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   570
        self warn:'set the class first'.
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   571
        ^ #()
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   572
    ].
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   573
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   574
    cls := self resolveName:className.
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   575
    methods := IdentitySet new.
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   576
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   577
    treeView propertiesDo:[:aProp|
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   578
        |selector|
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   579
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   580
        (selector := aProp model) notNil ifTrue:[
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   581
            selector isArray ifFalse:[
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   582
                selector := selector asSymbol.
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   583
                (cls implements:selector) ifTrue:[
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   584
                    skip := false.
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   585
                    (cls isSubclassOf:SimpleDialog) ifTrue:[
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   586
                        skip := SimpleDialog implements:selector asSymbol
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   587
                    ].
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   588
                    skip ifFalse:[
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   589
                        methods add:(cls compiledMethodAt:selector)
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   590
                    ].
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   591
                ].
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   592
            ].
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   593
        ].
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   594
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   595
        (selector := aProp menu) notNil ifTrue:[
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   596
            selector isArray ifFalse:[
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   597
                selector := selector asSymbol.
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   598
                (cls implements:selector) ifTrue:[
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   599
                    methods add:(cls compiledMethodAt:selector)
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   600
                ]
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   601
            ].
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   602
        ].
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   603
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   604
        (aProp spec aspectSelectors) do:[:aSel |
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   605
            |selector|
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   606
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   607
            aSel isArray ifFalse:[
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   608
                selector := aSel asSymbol.
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   609
                (cls implements:selector) ifTrue:[
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   610
                    methods add:(cls compiledMethodAt:selector)
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   611
                ]
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   612
            ].
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   613
        ].
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   614
        aProp spec actionSelectors do:[:aSel|
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   615
            |selector|
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   616
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   617
            aSel isArray ifFalse:[
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   618
                selector := aSel asSymbol.
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   619
                (cls implements:selector) ifTrue:[
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   620
                    methods add:(cls compiledMethodAt:selector)
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   621
                ]
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   622
            ].
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   623
        ].
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   624
        aProp spec valueSelectors do:[:aSel|
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   625
            |selector|
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   626
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   627
            aSel isArray ifFalse:[
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   628
                selector := aSel asSymbol.
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   629
                (cls implements:selector) ifTrue:[
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   630
                    methods add:(cls compiledMethodAt:selector)
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   631
                ]
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   632
            ].
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   633
        ]
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   634
    ].
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   635
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   636
    protoSpec := treeView canvasSpec.
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   637
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   638
    (selector := protoSpec menu) notNil ifTrue:[
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   639
        selector isArray ifFalse:[
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   640
            selector := selector asSymbol.
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   641
            (cls implements:selector) ifTrue:[
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   642
                methods add:(cls compiledMethodAt:selector)
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   643
            ]
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   644
        ].
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   645
    ].
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   646
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   647
    ^ methods
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   648
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   649
    "Created: / 25.10.1997 / 18:58:25 / cg"
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   650
    "Modified: / 26.10.1997 / 15:06:18 / cg"
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   651
!
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   652
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   653
generateActionMethodFor:aspect spec:protoSpec inClass:targetClass
568
7c4482bf37cf allow more than 1 numArg for an action
ca
parents: 511
diff changeset
   654
    |selector args showIt code alreadyInSuperclass numArgs method|
288
675327dd4d7d change drop mechanism:
ca
parents: 285
diff changeset
   655
675327dd4d7d change drop mechanism:
ca
parents: 285
diff changeset
   656
    selector := aspect asSymbol.
141
d06c04391233 generate actions with argument
ca
parents: 137
diff changeset
   657
288
675327dd4d7d change drop mechanism:
ca
parents: 285
diff changeset
   658
    alreadyInSuperclass := targetClass superclass canUnderstand:selector.
675327dd4d7d change drop mechanism:
ca
parents: 285
diff changeset
   659
568
7c4482bf37cf allow more than 1 numArg for an action
ca
parents: 511
diff changeset
   660
    numArgs := selector numArgs.
7c4482bf37cf allow more than 1 numArg for an action
ca
parents: 511
diff changeset
   661
    method  := aspect.
7c4482bf37cf allow more than 1 numArg for an action
ca
parents: 511
diff changeset
   662
7c4482bf37cf allow more than 1 numArg for an action
ca
parents: 511
diff changeset
   663
    numArgs == 1 ifTrue:[
7c4482bf37cf allow more than 1 numArg for an action
ca
parents: 511
diff changeset
   664
        args := 'anArgument'.
7c4482bf37cf allow more than 1 numArg for an action
ca
parents: 511
diff changeset
   665
        showIt := ''' , anArgument printString , '' ...''.\'.
7c4482bf37cf allow more than 1 numArg for an action
ca
parents: 511
diff changeset
   666
    ] ifFalse:[    
288
675327dd4d7d change drop mechanism:
ca
parents: 285
diff changeset
   667
        args := ''.
149
e652608690b1 help ...
ca
parents: 146
diff changeset
   668
        showIt := ' ...''.\'.
568
7c4482bf37cf allow more than 1 numArg for an action
ca
parents: 511
diff changeset
   669
7c4482bf37cf allow more than 1 numArg for an action
ca
parents: 511
diff changeset
   670
        numArgs ~~ 0 ifTrue:[
7c4482bf37cf allow more than 1 numArg for an action
ca
parents: 511
diff changeset
   671
            method := ''.
7c4482bf37cf allow more than 1 numArg for an action
ca
parents: 511
diff changeset
   672
7c4482bf37cf allow more than 1 numArg for an action
ca
parents: 511
diff changeset
   673
            selector keywords keysAndValuesDo:[:i :key|
7c4482bf37cf allow more than 1 numArg for an action
ca
parents: 511
diff changeset
   674
                method := method, key, 'arg', i printString, ' '
7c4482bf37cf allow more than 1 numArg for an action
ca
parents: 511
diff changeset
   675
            ]
7c4482bf37cf allow more than 1 numArg for an action
ca
parents: 511
diff changeset
   676
        ]
149
e652608690b1 help ...
ca
parents: 146
diff changeset
   677
    ].
141
d06c04391233 generate actions with argument
ca
parents: 137
diff changeset
   678
288
675327dd4d7d change drop mechanism:
ca
parents: 285
diff changeset
   679
    code := '!!' , targetClass name , ' methodsFor:''actions''!!\\' ,
568
7c4482bf37cf allow more than 1 numArg for an action
ca
parents: 511
diff changeset
   680
                method , args , '\' ,
352
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   681
                '    "automatically generated by UIPainter ..."\\' ,
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   682
                '    "*** the code below performs no action"\' ,
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   683
                '    "*** (except for some feedback on the Transcript)"\' ,
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   684
                '    "*** Please change as required and accept in the browser."\' ,
288
675327dd4d7d change drop mechanism:
ca
parents: 285
diff changeset
   685
                '\' .
675327dd4d7d change drop mechanism:
ca
parents: 285
diff changeset
   686
675327dd4d7d change drop mechanism:
ca
parents: 285
diff changeset
   687
    alreadyInSuperclass ifTrue:[
675327dd4d7d change drop mechanism:
ca
parents: 285
diff changeset
   688
        code := code ,
675327dd4d7d change drop mechanism:
ca
parents: 285
diff changeset
   689
                    '    "action for ' , aspect , ' is already provided in a superclass."\' ,
675327dd4d7d change drop mechanism:
ca
parents: 285
diff changeset
   690
                    '    "It may be redefined here ..."\\'.
675327dd4d7d change drop mechanism:
ca
parents: 285
diff changeset
   691
    ] ifFalse:[
675327dd4d7d change drop mechanism:
ca
parents: 285
diff changeset
   692
        code := code ,
675327dd4d7d change drop mechanism:
ca
parents: 285
diff changeset
   693
                    '    "action to be added ..."\\'.
675327dd4d7d change drop mechanism:
ca
parents: 285
diff changeset
   694
    ].
675327dd4d7d change drop mechanism:
ca
parents: 285
diff changeset
   695
675327dd4d7d change drop mechanism:
ca
parents: 285
diff changeset
   696
    code := code ,
675327dd4d7d change drop mechanism:
ca
parents: 285
diff changeset
   697
                '    Transcript showCR:self class name, '': '.
675327dd4d7d change drop mechanism:
ca
parents: 285
diff changeset
   698
    alreadyInSuperclass ifTrue:[
675327dd4d7d change drop mechanism:
ca
parents: 285
diff changeset
   699
        code := code , 'inherited '.
675327dd4d7d change drop mechanism:
ca
parents: 285
diff changeset
   700
    ].
675327dd4d7d change drop mechanism:
ca
parents: 285
diff changeset
   701
    code := code , 'action for ' , aspect , showIt.
675327dd4d7d change drop mechanism:
ca
parents: 285
diff changeset
   702
675327dd4d7d change drop mechanism:
ca
parents: 285
diff changeset
   703
    alreadyInSuperclass ifTrue:[
675327dd4d7d change drop mechanism:
ca
parents: 285
diff changeset
   704
        code := code ,
675327dd4d7d change drop mechanism:
ca
parents: 285
diff changeset
   705
                        '    super ' , aspect , args , '.\'.
675327dd4d7d change drop mechanism:
ca
parents: 285
diff changeset
   706
    ].
675327dd4d7d change drop mechanism:
ca
parents: 285
diff changeset
   707
675327dd4d7d change drop mechanism:
ca
parents: 285
diff changeset
   708
    code := code ,
675327dd4d7d change drop mechanism:
ca
parents: 285
diff changeset
   709
                '!! !!\\'.
675327dd4d7d change drop mechanism:
ca
parents: 285
diff changeset
   710
    ^ code withCRs
675327dd4d7d change drop mechanism:
ca
parents: 285
diff changeset
   711
352
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   712
    "Modified: / 25.10.1997 / 19:18:50 / cg"
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   713
!
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   714
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   715
generateAspectMethodFor:aspect spec:protoSpec inClass:targetClass
1257
acb8c0a58ef3 dataSPec defaultValue when generating aspects
Claus Gittinger <cg@exept.de>
parents: 1252
diff changeset
   716
    |modelClass modelValueString modelValue modelGen code|
134
d5ab85ec27fd undo history; keep view identifier
ca
parents: 131
diff changeset
   717
149
e652608690b1 help ...
ca
parents: 146
diff changeset
   718
    modelClass := protoSpec defaultModelClassFor:aspect.
1257
acb8c0a58ef3 dataSPec defaultValue when generating aspects
Claus Gittinger <cg@exept.de>
parents: 1252
diff changeset
   719
    modelValueString := protoSpec defaultModelValueStringFor:aspect.
acb8c0a58ef3 dataSPec defaultValue when generating aspects
Claus Gittinger <cg@exept.de>
parents: 1252
diff changeset
   720
    modelValueString notNil ifTrue:[
acb8c0a58ef3 dataSPec defaultValue when generating aspects
Claus Gittinger <cg@exept.de>
parents: 1252
diff changeset
   721
        modelGen := modelValueString
acb8c0a58ef3 dataSPec defaultValue when generating aspects
Claus Gittinger <cg@exept.de>
parents: 1252
diff changeset
   722
    ] ifFalse:[
acb8c0a58ef3 dataSPec defaultValue when generating aspects
Claus Gittinger <cg@exept.de>
parents: 1252
diff changeset
   723
        modelValue := protoSpec defaultModelValueFor:aspect.
acb8c0a58ef3 dataSPec defaultValue when generating aspects
Claus Gittinger <cg@exept.de>
parents: 1252
diff changeset
   724
        modelValue isNil ifTrue:[
acb8c0a58ef3 dataSPec defaultValue when generating aspects
Claus Gittinger <cg@exept.de>
parents: 1252
diff changeset
   725
            modelGen := modelClass name , ' new'
acb8c0a58ef3 dataSPec defaultValue when generating aspects
Claus Gittinger <cg@exept.de>
parents: 1252
diff changeset
   726
        ] ifFalse:[
acb8c0a58ef3 dataSPec defaultValue when generating aspects
Claus Gittinger <cg@exept.de>
parents: 1252
diff changeset
   727
            modelGen := modelValue storeString , ' asValue'
acb8c0a58ef3 dataSPec defaultValue when generating aspects
Claus Gittinger <cg@exept.de>
parents: 1252
diff changeset
   728
        ].
352
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   729
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   730
    ].
134
d5ab85ec27fd undo history; keep view identifier
ca
parents: 131
diff changeset
   731
655
093cba68e10a simplified to make microsoft cc happy
Claus Gittinger <cg@exept.de>
parents: 588
diff changeset
   732
    code := '!!' , targetClass name , ' methodsFor:''aspects''!!\\' ,
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   733
      aspect , '\' ,
352
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   734
      '    "automatically generated by UIPainter ..."\\' ,
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   735
      '    "*** the code below creates a default model when invoked."\' ,
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   736
      '    "*** (which may not be the one you wanted)"\' ,
1441
36916e4ce9ab generate better comments (in aspect methods)
Claus Gittinger <cg@exept.de>
parents: 1429
diff changeset
   737
      '    "*** Please change as required and accept it in the browser."\' ,
36916e4ce9ab generate better comments (in aspect methods)
Claus Gittinger <cg@exept.de>
parents: 1429
diff changeset
   738
      '    "*** (and replace this comment by something more useful ;-)"\' .
655
093cba68e10a simplified to make microsoft cc happy
Claus Gittinger <cg@exept.de>
parents: 588
diff changeset
   739
1474
d2ee565fa32a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1467
diff changeset
   740
925
e6ddd46581c3 added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents: 887
diff changeset
   741
    AspectsAsInstances ifTrue:[
1474
d2ee565fa32a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1467
diff changeset
   742
        code := code , '\' ,
925
e6ddd46581c3 added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents: 887
diff changeset
   743
          '    ' , aspect , ' isNil ifTrue:[\' ,
1474
d2ee565fa32a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1467
diff changeset
   744
          '       ' , aspect , ' := ' , ' ' , modelGen , '.\'.
d2ee565fa32a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1467
diff changeset
   745
        modelClass ~~ TriggerValue ifTrue:[
d2ee565fa32a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1467
diff changeset
   746
            code := code ,
d2ee565fa32a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1467
diff changeset
   747
              '"/ if your app needs to be notified of changes, uncomment one of the lines below:\' ,
d2ee565fa32a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1467
diff changeset
   748
              '"/       ' , aspect , ' addDependent:self.\' ,
d2ee565fa32a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1467
diff changeset
   749
              '"/       ' , aspect , ' onChangeSend:#', aspect ,'Changed to:self.\'.
d2ee565fa32a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1467
diff changeset
   750
        ].
d2ee565fa32a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1467
diff changeset
   751
        code := code ,
925
e6ddd46581c3 added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents: 887
diff changeset
   752
          '    ].\' ,
e6ddd46581c3 added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents: 887
diff changeset
   753
          '    ^ ' , aspect ,'.\' ,
1474
d2ee565fa32a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1467
diff changeset
   754
          '!! !!\\' 
925
e6ddd46581c3 added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents: 887
diff changeset
   755
    ] ifFalse:[
1474
d2ee565fa32a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1467
diff changeset
   756
        code := code , '\' ,
925
e6ddd46581c3 added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents: 887
diff changeset
   757
          '    |holder|\' ,
e6ddd46581c3 added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents: 887
diff changeset
   758
          '\' ,
e6ddd46581c3 added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents: 887
diff changeset
   759
          '    (holder := builder bindingAt:#' , aspect , ') isNil ifTrue:[\' ,
1225
0aa39cc5f0a3 Initialize class vars.
Stefan Vogel <sv@exept.de>
parents: 1201
diff changeset
   760
          '        holder := ', modelGen, '.\',
1474
d2ee565fa32a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1467
diff changeset
   761
          '        builder aspectAt:#' , aspect , ' put:holder.\'.
d2ee565fa32a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1467
diff changeset
   762
        modelClass ~~ TriggerValue ifTrue:[
d2ee565fa32a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1467
diff changeset
   763
            code := code ,
d2ee565fa32a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1467
diff changeset
   764
              '"/ if your app needs to be notified of changes, uncomment one of the lines below:\' ,
d2ee565fa32a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1467
diff changeset
   765
              '"/        holder addDependent:self.\' ,
d2ee565fa32a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1467
diff changeset
   766
              '"/        holder onChangeSend:#', aspect ,'Changed to:self.\'.
d2ee565fa32a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1467
diff changeset
   767
        ].
d2ee565fa32a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1467
diff changeset
   768
        code := code ,
925
e6ddd46581c3 added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents: 887
diff changeset
   769
          '    ].\' ,
e6ddd46581c3 added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents: 887
diff changeset
   770
          '    ^ holder.\' ,
1474
d2ee565fa32a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1467
diff changeset
   771
          '!! !!\\' 
925
e6ddd46581c3 added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents: 887
diff changeset
   772
    ].
1361
9020214f03e6 generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
   773
925
e6ddd46581c3 added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents: 887
diff changeset
   774
    ^ code withCRs
352
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   775
925
e6ddd46581c3 added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents: 887
diff changeset
   776
    "Modified: / 29.7.1998 / 11:29:16 / cg"
1225
0aa39cc5f0a3 Initialize class vars.
Stefan Vogel <sv@exept.de>
parents: 1201
diff changeset
   777
    "Modified: / 22.9.1999 / 12:33:47 / stefan"
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   778
!
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   779
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   780
generateAspectMethods
352
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   781
    "generate aspect, action & menu methods
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   782
     - but do not overwrite existing ones.
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   783
     Return a string ready to compile into the application class."
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   784
1069
7196ca547f5d code cleanup
Claus Gittinger <cg@exept.de>
parents: 1060
diff changeset
   785
    |cls code skip protoSpec thisCode
1361
9020214f03e6 generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
   786
     definedMethodSelectors iVars t exportSels|
858
6b2e9e31cf06 do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents: 796
diff changeset
   787
6b2e9e31cf06 do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents: 796
diff changeset
   788
    definedMethodSelectors := IdentitySet new.
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   789
78
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
   790
    code := ''.
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
   791
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   792
    className isNil ifTrue:[
698
5bf234e0e451 redefine methods flag
tz
parents: 662
diff changeset
   793
        self warn:'Set first the class!!'.
78
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
   794
        ^ code
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   795
    ].
698
5bf234e0e451 redefine methods flag
tz
parents: 662
diff changeset
   796
5bf234e0e451 redefine methods flag
tz
parents: 662
diff changeset
   797
    (cls := self resolveName:className) isNil ifTrue:[
5bf234e0e451 redefine methods flag
tz
parents: 662
diff changeset
   798
        self warn:'Class ', className asString, ' does not exist!!'.
5bf234e0e451 redefine methods flag
tz
parents: 662
diff changeset
   799
        ^ code
5bf234e0e451 redefine methods flag
tz
parents: 662
diff changeset
   800
    ].
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   801
316
053e2d3089b7 support of menu performer
ca
parents: 315
diff changeset
   802
    treeView propertiesDo:[:aProp|
1069
7196ca547f5d code cleanup
Claus Gittinger <cg@exept.de>
parents: 1060
diff changeset
   803
        |modelSelector|
352
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   804
134
d5ab85ec27fd undo history; keep view identifier
ca
parents: 131
diff changeset
   805
        protoSpec := aProp spec.
175
0b0b4d99e3e7 isResizeable
ca
parents: 165
diff changeset
   806
78
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
   807
        (modelSelector := aProp model) notNil ifTrue:[
698
5bf234e0e451 redefine methods flag
tz
parents: 662
diff changeset
   808
            self generateCodeFrom:(Array with:modelSelector) in:cls
5bf234e0e451 redefine methods flag
tz
parents: 662
diff changeset
   809
                do:[:aSel|
858
6b2e9e31cf06 do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents: 796
diff changeset
   810
                    |sym|
6b2e9e31cf06 do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents: 796
diff changeset
   811
6b2e9e31cf06 do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents: 796
diff changeset
   812
                    sym := aSel asSymbol.
352
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   813
                    skip := false.
698
5bf234e0e451 redefine methods flag
tz
parents: 662
diff changeset
   814
352
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   815
                    (cls isSubclassOf:SimpleDialog) ifTrue:[
858
6b2e9e31cf06 do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents: 796
diff changeset
   816
                        skip := SimpleDialog implements:sym
6b2e9e31cf06 do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents: 796
diff changeset
   817
                    ].
6b2e9e31cf06 do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents: 796
diff changeset
   818
                    (definedMethodSelectors includes:sym) ifTrue:[
6b2e9e31cf06 do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents: 796
diff changeset
   819
                        skip := true.
158
6e7f892308ae do not generate accept/cancel and help action methods,
Claus Gittinger <cg@exept.de>
parents: 156
diff changeset
   820
                    ].
698
5bf234e0e451 redefine methods flag
tz
parents: 662
diff changeset
   821
352
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   822
                    skip ifFalse:[
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   823
                        "/ kludge ..
796
05b2883a23b0 fixed aspect generation for RadioButtons
Claus Gittinger <cg@exept.de>
parents: 784
diff changeset
   824
                        "/ (protoSpec isKindOf:ActionButtonSpec) 
05b2883a23b0 fixed aspect generation for RadioButtons
Claus Gittinger <cg@exept.de>
parents: 784
diff changeset
   825
                        (protoSpec defaultModelIsCallBackMethodSelector:aSel)
05b2883a23b0 fixed aspect generation for RadioButtons
Claus Gittinger <cg@exept.de>
parents: 784
diff changeset
   826
                        ifTrue:[
698
5bf234e0e451 redefine methods flag
tz
parents: 662
diff changeset
   827
                            thisCode := (self generateActionMethodFor:aSel spec:protoSpec inClass:cls).
352
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   828
                        ] ifFalse:[
698
5bf234e0e451 redefine methods flag
tz
parents: 662
diff changeset
   829
                            thisCode := (self generateAspectMethodFor:aSel spec:protoSpec inClass:cls).
352
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   830
                        ].
858
6b2e9e31cf06 do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents: 796
diff changeset
   831
                        code := code, thisCode.
6b2e9e31cf06 do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents: 796
diff changeset
   832
                        definedMethodSelectors add:sym.
1363
0a7e7a1ade85 trace aspect-method generation on Transcript
Claus Gittinger <cg@exept.de>
parents: 1362
diff changeset
   833
                        Transcript showCR:'code generated for aspect: ' , sym
1030
0b9fbaecbe88 output a warning on the transcript, when an aspect method
Claus Gittinger <cg@exept.de>
parents: 1029
diff changeset
   834
                    ] ifTrue:[
1363
0a7e7a1ade85 trace aspect-method generation on Transcript
Claus Gittinger <cg@exept.de>
parents: 1362
diff changeset
   835
                        Transcript showCR:'*** no code generated for aspect: ' , sym , ' (method already exists)'
1361
9020214f03e6 generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
   836
                    ].
9020214f03e6 generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
   837
                ].
62
0e8573b4329a so far so good ...
ca
parents: 60
diff changeset
   838
        ].
0e8573b4329a so far so good ...
ca
parents: 60
diff changeset
   839
1361
9020214f03e6 generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
   840
        "/ for each aspect, generate getter (if not yet implemented)
698
5bf234e0e451 redefine methods flag
tz
parents: 662
diff changeset
   841
        self generateCodeFrom:(aProp spec aspectSelectors) in:cls
5bf234e0e451 redefine methods flag
tz
parents: 662
diff changeset
   842
                do:[:aSel|
858
6b2e9e31cf06 do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents: 796
diff changeset
   843
                    |sym|
6b2e9e31cf06 do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents: 796
diff changeset
   844
6b2e9e31cf06 do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents: 796
diff changeset
   845
                    sym := aSel asSymbol.
6b2e9e31cf06 do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents: 796
diff changeset
   846
                    (definedMethodSelectors includes:sym) ifFalse:[
6b2e9e31cf06 do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents: 796
diff changeset
   847
                        thisCode := (self generateAspectMethodFor:aSel spec:protoSpec inClass:cls).
6b2e9e31cf06 do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents: 796
diff changeset
   848
                        code := code , thisCode.
6b2e9e31cf06 do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents: 796
diff changeset
   849
                        definedMethodSelectors add:sym.
1363
0a7e7a1ade85 trace aspect-method generation on Transcript
Claus Gittinger <cg@exept.de>
parents: 1362
diff changeset
   850
                        Transcript showCR:'code generated for aspect: ' , sym
858
6b2e9e31cf06 do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents: 796
diff changeset
   851
                    ]
698
5bf234e0e451 redefine methods flag
tz
parents: 662
diff changeset
   852
                ].
5bf234e0e451 redefine methods flag
tz
parents: 662
diff changeset
   853
1361
9020214f03e6 generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
   854
        "/ exported aspects - need setter methods
9020214f03e6 generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
   855
        exportSels := (treeView exportedAspects ? #()) collect:[:entry | (entry subAspect , ':') asSymbol].
9020214f03e6 generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
   856
        self generateCodeFrom:exportSels in:cls
9020214f03e6 generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
   857
                do:[:aSel|
9020214f03e6 generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
   858
                    |sym aspect|
9020214f03e6 generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
   859
9020214f03e6 generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
   860
                    sym := aSel asSymbol.
9020214f03e6 generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
   861
                    (definedMethodSelectors includes:sym) ifFalse:[
9020214f03e6 generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
   862
                        aspect := (aSel copyWithoutLast:1) asSymbol.
9020214f03e6 generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
   863
                        thisCode := (self generateAspectSetMethodFor:aspect spec:protoSpec inClass:cls).
9020214f03e6 generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
   864
                        code := code , thisCode.
9020214f03e6 generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
   865
                        definedMethodSelectors add:sym.
1363
0a7e7a1ade85 trace aspect-method generation on Transcript
Claus Gittinger <cg@exept.de>
parents: 1362
diff changeset
   866
                        Transcript showCR:'export code generated for aspect: ' , sym
1361
9020214f03e6 generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
   867
                    ]
9020214f03e6 generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
   868
                ].
9020214f03e6 generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
   869
698
5bf234e0e451 redefine methods flag
tz
parents: 662
diff changeset
   870
        self generateCodeFrom:(aProp spec actionSelectors) in:cls
5bf234e0e451 redefine methods flag
tz
parents: 662
diff changeset
   871
                do:[:aSel|
858
6b2e9e31cf06 do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents: 796
diff changeset
   872
                    |sym|
6b2e9e31cf06 do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents: 796
diff changeset
   873
6b2e9e31cf06 do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents: 796
diff changeset
   874
                    sym := aSel asSymbol.
6b2e9e31cf06 do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents: 796
diff changeset
   875
                    (definedMethodSelectors includes:sym) ifFalse:[
6b2e9e31cf06 do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents: 796
diff changeset
   876
                        thisCode := (self generateActionMethodFor:aSel spec:protoSpec inClass:cls).
6b2e9e31cf06 do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents: 796
diff changeset
   877
                        code := code , thisCode.
6b2e9e31cf06 do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents: 796
diff changeset
   878
                        definedMethodSelectors add:sym.
1363
0a7e7a1ade85 trace aspect-method generation on Transcript
Claus Gittinger <cg@exept.de>
parents: 1362
diff changeset
   879
                        Transcript showCR:'action generated for aspect: ' , sym
858
6b2e9e31cf06 do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents: 796
diff changeset
   880
                    ]
698
5bf234e0e451 redefine methods flag
tz
parents: 662
diff changeset
   881
                ].
5bf234e0e451 redefine methods flag
tz
parents: 662
diff changeset
   882
5bf234e0e451 redefine methods flag
tz
parents: 662
diff changeset
   883
        self generateCodeFrom:(aProp spec valueSelectors) in:cls
5bf234e0e451 redefine methods flag
tz
parents: 662
diff changeset
   884
                do:[:aSel|
858
6b2e9e31cf06 do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents: 796
diff changeset
   885
                    |sym|
6b2e9e31cf06 do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents: 796
diff changeset
   886
6b2e9e31cf06 do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents: 796
diff changeset
   887
                    sym := aSel asSymbol.
6b2e9e31cf06 do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents: 796
diff changeset
   888
                    (definedMethodSelectors includes:sym) ifFalse:[
6b2e9e31cf06 do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents: 796
diff changeset
   889
                        "/ uppercase: - assume its a globals name.
6b2e9e31cf06 do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents: 796
diff changeset
   890
                        aSel first isUppercase ifFalse:[
6b2e9e31cf06 do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents: 796
diff changeset
   891
                            thisCode := (self generateValueMethodFor:aSel spec:protoSpec inClass:cls).
6b2e9e31cf06 do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents: 796
diff changeset
   892
                            code := code , thisCode.
6b2e9e31cf06 do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents: 796
diff changeset
   893
                            definedMethodSelectors add:sym.
1363
0a7e7a1ade85 trace aspect-method generation on Transcript
Claus Gittinger <cg@exept.de>
parents: 1362
diff changeset
   894
                            Transcript showCR:'code generated for aspect: ' , sym
858
6b2e9e31cf06 do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents: 796
diff changeset
   895
                        ]
376
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
   896
                    ]
698
5bf234e0e451 redefine methods flag
tz
parents: 662
diff changeset
   897
                ].
316
053e2d3089b7 support of menu performer
ca
parents: 315
diff changeset
   898
    ].
053e2d3089b7 support of menu performer
ca
parents: 315
diff changeset
   899
925
e6ddd46581c3 added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents: 887
diff changeset
   900
    AspectsAsInstances ifTrue:[
e6ddd46581c3 added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents: 887
diff changeset
   901
        iVars := cls instVarNames asOrderedCollection.
e6ddd46581c3 added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents: 887
diff changeset
   902
        definedMethodSelectors do:[:ivar |
e6ddd46581c3 added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents: 887
diff changeset
   903
            (iVars includes:ivar) ifFalse:[
e6ddd46581c3 added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents: 887
diff changeset
   904
                iVars add:ivar
e6ddd46581c3 added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents: 887
diff changeset
   905
            ]
e6ddd46581c3 added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents: 887
diff changeset
   906
        ].
e6ddd46581c3 added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents: 887
diff changeset
   907
        iVars := iVars asArray.
e6ddd46581c3 added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents: 887
diff changeset
   908
        t := cls shallowCopy.
e6ddd46581c3 added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents: 887
diff changeset
   909
        t setInstanceVariableString:iVars asStringCollection asString.
e6ddd46581c3 added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents: 887
diff changeset
   910
        code := (t definition) , '!!\' withCRs , code.
e6ddd46581c3 added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents: 887
diff changeset
   911
    ].
352
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   912
    ^ code
698
5bf234e0e451 redefine methods flag
tz
parents: 662
diff changeset
   913
925
e6ddd46581c3 added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents: 887
diff changeset
   914
    "Modified: / 29.7.1998 / 12:21:19 / cg"
698
5bf234e0e451 redefine methods flag
tz
parents: 662
diff changeset
   915
!
5bf234e0e451 redefine methods flag
tz
parents: 662
diff changeset
   916
1358
c0116e25a2ac generateAspectSelectorsMethod
ca
parents: 1347
diff changeset
   917
generateAspectSelectorsMethod
c0116e25a2ac generateAspectSelectorsMethod
ca
parents: 1347
diff changeset
   918
    "generate aspectSelectors method.
c0116e25a2ac generateAspectSelectorsMethod
ca
parents: 1347
diff changeset
   919
     Return a string ready to compile into the application class."
c0116e25a2ac generateAspectSelectorsMethod
ca
parents: 1347
diff changeset
   920
c0116e25a2ac generateAspectSelectorsMethod
ca
parents: 1347
diff changeset
   921
    |cls code spec|
c0116e25a2ac generateAspectSelectorsMethod
ca
parents: 1347
diff changeset
   922
c0116e25a2ac generateAspectSelectorsMethod
ca
parents: 1347
diff changeset
   923
    className isNil ifTrue:[
c0116e25a2ac generateAspectSelectorsMethod
ca
parents: 1347
diff changeset
   924
        self warn:'Set first the class!!'.
c0116e25a2ac generateAspectSelectorsMethod
ca
parents: 1347
diff changeset
   925
        ^ nil
c0116e25a2ac generateAspectSelectorsMethod
ca
parents: 1347
diff changeset
   926
    ].
c0116e25a2ac generateAspectSelectorsMethod
ca
parents: 1347
diff changeset
   927
c0116e25a2ac generateAspectSelectorsMethod
ca
parents: 1347
diff changeset
   928
    (cls := self resolveName:className) isNil ifTrue:[
c0116e25a2ac generateAspectSelectorsMethod
ca
parents: 1347
diff changeset
   929
        self warn:'Class ', className asString, ' does not exist!!'.
c0116e25a2ac generateAspectSelectorsMethod
ca
parents: 1347
diff changeset
   930
        ^ nil
c0116e25a2ac generateAspectSelectorsMethod
ca
parents: 1347
diff changeset
   931
    ].
c0116e25a2ac generateAspectSelectorsMethod
ca
parents: 1347
diff changeset
   932
    spec := treeView exportedAspects.
c0116e25a2ac generateAspectSelectorsMethod
ca
parents: 1347
diff changeset
   933
    spec size == 0 ifTrue:[^ nil].
c0116e25a2ac generateAspectSelectorsMethod
ca
parents: 1347
diff changeset
   934
c0116e25a2ac generateAspectSelectorsMethod
ca
parents: 1347
diff changeset
   935
    "/ make it an array ...
1362
b710bba663cb fixed generateAspectSelectors code generator
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   936
    spec := spec collect:[:entry | |subAspect type|
b710bba663cb fixed generateAspectSelectors code generator
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   937
                subAspect := entry subAspect asSymbol.
b710bba663cb fixed generateAspectSelectors code generator
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   938
                (type := entry type) isNil ifTrue:[
b710bba663cb fixed generateAspectSelectors code generator
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   939
                    subAspect
1358
c0116e25a2ac generateAspectSelectorsMethod
ca
parents: 1347
diff changeset
   940
                ] ifFalse:[
1362
b710bba663cb fixed generateAspectSelectors code generator
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   941
                    Array with:subAspect with:type asSymbol
1358
c0116e25a2ac generateAspectSelectorsMethod
ca
parents: 1347
diff changeset
   942
                ].
c0116e25a2ac generateAspectSelectorsMethod
ca
parents: 1347
diff changeset
   943
            ].
c0116e25a2ac generateAspectSelectorsMethod
ca
parents: 1347
diff changeset
   944
    spec := spec asArray.
c0116e25a2ac generateAspectSelectorsMethod
ca
parents: 1347
diff changeset
   945
c0116e25a2ac generateAspectSelectorsMethod
ca
parents: 1347
diff changeset
   946
    code := '!!' , cls name , ' class methodsFor:''plugIn spec''!!\\' .
c0116e25a2ac generateAspectSelectorsMethod
ca
parents: 1347
diff changeset
   947
c0116e25a2ac generateAspectSelectorsMethod
ca
parents: 1347
diff changeset
   948
    code := code , 'aspectSelectors
c0116e25a2ac generateAspectSelectorsMethod
ca
parents: 1347
diff changeset
   949
    "This resource specification was automatically generated
c0116e25a2ac generateAspectSelectorsMethod
ca
parents: 1347
diff changeset
   950
     by the UIPainter of ST/X."
c0116e25a2ac generateAspectSelectorsMethod
ca
parents: 1347
diff changeset
   951
c0116e25a2ac generateAspectSelectorsMethod
ca
parents: 1347
diff changeset
   952
    "Do not manually edit this. If it is corrupted,
c0116e25a2ac generateAspectSelectorsMethod
ca
parents: 1347
diff changeset
   953
     the UIPainter may not be able to read the specification."
c0116e25a2ac generateAspectSelectorsMethod
ca
parents: 1347
diff changeset
   954
c0116e25a2ac generateAspectSelectorsMethod
ca
parents: 1347
diff changeset
   955
    "Return a description of exported aspects;
c0116e25a2ac generateAspectSelectorsMethod
ca
parents: 1347
diff changeset
   956
     these can be connected to aspects of an embedding application
c0116e25a2ac generateAspectSelectorsMethod
ca
parents: 1347
diff changeset
   957
     (if this app is embedded in a subCanvas)."
c0116e25a2ac generateAspectSelectorsMethod
ca
parents: 1347
diff changeset
   958
1362
b710bba663cb fixed generateAspectSelectors code generator
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   959
    ^ #(\'.
b710bba663cb fixed generateAspectSelectors code generator
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   960
    spec do:[:el | code := code , ('        ' , el storeString , '\') ].
b710bba663cb fixed generateAspectSelectors code generator
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   961
    code := code , '      ).\'.
b710bba663cb fixed generateAspectSelectors code generator
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   962
    code := code , '\!!\'.
1358
c0116e25a2ac generateAspectSelectorsMethod
ca
parents: 1347
diff changeset
   963
    code := code withCRs.
c0116e25a2ac generateAspectSelectorsMethod
ca
parents: 1347
diff changeset
   964
    ^ code
c0116e25a2ac generateAspectSelectorsMethod
ca
parents: 1347
diff changeset
   965
1362
b710bba663cb fixed generateAspectSelectors code generator
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   966
    "Modified: / 18.2.2000 / 02:08:34 / cg"
1358
c0116e25a2ac generateAspectSelectorsMethod
ca
parents: 1347
diff changeset
   967
!
c0116e25a2ac generateAspectSelectorsMethod
ca
parents: 1347
diff changeset
   968
1361
9020214f03e6 generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
   969
generateAspectSetMethodFor:aspect spec:protoSpec inClass:targetClass
9020214f03e6 generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
   970
    |code|
9020214f03e6 generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
   971
9020214f03e6 generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
   972
    code := '!!' , targetClass name , ' methodsFor:''aspects - exported''!!\\' ,
9020214f03e6 generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
   973
      aspect , ':something\' ,
9020214f03e6 generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
   974
      '    "automatically generated by UIPainter ..."\\' ,
9020214f03e6 generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
   975
      '    "This method is used when I am embedded as subApplication,"\' ,
9020214f03e6 generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
   976
      '    "and the mainApp wants to connect its aspects to mine."\'.
9020214f03e6 generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
   977
9020214f03e6 generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
   978
    AspectsAsInstances ifTrue:[
9020214f03e6 generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
   979
        code := (code , '\' ,
1366
ffb95ba845ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1363
diff changeset
   980
          '"/     ' , aspect , ' notNil ifTrue:[\' ,
ffb95ba845ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1363
diff changeset
   981
          '"/        ' , aspect , ' removeDependent:self.\' ,
ffb95ba845ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1363
diff changeset
   982
          '"/     ].\' ,
1361
9020214f03e6 generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
   983
          '    ' , aspect ,' := something.\' ,
1366
ffb95ba845ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1363
diff changeset
   984
          '"/     ' , aspect ,' notNil ifTrue:[\' ,
ffb95ba845ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1363
diff changeset
   985
          '"/        ' , aspect , ' addDependent:self.\' ,
ffb95ba845ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1363
diff changeset
   986
          '"/     ].\' ,
1361
9020214f03e6 generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
   987
          '    ^ self.\' ,
9020214f03e6 generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
   988
          '!! !!\\') 
9020214f03e6 generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
   989
    ] ifFalse:[
9020214f03e6 generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
   990
        code := (code , '\' ,
1366
ffb95ba845ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1363
diff changeset
   991
          '"/     |holder|\' ,
1361
9020214f03e6 generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
   992
          '\' ,
1366
ffb95ba845ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1363
diff changeset
   993
          '"/     (holder := builder bindingAt:#' , aspect , ') notNil ifTrue:[\' ,
ffb95ba845ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1363
diff changeset
   994
          '"/         holder removeDependent:self.\' ,
ffb95ba845ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1363
diff changeset
   995
          '"/     ].\' ,
1361
9020214f03e6 generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
   996
          '    builder aspectAt:#' , aspect , ' put:something.\',
1366
ffb95ba845ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1363
diff changeset
   997
          '"/     something notNil ifTrue:[\' ,
ffb95ba845ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1363
diff changeset
   998
          '"/         something addDependent:self.\' ,
ffb95ba845ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1363
diff changeset
   999
          '"/     ].\' ,
1361
9020214f03e6 generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
  1000
          '    ^ self.\' ,
9020214f03e6 generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
  1001
          '!! !!\\') 
9020214f03e6 generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
  1002
    ].
9020214f03e6 generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
  1003
9020214f03e6 generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
  1004
    ^ code withCRs
9020214f03e6 generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
  1005
9020214f03e6 generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
  1006
    "Modified: / 29.7.1998 / 11:29:16 / cg"
9020214f03e6 generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
  1007
    "Modified: / 22.9.1999 / 12:33:47 / stefan"
9020214f03e6 generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
  1008
!
9020214f03e6 generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
  1009
698
5bf234e0e451 redefine methods flag
tz
parents: 662
diff changeset
  1010
generateCodeFrom:aListOfSelectors in:aClass do:aBlock
5bf234e0e451 redefine methods flag
tz
parents: 662
diff changeset
  1011
744
20cbba6d7e96 oops - no #redefineMethods found
tz
parents: 742
diff changeset
  1012
    self class redefineAspectMethods ifTrue:[
698
5bf234e0e451 redefine methods flag
tz
parents: 662
diff changeset
  1013
        aListOfSelectors do:[:aSelector|
5bf234e0e451 redefine methods flag
tz
parents: 662
diff changeset
  1014
            (aSelector isArray or:[aClass implements:aSelector]) ifFalse:[
5bf234e0e451 redefine methods flag
tz
parents: 662
diff changeset
  1015
                aBlock value:aSelector
1030
0b9fbaecbe88 output a warning on the transcript, when an aspect method
Claus Gittinger <cg@exept.de>
parents: 1029
diff changeset
  1016
            ] ifTrue:[
0b9fbaecbe88 output a warning on the transcript, when an aspect method
Claus Gittinger <cg@exept.de>
parents: 1029
diff changeset
  1017
                Transcript showCR:'#' , aSelector , ' skipped - already implemented in the class'
698
5bf234e0e451 redefine methods flag
tz
parents: 662
diff changeset
  1018
            ]
5bf234e0e451 redefine methods flag
tz
parents: 662
diff changeset
  1019
        ]
5bf234e0e451 redefine methods flag
tz
parents: 662
diff changeset
  1020
    ] ifFalse:[
5bf234e0e451 redefine methods flag
tz
parents: 662
diff changeset
  1021
        aListOfSelectors do:[:aSelector|
1092
60e029255679 oops - failed to generate code for constant-list-holders.
Claus Gittinger <cg@exept.de>
parents: 1084
diff changeset
  1022
            aSelector isArray ifFalse:[
60e029255679 oops - failed to generate code for constant-list-holders.
Claus Gittinger <cg@exept.de>
parents: 1084
diff changeset
  1023
                (aClass canUnderstand:aSelector) ifFalse:[
60e029255679 oops - failed to generate code for constant-list-holders.
Claus Gittinger <cg@exept.de>
parents: 1084
diff changeset
  1024
                    aBlock value:aSelector
60e029255679 oops - failed to generate code for constant-list-holders.
Claus Gittinger <cg@exept.de>
parents: 1084
diff changeset
  1025
                ] ifTrue:[
60e029255679 oops - failed to generate code for constant-list-holders.
Claus Gittinger <cg@exept.de>
parents: 1084
diff changeset
  1026
                    Transcript showCR:'#' , aSelector , ' skipped - already implemented in the class (or superclass)'
60e029255679 oops - failed to generate code for constant-list-holders.
Claus Gittinger <cg@exept.de>
parents: 1084
diff changeset
  1027
                ]
698
5bf234e0e451 redefine methods flag
tz
parents: 662
diff changeset
  1028
            ]
5bf234e0e451 redefine methods flag
tz
parents: 662
diff changeset
  1029
        ]
5bf234e0e451 redefine methods flag
tz
parents: 662
diff changeset
  1030
    ]
5bf234e0e451 redefine methods flag
tz
parents: 662
diff changeset
  1031
5bf234e0e451 redefine methods flag
tz
parents: 662
diff changeset
  1032
376
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1033
!
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1034
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1035
generateHookMethodFor:selectorSpec comment:commentWhen note:noteOrNil defaultCode:defaultCode inClass:targetClass
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1036
    ^ ('!!' , targetClass name , ' methodsFor:''hooks''!!\\' ,
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1037
      selectorSpec , '\' ,
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1038
      '    "automatically generated by UIPainter ..."\\' ,
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1039
      '    "*** the code here does nothing. It is invoked when"\' ,
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1040
      '    "*** ' , commentWhen , '"\' ,
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1041
      '    "*** Please change as required and accept in the browser."\' ,
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1042
      '\' ,
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1043
      '    "specific code to be added below ..."\' ,
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1044
      '    "' , (noteOrNil ? '') , '"\' ,
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1045
      '\' ,
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1046
      (defaultCode ? '^ self.') ,
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1047
      '!! !!\\') withCRs
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1048
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1049
    "Modified: / 25.10.1997 / 19:22:17 / cg"
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1050
    "Created: / 31.10.1997 / 17:31:53 / cg"
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1051
!
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1052
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1053
generateHookMethods
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1054
    "generate hook methods
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1055
     - but do not overwrite existing ones.
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1056
     Return a string ready to compile into the application class."
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1057
1069
7196ca547f5d code cleanup
Claus Gittinger <cg@exept.de>
parents: 1060
diff changeset
  1058
    |cls code|
376
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1059
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1060
    code := ''.
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1061
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1062
    className isNil ifTrue:[
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1063
        self warn:'set the class first'.
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1064
        ^ code
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1065
    ].
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1066
    cls := self resolveName:className.
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1067
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1068
    code := code , (self generateHookMethodsInClass:cls).
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1069
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1070
    ^ code
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1071
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1072
    "Created: / 31.10.1997 / 17:21:29 / cg"
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1073
    "Modified: / 31.10.1997 / 17:38:11 / cg"
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1074
!
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1075
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1076
generateHookMethodsInClass:targetClass
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1077
    |code|
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1078
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1079
    code := ''.
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1080
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1081
    (targetClass implements:#postBuildWith:) ifFalse:[
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1082
        code := code 
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1083
                , (self 
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1084
                    generateHookMethodFor:'postBuildWith:aBuilder'
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1085
                    comment:'the widgets have been built, but before the view is opened'
708
b5f3169a0ba7 super sends for the hook methods
tz
parents: 698
diff changeset
  1086
                    note:'or after the super send'
b5f3169a0ba7 super sends for the hook methods
tz
parents: 698
diff changeset
  1087
                    defaultCode:'    super postBuildWith:aBuilder'
376
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1088
                    inClass:targetClass)
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1089
    ].
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1090
    (targetClass implements:#postOpenWith:) ifFalse:[
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1091
        code := code 
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1092
                , (self 
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1093
                    generateHookMethodFor:'postOpenWith:aBuilder'
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1094
                    comment:'the topView has been opened, but before events are dispatched for it'
708
b5f3169a0ba7 super sends for the hook methods
tz
parents: 698
diff changeset
  1095
                    note:'or after the super send'
b5f3169a0ba7 super sends for the hook methods
tz
parents: 698
diff changeset
  1096
                    defaultCode:'    super postOpenWith:aBuilder'
376
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1097
                    inClass:targetClass)
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1098
    ].
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1099
    (targetClass implements:#closeRequest) ifFalse:[
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1100
        code := code 
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1101
                , (self 
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1102
                    generateHookMethodFor:'closeRequest'
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1103
                    comment:'the topView has been asked to close'
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1104
                    note:'return without the ''super closeRequest'' to stay open'
708
b5f3169a0ba7 super sends for the hook methods
tz
parents: 698
diff changeset
  1105
                    defaultCode:'    ^super closeRequest'
376
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1106
                    inClass:targetClass)
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1107
    ].
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1108
    ^ code
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1109
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1110
    "Modified: / 31.10.1997 / 17:30:34 / cg"
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1111
    "Created: / 31.10.1997 / 17:32:49 / cg"
316
053e2d3089b7 support of menu performer
ca
parents: 315
diff changeset
  1112
!
053e2d3089b7 support of menu performer
ca
parents: 315
diff changeset
  1113
965
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1114
generateMenuMethodFor:menuSel inClass:targetClass
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1115
    |selector args showIt code alreadyInSuperclass numArgs method|
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1116
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1117
    selector := menuSel asSymbol.
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1118
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1119
    alreadyInSuperclass := targetClass superclass canUnderstand:selector.
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1120
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1121
    code := '!!' , targetClass name , ' methodsFor:''menu actions''!!\\'.
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1122
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1123
    selector = 'openAboutThisApplication' ifTrue:[
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1124
        code := code ,
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1125
                'openAboutThisApplication\' ,
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1126
                '    "opens an about box for this application."\\' ,
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1127
                '    "automatically generated by UIPainter ..."\\' ,
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1128
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1129
                '    |rev box myClass clsRev image msg|\\' ,
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1130
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1131
                '    rev := ''''.\' ,
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1132
                '    myClass := self class.\' ,
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1133
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1134
                '    (clsRev := myClass revision) notNil ifTrue:[\' ,
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1135
                '       rev := ''  (rev: '', clsRev printString, '')''].\\' ,
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1136
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1137
                '    msg := Character cr asString , myClass name asBoldText, rev.\' ,
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1138
                '    msg := (msg , ''\\*** add more info here ***\\'') withCRs.\\' ,
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1139
                '    box := AboutBox title:msg.\' ,
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1140
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1141
                '    "/ *** add a #defaultIcon method in the class\' ,
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1142
                '    "/ *** and uncomment the following line:\' ,
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1143
                '    "/ image := self class defaultIcon.\\' ,
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1144
                '    image notNil ifTrue:[\' ,
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1145
                '        box image:image\' ,
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1146
                '    ].\' ,
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1147
                '    box   label:(resources string:''About %1'' with:myClass name).\' ,
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1148
                '    box   autoHideAfter:10 with:[].\' ,
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1149
                '    box   showAtPointer.\' ,
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1150
                '!! !!\\'.
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1151
        ^ code withCRs
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1152
    ].
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1153
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1154
    selector = 'menuOpen' ifTrue:[
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1155
        code := code ,
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1156
                'menuOpen\' ,
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1157
                '    "automatically generated by UIPainter ..."\\' ,
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1158
                '    "*** the code below opens a dialog for file selection"\' ,
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1159
                '    "*** and invokes the #doOpen: method with the selected file."\' ,
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1160
                '    "*** Please change as required and accept in the browser."\\' ,
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1161
                '    |file|\\' ,
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1162
                '    file :=\' ,
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1163
                '        (FileSelectionBrowser\' ,
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1164
                '            request: ''Open''\' ,
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1165
                '            fileName: ''''\' ,
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1166
                '            "/ inDirectory: lastOpenDirectory\' ,
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1167
                '            withFileFilters: #(''*'')).\\' ,
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1168
                '    file notNil ifTrue:[\' ,
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1169
                '       "/ lastOpenDirectory := file asFilename directory.\' ,
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1170
                '       self doOpen:file\' ,
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1171
                '    ]\' ,
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1172
                '!! !!\'.
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1173
        ^ code withCRs
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1174
    ].
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1175
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1176
    numArgs := selector numArgs.
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1177
    method  := selector.
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1178
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1179
    numArgs == 1 ifTrue:[
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1180
        args := 'anArgument'.
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1181
        showIt := ''' , anArgument printString , '' ...''.\'.
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1182
    ] ifFalse:[    
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1183
        args := ''.
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1184
        showIt := ' ...''.\'.
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1185
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1186
        numArgs ~~ 0 ifTrue:[
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1187
            method := ''.
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1188
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1189
            selector keywords keysAndValuesDo:[:i :key|
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1190
                method := method, key, 'arg', i printString, ' '
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1191
            ]
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1192
        ]
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1193
    ].
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1194
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1195
    code := code ,
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1196
                method , args , '\' ,
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1197
                '    "automatically generated by UIPainter ..."\\' ,
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1198
                '    "*** the code below performs no action"\' ,
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1199
                '    "*** (except for some feedback on the Transcript)"\' ,
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1200
                '    "*** Please change as required and accept in the browser."\' ,
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1201
                '\' .
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1202
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1203
    alreadyInSuperclass ifTrue:[
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1204
        code := code ,
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1205
                    '    "action for ' , selector , ' is already provided in a superclass."\' ,
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1206
                    '    "It may be redefined here ..."\\'.
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1207
    ] ifFalse:[
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1208
        code := code ,
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1209
                    '    "action to be added ..."\\'.
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1210
    ].
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1211
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1212
    code := code ,
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1213
                '    Transcript showCR:self class name, '': '.
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1214
    alreadyInSuperclass ifTrue:[
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1215
        code := code , 'inherited '.
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1216
    ].
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1217
    code := code , 'menu action for ' , selector , showIt.
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1218
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1219
    alreadyInSuperclass ifTrue:[
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1220
        code := code ,
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1221
                        '    super ' , selector , args , '.\'.
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1222
    ].
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1223
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1224
    code := code ,
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1225
                '!! !!\\'.
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1226
    ^ code withCRs
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1227
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1228
    "Created: / 23.8.1998 / 16:46:51 / cg"
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1229
    "Modified: / 23.8.1998 / 18:13:05 / cg"
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1230
!
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1231
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1232
generateMenuMethods
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1233
    "generate menu methods
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1234
     - but do not overwrite existing ones.
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1235
     Return a string ready to compile into the application class."
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1236
1069
7196ca547f5d code cleanup
Claus Gittinger <cg@exept.de>
parents: 1060
diff changeset
  1237
    |cls code menuSelector thisCode
7196ca547f5d code cleanup
Claus Gittinger <cg@exept.de>
parents: 1060
diff changeset
  1238
     definedMethodSelectors
965
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1239
     specArray fullSpec winSpec menuSpec
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1240
     |
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1241
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1242
    className isNil ifTrue:[
1069
7196ca547f5d code cleanup
Claus Gittinger <cg@exept.de>
parents: 1060
diff changeset
  1243
        self warn:'Define the class first !!'.
7196ca547f5d code cleanup
Claus Gittinger <cg@exept.de>
parents: 1060
diff changeset
  1244
        ^ nil
965
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1245
    ].
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1246
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1247
    (cls := self resolveName:className) isNil ifTrue:[
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1248
        self warn:'Class ', className asString, ' does not exist!!'.
1069
7196ca547f5d code cleanup
Claus Gittinger <cg@exept.de>
parents: 1060
diff changeset
  1249
        ^ nil
965
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1250
    ].
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1251
1058
243d945b1daf name the (full-)spec
tm
parents: 1050
diff changeset
  1252
    specArray := treeView generateFullSpecForComponents:#() named:nil.
965
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1253
    fullSpec := specArray decodeAsLiteralArray.
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1254
    winSpec := fullSpec window.
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1255
    menuSelector := winSpec menu.
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1256
1069
7196ca547f5d code cleanup
Claus Gittinger <cg@exept.de>
parents: 1060
diff changeset
  1257
    (menuSelector notNil 
7196ca547f5d code cleanup
Claus Gittinger <cg@exept.de>
parents: 1060
diff changeset
  1258
    and:[ (cls respondsTo:menuSelector) ]) ifFalse:[
965
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1259
        self warn:'No menu defined (yet)'.
1069
7196ca547f5d code cleanup
Claus Gittinger <cg@exept.de>
parents: 1060
diff changeset
  1260
        ^ nil.
965
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1261
    ].
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1262
    menuSpec := cls perform:menuSelector.
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1263
    menuSpec := menuSpec decodeAsLiteralArray.
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1264
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1265
    definedMethodSelectors := IdentitySet new.
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1266
    code := ''.
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1267
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1268
    menuSpec allItemsDo:[:item |
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1269
        |sel|
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1270
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1271
        (sel := item value) notNil ifTrue:[
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1272
            (definedMethodSelectors includes:sel) ifFalse:[
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1273
                self generateCodeFrom:(Array with:sel) in:cls do:[:aSel|
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1274
                    thisCode := (self generateMenuMethodFor:aSel inClass:cls).
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1275
                    code := code, thisCode.
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1276
                ].
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1277
                definedMethodSelectors add:sel.
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1278
            ].
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1279
        ]
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1280
    ].
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1281
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1282
    (definedMethodSelectors includes:#menuOpen) ifTrue:[
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1283
        self generateCodeFrom:(Array with:#doOpen:) in:cls do:[:aSel|
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1284
            thisCode := (self generateMenuMethodFor:aSel inClass:cls).
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1285
            code := code, thisCode.
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1286
        ].
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1287
    ].
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1288
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1289
    ^ code
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1290
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1291
    "Created: / 23.8.1998 / 16:12:09 / cg"
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1292
    "Modified: / 23.8.1998 / 18:12:23 / cg"
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1293
!
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1294
188
8091a35bccf1 generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents: 180
diff changeset
  1295
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
8091a35bccf1 generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents: 180
diff changeset
  1296
    ^ ('!!' , targetClass name , ' methodsFor:''values''!!\\' ,
8091a35bccf1 generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents: 180
diff changeset
  1297
      aspect , '\' ,
352
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
  1298
      '    "automatically generated by UIPainter ..."\\' ,
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
  1299
      '    "*** the code below returns a default value when invoked."\' ,
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
  1300
      '    "*** (which may not be the one you wanted)"\' ,
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
  1301
      '    "*** Please change as required and accept in the browser."\' ,
188
8091a35bccf1 generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents: 180
diff changeset
  1302
      '\' ,
8091a35bccf1 generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents: 180
diff changeset
  1303
      '    "value to be added below ..."\' ,
8091a35bccf1 generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents: 180
diff changeset
  1304
      '    Transcript showCR:self class name , '': no value yet for ' , aspect , ' ...''.\' ,
8091a35bccf1 generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents: 180
diff changeset
  1305
      '\' ,
8091a35bccf1 generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents: 180
diff changeset
  1306
      '^ nil.' ,
8091a35bccf1 generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents: 180
diff changeset
  1307
      '!! !!\\') withCRs
8091a35bccf1 generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents: 180
diff changeset
  1308
352
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
  1309
    "Modified: / 25.10.1997 / 19:22:17 / cg"
188
8091a35bccf1 generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents: 180
diff changeset
  1310
!
8091a35bccf1 generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents: 180
diff changeset
  1311
78
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
  1312
generateWindowSpecMethodSource
457
0b39d43d4324 care for exclas in spec-code
Claus Gittinger <cg@exept.de>
parents: 445
diff changeset
  1313
    |spec str code category cls mthd specCode|
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
  1314
310
a68c182d050f support of scrollers and menu for the canvas
ca
parents: 288
diff changeset
  1315
    spec := OrderedCollection new.
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
  1316
78
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
  1317
    self subViews do:[:aView|
1191
32bb9f029ad2 care for wrapped views
Claus Gittinger <cg@exept.de>
parents: 1173
diff changeset
  1318
        |vSpec|
32bb9f029ad2 care for wrapped views
Claus Gittinger <cg@exept.de>
parents: 1173
diff changeset
  1319
78
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
  1320
        aView ~~ inputView ifTrue:[
1191
32bb9f029ad2 care for wrapped views
Claus Gittinger <cg@exept.de>
parents: 1173
diff changeset
  1321
            "/ care for wrapped views ...
32bb9f029ad2 care for wrapped views
Claus Gittinger <cg@exept.de>
parents: 1173
diff changeset
  1322
            vSpec := self fullSpecFor:aView.
32bb9f029ad2 care for wrapped views
Claus Gittinger <cg@exept.de>
parents: 1173
diff changeset
  1323
            vSpec isNil ifTrue:[
32bb9f029ad2 care for wrapped views
Claus Gittinger <cg@exept.de>
parents: 1173
diff changeset
  1324
                aView subViews size == 1 ifTrue:[
32bb9f029ad2 care for wrapped views
Claus Gittinger <cg@exept.de>
parents: 1173
diff changeset
  1325
                    vSpec := self fullSpecFor:(aView subViews first).
32bb9f029ad2 care for wrapped views
Claus Gittinger <cg@exept.de>
parents: 1173
diff changeset
  1326
                ]
32bb9f029ad2 care for wrapped views
Claus Gittinger <cg@exept.de>
parents: 1173
diff changeset
  1327
            ].
32bb9f029ad2 care for wrapped views
Claus Gittinger <cg@exept.de>
parents: 1173
diff changeset
  1328
            vSpec isNil ifTrue:[
32bb9f029ad2 care for wrapped views
Claus Gittinger <cg@exept.de>
parents: 1173
diff changeset
  1329
                self warn:'Oops - could not create spec for some view'
32bb9f029ad2 care for wrapped views
Claus Gittinger <cg@exept.de>
parents: 1173
diff changeset
  1330
            ].
32bb9f029ad2 care for wrapped views
Claus Gittinger <cg@exept.de>
parents: 1173
diff changeset
  1331
            spec add:vSpec
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
  1332
        ]
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
  1333
    ].
1058
243d945b1daf name the (full-)spec
tm
parents: 1050
diff changeset
  1334
243d945b1daf name the (full-)spec
tm
parents: 1050
diff changeset
  1335
    spec := treeView generateFullSpecForComponents:spec named:methodName.
310
a68c182d050f support of scrollers and menu for the canvas
ca
parents: 288
diff changeset
  1336
    str  := WriteStream on:String new.
a68c182d050f support of scrollers and menu for the canvas
ca
parents: 288
diff changeset
  1337
    UISpecification prettyPrintSpecArray:spec on:str indent:5.
464
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1338
    specCode := str contents.
457
0b39d43d4324 care for exclas in spec-code
Claus Gittinger <cg@exept.de>
parents: 445
diff changeset
  1339
0b39d43d4324 care for exclas in spec-code
Claus Gittinger <cg@exept.de>
parents: 445
diff changeset
  1340
    (specCode includes:$!!) ifTrue:[
0b39d43d4324 care for exclas in spec-code
Claus Gittinger <cg@exept.de>
parents: 445
diff changeset
  1341
        "/ oops - must be chunk format ...
0b39d43d4324 care for exclas in spec-code
Claus Gittinger <cg@exept.de>
parents: 445
diff changeset
  1342
        str  := WriteStream on:String new.
0b39d43d4324 care for exclas in spec-code
Claus Gittinger <cg@exept.de>
parents: 445
diff changeset
  1343
        str nextPutAllAsChunk:specCode.
0b39d43d4324 care for exclas in spec-code
Claus Gittinger <cg@exept.de>
parents: 445
diff changeset
  1344
        specCode := str contents.
0b39d43d4324 care for exclas in spec-code
Claus Gittinger <cg@exept.de>
parents: 445
diff changeset
  1345
    ].
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
  1346
178
fb8451053c96 keep windowSpec methods category if it already exists
Claus Gittinger <cg@exept.de>
parents: 175
diff changeset
  1347
    "/ if that method already exists, do not overwrite the category
fb8451053c96 keep windowSpec methods category if it already exists
Claus Gittinger <cg@exept.de>
parents: 175
diff changeset
  1348
fb8451053c96 keep windowSpec methods category if it already exists
Claus Gittinger <cg@exept.de>
parents: 175
diff changeset
  1349
    category := 'interface specs'.
330
ca
parents: 327
diff changeset
  1350
    cls := self resolveName:className.
ca
parents: 327
diff changeset
  1351
ca
parents: 327
diff changeset
  1352
    cls notNil ifTrue:[
178
fb8451053c96 keep windowSpec methods category if it already exists
Claus Gittinger <cg@exept.de>
parents: 175
diff changeset
  1353
        (mthd := cls class compiledMethodAt:methodName asSymbol) notNil ifTrue:[
fb8451053c96 keep windowSpec methods category if it already exists
Claus Gittinger <cg@exept.de>
parents: 175
diff changeset
  1354
            category := mthd category.
fb8451053c96 keep windowSpec methods category if it already exists
Claus Gittinger <cg@exept.de>
parents: 175
diff changeset
  1355
        ]
fb8451053c96 keep windowSpec methods category if it already exists
Claus Gittinger <cg@exept.de>
parents: 175
diff changeset
  1356
    ].
fb8451053c96 keep windowSpec methods category if it already exists
Claus Gittinger <cg@exept.de>
parents: 175
diff changeset
  1357
238
882be7e03af4 renamed claus instVar (;-)
Claus Gittinger <cg@exept.de>
parents: 231
diff changeset
  1358
    code := '!!'
178
fb8451053c96 keep windowSpec methods category if it already exists
Claus Gittinger <cg@exept.de>
parents: 175
diff changeset
  1359
            , className , ' class methodsFor:' , category storeString
238
882be7e03af4 renamed claus instVar (;-)
Claus Gittinger <cg@exept.de>
parents: 231
diff changeset
  1360
            , '!!' , '\\'
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
  1361
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
  1362
            , methodName , '\'
742
688fd0a0b0fd code generation comment
tz
parents: 723
diff changeset
  1363
            , ((ResourceSpecEditor codeGenerationCommentForClass: UIPainter) replChar:$!! withString:'!!!!')
688fd0a0b0fd code generation comment
tz
parents: 723
diff changeset
  1364
            , '\\    "\'
1013
c6428ebd2f0d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 995
diff changeset
  1365
            , ('     UIPainter new openOnClass:' , className , ' andSelector:#' , methodName , '\').
c6428ebd2f0d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 995
diff changeset
  1366
1050
355a8ff451b6 care for as-yet-unspecified class in show-spec menu item.
Claus Gittinger <cg@exept.de>
parents: 1039
diff changeset
  1367
    (cls notNil and:[cls isSubclassOf:ApplicationModel]) ifTrue:[
1013
c6428ebd2f0d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 995
diff changeset
  1368
        code := code
c6428ebd2f0d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 995
diff changeset
  1369
            , ('     ' , className , ' new openInterface:#' , methodName , '\').
c6428ebd2f0d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 995
diff changeset
  1370
    ].
c6428ebd2f0d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 995
diff changeset
  1371
c6428ebd2f0d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 995
diff changeset
  1372
    code := code
742
688fd0a0b0fd code generation comment
tz
parents: 723
diff changeset
  1373
            ,(methodName = 'windowSpec' 
688fd0a0b0fd code generation comment
tz
parents: 723
diff changeset
  1374
                ifTrue:['     ' , className , ' open\'] ifFalse: [''])
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
  1375
            , '    "\'.
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
  1376
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
  1377
    code := code 
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
  1378
            , '\'
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
  1379
            , '    <resource: #canvas>\\'
1084
5b46f277b3e1 nicer code generated
Claus Gittinger <cg@exept.de>
parents: 1069
diff changeset
  1380
            , '    ^ ' , specCode 
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
  1381
            , '\'
238
882be7e03af4 renamed claus instVar (;-)
Claus Gittinger <cg@exept.de>
parents: 231
diff changeset
  1382
            , '!! !!'
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
  1383
            , '\\'.
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
  1384
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
  1385
    ^ code withCRs
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
  1386
1013
c6428ebd2f0d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 995
diff changeset
  1387
    "Modified: / 5.9.1995 / 21:01:35 / claus"
c6428ebd2f0d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 995
diff changeset
  1388
    "Modified: / 15.10.1998 / 11:29:53 / cg"
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
  1389
! !
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
  1390
754
04e802a6a920 color master selection in red + grid background colored
tz
parents: 744
diff changeset
  1391
!UIPainterView methodsFor:'grid manipulation'!
04e802a6a920 color master selection in red + grid background colored
tz
parents: 744
diff changeset
  1392
04e802a6a920 color master selection in red + grid background colored
tz
parents: 744
diff changeset
  1393
newGrid
04e802a6a920 color master selection in red + grid background colored
tz
parents: 744
diff changeset
  1394
    "define a new grid - this is a private helper which has to be
04e802a6a920 color master selection in red + grid background colored
tz
parents: 744
diff changeset
  1395
     called after any change in the grid. It (re)creates the gridPixmap,
04e802a6a920 color master selection in red + grid background colored
tz
parents: 744
diff changeset
  1396
     clears the view and redraws all visible objects."
04e802a6a920 color master selection in red + grid background colored
tz
parents: 744
diff changeset
  1397
04e802a6a920 color master selection in red + grid background colored
tz
parents: 744
diff changeset
  1398
    |defaultViewBackground|
04e802a6a920 color master selection in red + grid background colored
tz
parents: 744
diff changeset
  1399
04e802a6a920 color master selection in red + grid background colored
tz
parents: 744
diff changeset
  1400
    gridPixmap := nil.
04e802a6a920 color master selection in red + grid background colored
tz
parents: 744
diff changeset
  1401
    defaultViewBackground := self class defaultViewBackgroundColor.
04e802a6a920 color master selection in red + grid background colored
tz
parents: 744
diff changeset
  1402
04e802a6a920 color master selection in red + grid background colored
tz
parents: 744
diff changeset
  1403
    shown ifTrue:[
04e802a6a920 color master selection in red + grid background colored
tz
parents: 744
diff changeset
  1404
        self viewBackground: (defaultViewBackground isColor
04e802a6a920 color master selection in red + grid background colored
tz
parents: 744
diff changeset
  1405
            ifTrue: [defaultViewBackground]
04e802a6a920 color master selection in red + grid background colored
tz
parents: 744
diff changeset
  1406
            ifFalse:[Black]).
04e802a6a920 color master selection in red + grid background colored
tz
parents: 744
diff changeset
  1407
        self clear.
04e802a6a920 color master selection in red + grid background colored
tz
parents: 744
diff changeset
  1408
    ].
04e802a6a920 color master selection in red + grid background colored
tz
parents: 744
diff changeset
  1409
04e802a6a920 color master selection in red + grid background colored
tz
parents: 744
diff changeset
  1410
    gridShown ifTrue:[
04e802a6a920 color master selection in red + grid background colored
tz
parents: 744
diff changeset
  1411
        self defineGrid.
04e802a6a920 color master selection in red + grid background colored
tz
parents: 744
diff changeset
  1412
        gridPixmap colorMap: (defaultViewBackground isColor
04e802a6a920 color master selection in red + grid background colored
tz
parents: 744
diff changeset
  1413
            ifTrue: [Array with:defaultViewBackground with:Color darkGray]
04e802a6a920 color master selection in red + grid background colored
tz
parents: 744
diff changeset
  1414
            ifFalse:[Array with:White with:Black]).
04e802a6a920 color master selection in red + grid background colored
tz
parents: 744
diff changeset
  1415
        self viewBackground:gridPixmap.
04e802a6a920 color master selection in red + grid background colored
tz
parents: 744
diff changeset
  1416
    ].
04e802a6a920 color master selection in red + grid background colored
tz
parents: 744
diff changeset
  1417
04e802a6a920 color master selection in red + grid background colored
tz
parents: 744
diff changeset
  1418
    self invalidate
04e802a6a920 color master selection in red + grid background colored
tz
parents: 744
diff changeset
  1419
04e802a6a920 color master selection in red + grid background colored
tz
parents: 744
diff changeset
  1420
! !
04e802a6a920 color master selection in red + grid background colored
tz
parents: 744
diff changeset
  1421
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
  1422
!UIPainterView methodsFor:'initialization'!
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
  1423
770
96f106b0a61e set color on device
ca
parents: 768
diff changeset
  1424
create
96f106b0a61e set color on device
ca
parents: 768
diff changeset
  1425
    "colors on device
96f106b0a61e set color on device
ca
parents: 768
diff changeset
  1426
    "
96f106b0a61e set color on device
ca
parents: 768
diff changeset
  1427
    super create.
96f106b0a61e set color on device
ca
parents: 768
diff changeset
  1428
1467
b46624bb6994 use white handles, if the views background color is dark.
Claus Gittinger <cg@exept.de>
parents: 1450
diff changeset
  1429
    handleColorBlack  := handleColorBlack onDevice:device.
b46624bb6994 use white handles, if the views background color is dark.
Claus Gittinger <cg@exept.de>
parents: 1450
diff changeset
  1430
    handleColorWhite  := handleColorWhite onDevice:device.
1201
c88c6cee0cca #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1191
diff changeset
  1431
    handleMasterColor := handleMasterColor onDevice:device.
770
96f106b0a61e set color on device
ca
parents: 768
diff changeset
  1432
!
96f106b0a61e set color on device
ca
parents: 768
diff changeset
  1433
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
  1434
initialize
62
0e8573b4329a so far so good ...
ca
parents: 60
diff changeset
  1435
    "setup attributes
0e8573b4329a so far so good ...
ca
parents: 60
diff changeset
  1436
    "
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
  1437
    super initialize.
770
96f106b0a61e set color on device
ca
parents: 768
diff changeset
  1438
    superclassName    := 'ApplicationModel'.
96f106b0a61e set color on device
ca
parents: 768
diff changeset
  1439
    className         := 'NewApplication'.
96f106b0a61e set color on device
ca
parents: 768
diff changeset
  1440
    methodName        := 'windowSpec'.
96f106b0a61e set color on device
ca
parents: 768
diff changeset
  1441
    categoryName      := 'Applications'.
96f106b0a61e set color on device
ca
parents: 768
diff changeset
  1442
    HandCursor        := Cursor leftHand.
1467
b46624bb6994 use white handles, if the views background color is dark.
Claus Gittinger <cg@exept.de>
parents: 1450
diff changeset
  1443
    handleColorBlack  := Color black.
b46624bb6994 use white handles, if the views background color is dark.
Claus Gittinger <cg@exept.de>
parents: 1450
diff changeset
  1444
    handleColorWhite  := Color white.
770
96f106b0a61e set color on device
ca
parents: 768
diff changeset
  1445
    handleMasterColor := Color red.
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
  1446
712
bf8aa59e82b6 user friendly names
tz
parents: 708
diff changeset
  1447
    self backgroundColor: self class defaultViewBackgroundColor.
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
  1448
!
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
  1449
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
  1450
setupFromSpec:specOrSpecArray
784
9ae2b94658e5 wait cursor
tz
parents: 776
diff changeset
  1451
78
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
  1452
    |spec builder|
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
  1453
784
9ae2b94658e5 wait cursor
tz
parents: 776
diff changeset
  1454
    Cursor wait showWhile: [
9ae2b94658e5 wait cursor
tz
parents: 776
diff changeset
  1455
        self removeAll.
1029
240e51822e15 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1015
diff changeset
  1456
        specOrSpecArray notNil ifTrue:[
240e51822e15 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1015
diff changeset
  1457
            spec    := UISpecification from:specOrSpecArray.
240e51822e15 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1015
diff changeset
  1458
        ].
784
9ae2b94658e5 wait cursor
tz
parents: 776
diff changeset
  1459
        builder := UIBuilder new isEditing:true.
9ae2b94658e5 wait cursor
tz
parents: 776
diff changeset
  1460
        "set applicationClass, in order that subspecifications may be resolved"
9ae2b94658e5 wait cursor
tz
parents: 776
diff changeset
  1461
        className notNil ifTrue:[
9ae2b94658e5 wait cursor
tz
parents: 776
diff changeset
  1462
            builder applicationClass:(self resolveName:className).
9ae2b94658e5 wait cursor
tz
parents: 776
diff changeset
  1463
        ].
1029
240e51822e15 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1015
diff changeset
  1464
        spec notNil ifTrue:[
240e51822e15 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1015
diff changeset
  1465
            spec window setupView:self topView for:builder.
240e51822e15 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1015
diff changeset
  1466
            self addSpec:(spec component) builder:builder in:self.
240e51822e15 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1015
diff changeset
  1467
        ].
784
9ae2b94658e5 wait cursor
tz
parents: 776
diff changeset
  1468
        self realizeAllSubViews.
9ae2b94658e5 wait cursor
tz
parents: 776
diff changeset
  1469
        inputView raise.
1029
240e51822e15 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1015
diff changeset
  1470
        spec notNil ifTrue:[
240e51822e15 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1015
diff changeset
  1471
            treeView setAttributesFromWindowSpec:(spec window)
240e51822e15 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1015
diff changeset
  1472
        ]
784
9ae2b94658e5 wait cursor
tz
parents: 776
diff changeset
  1473
    ]
9ae2b94658e5 wait cursor
tz
parents: 776
diff changeset
  1474
223
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
  1475
!
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
  1476
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
  1477
treeView:aTreeView
361
6624bb5d9a1a configuration of grid parameters
ca
parents: 352
diff changeset
  1478
    treeView := aTreeView.
6624bb5d9a1a configuration of grid parameters
ca
parents: 352
diff changeset
  1479
6624bb5d9a1a configuration of grid parameters
ca
parents: 352
diff changeset
  1480
    treeView delegate:(
376
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1481
        "/
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1482
        "/ I want to handle everything typed
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1483
        "/ in the treeView, except for Return and Cursor-keys
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1484
        "/
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1485
        KeyboardForwarder 
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1486
            toView:self
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1487
            condition:nil
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1488
            filter:[:k | (k isSymbol 
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1489
                         and:[k ~~ #Return 
1308
e0bf7aae9c51 keyboardForwarder: delegate no #Tab
ca
parents: 1258
diff changeset
  1490
                         and:[k ~~ #Tab 
e0bf7aae9c51 keyboardForwarder: delegate no #Tab
ca
parents: 1258
diff changeset
  1491
                         and:[(k startsWith:#Cursor) not]]])
376
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1492
                   ]
361
6624bb5d9a1a configuration of grid parameters
ca
parents: 352
diff changeset
  1493
    )
6624bb5d9a1a configuration of grid parameters
ca
parents: 352
diff changeset
  1494
376
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1495
    "Modified: / 31.10.1997 / 20:22:09 / cg"
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
  1496
! !
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
  1497
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
  1498
!UIPainterView methodsFor:'menus'!
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
  1499
121
96d6feeeb049 middleButtonMen:
ca
parents: 119
diff changeset
  1500
showMiddleButtonMenu
96d6feeeb049 middleButtonMen:
ca
parents: 119
diff changeset
  1501
    "show the middle button menu; this returns nil
62
0e8573b4329a so far so good ...
ca
parents: 60
diff changeset
  1502
    "
223
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
  1503
    self enabled ifTrue:[
754
04e802a6a920 color master selection in red + grid background colored
tz
parents: 744
diff changeset
  1504
        (MenuPanel fromSpec:(UIPainter menuEdit) receiver:self superView application) startUp
111
ca
parents: 103
diff changeset
  1505
    ].
121
96d6feeeb049 middleButtonMen:
ca
parents: 119
diff changeset
  1506
  ^ nil
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
  1507
62
0e8573b4329a so far so good ...
ca
parents: 60
diff changeset
  1508
0e8573b4329a so far so good ...
ca
parents: 60
diff changeset
  1509
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
  1510
! !
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
  1511
754
04e802a6a920 color master selection in red + grid background colored
tz
parents: 744
diff changeset
  1512
!UIPainterView methodsFor:'private handles'!
04e802a6a920 color master selection in red + grid background colored
tz
parents: 744
diff changeset
  1513
04e802a6a920 color master selection in red + grid background colored
tz
parents: 744
diff changeset
  1514
showSelected:aComponent
04e802a6a920 color master selection in red + grid background colored
tz
parents: 744
diff changeset
  1515
    "show object selected
04e802a6a920 color master selection in red + grid background colored
tz
parents: 744
diff changeset
  1516
    "
1039
99a4be876840 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1031
diff changeset
  1517
    |wasClipped sel hColor|
754
04e802a6a920 color master selection in red + grid background colored
tz
parents: 744
diff changeset
  1518
04e802a6a920 color master selection in red + grid background colored
tz
parents: 744
diff changeset
  1519
    selectionHiddenLevel == 0 ifTrue:[
995
245dcca31eec checkin from browser
Claus Gittinger <cg@exept.de>
parents: 965
diff changeset
  1520
        sel := treeView selection.
245dcca31eec checkin from browser
Claus Gittinger <cg@exept.de>
parents: 965
diff changeset
  1521
        (sel size > 1 and: 
245dcca31eec checkin from browser
Claus Gittinger <cg@exept.de>
parents: 965
diff changeset
  1522
        [(treeView model list at: sel first) contents view == aComponent])
1467
b46624bb6994 use white handles, if the views background color is dark.
Claus Gittinger <cg@exept.de>
parents: 1450
diff changeset
  1523
        ifTrue: [
b46624bb6994 use white handles, if the views background color is dark.
Claus Gittinger <cg@exept.de>
parents: 1450
diff changeset
  1524
            hColor := handleMasterColor
b46624bb6994 use white handles, if the views background color is dark.
Claus Gittinger <cg@exept.de>
parents: 1450
diff changeset
  1525
        ] ifFalse:[
b46624bb6994 use white handles, if the views background color is dark.
Claus Gittinger <cg@exept.de>
parents: 1450
diff changeset
  1526
            aComponent viewBackground brightness < 0.5 ifTrue:[
b46624bb6994 use white handles, if the views background color is dark.
Claus Gittinger <cg@exept.de>
parents: 1450
diff changeset
  1527
                hColor := handleColorWhite
b46624bb6994 use white handles, if the views background color is dark.
Claus Gittinger <cg@exept.de>
parents: 1450
diff changeset
  1528
            ] ifFalse:[
b46624bb6994 use white handles, if the views background color is dark.
Claus Gittinger <cg@exept.de>
parents: 1450
diff changeset
  1529
                hColor := handleColorBlack
b46624bb6994 use white handles, if the views background color is dark.
Claus Gittinger <cg@exept.de>
parents: 1450
diff changeset
  1530
            ]
b46624bb6994 use white handles, if the views background color is dark.
Claus Gittinger <cg@exept.de>
parents: 1450
diff changeset
  1531
        ].
1039
99a4be876840 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1031
diff changeset
  1532
99a4be876840 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1031
diff changeset
  1533
        self paint:hColor.
754
04e802a6a920 color master selection in red + grid background colored
tz
parents: 744
diff changeset
  1534
04e802a6a920 color master selection in red + grid background colored
tz
parents: 744
diff changeset
  1535
        (wasClipped := clipChildren) ifTrue:[
04e802a6a920 color master selection in red + grid background colored
tz
parents: 744
diff changeset
  1536
            self clippedByChildren:(clipChildren := false). 
04e802a6a920 color master selection in red + grid background colored
tz
parents: 744
diff changeset
  1537
        ].
04e802a6a920 color master selection in red + grid background colored
tz
parents: 744
diff changeset
  1538
1450
a113274a03bf bugfix redrawing handles selected
ca
parents: 1445
diff changeset
  1539
        self handlesOf:aComponent do:[:aRectangle :what| |l t w h|
a113274a03bf bugfix redrawing handles selected
ca
parents: 1445
diff changeset
  1540
            l := aRectangle left   + 1.
a113274a03bf bugfix redrawing handles selected
ca
parents: 1445
diff changeset
  1541
            t := aRectangle top    + 1.
a113274a03bf bugfix redrawing handles selected
ca
parents: 1445
diff changeset
  1542
            w := aRectangle width  - 2.
a113274a03bf bugfix redrawing handles selected
ca
parents: 1445
diff changeset
  1543
            h := aRectangle height - 2.
a113274a03bf bugfix redrawing handles selected
ca
parents: 1445
diff changeset
  1544
a113274a03bf bugfix redrawing handles selected
ca
parents: 1445
diff changeset
  1545
            what == #view ifTrue:[self displayRectangleX:l y:t width:w height:h]
a113274a03bf bugfix redrawing handles selected
ca
parents: 1445
diff changeset
  1546
                         ifFalse:[self fillRectangleX:l y:t width:w height:h]
754
04e802a6a920 color master selection in red + grid background colored
tz
parents: 744
diff changeset
  1547
        ].
04e802a6a920 color master selection in red + grid background colored
tz
parents: 744
diff changeset
  1548
04e802a6a920 color master selection in red + grid background colored
tz
parents: 744
diff changeset
  1549
        wasClipped ifTrue:[
04e802a6a920 color master selection in red + grid background colored
tz
parents: 744
diff changeset
  1550
            self clippedByChildren:(clipChildren := true).
04e802a6a920 color master selection in red + grid background colored
tz
parents: 744
diff changeset
  1551
        ]
04e802a6a920 color master selection in red + grid background colored
tz
parents: 744
diff changeset
  1552
    ]
04e802a6a920 color master selection in red + grid background colored
tz
parents: 744
diff changeset
  1553
! !
04e802a6a920 color master selection in red + grid background colored
tz
parents: 744
diff changeset
  1554
335
9f048ededd7d resolveName:
ca
parents: 330
diff changeset
  1555
!UIPainterView methodsFor:'queries'!
9f048ededd7d resolveName:
ca
parents: 330
diff changeset
  1556
9f048ededd7d resolveName:
ca
parents: 330
diff changeset
  1557
resolveName:aName
9f048ededd7d resolveName:
ca
parents: 330
diff changeset
  1558
    |appl|
9f048ededd7d resolveName:
ca
parents: 330
diff changeset
  1559
9f048ededd7d resolveName:
ca
parents: 330
diff changeset
  1560
    appl := self application.
9f048ededd7d resolveName:
ca
parents: 330
diff changeset
  1561
9f048ededd7d resolveName:
ca
parents: 330
diff changeset
  1562
    appl notNil ifTrue:[
9f048ededd7d resolveName:
ca
parents: 330
diff changeset
  1563
        ^ appl resolveName:aName
9f048ededd7d resolveName:
ca
parents: 330
diff changeset
  1564
    ].
9f048ededd7d resolveName:
ca
parents: 330
diff changeset
  1565
    ^ Smalltalk resolveName:aName inClass:self class
9f048ededd7d resolveName:
ca
parents: 330
diff changeset
  1566
! !
9f048ededd7d resolveName:
ca
parents: 330
diff changeset
  1567
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
  1568
!UIPainterView methodsFor:'removing components'!
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
  1569
78
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
  1570
remove:anObject
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
  1571
    "remove anObject from the contents do redraw
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
  1572
    "
134
d5ab85ec27fd undo history; keep view identifier
ca
parents: 131
diff changeset
  1573
    anObject notNil ifTrue:[
238
882be7e03af4 renamed claus instVar (;-)
Claus Gittinger <cg@exept.de>
parents: 231
diff changeset
  1574
        treeView removeView:anObject.
134
d5ab85ec27fd undo history; keep view identifier
ca
parents: 131
diff changeset
  1575
    ]
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
  1576
!
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
  1577
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
  1578
removeAll
62
0e8573b4329a so far so good ...
ca
parents: 60
diff changeset
  1579
    "remove all objects and properties
0e8573b4329a so far so good ...
ca
parents: 60
diff changeset
  1580
    "
776
1df0525eeec9 reuse methods provided by the model
ca
parents: 770
diff changeset
  1581
    self select:nil.
1df0525eeec9 reuse methods provided by the model
ca
parents: 770
diff changeset
  1582
    treeView removeAll.
1df0525eeec9 reuse methods provided by the model
ca
parents: 770
diff changeset
  1583
    self removeUndoHistory.
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
  1584
! !
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
  1585
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
  1586
!UIPainterView methodsFor:'searching'!
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
  1587
285
d80b3c6a4373 don't use superView instead parent properties derived
ca
parents: 281
diff changeset
  1588
findContainerOfView:aView
d80b3c6a4373 don't use superView instead parent properties derived
ca
parents: 281
diff changeset
  1589
    "returns the super view assigned to a view
89
35c5711729c2 so far so good
ca
parents: 86
diff changeset
  1590
    "
285
d80b3c6a4373 don't use superView instead parent properties derived
ca
parents: 281
diff changeset
  1591
    |p|
89
35c5711729c2 so far so good
ca
parents: 86
diff changeset
  1592
285
d80b3c6a4373 don't use superView instead parent properties derived
ca
parents: 281
diff changeset
  1593
    (p := self propertyOfParentForView:aView) isNil ifTrue:[
89
35c5711729c2 so far so good
ca
parents: 86
diff changeset
  1594
        ^ self
35c5711729c2 so far so good
ca
parents: 86
diff changeset
  1595
    ].
285
d80b3c6a4373 don't use superView instead parent properties derived
ca
parents: 281
diff changeset
  1596
    ^ p view
89
35c5711729c2 so far so good
ca
parents: 86
diff changeset
  1597
!
35c5711729c2 so far so good
ca
parents: 86
diff changeset
  1598
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
  1599
findObjectAt:aPoint
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
  1600
    "find the origin/corner of the currentWidget
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
  1601
    "
285
d80b3c6a4373 don't use superView instead parent properties derived
ca
parents: 281
diff changeset
  1602
    |view prop|
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
  1603
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
  1604
    view := super findObjectAt:aPoint.
285
d80b3c6a4373 don't use superView instead parent properties derived
ca
parents: 281
diff changeset
  1605
    prop := self propertyRespondsToView:view.
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
  1606
285
d80b3c6a4373 don't use superView instead parent properties derived
ca
parents: 281
diff changeset
  1607
    prop notNil ifTrue:[^ prop view].
d80b3c6a4373 don't use superView instead parent properties derived
ca
parents: 281
diff changeset
  1608
  ^ nil
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
  1609
!
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
  1610
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
  1611
findViewWithId:aViewId
62
0e8573b4329a so far so good ...
ca
parents: 60
diff changeset
  1612
    "finds view assigned to identifier and returns the view or nil
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
  1613
    "
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
  1614
    |prop|
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
  1615
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
  1616
    prop := self propertyOfIdentifier:aViewId.
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
  1617
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
  1618
    prop notNil ifTrue:[^ prop view]
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
  1619
               ifFalse:[^ nil]
78
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
  1620
!
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
  1621
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
  1622
propertyOfIdentifier:anId
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
  1623
    "returns property assigned to unique identifier
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
  1624
    "
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
  1625
    anId notNil ifTrue:[
238
882be7e03af4 renamed claus instVar (;-)
Claus Gittinger <cg@exept.de>
parents: 231
diff changeset
  1626
        ^ treeView propertyDetect:[:p| p identifier == anId ]
78
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
  1627
    ].
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
  1628
    ^ nil
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
  1629
!
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
  1630
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
  1631
propertyOfName:aString
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
  1632
    "returns property assigned to name
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
  1633
    "
111
ca
parents: 103
diff changeset
  1634
    |name|
ca
parents: 103
diff changeset
  1635
ca
parents: 103
diff changeset
  1636
    aString isNil ifFalse:[
ca
parents: 103
diff changeset
  1637
        name := aString string withoutSeparators.
238
882be7e03af4 renamed claus instVar (;-)
Claus Gittinger <cg@exept.de>
parents: 231
diff changeset
  1638
      ^ treeView propertyDetect:[:p| p name = name ].
78
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
  1639
    ].
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
  1640
    ^ nil
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
  1641
!
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
  1642
285
d80b3c6a4373 don't use superView instead parent properties derived
ca
parents: 281
diff changeset
  1643
propertyOfParentForView:aSubView
d80b3c6a4373 don't use superView instead parent properties derived
ca
parents: 281
diff changeset
  1644
    "returns the property of the parent or nil
d80b3c6a4373 don't use superView instead parent properties derived
ca
parents: 281
diff changeset
  1645
    "
d80b3c6a4373 don't use superView instead parent properties derived
ca
parents: 281
diff changeset
  1646
    |item|
d80b3c6a4373 don't use superView instead parent properties derived
ca
parents: 281
diff changeset
  1647
d80b3c6a4373 don't use superView instead parent properties derived
ca
parents: 281
diff changeset
  1648
    (item := treeView detectItemRespondsToView:aSubView) notNil ifTrue:[
d80b3c6a4373 don't use superView instead parent properties derived
ca
parents: 281
diff changeset
  1649
        (item := item parent) notNil ifTrue:[^ item contents]
d80b3c6a4373 don't use superView instead parent properties derived
ca
parents: 281
diff changeset
  1650
    ].
d80b3c6a4373 don't use superView instead parent properties derived
ca
parents: 281
diff changeset
  1651
    ^ nil
d80b3c6a4373 don't use superView instead parent properties derived
ca
parents: 281
diff changeset
  1652
!
d80b3c6a4373 don't use superView instead parent properties derived
ca
parents: 281
diff changeset
  1653
78
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
  1654
propertyOfView:aView
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
  1655
    "returns property assigned to view
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
  1656
    "
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
  1657
    (aView isNil or:[aView == self]) ifFalse:[
238
882be7e03af4 renamed claus instVar (;-)
Claus Gittinger <cg@exept.de>
parents: 231
diff changeset
  1658
        ^ treeView propertyDetect:[:p| p view == aView ]
78
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
  1659
    ].
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
  1660
    ^ nil
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
  1661
!
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
  1662
285
d80b3c6a4373 don't use superView instead parent properties derived
ca
parents: 281
diff changeset
  1663
propertyRespondsToView:aView
d80b3c6a4373 don't use superView instead parent properties derived
ca
parents: 281
diff changeset
  1664
    "detect the property responding to the argument a view. The property of the view or
d80b3c6a4373 don't use superView instead parent properties derived
ca
parents: 281
diff changeset
  1665
     the first subview providing the properties is returned. If no property is detected
d80b3c6a4373 don't use superView instead parent properties derived
ca
parents: 281
diff changeset
  1666
     nil is returned.
d80b3c6a4373 don't use superView instead parent properties derived
ca
parents: 281
diff changeset
  1667
    "
d80b3c6a4373 don't use superView instead parent properties derived
ca
parents: 281
diff changeset
  1668
    |item|
d80b3c6a4373 don't use superView instead parent properties derived
ca
parents: 281
diff changeset
  1669
d80b3c6a4373 don't use superView instead parent properties derived
ca
parents: 281
diff changeset
  1670
    item := treeView detectItemRespondsToView:aView.
d80b3c6a4373 don't use superView instead parent properties derived
ca
parents: 281
diff changeset
  1671
d80b3c6a4373 don't use superView instead parent properties derived
ca
parents: 281
diff changeset
  1672
    (item notNil and:[item parent notNil]) ifTrue:[
d80b3c6a4373 don't use superView instead parent properties derived
ca
parents: 281
diff changeset
  1673
        ^ item contents
d80b3c6a4373 don't use superView instead parent properties derived
ca
parents: 281
diff changeset
  1674
    ].
d80b3c6a4373 don't use superView instead parent properties derived
ca
parents: 281
diff changeset
  1675
    ^ nil
d80b3c6a4373 don't use superView instead parent properties derived
ca
parents: 281
diff changeset
  1676
!
d80b3c6a4373 don't use superView instead parent properties derived
ca
parents: 281
diff changeset
  1677
111
ca
parents: 103
diff changeset
  1678
uniqueNameFor:aSpecOrString
78
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
  1679
    "generate and return an unique name for a class
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
  1680
    "
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
  1681
    |next name size|
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
  1682
712
bf8aa59e82b6 user friendly names
tz
parents: 708
diff changeset
  1683
    aSpecOrString isString ifFalse:[name := aSpecOrString userFriendlyName]
111
ca
parents: 103
diff changeset
  1684
                            ifTrue:[name := aSpecOrString].
78
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
  1685
111
ca
parents: 103
diff changeset
  1686
    size  := name size + 1.
ca
parents: 103
diff changeset
  1687
    next  := 0.
78
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
  1688
238
882be7e03af4 renamed claus instVar (;-)
Claus Gittinger <cg@exept.de>
parents: 231
diff changeset
  1689
    treeView propertiesDo:[:p|
111
ca
parents: 103
diff changeset
  1690
        |n|
78
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
  1691
        n := p name.
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
  1692
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
  1693
        (n size >= size and:[n startsWith:name]) ifTrue:[
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
  1694
            next := next max:(p extractNumberStartingAt:size)
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
  1695
        ]
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
  1696
    ].
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
  1697
    next := next + 1.
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
  1698
    name := name, next printString.
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
  1699
  ^ name
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
  1700
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
  1701
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
  1702
662
28d6cac7968b consistent ID-naming of the widgets
tz
parents: 655
diff changeset
  1703
78
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
  1704
!
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
  1705
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
  1706
uniqueNameOf:aView
111
ca
parents: 103
diff changeset
  1707
    |prop|
78
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
  1708
111
ca
parents: 103
diff changeset
  1709
    (prop := self propertyOfView:aView) notNil ifTrue:[
ca
parents: 103
diff changeset
  1710
        prop name isNil ifTrue:[
ca
parents: 103
diff changeset
  1711
            prop name:(self uniqueNameFor:(prop spec)).
ca
parents: 103
diff changeset
  1712
        ].
ca
parents: 103
diff changeset
  1713
        ^ prop name
78
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
  1714
    ].
111
ca
parents: 103
diff changeset
  1715
    ^ 'self'
78
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
  1716
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
  1717
! !
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
  1718
223
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
  1719
!UIPainterView methodsFor:'selection basics'!
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
  1720
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
  1721
addToSelection:anObject
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
  1722
    "add an object to the selection
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
  1723
    "
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
  1724
    (self enabled and:[(self isSelected:anObject) not]) ifTrue:[
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
  1725
        selection isCollection ifFalse:[
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
  1726
            selection isNil ifTrue:[
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
  1727
                selection := anObject
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
  1728
            ] ifFalse:[
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
  1729
                selection := OrderedCollection with:selection with:anObject
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
  1730
            ]
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
  1731
        ] ifTrue:[
1347
c4046d0b638e care for multiSelect into a non-list;
Claus Gittinger <cg@exept.de>
parents: 1338
diff changeset
  1732
            "/ to enforce the change-message (value is identical to oldValue)
c4046d0b638e care for multiSelect into a non-list;
Claus Gittinger <cg@exept.de>
parents: 1338
diff changeset
  1733
            selection isList ifTrue:[
c4046d0b638e care for multiSelect into a non-list;
Claus Gittinger <cg@exept.de>
parents: 1338
diff changeset
  1734
                selection add:anObject
c4046d0b638e care for multiSelect into a non-list;
Claus Gittinger <cg@exept.de>
parents: 1338
diff changeset
  1735
            ] ifFalse:[
c4046d0b638e care for multiSelect into a non-list;
Claus Gittinger <cg@exept.de>
parents: 1338
diff changeset
  1736
                selection := selection asOrderedCollection.
c4046d0b638e care for multiSelect into a non-list;
Claus Gittinger <cg@exept.de>
parents: 1338
diff changeset
  1737
                selection := selection copyWith:anObject
c4046d0b638e care for multiSelect into a non-list;
Claus Gittinger <cg@exept.de>
parents: 1338
diff changeset
  1738
            ]
223
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
  1739
        ].
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
  1740
        self showSelected:anObject.
238
882be7e03af4 renamed claus instVar (;-)
Claus Gittinger <cg@exept.de>
parents: 231
diff changeset
  1741
        treeView cvsSelectionAdd:anObject.
223
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
  1742
    ]
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
  1743
1347
c4046d0b638e care for multiSelect into a non-list;
Claus Gittinger <cg@exept.de>
parents: 1338
diff changeset
  1744
    "Modified: / 11.2.2000 / 01:39:05 / cg"
223
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
  1745
!
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
  1746
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
  1747
removeFromSelection:anObject
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
  1748
    "remove an object from the selection
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
  1749
    "
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
  1750
    (self isSelected:anObject) ifTrue:[
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
  1751
        self showUnselected:anObject.
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
  1752
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
  1753
        selection size > 1 ifTrue:[
1347
c4046d0b638e care for multiSelect into a non-list;
Claus Gittinger <cg@exept.de>
parents: 1338
diff changeset
  1754
            selection isList ifTrue:[
c4046d0b638e care for multiSelect into a non-list;
Claus Gittinger <cg@exept.de>
parents: 1338
diff changeset
  1755
                selection remove:anObject ifAbsent:nil
c4046d0b638e care for multiSelect into a non-list;
Claus Gittinger <cg@exept.de>
parents: 1338
diff changeset
  1756
            ] ifFalse:[
c4046d0b638e care for multiSelect into a non-list;
Claus Gittinger <cg@exept.de>
parents: 1338
diff changeset
  1757
                "/ to enforce the change-message (value is identical to oldValue)
c4046d0b638e care for multiSelect into a non-list;
Claus Gittinger <cg@exept.de>
parents: 1338
diff changeset
  1758
                selection := selection asOrderedCollection.
c4046d0b638e care for multiSelect into a non-list;
Claus Gittinger <cg@exept.de>
parents: 1338
diff changeset
  1759
                selection := selection copyWithout:anObject
c4046d0b638e care for multiSelect into a non-list;
Claus Gittinger <cg@exept.de>
parents: 1338
diff changeset
  1760
            ].
223
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
  1761
            self showSelection.
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
  1762
        ] ifFalse:[
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
  1763
            selection := nil
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
  1764
        ].
238
882be7e03af4 renamed claus instVar (;-)
Claus Gittinger <cg@exept.de>
parents: 231
diff changeset
  1765
        treeView cvsSelectionRemove:anObject.
223
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
  1766
    ]
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
  1767
1347
c4046d0b638e care for multiSelect into a non-list;
Claus Gittinger <cg@exept.de>
parents: 1338
diff changeset
  1768
    "Modified: / 11.2.2000 / 01:41:11 / cg"
223
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
  1769
!
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
  1770
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
  1771
select:something
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
  1772
    "change selection to something
886
3c67610b9631 after deleting a widget do select the neighbour then the parent
tz
parents: 858
diff changeset
  1773
    "         
760
ca9488ba9876 selection order changed (step 2)
tz
parents: 758
diff changeset
  1774
    (self enabled and:[something ~= self selection]) ifTrue:[   
ca9488ba9876 selection order changed (step 2)
tz
parents: 758
diff changeset
  1775
        something isNil 
ca9488ba9876 selection order changed (step 2)
tz
parents: 758
diff changeset
  1776
            ifTrue: [treeView selection: (Array with: 1)]
ca9488ba9876 selection order changed (step 2)
tz
parents: 758
diff changeset
  1777
            ifFalse:[treeView cvsSelection:something].
886
3c67610b9631 after deleting a widget do select the neighbour then the parent
tz
parents: 858
diff changeset
  1778
        self setSelection:something withRedraw:true 
223
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
  1779
    ]
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
  1780
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
  1781
!
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
  1782
285
d80b3c6a4373 don't use superView instead parent properties derived
ca
parents: 281
diff changeset
  1783
updateSelectionFromModel:aSelOrNil
223
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
  1784
    "update selection from a new selection
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
  1785
    "
1427
85b9b5da0b8d optimize: undraw selection
ca
parents: 1402
diff changeset
  1786
    |list|
768
2ef5b8bed914 catch expose events when unselecting
ca
parents: 760
diff changeset
  1787
223
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
  1788
    selectionHiddenLevel == 0 ifTrue:[
285
d80b3c6a4373 don't use superView instead parent properties derived
ca
parents: 281
diff changeset
  1789
        aSelOrNil size ~~ 0 ifTrue:[
1427
85b9b5da0b8d optimize: undraw selection
ca
parents: 1402
diff changeset
  1790
            list := OrderedCollection new.
85b9b5da0b8d optimize: undraw selection
ca
parents: 1402
diff changeset
  1791
768
2ef5b8bed914 catch expose events when unselecting
ca
parents: 760
diff changeset
  1792
            self selectionDo:[:el|
1427
85b9b5da0b8d optimize: undraw selection
ca
parents: 1402
diff changeset
  1793
                (aSelOrNil includes:el) ifFalse:[list add:el]
768
2ef5b8bed914 catch expose events when unselecting
ca
parents: 760
diff changeset
  1794
            ].
1427
85b9b5da0b8d optimize: undraw selection
ca
parents: 1402
diff changeset
  1795
            self showUnselected:list.
285
d80b3c6a4373 don't use superView instead parent properties derived
ca
parents: 281
diff changeset
  1796
        ] ifFalse:[
768
2ef5b8bed914 catch expose events when unselecting
ca
parents: 760
diff changeset
  1797
            self hideSelection.
285
d80b3c6a4373 don't use superView instead parent properties derived
ca
parents: 281
diff changeset
  1798
        ]
223
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
  1799
    ].
285
d80b3c6a4373 don't use superView instead parent properties derived
ca
parents: 281
diff changeset
  1800
    self setSelection:aSelOrNil withRedraw:false.
223
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
  1801
    self showSelection
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
  1802
! !
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
  1803
78
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
  1804
!UIPainterView methodsFor:'specification'!
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
  1805
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
  1806
addSpec:aSpecification builder:aBuilder in:aFrame
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
  1807
    "build view and subviews from aSpecification into a frame. The top view
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
  1808
     is returned. The contained components of a spec are set to nil
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
  1809
    "
330
ca
parents: 327
diff changeset
  1810
    |cls|
212
1836a16763cc oops again
Claus Gittinger <cg@exept.de>
parents: 211
diff changeset
  1811
330
ca
parents: 327
diff changeset
  1812
    cls := self resolveName:className.
ca
parents: 327
diff changeset
  1813
ca
parents: 327
diff changeset
  1814
    cls notNil ifTrue:[
ca
parents: 327
diff changeset
  1815
        aBuilder applicationClass:cls.
212
1836a16763cc oops again
Claus Gittinger <cg@exept.de>
parents: 211
diff changeset
  1816
    ].
78
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
  1817
111
ca
parents: 103
diff changeset
  1818
    aBuilder componentCreationHook:[:aView :aSpec :aBdr||sv p s n|
78
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
  1819
        p := ViewProperty new.
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
  1820
        s := aSpec copy.
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
  1821
        p spec:s.
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
  1822
        p view:aView.
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
  1823
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
  1824
        s class supportsSubComponents ifTrue:[
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
  1825
            s component:nil
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
  1826
        ].
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
  1827
111
ca
parents: 103
diff changeset
  1828
        n := s name.
ca
parents: 103
diff changeset
  1829
ca
parents: 103
diff changeset
  1830
        (n isNil or:[(self propertyOfName:n) notNil]) ifTrue:[
ca
parents: 103
diff changeset
  1831
            s name:(self uniqueNameFor:s)
78
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
  1832
        ].
238
882be7e03af4 renamed claus instVar (;-)
Claus Gittinger <cg@exept.de>
parents: 231
diff changeset
  1833
        treeView addProperty:p.
78
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
  1834
    ].
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
  1835
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
  1836
    ^ aSpecification buildViewWithLayoutFor:aBuilder in:aFrame.
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
  1837
212
1836a16763cc oops again
Claus Gittinger <cg@exept.de>
parents: 211
diff changeset
  1838
    "Modified: 4.7.1997 / 23:48:55 / cg"
78
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
  1839
!
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
  1840
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
  1841
fullSpecFor:anObject
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
  1842
    "generate a full spec for an object
62
0e8573b4329a so far so good ...
ca
parents: 60
diff changeset
  1843
    "
78
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
  1844
    |mySpec subSpecs|
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
  1845
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
  1846
    mySpec := self specFor:anObject.
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
  1847
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
  1848
    (mySpec notNil and:[mySpec class supportsSubComponents]) ifTrue:[
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
  1849
        (anObject subViews notNil) ifTrue:[
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
  1850
            anObject subViews do:[:aSubView||spec|
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
  1851
                spec := self fullSpecFor:aSubView.
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
  1852
                spec notNil ifTrue:[
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
  1853
                    subSpecs isNil ifTrue:[
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
  1854
                        subSpecs := OrderedCollection new
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
  1855
                    ].
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
  1856
                    subSpecs add:spec.
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
  1857
                ].
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
  1858
            ].
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
  1859
            subSpecs notNil ifTrue:[
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
  1860
                mySpec component:(SpecCollection new collection:subSpecs)
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
  1861
            ]
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
  1862
        ]
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
  1863
    ].
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
  1864
    ^ mySpec
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
  1865
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
  1866
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
  1867
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
  1868
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
  1869
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
  1870
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
  1871
!
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
  1872
1173
7b5f40822819 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1092
diff changeset
  1873
rebuildView:aView fromSpec:aSpec withBuilder:aBuilderOrNil
7b5f40822819 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1092
diff changeset
  1874
    |v builder|
7b5f40822819 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1092
diff changeset
  1875
7b5f40822819 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1092
diff changeset
  1876
    (builder := aBuilderOrNil) isNil ifTrue:[
7b5f40822819 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1092
diff changeset
  1877
        "/ create a dummy builder
7b5f40822819 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1092
diff changeset
  1878
        builder := UIBuilder new isEditing:true.
7b5f40822819 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1092
diff changeset
  1879
        className notNil ifTrue:[
7b5f40822819 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1092
diff changeset
  1880
            builder applicationClass:(self resolveName:className).
7b5f40822819 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1092
diff changeset
  1881
        ].
7b5f40822819 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1092
diff changeset
  1882
    ].
285
d80b3c6a4373 don't use superView instead parent properties derived
ca
parents: 281
diff changeset
  1883
1252
f886528c2b35 when changing a layoutContainer
Claus Gittinger <cg@exept.de>
parents: 1230
diff changeset
  1884
    aSpec class isLayoutContainer ifTrue:[
f886528c2b35 when changing a layoutContainer
Claus Gittinger <cg@exept.de>
parents: 1230
diff changeset
  1885
        "/ TODO:
f886528c2b35 when changing a layoutContainer
Claus Gittinger <cg@exept.de>
parents: 1230
diff changeset
  1886
        "/ go through subviews and let them resize to their default/preferred
f886528c2b35 when changing a layoutContainer
Claus Gittinger <cg@exept.de>
parents: 1230
diff changeset
  1887
        "/ needed if we change a containers layout from fit to non-fit.
f886528c2b35 when changing a layoutContainer
Claus Gittinger <cg@exept.de>
parents: 1230
diff changeset
  1888
1258
e604e55e0237 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1257
diff changeset
  1889
        (aView subViews ? #()) do:[:aSubView |
1252
f886528c2b35 when changing a layoutContainer
Claus Gittinger <cg@exept.de>
parents: 1230
diff changeset
  1890
            |fix spec prop|
f886528c2b35 when changing a layoutContainer
Claus Gittinger <cg@exept.de>
parents: 1230
diff changeset
  1891
f886528c2b35 when changing a layoutContainer
Claus Gittinger <cg@exept.de>
parents: 1230
diff changeset
  1892
            (prop := self propertyOfView:aSubView) notNil ifTrue:[
f886528c2b35 when changing a layoutContainer
Claus Gittinger <cg@exept.de>
parents: 1230
diff changeset
  1893
                spec := prop spec.
f886528c2b35 when changing a layoutContainer
Claus Gittinger <cg@exept.de>
parents: 1230
diff changeset
  1894
f886528c2b35 when changing a layoutContainer
Claus Gittinger <cg@exept.de>
parents: 1230
diff changeset
  1895
                spec useDefaultExtent ifTrue:[
f886528c2b35 when changing a layoutContainer
Claus Gittinger <cg@exept.de>
parents: 1230
diff changeset
  1896
                    fix := aSubView sizeFixed:false.
f886528c2b35 when changing a layoutContainer
Claus Gittinger <cg@exept.de>
parents: 1230
diff changeset
  1897
                    aSubView extent:aSubView preferredExtent.
f886528c2b35 when changing a layoutContainer
Claus Gittinger <cg@exept.de>
parents: 1230
diff changeset
  1898
                    aSubView sizeFixed:fix
f886528c2b35 when changing a layoutContainer
Claus Gittinger <cg@exept.de>
parents: 1230
diff changeset
  1899
                ]
f886528c2b35 when changing a layoutContainer
Claus Gittinger <cg@exept.de>
parents: 1230
diff changeset
  1900
            ]
f886528c2b35 when changing a layoutContainer
Claus Gittinger <cg@exept.de>
parents: 1230
diff changeset
  1901
        ].
f886528c2b35 when changing a layoutContainer
Claus Gittinger <cg@exept.de>
parents: 1230
diff changeset
  1902
    ].
f886528c2b35 when changing a layoutContainer
Claus Gittinger <cg@exept.de>
parents: 1230
diff changeset
  1903
285
d80b3c6a4373 don't use superView instead parent properties derived
ca
parents: 281
diff changeset
  1904
    aSpec needsRebuildForAttributes ifTrue:[
1173
7b5f40822819 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1092
diff changeset
  1905
        "/ needs a full rebuild (in case view class depends upon spec-attribute)
7b5f40822819 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1092
diff changeset
  1906
        v := aSpec buildViewWithLayoutFor:builder in:(self findContainerOfView:aView).
285
d80b3c6a4373 don't use superView instead parent properties derived
ca
parents: 281
diff changeset
  1907
        v realize.    
d80b3c6a4373 don't use superView instead parent properties derived
ca
parents: 281
diff changeset
  1908
        aView destroy.
d80b3c6a4373 don't use superView instead parent properties derived
ca
parents: 281
diff changeset
  1909
        device sync.
d80b3c6a4373 don't use superView instead parent properties derived
ca
parents: 281
diff changeset
  1910
        device flush.
d80b3c6a4373 don't use superView instead parent properties derived
ca
parents: 281
diff changeset
  1911
        aView becomeSameAs:v.
d80b3c6a4373 don't use superView instead parent properties derived
ca
parents: 281
diff changeset
  1912
        inputView raise.
d80b3c6a4373 don't use superView instead parent properties derived
ca
parents: 281
diff changeset
  1913
    ] ifFalse:[
1173
7b5f40822819 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1092
diff changeset
  1914
        aSpec setAttributesIn:aView with:builder.
285
d80b3c6a4373 don't use superView instead parent properties derived
ca
parents: 281
diff changeset
  1915
        self elementChangedSize:aView.
d80b3c6a4373 don't use superView instead parent properties derived
ca
parents: 281
diff changeset
  1916
    ].
d80b3c6a4373 don't use superView instead parent properties derived
ca
parents: 281
diff changeset
  1917
d80b3c6a4373 don't use superView instead parent properties derived
ca
parents: 281
diff changeset
  1918
!
d80b3c6a4373 don't use superView instead parent properties derived
ca
parents: 281
diff changeset
  1919
78
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
  1920
specFor:anObject
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
  1921
    "returns spec assigned to an object
62
0e8573b4329a so far so good ...
ca
parents: 60
diff changeset
  1922
    "
78
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
  1923
    |prop spec|
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
  1924
78
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
  1925
    (prop := self propertyOfView:anObject) notNil ifTrue:[
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
  1926
        spec := prop spec copy.
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
  1927
        spec layoutFromView:anObject
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
  1928
    ].
78
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
  1929
    ^ spec
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
  1930
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
  1931
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
  1932
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
  1933
!
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
  1934
146
ae84facd80be checkin from browser
ca
parents: 141
diff changeset
  1935
specForSelection
ae84facd80be checkin from browser
ca
parents: 141
diff changeset
  1936
    "returns spec assigned to current single selection or nil
ae84facd80be checkin from browser
ca
parents: 141
diff changeset
  1937
    "
ae84facd80be checkin from browser
ca
parents: 141
diff changeset
  1938
    ^ self specFor:(self singleSelection)
ae84facd80be checkin from browser
ca
parents: 141
diff changeset
  1939
ae84facd80be checkin from browser
ca
parents: 141
diff changeset
  1940
ae84facd80be checkin from browser
ca
parents: 141
diff changeset
  1941
!
ae84facd80be checkin from browser
ca
parents: 141
diff changeset
  1942
78
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
  1943
updateFromSpec:aSpec
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
  1944
    "update current selected view from specification
62
0e8573b4329a so far so good ...
ca
parents: 60
diff changeset
  1945
    "
1173
7b5f40822819 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1092
diff changeset
  1946
    |props name|
78
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
  1947
281
aabb4037f6a3 window spec
ca
parents: 279
diff changeset
  1948
    aSpec class == WindowSpec ifTrue:[
698
5bf234e0e451 redefine methods flag
tz
parents: 662
diff changeset
  1949
         ^ treeView canvasSpec:aSpec
281
aabb4037f6a3 window spec
ca
parents: 279
diff changeset
  1950
    ].
aabb4037f6a3 window spec
ca
parents: 279
diff changeset
  1951
78
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
  1952
    self singleSelection notNil ifTrue:[
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
  1953
        self withSelectionHiddenDo:[
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
  1954
            self transaction:#specification selectionDo:[:aView|
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
  1955
                props   := self propertyOfView:aView.
82
99dc76d66eab checkin from browser
ca
parents: 80
diff changeset
  1956
                name    := (aSpec name) withoutSeparators.
78
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
  1957
82
99dc76d66eab checkin from browser
ca
parents: 80
diff changeset
  1958
                name = props name ifFalse:[
99dc76d66eab checkin from browser
ca
parents: 80
diff changeset
  1959
                    (self propertyOfName:name) notNil ifTrue:[
99dc76d66eab checkin from browser
ca
parents: 80
diff changeset
  1960
                        name := props name
78
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
  1961
                    ]
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
  1962
                ].
82
99dc76d66eab checkin from browser
ca
parents: 80
diff changeset
  1963
                aSpec name:name.
134
d5ab85ec27fd undo history; keep view identifier
ca
parents: 131
diff changeset
  1964
                self createUndoSpecModify:props.
1173
7b5f40822819 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1092
diff changeset
  1965
                self rebuildView:aView fromSpec:aSpec withBuilder:nil.
78
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
  1966
                props spec:(aSpec copy).
238
882be7e03af4 renamed claus instVar (;-)
Claus Gittinger <cg@exept.de>
parents: 231
diff changeset
  1967
                treeView propertyChanged:props.
78
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
  1968
            ]
111
ca
parents: 103
diff changeset
  1969
        ]
82
99dc76d66eab checkin from browser
ca
parents: 80
diff changeset
  1970
    ]
212
1836a16763cc oops again
Claus Gittinger <cg@exept.de>
parents: 211
diff changeset
  1971
1836a16763cc oops again
Claus Gittinger <cg@exept.de>
parents: 211
diff changeset
  1972
    "Modified: 4.7.1997 / 23:49:44 / cg"
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
  1973
! !
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
  1974
285
d80b3c6a4373 don't use superView instead parent properties derived
ca
parents: 281
diff changeset
  1975
!UIPainterView methodsFor:'testing'!
d80b3c6a4373 don't use superView instead parent properties derived
ca
parents: 281
diff changeset
  1976
d80b3c6a4373 don't use superView instead parent properties derived
ca
parents: 281
diff changeset
  1977
canChangeLayoutOfView:aView
d80b3c6a4373 don't use superView instead parent properties derived
ca
parents: 281
diff changeset
  1978
    "returns true if the view can change its layout which is dependant on
d80b3c6a4373 don't use superView instead parent properties derived
ca
parents: 281
diff changeset
  1979
     its parent view.
d80b3c6a4373 don't use superView instead parent properties derived
ca
parents: 281
diff changeset
  1980
    "
d80b3c6a4373 don't use superView instead parent properties derived
ca
parents: 281
diff changeset
  1981
    |item prnt|
d80b3c6a4373 don't use superView instead parent properties derived
ca
parents: 281
diff changeset
  1982
d80b3c6a4373 don't use superView instead parent properties derived
ca
parents: 281
diff changeset
  1983
    (     (item := treeView itemOfView:aView) isNil
d80b3c6a4373 don't use superView instead parent properties derived
ca
parents: 281
diff changeset
  1984
      or:[(prnt := item parent) isNil]
d80b3c6a4373 don't use superView instead parent properties derived
ca
parents: 281
diff changeset
  1985
    ) ifTrue:[
d80b3c6a4373 don't use superView instead parent properties derived
ca
parents: 281
diff changeset
  1986
        ^ false
d80b3c6a4373 don't use superView instead parent properties derived
ca
parents: 281
diff changeset
  1987
    ].
d80b3c6a4373 don't use superView instead parent properties derived
ca
parents: 281
diff changeset
  1988
    ^ (prnt parent isNil or:[prnt contents spec class isLayoutContainer not])
d80b3c6a4373 don't use superView instead parent properties derived
ca
parents: 281
diff changeset
  1989
!
d80b3c6a4373 don't use superView instead parent properties derived
ca
parents: 281
diff changeset
  1990
1230
23e5d0c133e8 added exchangeLayouts function
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
  1991
canExchangeSelectionLayouts
23e5d0c133e8 added exchangeLayouts function
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
  1992
    "returns true if the selection size is exactly 2
23e5d0c133e8 added exchangeLayouts function
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
  1993
     and all elements in the selection can be moved or aligned
23e5d0c133e8 added exchangeLayouts function
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
  1994
    "
23e5d0c133e8 added exchangeLayouts function
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
  1995
    selection size == 2 ifFalse:[
23e5d0c133e8 added exchangeLayouts function
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
  1996
        ^ false
23e5d0c133e8 added exchangeLayouts function
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
  1997
    ].
23e5d0c133e8 added exchangeLayouts function
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
  1998
    ^ self canMoveOrAlignSelection
23e5d0c133e8 added exchangeLayouts function
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
  1999
23e5d0c133e8 added exchangeLayouts function
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
  2000
!
23e5d0c133e8 added exchangeLayouts function
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
  2001
285
d80b3c6a4373 don't use superView instead parent properties derived
ca
parents: 281
diff changeset
  2002
canKeepLayoutInSelection
d80b3c6a4373 don't use superView instead parent properties derived
ca
parents: 281
diff changeset
  2003
    "returns true if layout can be kept during a paste operation
d80b3c6a4373 don't use superView instead parent properties derived
ca
parents: 281
diff changeset
  2004
    "
d80b3c6a4373 don't use superView instead parent properties derived
ca
parents: 281
diff changeset
  2005
    |prop|
d80b3c6a4373 don't use superView instead parent properties derived
ca
parents: 281
diff changeset
  2006
d80b3c6a4373 don't use superView instead parent properties derived
ca
parents: 281
diff changeset
  2007
    prop := self propertyOfView:(self singleSelection).
d80b3c6a4373 don't use superView instead parent properties derived
ca
parents: 281
diff changeset
  2008
  ^ (prop isNil or:[prop spec class isLayoutContainer not])
d80b3c6a4373 don't use superView instead parent properties derived
ca
parents: 281
diff changeset
  2009
!
d80b3c6a4373 don't use superView instead parent properties derived
ca
parents: 281
diff changeset
  2010
d80b3c6a4373 don't use superView instead parent properties derived
ca
parents: 281
diff changeset
  2011
canMove:something
d80b3c6a4373 don't use superView instead parent properties derived
ca
parents: 281
diff changeset
  2012
    "checks whether something is not nil and if all widgets derived from
d80b3c6a4373 don't use superView instead parent properties derived
ca
parents: 281
diff changeset
  2013
     something can change their layout ( move, align, ... operation ).
d80b3c6a4373 don't use superView instead parent properties derived
ca
parents: 281
diff changeset
  2014
    "
d80b3c6a4373 don't use superView instead parent properties derived
ca
parents: 281
diff changeset
  2015
    something notNil ifTrue:[
d80b3c6a4373 don't use superView instead parent properties derived
ca
parents: 281
diff changeset
  2016
        self forEach:something do:[:aView|
d80b3c6a4373 don't use superView instead parent properties derived
ca
parents: 281
diff changeset
  2017
            (self canChangeLayoutOfView:aView) ifFalse:[^ false]
d80b3c6a4373 don't use superView instead parent properties derived
ca
parents: 281
diff changeset
  2018
        ].
d80b3c6a4373 don't use superView instead parent properties derived
ca
parents: 281
diff changeset
  2019
        ^ true
d80b3c6a4373 don't use superView instead parent properties derived
ca
parents: 281
diff changeset
  2020
    ].
d80b3c6a4373 don't use superView instead parent properties derived
ca
parents: 281
diff changeset
  2021
    ^ false
d80b3c6a4373 don't use superView instead parent properties derived
ca
parents: 281
diff changeset
  2022
!
d80b3c6a4373 don't use superView instead parent properties derived
ca
parents: 281
diff changeset
  2023
d80b3c6a4373 don't use superView instead parent properties derived
ca
parents: 281
diff changeset
  2024
canMoveOrAlignSelection
d80b3c6a4373 don't use superView instead parent properties derived
ca
parents: 281
diff changeset
  2025
    "returns true if a selection exists and all elements in the selection
d80b3c6a4373 don't use superView instead parent properties derived
ca
parents: 281
diff changeset
  2026
     can be moved or aligned
d80b3c6a4373 don't use superView instead parent properties derived
ca
parents: 281
diff changeset
  2027
    "
d80b3c6a4373 don't use superView instead parent properties derived
ca
parents: 281
diff changeset
  2028
  ^ self canMove:(self selection)
d80b3c6a4373 don't use superView instead parent properties derived
ca
parents: 281
diff changeset
  2029
d80b3c6a4373 don't use superView instead parent properties derived
ca
parents: 281
diff changeset
  2030
! !
d80b3c6a4373 don't use superView instead parent properties derived
ca
parents: 281
diff changeset
  2031
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
  2032
!UIPainterView methodsFor:'transaction'!
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
  2033
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
  2034
transaction:aType objects:something do:aOneArgBlock
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
  2035
    "opens a transaction and evaluates a block within the transaction; the
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
  2036
     argument to the block is a view from derived from something
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
  2037
    "
134
d5ab85ec27fd undo history; keep view identifier
ca
parents: 131
diff changeset
  2038
    self withinTransaction:aType objects:something do:[
d5ab85ec27fd undo history; keep view identifier
ca
parents: 131
diff changeset
  2039
        self forEach:something do:aOneArgBlock
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
  2040
    ]
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
  2041
!
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
  2042
134
d5ab85ec27fd undo history; keep view identifier
ca
parents: 131
diff changeset
  2043
withinTransaction:aType objects:objects do:aNoneArgBlock
d5ab85ec27fd undo history; keep view identifier
ca
parents: 131
diff changeset
  2044
    "evaluate a block with no arguments within a transaction
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
  2045
    "
134
d5ab85ec27fd undo history; keep view identifier
ca
parents: 131
diff changeset
  2046
    |text size prop|
d5ab85ec27fd undo history; keep view identifier
ca
parents: 131
diff changeset
  2047
d5ab85ec27fd undo history; keep view identifier
ca
parents: 131
diff changeset
  2048
    objects isNil ifTrue:[ ^ self ].
d5ab85ec27fd undo history; keep view identifier
ca
parents: 131
diff changeset
  2049
d5ab85ec27fd undo history; keep view identifier
ca
parents: 131
diff changeset
  2050
    size := objects size.
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
  2051
134
d5ab85ec27fd undo history; keep view identifier
ca
parents: 131
diff changeset
  2052
    objects isCollection ifTrue:[
d5ab85ec27fd undo history; keep view identifier
ca
parents: 131
diff changeset
  2053
        size == 0 ifTrue:[ ^ self ].
d5ab85ec27fd undo history; keep view identifier
ca
parents: 131
diff changeset
  2054
        size == 1 ifTrue:[ prop := self propertyOfView:(objects first) ]
d5ab85ec27fd undo history; keep view identifier
ca
parents: 131
diff changeset
  2055
    ] ifFalse:[
d5ab85ec27fd undo history; keep view identifier
ca
parents: 131
diff changeset
  2056
        prop := self propertyOfView:objects
d5ab85ec27fd undo history; keep view identifier
ca
parents: 131
diff changeset
  2057
    ].
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
  2058
134
d5ab85ec27fd undo history; keep view identifier
ca
parents: 131
diff changeset
  2059
    prop notNil ifTrue:[
d5ab85ec27fd undo history; keep view identifier
ca
parents: 131
diff changeset
  2060
        text := prop name
d5ab85ec27fd undo history; keep view identifier
ca
parents: 131
diff changeset
  2061
    ] ifFalse:[
d5ab85ec27fd undo history; keep view identifier
ca
parents: 131
diff changeset
  2062
        text := size printString, ' elements'
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
  2063
    ].
134
d5ab85ec27fd undo history; keep view identifier
ca
parents: 131
diff changeset
  2064
d5ab85ec27fd undo history; keep view identifier
ca
parents: 131
diff changeset
  2065
    undoHistory withinTransaction:aType text:text do:[
d5ab85ec27fd undo history; keep view identifier
ca
parents: 131
diff changeset
  2066
        aNoneArgBlock value
d5ab85ec27fd undo history; keep view identifier
ca
parents: 131
diff changeset
  2067
    ]
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
  2068
! !
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
  2069
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
  2070
!UIPainterView methodsFor:'undo actions'!
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
  2071
134
d5ab85ec27fd undo history; keep view identifier
ca
parents: 131
diff changeset
  2072
createUndoLayout:aView
d5ab85ec27fd undo history; keep view identifier
ca
parents: 131
diff changeset
  2073
    "create undo action before changing a views layout
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
  2074
    "
134
d5ab85ec27fd undo history; keep view identifier
ca
parents: 131
diff changeset
  2075
    |lyt args prop|
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
  2076
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
  2077
    undoHistory isTransactionOpen ifTrue:[
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
  2078
        prop := self propertyOfView:aView.
134
d5ab85ec27fd undo history; keep view identifier
ca
parents: 131
diff changeset
  2079
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
  2080
        prop notNil ifTrue:[
134
d5ab85ec27fd undo history; keep view identifier
ca
parents: 131
diff changeset
  2081
            args := Array new:3.
d5ab85ec27fd undo history; keep view identifier
ca
parents: 131
diff changeset
  2082
            args at:1 put:(prop identifier).
d5ab85ec27fd undo history; keep view identifier
ca
parents: 131
diff changeset
  2083
d5ab85ec27fd undo history; keep view identifier
ca
parents: 131
diff changeset
  2084
            (lyt := aView geometryLayout) notNil ifTrue:[
d5ab85ec27fd undo history; keep view identifier
ca
parents: 131
diff changeset
  2085
                args at:2 put:#geometryLayout:
d5ab85ec27fd undo history; keep view identifier
ca
parents: 131
diff changeset
  2086
            ] ifFalse:[
146
ae84facd80be checkin from browser
ca
parents: 141
diff changeset
  2087
                lyt := aView extent.
134
d5ab85ec27fd undo history; keep view identifier
ca
parents: 131
diff changeset
  2088
                args at:2 put:#extent:
d5ab85ec27fd undo history; keep view identifier
ca
parents: 131
diff changeset
  2089
            ].
d5ab85ec27fd undo history; keep view identifier
ca
parents: 131
diff changeset
  2090
            args at:3 put:(lyt copy).
d5ab85ec27fd undo history; keep view identifier
ca
parents: 131
diff changeset
  2091
            undoHistory addUndoSelector:#undoLayout: withArgs:args.
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
  2092
        ]
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
  2093
    ]
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
  2094
!
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
  2095
134
d5ab85ec27fd undo history; keep view identifier
ca
parents: 131
diff changeset
  2096
createUndoRemove:aView
d5ab85ec27fd undo history; keep view identifier
ca
parents: 131
diff changeset
  2097
    "create undo method before deleting views
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
  2098
    "
285
d80b3c6a4373 don't use superView instead parent properties derived
ca
parents: 281
diff changeset
  2099
    |prop pid|
134
d5ab85ec27fd undo history; keep view identifier
ca
parents: 131
diff changeset
  2100
d5ab85ec27fd undo history; keep view identifier
ca
parents: 131
diff changeset
  2101
    (prop := self propertyOfView:aView) notNil ifTrue:[
285
d80b3c6a4373 don't use superView instead parent properties derived
ca
parents: 281
diff changeset
  2102
        (pid := self propertyOfParentForView:aView) notNil ifTrue:[
d80b3c6a4373 don't use superView instead parent properties derived
ca
parents: 281
diff changeset
  2103
            pid := pid identifier
d80b3c6a4373 don't use superView instead parent properties derived
ca
parents: 281
diff changeset
  2104
        ].
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
  2105
134
d5ab85ec27fd undo history; keep view identifier
ca
parents: 131
diff changeset
  2106
        undoHistory addUndoSelector:#undoRemove:
285
d80b3c6a4373 don't use superView instead parent properties derived
ca
parents: 281
diff changeset
  2107
                           withArgs:(Array with:(self fullSpecFor:aView)
d80b3c6a4373 don't use superView instead parent properties derived
ca
parents: 281
diff changeset
  2108
                               with:(prop identifier)
d80b3c6a4373 don't use superView instead parent properties derived
ca
parents: 281
diff changeset
  2109
                               with:pid)
134
d5ab85ec27fd undo history; keep view identifier
ca
parents: 131
diff changeset
  2110
    ]
d5ab85ec27fd undo history; keep view identifier
ca
parents: 131
diff changeset
  2111
!
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
  2112
134
d5ab85ec27fd undo history; keep view identifier
ca
parents: 131
diff changeset
  2113
createUndoSpecModify:aProp
d5ab85ec27fd undo history; keep view identifier
ca
parents: 131
diff changeset
  2114
    "undo method when changing the specification for an object
d5ab85ec27fd undo history; keep view identifier
ca
parents: 131
diff changeset
  2115
    "
d5ab85ec27fd undo history; keep view identifier
ca
parents: 131
diff changeset
  2116
    aProp notNil ifTrue:[
d5ab85ec27fd undo history; keep view identifier
ca
parents: 131
diff changeset
  2117
        undoHistory addUndoSelector:#undoSpecModify:
d5ab85ec27fd undo history; keep view identifier
ca
parents: 131
diff changeset
  2118
                           withArgs:(Array with:(aProp spec) with:(aProp identifier))
d5ab85ec27fd undo history; keep view identifier
ca
parents: 131
diff changeset
  2119
    ]
d5ab85ec27fd undo history; keep view identifier
ca
parents: 131
diff changeset
  2120
!
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
  2121
134
d5ab85ec27fd undo history; keep view identifier
ca
parents: 131
diff changeset
  2122
undoCreate:something
d5ab85ec27fd undo history; keep view identifier
ca
parents: 131
diff changeset
  2123
    "undo method for creating or pasting an object
d5ab85ec27fd undo history; keep view identifier
ca
parents: 131
diff changeset
  2124
    "
d5ab85ec27fd undo history; keep view identifier
ca
parents: 131
diff changeset
  2125
    self forEach:something do:[:anId|self remove:(self findViewWithId:anId)].
d5ab85ec27fd undo history; keep view identifier
ca
parents: 131
diff changeset
  2126
!
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
  2127
134
d5ab85ec27fd undo history; keep view identifier
ca
parents: 131
diff changeset
  2128
undoLayout:args
d5ab85ec27fd undo history; keep view identifier
ca
parents: 131
diff changeset
  2129
    "undo method to set the old layout; see 'createUndoLayout:'
d5ab85ec27fd undo history; keep view identifier
ca
parents: 131
diff changeset
  2130
    "
d5ab85ec27fd undo history; keep view identifier
ca
parents: 131
diff changeset
  2131
    |view|
d5ab85ec27fd undo history; keep view identifier
ca
parents: 131
diff changeset
  2132
d5ab85ec27fd undo history; keep view identifier
ca
parents: 131
diff changeset
  2133
    (view := self findViewWithId:(args at:1)) notNil ifTrue:[
146
ae84facd80be checkin from browser
ca
parents: 141
diff changeset
  2134
        view perform:(args at:2) with:(args at:3).
223
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
  2135
        self layoutChanged.
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
  2136
    ]
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
  2137
!
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
  2138
134
d5ab85ec27fd undo history; keep view identifier
ca
parents: 131
diff changeset
  2139
undoRemove:args
d5ab85ec27fd undo history; keep view identifier
ca
parents: 131
diff changeset
  2140
    "undo method when removing an object; see 'createUndoRemove:'
d5ab85ec27fd undo history; keep view identifier
ca
parents: 131
diff changeset
  2141
    "
d5ab85ec27fd undo history; keep view identifier
ca
parents: 131
diff changeset
  2142
    |frame prop view|
d5ab85ec27fd undo history; keep view identifier
ca
parents: 131
diff changeset
  2143
d5ab85ec27fd undo history; keep view identifier
ca
parents: 131
diff changeset
  2144
    (args at:3) notNil ifTrue:[
d5ab85ec27fd undo history; keep view identifier
ca
parents: 131
diff changeset
  2145
        frame := self findViewWithId:(args at:3).
d5ab85ec27fd undo history; keep view identifier
ca
parents: 131
diff changeset
  2146
    ].
d5ab85ec27fd undo history; keep view identifier
ca
parents: 131
diff changeset
  2147
    frame isNil ifTrue:[
d5ab85ec27fd undo history; keep view identifier
ca
parents: 131
diff changeset
  2148
        frame := self
d5ab85ec27fd undo history; keep view identifier
ca
parents: 131
diff changeset
  2149
    ].
395
d39076243277 sett UIBuilder isEditing to true
ca
parents: 392
diff changeset
  2150
    view := self addSpec:(args at:1) builder:(UIBuilder new isEditing:true) in:frame.
134
d5ab85ec27fd undo history; keep view identifier
ca
parents: 131
diff changeset
  2151
    view realize.
d5ab85ec27fd undo history; keep view identifier
ca
parents: 131
diff changeset
  2152
    inputView raise.
d5ab85ec27fd undo history; keep view identifier
ca
parents: 131
diff changeset
  2153
d5ab85ec27fd undo history; keep view identifier
ca
parents: 131
diff changeset
  2154
    prop := self propertyOfView:view.
d5ab85ec27fd undo history; keep view identifier
ca
parents: 131
diff changeset
  2155
    prop identifier:(args at:2).
d5ab85ec27fd undo history; keep view identifier
ca
parents: 131
diff changeset
  2156
d5ab85ec27fd undo history; keep view identifier
ca
parents: 131
diff changeset
  2157
!
d5ab85ec27fd undo history; keep view identifier
ca
parents: 131
diff changeset
  2158
d5ab85ec27fd undo history; keep view identifier
ca
parents: 131
diff changeset
  2159
undoSpecModify:args
d5ab85ec27fd undo history; keep view identifier
ca
parents: 131
diff changeset
  2160
    "undo method when changing a spec; see 'createUndoSpecModify:'
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
  2161
    "
1173
7b5f40822819 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1092
diff changeset
  2162
    |view spec props|
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
  2163
134
d5ab85ec27fd undo history; keep view identifier
ca
parents: 131
diff changeset
  2164
    props := self propertyOfIdentifier:(args at:2).
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
  2165
134
d5ab85ec27fd undo history; keep view identifier
ca
parents: 131
diff changeset
  2166
    props notNil ifTrue:[
d5ab85ec27fd undo history; keep view identifier
ca
parents: 131
diff changeset
  2167
        view    := props view.
d5ab85ec27fd undo history; keep view identifier
ca
parents: 131
diff changeset
  2168
        spec    := args at:1.
395
d39076243277 sett UIBuilder isEditing to true
ca
parents: 392
diff changeset
  2169
134
d5ab85ec27fd undo history; keep view identifier
ca
parents: 131
diff changeset
  2170
        props spec:spec.
1173
7b5f40822819 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1092
diff changeset
  2171
        self rebuildView:view fromSpec:spec withBuilder:nil.
238
882be7e03af4 renamed claus instVar (;-)
Claus Gittinger <cg@exept.de>
parents: 231
diff changeset
  2172
        treeView propertyChanged:props.
211
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
  2173
    ]
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
  2174
! !
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
  2175
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
  2176
!UIPainterView::ViewProperty class methodsFor:'instance creation'!
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
  2177
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
  2178
new
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
  2179
    Identifier notNil ifTrue:[Identifier := Identifier + 1]
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
  2180
                     ifFalse:[Identifier := 1].
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
  2181
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
  2182
  ^ self basicNew initialize
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
  2183
! !
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
  2184
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
  2185
!UIPainterView::ViewProperty methodsFor:'accessing'!
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
  2186
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
  2187
identifier
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
  2188
    "return the unique identifier assigned to property
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
  2189
    "
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
  2190
    ^ identifier
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
  2191
!
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
  2192
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
  2193
identifier:anIdentifier
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
  2194
    "set the unique identifier assigned to property; called after an restore of
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
  2195
     a deleted instance
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
  2196
    "
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
  2197
    identifier := anIdentifier
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
  2198
!
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
  2199
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
  2200
spec
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
  2201
    "return the value of the instance variable 'spec' (automatically generated)"
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
  2202
1427
85b9b5da0b8d optimize: undraw selection
ca
parents: 1402
diff changeset
  2203
    ^ spec
85b9b5da0b8d optimize: undraw selection
ca
parents: 1402
diff changeset
  2204
!
211
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
  2205
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
  2206
spec:something
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
  2207
    "set the value of the instance variable 'spec' (automatically generated)"
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
  2208
1427
85b9b5da0b8d optimize: undraw selection
ca
parents: 1402
diff changeset
  2209
    spec := something.
85b9b5da0b8d optimize: undraw selection
ca
parents: 1402
diff changeset
  2210
!
211
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
  2211
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
  2212
view
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
  2213
    "return the value of the instance variable 'view' (automatically generated)"
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
  2214
1427
85b9b5da0b8d optimize: undraw selection
ca
parents: 1402
diff changeset
  2215
    ^ view
85b9b5da0b8d optimize: undraw selection
ca
parents: 1402
diff changeset
  2216
!
211
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
  2217
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
  2218
view:something
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
  2219
    "set the value of the instance variable 'view' (automatically generated)"
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
  2220
1427
85b9b5da0b8d optimize: undraw selection
ca
parents: 1402
diff changeset
  2221
    view := something.
85b9b5da0b8d optimize: undraw selection
ca
parents: 1402
diff changeset
  2222
! !
211
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
  2223
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
  2224
!UIPainterView::ViewProperty methodsFor:'initialization'!
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
  2225
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
  2226
initialize
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
  2227
    super initialize.
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
  2228
    identifier := Identifier
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
  2229
! !
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
  2230
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
  2231
!UIPainterView::ViewProperty methodsFor:'misc'!
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
  2232
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
  2233
extractNumberStartingAt:anIndex
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
  2234
    "return the number from the name starting at anIndex or 0.
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
  2235
    "
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
  2236
    |val|
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
  2237
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
  2238
    val := 0.
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
  2239
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
  2240
    self name from:anIndex do:[:c|
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
  2241
        c isDigit ifTrue:[val := val * 10 + c digitValue]
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
  2242
                 ifFalse:[^ 0]
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
  2243
    ].
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
  2244
    ^ val
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
  2245
        
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
  2246
! !
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
  2247
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
  2248
!UIPainterView::ViewProperty methodsFor:'spec messages'!
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
  2249
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
  2250
doesNotUnderstand:aMessage
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
  2251
    spec notNil ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
  2252
        (spec respondsTo:(aMessage selector)) ifTrue:[^ aMessage sendTo:spec]
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
  2253
    ].
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
  2254
    ^ nil
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
  2255
!
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
  2256
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
  2257
layout
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
  2258
    spec layout
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
  2259
!
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
  2260
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
  2261
layout:aLayout
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
  2262
    spec layout:aLayout
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
  2263
!
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
  2264
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
  2265
name
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
  2266
    ^ spec name
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
  2267
!
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
  2268
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
  2269
name:aName
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
  2270
    spec name:aName
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
  2271
! !
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
  2272
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
  2273
!UIPainterView class methodsFor:'documentation'!
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
  2274
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
  2275
version
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
  2276
    ^ '$Header$'
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
  2277
! !
1225
0aa39cc5f0a3 Initialize class vars.
Stefan Vogel <sv@exept.de>
parents: 1201
diff changeset
  2278
UIPainterView initialize!