UIPainterView.st
author Patrik Svestka <patrik.svestka@gmail.com>
Wed, 14 Nov 2018 12:07:51 +0100
branchjv
changeset 3630 5e718e0a754e
parent 3360 b7f7e48455dd
child 3387 462d9e0dea1f
permissions -rw-r--r--
Issue #239: Fix all Smalltak/X source files to be in unicode (UTF8 without BOM) and prefixed by "{ Encoding: utf8 }" when any unicode character is present - All source *.st files are now Unicode UTF8 without BOM Files are in two groups (fileOut works this way in Smalltalk/X): - containing a unicode character have "{ Encoding: utf8 }" at the header - ASCII only are without the header
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
1834
2c640b5f7fa9 *** empty log message ***
werner
parents: 1833
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
"
1387
65c9df9cb1ad change selection behaviour after delete
ca
parents: 1366
diff changeset
    12
"{ Package: 'stx:libtool2' }"
65c9df9cb1ad change selection behaviour after delete
ca
parents: 1366
diff changeset
    13
3223
38d493fcc782 class: UIPainterView
Claus Gittinger <cg@exept.de>
parents: 3136
diff changeset
    14
"{ NameSpace: Smalltalk }"
38d493fcc782 class: UIPainterView
Claus Gittinger <cg@exept.de>
parents: 3136
diff changeset
    15
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
    16
UIObjectView subclass:#UIPainterView
278
5b7dfe33b497 drag & drop offset
Claus Gittinger <cg@exept.de>
parents: 238
diff changeset
    17
	instanceVariableNames:'treeView listHolder superclassName className methodName
2244
580cac31c444 changed #initialize
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
    18
		categoryName handleColorBlack handleColorWhite handleMasterColor
2276
485bda17023f more changes to allow for non-class/selector (i.e. spec-only) use
Claus Gittinger <cg@exept.de>
parents: 2265
diff changeset
    19
		sketchPainter listOfAspectsHolder'
3097
766d2055ce4a class: UIPainterView
Claus Gittinger <cg@exept.de>
parents: 3092
diff changeset
    20
	classVariableNames:'HandCursor RedefineAspectMethods AspectsAsInstances'
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
    21
	poolDictionaries:''
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
    22
	category:'Interface-UIPainter'
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
    23
!
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
    24
211
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
    25
Object subclass:#ViewProperty
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
    26
	instanceVariableNames:'view spec identifier'
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
    27
	classVariableNames:'Identifier'
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
    28
	poolDictionaries:''
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
    29
	privateIn:UIPainterView
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
    30
!
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
    31
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
    32
!UIPainterView class methodsFor:'documentation'!
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
    33
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
    34
copyright
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
    35
"
156
b332d7117c40 added copyrights
Claus Gittinger <cg@exept.de>
parents: 154
diff changeset
    36
 COPYRIGHT (c) 1995 by Claus Gittinger / eXept Software AG
1834
2c640b5f7fa9 *** empty log message ***
werner
parents: 1833
diff changeset
    37
	      All Rights Reserved
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
    38
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
    39
 This software is furnished under a license and may be used
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
    40
 only in accordance with the terms of that license and with the
742
688fd0a0b0fd code generation comment
tz
parents: 723
diff changeset
    41
 inclusion of the above copyright notice. This software may not
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
    42
 be provided or otherwise made available to, or used by, any
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
    43
 other person.  No title to or ownership of the software is
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
    44
 hereby transferred.
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
!
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
    47
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
    48
documentation
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
    49
"
128
9779b7459a1c selection and update from selection
ca
parents: 121
diff changeset
    50
    buildIn view used by the UIPainter; from this view, the layout of the
9779b7459a1c selection and update from selection
ca
parents: 121
diff changeset
    51
    new application derives from.
9779b7459a1c selection and update from selection
ca
parents: 121
diff changeset
    52
9779b7459a1c selection and update from selection
ca
parents: 121
diff changeset
    53
    [see also:]
1834
2c640b5f7fa9 *** empty log message ***
werner
parents: 1833
diff changeset
    54
	UIBuilder
2c640b5f7fa9 *** empty log message ***
werner
parents: 1833
diff changeset
    55
	UIObjectView
156
b332d7117c40 added copyrights
Claus Gittinger <cg@exept.de>
parents: 154
diff changeset
    56
b332d7117c40 added copyrights
Claus Gittinger <cg@exept.de>
parents: 154
diff changeset
    57
    [author:]
1834
2c640b5f7fa9 *** empty log message ***
werner
parents: 1833
diff changeset
    58
	Claus Gittinger
2c640b5f7fa9 *** empty log message ***
werner
parents: 1833
diff changeset
    59
	Claus Atzkern
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
    60
"
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
    61
! !
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
    62
1225
0aa39cc5f0a3 Initialize class vars.
Stefan Vogel <sv@exept.de>
parents: 1201
diff changeset
    63
!UIPainterView class methodsFor:'initialization'!
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
initialize
0aa39cc5f0a3 Initialize class vars.
Stefan Vogel <sv@exept.de>
parents: 1201
diff changeset
    66
1494
115ae5972b27 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1474
diff changeset
    67
    AspectsAsInstances := true. "/ false.
1225
0aa39cc5f0a3 Initialize class vars.
Stefan Vogel <sv@exept.de>
parents: 1201
diff changeset
    68
    RedefineAspectMethods := false.
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
    "Created: / 22.9.1999 / 12:32:31 / stefan"
0aa39cc5f0a3 Initialize class vars.
Stefan Vogel <sv@exept.de>
parents: 1201
diff changeset
    71
! !
0aa39cc5f0a3 Initialize class vars.
Stefan Vogel <sv@exept.de>
parents: 1201
diff changeset
    72
698
5bf234e0e451 redefine methods flag
tz
parents: 662
diff changeset
    73
!UIPainterView class methodsFor:'code generation mode'!
5bf234e0e451 redefine methods flag
tz
parents: 662
diff changeset
    74
925
e6ddd46581c3 added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents: 887
diff changeset
    75
generateAspectsAsInstanceVariables
e6ddd46581c3 added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents: 887
diff changeset
    76
    "if on, aspects are held as instance variables;
2244
580cac31c444 changed #initialize
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
    77
     if off (the default), they are kept in the bindings dictionary."
580cac31c444 changed #initialize
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
    78
925
e6ddd46581c3 added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents: 887
diff changeset
    79
    ^ AspectsAsInstances
e6ddd46581c3 added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents: 887
diff changeset
    80
e6ddd46581c3 added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents: 887
diff changeset
    81
    "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
    82
    "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
    83
!
e6ddd46581c3 added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents: 887
diff changeset
    84
e6ddd46581c3 added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents: 887
diff changeset
    85
generateAspectsAsInstanceVariables:aBoolean
e6ddd46581c3 added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents: 887
diff changeset
    86
    "if on, aspects are held as instance variables;
2244
580cac31c444 changed #initialize
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
    87
     if off (the default), they are kept in the bindings dictionary."
580cac31c444 changed #initialize
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
    88
925
e6ddd46581c3 added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents: 887
diff changeset
    89
    AspectsAsInstances := aBoolean
e6ddd46581c3 added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents: 887
diff changeset
    90
e6ddd46581c3 added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents: 887
diff changeset
    91
    "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
    92
    "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
    93
!
e6ddd46581c3 added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents: 887
diff changeset
    94
2244
580cac31c444 changed #initialize
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
    95
generateCommentedCode
580cac31c444 changed #initialize
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
    96
    "comments in generated aspect methods; yes or no."
580cac31c444 changed #initialize
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
    97
2714
abaae556bec8 commentCode flags now in userPrefs
Claus Gittinger <cg@exept.de>
parents: 2627
diff changeset
    98
    ^ UserPreferences current generateComments
abaae556bec8 commentCode flags now in userPrefs
Claus Gittinger <cg@exept.de>
parents: 2627
diff changeset
    99
    and:[ UserPreferences current generateCommentsForAspectMethods ]
2244
580cac31c444 changed #initialize
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
   100
!
580cac31c444 changed #initialize
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
   101
580cac31c444 changed #initialize
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
   102
generateCommentedCode:aBoolean
580cac31c444 changed #initialize
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
   103
    "comments in generated aspect methods; yes or no."
580cac31c444 changed #initialize
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
   104
2716
ed0006640fb4 changed: #generateCommentedCode:
Claus Gittinger <cg@exept.de>
parents: 2714
diff changeset
   105
    UserPreferences current generateComments ifFalse:[
ed0006640fb4 changed: #generateCommentedCode:
Claus Gittinger <cg@exept.de>
parents: 2714
diff changeset
   106
        aBoolean ifTrue:[
ed0006640fb4 changed: #generateCommentedCode:
Claus Gittinger <cg@exept.de>
parents: 2714
diff changeset
   107
            UserPreferences current generateComments:true
ed0006640fb4 changed: #generateCommentedCode:
Claus Gittinger <cg@exept.de>
parents: 2714
diff changeset
   108
        ].
ed0006640fb4 changed: #generateCommentedCode:
Claus Gittinger <cg@exept.de>
parents: 2714
diff changeset
   109
    ].
ed0006640fb4 changed: #generateCommentedCode:
Claus Gittinger <cg@exept.de>
parents: 2714
diff changeset
   110
2714
abaae556bec8 commentCode flags now in userPrefs
Claus Gittinger <cg@exept.de>
parents: 2627
diff changeset
   111
    UserPreferences current 
2716
ed0006640fb4 changed: #generateCommentedCode:
Claus Gittinger <cg@exept.de>
parents: 2714
diff changeset
   112
        generateCommentsForAspectMethods:aBoolean.
2244
580cac31c444 changed #initialize
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
   113
!
580cac31c444 changed #initialize
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
   114
742
688fd0a0b0fd code generation comment
tz
parents: 723
diff changeset
   115
redefineAspectMethods
2244
580cac31c444 changed #initialize
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
   116
    "redefine methods yes or no. 
580cac31c444 changed #initialize
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
   117
     If a method is defined in super class should the message be reinstalled ?"
580cac31c444 changed #initialize
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
   118
1225
0aa39cc5f0a3 Initialize class vars.
Stefan Vogel <sv@exept.de>
parents: 1201
diff changeset
   119
    ^ RedefineAspectMethods
698
5bf234e0e451 redefine methods flag
tz
parents: 662
diff changeset
   120
1225
0aa39cc5f0a3 Initialize class vars.
Stefan Vogel <sv@exept.de>
parents: 1201
diff changeset
   121
    "Modified: / 22.9.1999 / 12:33:03 / stefan"
698
5bf234e0e451 redefine methods flag
tz
parents: 662
diff changeset
   122
!
5bf234e0e451 redefine methods flag
tz
parents: 662
diff changeset
   123
742
688fd0a0b0fd code generation comment
tz
parents: 723
diff changeset
   124
redefineAspectMethods:aBoolean
2244
580cac31c444 changed #initialize
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
   125
    "redefine methods yes or no.
580cac31c444 changed #initialize
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
   126
     If a method is defined in super class should the message be reinstalled ?"
580cac31c444 changed #initialize
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
   127
742
688fd0a0b0fd code generation comment
tz
parents: 723
diff changeset
   128
    RedefineAspectMethods := aBoolean
698
5bf234e0e451 redefine methods flag
tz
parents: 662
diff changeset
   129
! !
5bf234e0e451 redefine methods flag
tz
parents: 662
diff changeset
   130
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   131
!UIPainterView class methodsFor:'defaults'!
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   132
1834
2c640b5f7fa9 *** empty log message ***
werner
parents: 1833
diff changeset
   133
defaultMenuMessage
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   134
    "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
   135
    "
121
96d6feeeb049 middleButtonMen:
ca
parents: 119
diff changeset
   136
    ^ #showMiddleButtonMenu
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   137
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   138
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
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   141
!UIPainterView methodsFor:'accessing'!
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   142
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   143
application
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   144
    ^ nil
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   145
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   146
    "Modified: 6.9.1995 / 00:46:44 / claus"
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   147
!
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   148
78
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
   149
applicationName
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
   150
    ^ self className
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
   151
!
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
   152
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
   153
applicationName:aName
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
   154
    self className:aName
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
   155
!
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
   156
1977
cf8a54d02ac0 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 1959
diff changeset
   157
class:aClass superclassName:aSuperclassName selector:aSelector
cf8a54d02ac0 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 1959
diff changeset
   158
    self assert:(aClass isBehavior).
cf8a54d02ac0 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 1959
diff changeset
   159
    className      := aClass name.
cf8a54d02ac0 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 1959
diff changeset
   160
    superclassName := aSuperclassName.
cf8a54d02ac0 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 1959
diff changeset
   161
    methodName     := aSelector.
cf8a54d02ac0 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 1959
diff changeset
   162
!
cf8a54d02ac0 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 1959
diff changeset
   163
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   164
className
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   165
    ^ className
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   166
!
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   167
78
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
   168
className:aName
1977
cf8a54d02ac0 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 1959
diff changeset
   169
    self assert:(aName isString).
78
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
   170
    className := 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
className:aClassName superclassName:aSuperclassName selector:aSelector
1977
cf8a54d02ac0 code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 1959
diff changeset
   174
    self assert:(aClassName isString).
78
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
   175
    className      := aClassName.
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   176
    superclassName := aSuperclassName.
78
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
   177
    methodName     := aSelector.
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   178
!
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   179
2276
485bda17023f more changes to allow for non-class/selector (i.e. spec-only) use
Claus Gittinger <cg@exept.de>
parents: 2265
diff changeset
   180
listOfAspectsHolder:something
485bda17023f more changes to allow for non-class/selector (i.e. spec-only) use
Claus Gittinger <cg@exept.de>
parents: 2265
diff changeset
   181
    listOfAspectsHolder := something.
485bda17023f more changes to allow for non-class/selector (i.e. spec-only) use
Claus Gittinger <cg@exept.de>
parents: 2265
diff changeset
   182
!
485bda17023f more changes to allow for non-class/selector (i.e. spec-only) use
Claus Gittinger <cg@exept.de>
parents: 2265
diff changeset
   183
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   184
methodName
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   185
    ^ methodName
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   186
!
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   187
78
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
   188
methodName:aName
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
   189
    methodName := aName
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   190
!
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   191
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   192
selectNames:aStringOrCollection
1031
7ce4b97f2c43 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   193
    |prop coll s n newSel|
7ce4b97f2c43 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   194
7ce4b97f2c43 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   195
    (aStringOrCollection size == 0) ifTrue:[
1834
2c640b5f7fa9 *** empty log message ***
werner
parents: 1833
diff changeset
   196
	newSel := nil.
1031
7ce4b97f2c43 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   197
    ] ifFalse:[
1834
2c640b5f7fa9 *** empty log message ***
werner
parents: 1833
diff changeset
   198
	(s := aStringOrCollection) isString ifFalse:[
2c640b5f7fa9 *** empty log message ***
werner
parents: 1833
diff changeset
   199
	    s size == 1 ifTrue:[
2c640b5f7fa9 *** empty log message ***
werner
parents: 1833
diff changeset
   200
		s := s first
2c640b5f7fa9 *** empty log message ***
werner
parents: 1833
diff changeset
   201
	    ] ifFalse:[
2c640b5f7fa9 *** empty log message ***
werner
parents: 1833
diff changeset
   202
		coll := OrderedCollection new.
2c640b5f7fa9 *** empty log message ***
werner
parents: 1833
diff changeset
   203
2c640b5f7fa9 *** empty log message ***
werner
parents: 1833
diff changeset
   204
		s do:[:aName|
2c640b5f7fa9 *** empty log message ***
werner
parents: 1833
diff changeset
   205
		    (prop := self propertyOfName:aName) notNil ifTrue:[
2c640b5f7fa9 *** empty log message ***
werner
parents: 1833
diff changeset
   206
			coll add:(prop view)
2c640b5f7fa9 *** empty log message ***
werner
parents: 1833
diff changeset
   207
		    ]
2c640b5f7fa9 *** empty log message ***
werner
parents: 1833
diff changeset
   208
		].
2c640b5f7fa9 *** empty log message ***
werner
parents: 1833
diff changeset
   209
		(n := coll size) == 1 ifTrue:[
2c640b5f7fa9 *** empty log message ***
werner
parents: 1833
diff changeset
   210
		    newSel := coll at:1
2c640b5f7fa9 *** empty log message ***
werner
parents: 1833
diff changeset
   211
		] ifFalse:[
2c640b5f7fa9 *** empty log message ***
werner
parents: 1833
diff changeset
   212
		    n == 0 ifTrue:[
2c640b5f7fa9 *** empty log message ***
werner
parents: 1833
diff changeset
   213
			newSel := nil
2c640b5f7fa9 *** empty log message ***
werner
parents: 1833
diff changeset
   214
		    ] ifFalse:[
2c640b5f7fa9 *** empty log message ***
werner
parents: 1833
diff changeset
   215
			newSel := coll
2c640b5f7fa9 *** empty log message ***
werner
parents: 1833
diff changeset
   216
		    ]
2c640b5f7fa9 *** empty log message ***
werner
parents: 1833
diff changeset
   217
		].
2c640b5f7fa9 *** empty log message ***
werner
parents: 1833
diff changeset
   218
		^ self select:newSel.
2c640b5f7fa9 *** empty log message ***
werner
parents: 1833
diff changeset
   219
	    ]
2c640b5f7fa9 *** empty log message ***
werner
parents: 1833
diff changeset
   220
	].
2c640b5f7fa9 *** empty log message ***
werner
parents: 1833
diff changeset
   221
2c640b5f7fa9 *** empty log message ***
werner
parents: 1833
diff changeset
   222
	prop := self propertyOfName:s.
2c640b5f7fa9 *** empty log message ***
werner
parents: 1833
diff changeset
   223
	prop isNil ifTrue:[
2c640b5f7fa9 *** empty log message ***
werner
parents: 1833
diff changeset
   224
	    newSel := nil
2c640b5f7fa9 *** empty log message ***
werner
parents: 1833
diff changeset
   225
	] ifFalse:[
2c640b5f7fa9 *** empty log message ***
werner
parents: 1833
diff changeset
   226
	    newSel := prop view
2c640b5f7fa9 *** empty log message ***
werner
parents: 1833
diff changeset
   227
	].
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   228
    ].
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   229
1031
7ce4b97f2c43 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   230
    ^ self select:newSel
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   231
! !
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   232
111
ca
parents: 103
diff changeset
   233
!UIPainterView methodsFor:'change & update'!
ca
parents: 103
diff changeset
   234
223
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
   235
layoutChanged
1445
d2654a3b1e3a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1441
diff changeset
   236
    treeView notNil ifTrue:[
1834
2c640b5f7fa9 *** empty log message ***
werner
parents: 1833
diff changeset
   237
	treeView layoutChanged
1445
d2654a3b1e3a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1441
diff changeset
   238
    ]
111
ca
parents: 103
diff changeset
   239
! !
ca
parents: 103
diff changeset
   240
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   241
!UIPainterView methodsFor:'copy & cut & paste'!
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   242
2221
8ac60d4545ad selection after paste
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   243
changeSelectionAfterPasteOf:sel
8ac60d4545ad selection after paste
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   244
    sel notNil ifTrue:[
8ac60d4545ad selection after paste
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   245
        self select:sel.
8ac60d4545ad selection after paste
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   246
    ].
8ac60d4545ad selection after paste
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   247
!
8ac60d4545ad selection after paste
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   248
1744
c59a91953b64 paste with no container selected: search for a good one
Claus Gittinger <cg@exept.de>
parents: 1733
diff changeset
   249
commonContainerOf:someComponents
c59a91953b64 paste with no container selected: search for a good one
Claus Gittinger <cg@exept.de>
parents: 1733
diff changeset
   250
    |container|
c59a91953b64 paste with no container selected: search for a good one
Claus Gittinger <cg@exept.de>
parents: 1733
diff changeset
   251
c59a91953b64 paste with no container selected: search for a good one
Claus Gittinger <cg@exept.de>
parents: 1733
diff changeset
   252
    container := someComponents first container.
c59a91953b64 paste with no container selected: search for a good one
Claus Gittinger <cg@exept.de>
parents: 1733
diff changeset
   253
    [container notNil
c59a91953b64 paste with no container selected: search for a good one
Claus Gittinger <cg@exept.de>
parents: 1733
diff changeset
   254
     and:[ (someComponents conform:[:eachComponent | eachComponent isComponentOf:container]) not]]
1834
2c640b5f7fa9 *** empty log message ***
werner
parents: 1833
diff changeset
   255
	whileTrue:[
2c640b5f7fa9 *** empty log message ***
werner
parents: 1833
diff changeset
   256
	container := container container.
1744
c59a91953b64 paste with no container selected: search for a good one
Claus Gittinger <cg@exept.de>
parents: 1733
diff changeset
   257
    ].
c59a91953b64 paste with no container selected: search for a good one
Claus Gittinger <cg@exept.de>
parents: 1733
diff changeset
   258
    ^ container
c59a91953b64 paste with no container selected: search for a good one
Claus Gittinger <cg@exept.de>
parents: 1733
diff changeset
   259
!
c59a91953b64 paste with no container selected: search for a good one
Claus Gittinger <cg@exept.de>
parents: 1733
diff changeset
   260
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   261
copySelection
1959
fd6bf76e712a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1954
diff changeset
   262
    "copy the selection into the cut & paste-buffer"
fd6bf76e712a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1954
diff changeset
   263
2362
a6a7ef98fdc3 can resize - allow resizing all;
Claus Gittinger <cg@exept.de>
parents: 2358
diff changeset
   264
    |specs coll|
71
407d25aca670 checkin from browser
ca
parents: 69
diff changeset
   265
2257
badd429a2a2a code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents: 2250
diff changeset
   266
    coll := self minClosedViewSetFor:(self selection).
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   267
71
407d25aca670 checkin from browser
ca
parents: 69
diff changeset
   268
    coll notNil ifTrue:[
776
1df0525eeec9 reuse methods provided by the model
ca
parents: 770
diff changeset
   269
"/        self select:nil.
2362
a6a7ef98fdc3 can resize - allow resizing all;
Claus Gittinger <cg@exept.de>
parents: 2358
diff changeset
   270
        specs := coll collect:[:eachView | self fullSpecWithAbsolutePositionFor:eachView].
1870
771fcc38ecb8 set selection interface changed
ca
parents: 1869
diff changeset
   271
        self setClipboardObject:specs.
776
1df0525eeec9 reuse methods provided by the model
ca
parents: 770
diff changeset
   272
"/        treeView selection: sel
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   273
    ].
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   274
!
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   275
723
60e8ffac2f38 #deleteSelection in #deleteTotalSelection renamed
tz
parents: 712
diff changeset
   276
deleteSelection
1959
fd6bf76e712a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1954
diff changeset
   277
    "delete the selection buffered"
fd6bf76e712a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1954
diff changeset
   278
887
79a6e12e1d0f after deleting a widget do select the neighbour then the parent (step 2)
tz
parents: 886
diff changeset
   279
    self deleteSelectionBuffered: true
79a6e12e1d0f after deleting a widget do select the neighbour then the parent (step 2)
tz
parents: 886
diff changeset
   280
!
79a6e12e1d0f after deleting a widget do select the neighbour then the parent (step 2)
tz
parents: 886
diff changeset
   281
2396
042e31fded4f *** empty log message ***
ca
parents: 2395
diff changeset
   282
deleteSelectionBuffered:buffered
2257
badd429a2a2a code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents: 2250
diff changeset
   283
    "cut the selection. If buffered is true, place it into the cut&paste-buffer"
badd429a2a2a code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents: 2250
diff changeset
   284
2396
042e31fded4f *** empty log message ***
ca
parents: 2395
diff changeset
   285
    |specs viewsToRemove newSelection firstView|
71
407d25aca670 checkin from browser
ca
parents: 69
diff changeset
   286
1621
112670159075 cg: check if selection change is allowed BEFORE changing the
tm
parents: 1574
diff changeset
   287
    treeView askForSelectionChangeAllowed ifFalse:[^ self].
112670159075 cg: check if selection change is allowed BEFORE changing the
tm
parents: 1574
diff changeset
   288
2396
042e31fded4f *** empty log message ***
ca
parents: 2395
diff changeset
   289
    viewsToRemove := self minClosedViewSetFor:(self selection).
042e31fded4f *** empty log message ***
ca
parents: 2395
diff changeset
   290
    viewsToRemove isEmptyOrNil ifTrue:[ ^ self].
042e31fded4f *** empty log message ***
ca
parents: 2395
diff changeset
   291
042e31fded4f *** empty log message ***
ca
parents: 2395
diff changeset
   292
    buffered ifTrue:[
042e31fded4f *** empty log message ***
ca
parents: 2395
diff changeset
   293
        specs := viewsToRemove collect:[:aView| self fullSpecWithAbsolutePositionFor:aView ].
042e31fded4f *** empty log message ***
ca
parents: 2395
diff changeset
   294
        self setClipboardObject:specs
042e31fded4f *** empty log message ***
ca
parents: 2395
diff changeset
   295
    ].
042e31fded4f *** empty log message ***
ca
parents: 2395
diff changeset
   296
    firstView    := viewsToRemove first.
042e31fded4f *** empty log message ***
ca
parents: 2395
diff changeset
   297
    newSelection := self findContainerOfView:firstView.
042e31fded4f *** empty log message ***
ca
parents: 2395
diff changeset
   298
042e31fded4f *** empty log message ***
ca
parents: 2395
diff changeset
   299
    newSelection isNil ifTrue:[
042e31fded4f *** empty log message ***
ca
parents: 2395
diff changeset
   300
        newSelection := self.
042e31fded4f *** empty log message ***
ca
parents: 2395
diff changeset
   301
    ] ifFalse:[
042e31fded4f *** empty log message ***
ca
parents: 2395
diff changeset
   302
        viewsToRemove size == 1 ifTrue:[
042e31fded4f *** empty log message ***
ca
parents: 2395
diff changeset
   303
            |subviews index|
042e31fded4f *** empty log message ***
ca
parents: 2395
diff changeset
   304
2508
d9dc378aaf8d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2505
diff changeset
   305
            "/ newSelection components notEmptyOrNil ifTrue:[ self halt ].
2396
042e31fded4f *** empty log message ***
ca
parents: 2395
diff changeset
   306
            subviews := newSelection subViews.
042e31fded4f *** empty log message ***
ca
parents: 2395
diff changeset
   307
042e31fded4f *** empty log message ***
ca
parents: 2395
diff changeset
   308
            subviews size > 1 ifTrue:[
042e31fded4f *** empty log message ***
ca
parents: 2395
diff changeset
   309
                index := subviews findFirst:[:eachView| eachView isSameOrComponentOf:firstView ].
042e31fded4f *** empty log message ***
ca
parents: 2395
diff changeset
   310
                index > 0 ifTrue:[
042e31fded4f *** empty log message ***
ca
parents: 2395
diff changeset
   311
                    newSelection := subviews
042e31fded4f *** empty log message ***
ca
parents: 2395
diff changeset
   312
                            at:(index + 1)
042e31fded4f *** empty log message ***
ca
parents: 2395
diff changeset
   313
                            ifAbsent:[subviews at:index -1].
042e31fded4f *** empty log message ***
ca
parents: 2395
diff changeset
   314
                ].
042e31fded4f *** empty log message ***
ca
parents: 2395
diff changeset
   315
            ].
042e31fded4f *** empty log message ***
ca
parents: 2395
diff changeset
   316
        ].
042e31fded4f *** empty log message ***
ca
parents: 2395
diff changeset
   317
    ].
042e31fded4f *** empty log message ***
ca
parents: 2395
diff changeset
   318
042e31fded4f *** empty log message ***
ca
parents: 2395
diff changeset
   319
    self withSelectionHiddenDo:[
042e31fded4f *** empty log message ***
ca
parents: 2395
diff changeset
   320
        self select:newSelection.
042e31fded4f *** empty log message ***
ca
parents: 2395
diff changeset
   321
2257
badd429a2a2a code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents: 2250
diff changeset
   322
        treeView canvasEventsDisabledDo:[
2396
042e31fded4f *** empty log message ***
ca
parents: 2395
diff changeset
   323
            self withinTransaction:#cut objects:viewsToRemove do:[
042e31fded4f *** empty log message ***
ca
parents: 2395
diff changeset
   324
                viewsToRemove reverseDo:[:aView|
1870
771fcc38ecb8 set selection interface changed
ca
parents: 1869
diff changeset
   325
                    self createUndoRemove:aView.
771fcc38ecb8 set selection interface changed
ca
parents: 1869
diff changeset
   326
                    self remove:aView.
771fcc38ecb8 set selection interface changed
ca
parents: 1869
diff changeset
   327
                ]
771fcc38ecb8 set selection interface changed
ca
parents: 1869
diff changeset
   328
            ].
2396
042e31fded4f *** empty log message ***
ca
parents: 2395
diff changeset
   329
        ].
042e31fded4f *** empty log message ***
ca
parents: 2395
diff changeset
   330
        self windowGroup processRealExposeEvents.
042e31fded4f *** empty log message ***
ca
parents: 2395
diff changeset
   331
    ].
698
5bf234e0e451 redefine methods flag
tz
parents: 662
diff changeset
   332
!
5bf234e0e451 redefine methods flag
tz
parents: 662
diff changeset
   333
723
60e8ffac2f38 #deleteSelection in #deleteTotalSelection renamed
tz
parents: 712
diff changeset
   334
deleteTotalSelection
1959
fd6bf76e712a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1954
diff changeset
   335
    "delete the selection"
fd6bf76e712a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1954
diff changeset
   336
887
79a6e12e1d0f after deleting a widget do select the neighbour then the parent (step 2)
tz
parents: 886
diff changeset
   337
    self deleteSelectionBuffered: false
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   338
!
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   339
1832
ba152306fbf5 group & ungroup
werner
parents: 1830
diff changeset
   340
getSelectedViewsAndSpecs
ba152306fbf5 group & ungroup
werner
parents: 1830
diff changeset
   341
    "return an array filed with selected views and corresponding specs.
1959
fd6bf76e712a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1954
diff changeset
   342
     Nil if there is none."
fd6bf76e712a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1954
diff changeset
   343
1832
ba152306fbf5 group & ungroup
werner
parents: 1830
diff changeset
   344
    |specs coll sel|
ba152306fbf5 group & ungroup
werner
parents: 1830
diff changeset
   345
ba152306fbf5 group & ungroup
werner
parents: 1830
diff changeset
   346
    sel := treeView selection.
ba152306fbf5 group & ungroup
werner
parents: 1830
diff changeset
   347
2257
badd429a2a2a code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents: 2250
diff changeset
   348
    coll := self minClosedViewSetFor:(self selection).
1832
ba152306fbf5 group & ungroup
werner
parents: 1830
diff changeset
   349
ba152306fbf5 group & ungroup
werner
parents: 1830
diff changeset
   350
    coll isNil ifTrue:[^ nil].
ba152306fbf5 group & ungroup
werner
parents: 1830
diff changeset
   351
ba152306fbf5 group & ungroup
werner
parents: 1830
diff changeset
   352
    specs := coll collect:[:aView| self fullSpecFor:aView ].
ba152306fbf5 group & ungroup
werner
parents: 1830
diff changeset
   353
    ^ Array with: coll with: specs
ba152306fbf5 group & ungroup
werner
parents: 1830
diff changeset
   354
!
ba152306fbf5 group & ungroup
werner
parents: 1830
diff changeset
   355
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   356
pasteBuffer
2311
67811bdeb0f5 Support sorting of items in tree
Stefan Vogel <sv@exept.de>
parents: 2295
diff changeset
   357
    "add the objects in the paste-buffer to the object view; 
67811bdeb0f5 Support sorting of items in tree
Stefan Vogel <sv@exept.de>
parents: 2295
diff changeset
   358
     don't change the layout if more than a single item has been selected"
67811bdeb0f5 Support sorting of items in tree
Stefan Vogel <sv@exept.de>
parents: 2295
diff changeset
   359
67811bdeb0f5 Support sorting of items in tree
Stefan Vogel <sv@exept.de>
parents: 2295
diff changeset
   360
    |sel clipboard|
67811bdeb0f5 Support sorting of items in tree
Stefan Vogel <sv@exept.de>
parents: 2295
diff changeset
   361
2362
a6a7ef98fdc3 can resize - allow resizing all;
Claus Gittinger <cg@exept.de>
parents: 2358
diff changeset
   362
    self enabled ifFalse:[
a6a7ef98fdc3 can resize - allow resizing all;
Claus Gittinger <cg@exept.de>
parents: 2358
diff changeset
   363
        Dialog warn:'Operation currently disabled (In geometry test mode)'.
a6a7ef98fdc3 can resize - allow resizing all;
Claus Gittinger <cg@exept.de>
parents: 2358
diff changeset
   364
        ^ self
a6a7ef98fdc3 can resize - allow resizing all;
Claus Gittinger <cg@exept.de>
parents: 2358
diff changeset
   365
    ]. 
a6a7ef98fdc3 can resize - allow resizing all;
Claus Gittinger <cg@exept.de>
parents: 2358
diff changeset
   366
2311
67811bdeb0f5 Support sorting of items in tree
Stefan Vogel <sv@exept.de>
parents: 2295
diff changeset
   367
    clipboard := self getClipboardObject.
2951
c2b24bf7b967 class: UIPainterView
Claus Gittinger <cg@exept.de>
parents: 2853
diff changeset
   368
    clipboard isString ifTrue:[
c2b24bf7b967 class: UIPainterView
Claus Gittinger <cg@exept.de>
parents: 2853
diff changeset
   369
        Dialog warn:'can only paste widgets here'.
c2b24bf7b967 class: UIPainterView
Claus Gittinger <cg@exept.de>
parents: 2853
diff changeset
   370
    ] ifFalse:[
c2b24bf7b967 class: UIPainterView
Claus Gittinger <cg@exept.de>
parents: 2853
diff changeset
   371
        sel := self pasteSpecifications:clipboard keepLayout:true "(clipboard size > 1)".
c2b24bf7b967 class: UIPainterView
Claus Gittinger <cg@exept.de>
parents: 2853
diff changeset
   372
        self changeSelectionAfterPasteOf:sel.
c2b24bf7b967 class: UIPainterView
Claus Gittinger <cg@exept.de>
parents: 2853
diff changeset
   373
    ].
89
35c5711729c2 so far so good
ca
parents: 86
diff changeset
   374
!
35c5711729c2 so far so good
ca
parents: 86
diff changeset
   375
1338
3c1a528c50db added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   376
pasteKeepingPosition
1834
2c640b5f7fa9 *** empty log message ***
werner
parents: 1833
diff changeset
   377
    "add the objects in the paste-buffer to the object view;
1338
3c1a528c50db added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   378
     translate the layout as appropriate, to position the component
1959
fd6bf76e712a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1954
diff changeset
   379
     at the same absolute position (relative to topView) as before"
fd6bf76e712a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1954
diff changeset
   380
1338
3c1a528c50db added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   381
    |sel|
3c1a528c50db added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   382
3c1a528c50db added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   383
    sel := self
1872
ab5cc43b193a get selection interface changed
ca
parents: 1870
diff changeset
   384
        pasteSpecifications:(self getClipboardObject)
ab5cc43b193a get selection interface changed
ca
parents: 1870
diff changeset
   385
        keepLayout:true
ab5cc43b193a get selection interface changed
ca
parents: 1870
diff changeset
   386
        keepPosition:true
3055
db492f86c9b1 class: UIPainterView
Claus Gittinger <cg@exept.de>
parents: 3038
diff changeset
   387
        at:#keep.
1338
3c1a528c50db added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   388
2221
8ac60d4545ad selection after paste
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   389
    self changeSelectionAfterPasteOf:sel.
1338
3c1a528c50db added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   390
!
3c1a528c50db added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   391
2395
9f9cf71a311c *** empty log message ***
ca
parents: 2392
diff changeset
   392
pasteSpecifications:aSpecificationOrList into:aContainerOrNil beforeIndex:anIndexOrNil keepLayout:keepLayout keepPosition:keepPosition at:aPointOrNilOrKeep
2537
12e3b32befe4 handle changes
Claus Gittinger <cg@exept.de>
parents: 2526
diff changeset
   393
    "add the specs to the object view; 
12e3b32befe4 handle changes
Claus Gittinger <cg@exept.de>
parents: 2526
diff changeset
   394
     if given a collection of specs, returns a list of pasted widgets;
12e3b32befe4 handle changes
Claus Gittinger <cg@exept.de>
parents: 2526
diff changeset
   395
     if given a single spec, returns that view (sigh - a stupid bw-compatibility kludge)"
2257
badd429a2a2a code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents: 2250
diff changeset
   396
2494
43400c4e5196 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2483
diff changeset
   397
    |sensor specsToPaste pasteOffset builder newSel 
2560
efad0ef440c7 oops - need repairDamage for shown to be set (under unix; it used to
Michael Beyl <mb@exept.de>
parents: 2537
diff changeset
   398
     bounds containerToPasteInto pastePoint beforeIndex count|
1621
112670159075 cg: check if selection change is allowed BEFORE changing the
tm
parents: 1574
diff changeset
   399
112670159075 cg: check if selection change is allowed BEFORE changing the
tm
parents: 1574
diff changeset
   400
    treeView askForSelectionChangeAllowed ifFalse:[^ nil].
112670159075 cg: check if selection change is allowed BEFORE changing the
tm
parents: 1574
diff changeset
   401
2494
43400c4e5196 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2483
diff changeset
   402
    sensor := self window sensor.
43400c4e5196 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2483
diff changeset
   403
2387
050c6d4d427d bugfix - replaceSelectionBy: (1)
ca
parents: 2386
diff changeset
   404
    containerToPasteInto := aContainerOrNil.
050c6d4d427d bugfix - replaceSelectionBy: (1)
ca
parents: 2386
diff changeset
   405
2366
Claus Gittinger <cg@exept.de>
parents: 2362
diff changeset
   406
    (aPointOrNilOrKeep == #keep
2494
43400c4e5196 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2483
diff changeset
   407
    or:[ sensor shiftDown
43400c4e5196 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2483
diff changeset
   408
    or:[ sensor ctrlDown ]]) ifTrue:[
2362
a6a7ef98fdc3 can resize - allow resizing all;
Claus Gittinger <cg@exept.de>
parents: 2358
diff changeset
   409
        "/ paste into the selection
2387
050c6d4d427d bugfix - replaceSelectionBy: (1)
ca
parents: 2386
diff changeset
   410
        containerToPasteInto isNil ifTrue:[
050c6d4d427d bugfix - replaceSelectionBy: (1)
ca
parents: 2386
diff changeset
   411
            containerToPasteInto := self singleSelection.
050c6d4d427d bugfix - replaceSelectionBy: (1)
ca
parents: 2386
diff changeset
   412
        ].
2362
a6a7ef98fdc3 can resize - allow resizing all;
Claus Gittinger <cg@exept.de>
parents: 2358
diff changeset
   413
    ] ifFalse:[
a6a7ef98fdc3 can resize - allow resizing all;
Claus Gittinger <cg@exept.de>
parents: 2358
diff changeset
   414
        "/ ignore the selection and paste where we drop!!
2366
Claus Gittinger <cg@exept.de>
parents: 2362
diff changeset
   415
        pastePoint := aPointOrNilOrKeep.
2362
a6a7ef98fdc3 can resize - allow resizing all;
Claus Gittinger <cg@exept.de>
parents: 2358
diff changeset
   416
        pastePoint isNil ifTrue:[
3262
3168fe296011 device access
Claus Gittinger <cg@exept.de>
parents: 3249
diff changeset
   417
            pastePoint := device 
2494
43400c4e5196 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2483
diff changeset
   418
                                translatePoint:(sensor mousePoint)
2362
a6a7ef98fdc3 can resize - allow resizing all;
Claus Gittinger <cg@exept.de>
parents: 2358
diff changeset
   419
                                fromView:nil
a6a7ef98fdc3 can resize - allow resizing all;
Claus Gittinger <cg@exept.de>
parents: 2358
diff changeset
   420
                                toView:self.
a6a7ef98fdc3 can resize - allow resizing all;
Claus Gittinger <cg@exept.de>
parents: 2358
diff changeset
   421
        ].
2387
050c6d4d427d bugfix - replaceSelectionBy: (1)
ca
parents: 2386
diff changeset
   422
        containerToPasteInto isNil ifTrue:[
050c6d4d427d bugfix - replaceSelectionBy: (1)
ca
parents: 2386
diff changeset
   423
            containerToPasteInto := self findObjectAt:pastePoint.
050c6d4d427d bugfix - replaceSelectionBy: (1)
ca
parents: 2386
diff changeset
   424
        ].
2362
a6a7ef98fdc3 can resize - allow resizing all;
Claus Gittinger <cg@exept.de>
parents: 2358
diff changeset
   425
    ].
a6a7ef98fdc3 can resize - allow resizing all;
Claus Gittinger <cg@exept.de>
parents: 2358
diff changeset
   426
1744
c59a91953b64 paste with no container selected: search for a good one
Claus Gittinger <cg@exept.de>
parents: 1733
diff changeset
   427
    containerToPasteInto isNil ifTrue:[
1878
6ae0cf83738f Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents: 1872
diff changeset
   428
        self selection size > 0 ifTrue:[
6ae0cf83738f Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents: 1872
diff changeset
   429
            containerToPasteInto := self commonContainerOf:self selection
6ae0cf83738f Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents: 1872
diff changeset
   430
        ] ifFalse:[
6ae0cf83738f Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents: 1872
diff changeset
   431
            containerToPasteInto := self
6ae0cf83738f Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents: 1872
diff changeset
   432
        ].
2221
8ac60d4545ad selection after paste
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   433
"/        self selection:containerToPasteInto.
1744
c59a91953b64 paste with no container selected: search for a good one
Claus Gittinger <cg@exept.de>
parents: 1733
diff changeset
   434
    ].
c59a91953b64 paste with no container selected: search for a good one
Claus Gittinger <cg@exept.de>
parents: 1733
diff changeset
   435
2362
a6a7ef98fdc3 can resize - allow resizing all;
Claus Gittinger <cg@exept.de>
parents: 2358
diff changeset
   436
    "/ search up parent list for something we can paste into
a6a7ef98fdc3 can resize - allow resizing all;
Claus Gittinger <cg@exept.de>
parents: 2358
diff changeset
   437
    [containerToPasteInto notNil and:[(self canPasteInto:containerToPasteInto) not]] whileTrue:[
a6a7ef98fdc3 can resize - allow resizing all;
Claus Gittinger <cg@exept.de>
parents: 2358
diff changeset
   438
        containerToPasteInto == self ifTrue:[
a6a7ef98fdc3 can resize - allow resizing all;
Claus Gittinger <cg@exept.de>
parents: 2358
diff changeset
   439
            containerToPasteInto := nil
a6a7ef98fdc3 can resize - allow resizing all;
Claus Gittinger <cg@exept.de>
parents: 2358
diff changeset
   440
        ] ifFalse:[
a6a7ef98fdc3 can resize - allow resizing all;
Claus Gittinger <cg@exept.de>
parents: 2358
diff changeset
   441
            containerToPasteInto := containerToPasteInto container.
1878
6ae0cf83738f Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents: 1872
diff changeset
   442
        ].
1621
112670159075 cg: check if selection change is allowed BEFORE changing the
tm
parents: 1574
diff changeset
   443
    ].
1752
78d47dc11501 oops - dropping specs
Claus Gittinger <cg@exept.de>
parents: 1746
diff changeset
   444
    containerToPasteInto isNil ifTrue:[
1878
6ae0cf83738f Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents: 1872
diff changeset
   445
        containerToPasteInto := self
1752
78d47dc11501 oops - dropping specs
Claus Gittinger <cg@exept.de>
parents: 1746
diff changeset
   446
    ].
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   447
2221
8ac60d4545ad selection after paste
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   448
    (self canPaste:aSpecificationOrList into:containerToPasteInto)
8ac60d4545ad selection after paste
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   449
    ifFalse:[
2362
a6a7ef98fdc3 can resize - allow resizing all;
Claus Gittinger <cg@exept.de>
parents: 2358
diff changeset
   450
        self enabled ifTrue:[
a6a7ef98fdc3 can resize - allow resizing all;
Claus Gittinger <cg@exept.de>
parents: 2358
diff changeset
   451
            Dialog warn:'Cannot paste into selected component (not a container ?)'.
a6a7ef98fdc3 can resize - allow resizing all;
Claus Gittinger <cg@exept.de>
parents: 2358
diff changeset
   452
        ] ifFalse:[
2951
c2b24bf7b967 class: UIPainterView
Claus Gittinger <cg@exept.de>
parents: 2853
diff changeset
   453
            Dialog warn:'Operation currently disabled (In geometry test mode)'.
2362
a6a7ef98fdc3 can resize - allow resizing all;
Claus Gittinger <cg@exept.de>
parents: 2358
diff changeset
   454
        ]. 
1878
6ae0cf83738f Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents: 1872
diff changeset
   455
        ^ nil
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
2537
12e3b32befe4 handle changes
Claus Gittinger <cg@exept.de>
parents: 2526
diff changeset
   458
    self hideSelection.
12e3b32befe4 handle changes
Claus Gittinger <cg@exept.de>
parents: 2526
diff changeset
   459
776
1df0525eeec9 reuse methods provided by the model
ca
parents: 770
diff changeset
   460
    aSpecificationOrList isCollection ifTrue:[
2257
badd429a2a2a code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents: 2250
diff changeset
   461
        specsToPaste := aSpecificationOrList
776
1df0525eeec9 reuse methods provided by the model
ca
parents: 770
diff changeset
   462
    ] ifFalse:[
2257
badd429a2a2a code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents: 2250
diff changeset
   463
        specsToPaste := Array with:aSpecificationOrList
776
1df0525eeec9 reuse methods provided by the model
ca
parents: 770
diff changeset
   464
    ].
2221
8ac60d4545ad selection after paste
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   465
"/    self setClipboardObject:nil.
776
1df0525eeec9 reuse methods provided by the model
ca
parents: 770
diff changeset
   466
1df0525eeec9 reuse methods provided by the model
ca
parents: 770
diff changeset
   467
    newSel  := OrderedCollection new.
1df0525eeec9 reuse methods provided by the model
ca
parents: 770
diff changeset
   468
    builder := UIBuilder new isEditing:true.
1df0525eeec9 reuse methods provided by the model
ca
parents: 770
diff changeset
   469
1df0525eeec9 reuse methods provided by the model
ca
parents: 770
diff changeset
   470
    className notNil ifTrue:[
1878
6ae0cf83738f Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents: 1872
diff changeset
   471
        builder applicationClass:(self resolveName:className)
776
1df0525eeec9 reuse methods provided by the model
ca
parents: 770
diff changeset
   472
    ].
2362
a6a7ef98fdc3 can resize - allow resizing all;
Claus Gittinger <cg@exept.de>
parents: 2358
diff changeset
   473
    bounds := Rectangle origin:0@0 extent:(containerToPasteInto bounds extent).
a6a7ef98fdc3 can resize - allow resizing all;
Claus Gittinger <cg@exept.de>
parents: 2358
diff changeset
   474
a6a7ef98fdc3 can resize - allow resizing all;
Claus Gittinger <cg@exept.de>
parents: 2358
diff changeset
   475
    pasteOffset := 0.
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   476
2395
9f9cf71a311c *** empty log message ***
ca
parents: 2392
diff changeset
   477
    (anIndexOrNil notNil and:[anIndexOrNil > 0]) ifTrue:[
9f9cf71a311c *** empty log message ***
ca
parents: 2392
diff changeset
   478
        beforeIndex := anIndexOrNil.
9f9cf71a311c *** empty log message ***
ca
parents: 2392
diff changeset
   479
    ].
2257
badd429a2a2a code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents: 2250
diff changeset
   480
    specsToPaste do:[:eachSpec|
2362
a6a7ef98fdc3 can resize - allow resizing all;
Claus Gittinger <cg@exept.de>
parents: 2358
diff changeset
   481
        |view newOrigin uiPainterAttributes thisAbsOrigin|
a6a7ef98fdc3 can resize - allow resizing all;
Claus Gittinger <cg@exept.de>
parents: 2358
diff changeset
   482
a6a7ef98fdc3 can resize - allow resizing all;
Claus Gittinger <cg@exept.de>
parents: 2358
diff changeset
   483
        uiPainterAttributes := eachSpec otherAttributeAt:#uiPainterAttributes.
2388
17bbaf777e08 *** empty log message ***
sr
parents: 2387
diff changeset
   484
        eachSpec otherAttributeAt:#uiPainterAttributes put:nil.
1878
6ae0cf83738f Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents: 1872
diff changeset
   485
2395
9f9cf71a311c *** empty log message ***
ca
parents: 2392
diff changeset
   486
        view := self addSpec:eachSpec builder:builder in:containerToPasteInto beforeIndex:beforeIndex.
9f9cf71a311c *** empty log message ***
ca
parents: 2392
diff changeset
   487
        beforeIndex notNil ifTrue:[
9f9cf71a311c *** empty log message ***
ca
parents: 2392
diff changeset
   488
            beforeIndex := beforeIndex + 1
9f9cf71a311c *** empty log message ***
ca
parents: 2392
diff changeset
   489
        ].
3244
6b83ffb461b5 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 3223
diff changeset
   490
        (keepLayout or:[eachSpec keepUILayout]) ifTrue:[
3249
Claus Gittinger <cg@exept.de>
parents: 3244
diff changeset
   491
            eachSpec layout isAssociation ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 3244
diff changeset
   492
                eachSpec layout key == #extent ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 3244
diff changeset
   493
                    view pixelExtent:eachSpec layout value
Claus Gittinger <cg@exept.de>
parents: 3244
diff changeset
   494
                ] ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 3244
diff changeset
   495
                    "/ self halt.
Claus Gittinger <cg@exept.de>
parents: 3244
diff changeset
   496
                    view geometryLayout:eachSpec layout value
Claus Gittinger <cg@exept.de>
parents: 3244
diff changeset
   497
                ].
Claus Gittinger <cg@exept.de>
parents: 3244
diff changeset
   498
            ] ifFalse:[    
Claus Gittinger <cg@exept.de>
parents: 3244
diff changeset
   499
                view geometryLayout:eachSpec layout.
Claus Gittinger <cg@exept.de>
parents: 3244
diff changeset
   500
            ]
3129
9a90a9d52bc6 class: UIPainterView
Claus Gittinger <cg@exept.de>
parents: 3097
diff changeset
   501
        ] ifFalse:[
9a90a9d52bc6 class: UIPainterView
Claus Gittinger <cg@exept.de>
parents: 3097
diff changeset
   502
            (keepPosition and:[ uiPainterAttributes notNil ]) ifTrue:[
9a90a9d52bc6 class: UIPainterView
Claus Gittinger <cg@exept.de>
parents: 3097
diff changeset
   503
                aPointOrNilOrKeep == #keep ifTrue:[
9a90a9d52bc6 class: UIPainterView
Claus Gittinger <cg@exept.de>
parents: 3097
diff changeset
   504
                    newOrigin := uiPainterAttributes at:#origin.
9a90a9d52bc6 class: UIPainterView
Claus Gittinger <cg@exept.de>
parents: 3097
diff changeset
   505
                ] ifFalse:[
9a90a9d52bc6 class: UIPainterView
Claus Gittinger <cg@exept.de>
parents: 3097
diff changeset
   506
                    thisAbsOrigin := uiPainterAttributes at:#absOrigin.
9a90a9d52bc6 class: UIPainterView
Claus Gittinger <cg@exept.de>
parents: 3097
diff changeset
   507
3262
3168fe296011 device access
Claus Gittinger <cg@exept.de>
parents: 3249
diff changeset
   508
                    newOrigin := device 
3129
9a90a9d52bc6 class: UIPainterView
Claus Gittinger <cg@exept.de>
parents: 3097
diff changeset
   509
                                        translatePoint:thisAbsOrigin
9a90a9d52bc6 class: UIPainterView
Claus Gittinger <cg@exept.de>
parents: 3097
diff changeset
   510
                                        fromView:self
9a90a9d52bc6 class: UIPainterView
Claus Gittinger <cg@exept.de>
parents: 3097
diff changeset
   511
                                        toView:containerToPasteInto.
9a90a9d52bc6 class: UIPainterView
Claus Gittinger <cg@exept.de>
parents: 3097
diff changeset
   512
                ].
2386
4471bede7939 bugfix - copy & paste with layout
ca
parents: 2376
diff changeset
   513
            ] ifFalse:[
3129
9a90a9d52bc6 class: UIPainterView
Claus Gittinger <cg@exept.de>
parents: 3097
diff changeset
   514
                pastePoint isNil ifTrue:[ pastePoint := 0@0 ].
3262
3168fe296011 device access
Claus Gittinger <cg@exept.de>
parents: 3249
diff changeset
   515
                newOrigin := device 
3129
9a90a9d52bc6 class: UIPainterView
Claus Gittinger <cg@exept.de>
parents: 3097
diff changeset
   516
                                    translatePoint:pastePoint
2386
4471bede7939 bugfix - copy & paste with layout
ca
parents: 2376
diff changeset
   517
                                    fromView:self
4471bede7939 bugfix - copy & paste with layout
ca
parents: 2376
diff changeset
   518
                                    toView:containerToPasteInto.
4471bede7939 bugfix - copy & paste with layout
ca
parents: 2376
diff changeset
   519
            ].
3129
9a90a9d52bc6 class: UIPainterView
Claus Gittinger <cg@exept.de>
parents: 3097
diff changeset
   520
9a90a9d52bc6 class: UIPainterView
Claus Gittinger <cg@exept.de>
parents: 3097
diff changeset
   521
            (bounds containsPoint:newOrigin) ifFalse:[
9a90a9d52bc6 class: UIPainterView
Claus Gittinger <cg@exept.de>
parents: 3097
diff changeset
   522
                newOrigin := pasteOffset asPoint.
9a90a9d52bc6 class: UIPainterView
Claus Gittinger <cg@exept.de>
parents: 3097
diff changeset
   523
                pasteOffset := pasteOffset + 4.
9a90a9d52bc6 class: UIPainterView
Claus Gittinger <cg@exept.de>
parents: 3097
diff changeset
   524
            ].
9a90a9d52bc6 class: UIPainterView
Claus Gittinger <cg@exept.de>
parents: 3097
diff changeset
   525
            newOrigin notNil ifTrue:[
9a90a9d52bc6 class: UIPainterView
Claus Gittinger <cg@exept.de>
parents: 3097
diff changeset
   526
                self moveObject:view to:newOrigin.
9a90a9d52bc6 class: UIPainterView
Claus Gittinger <cg@exept.de>
parents: 3097
diff changeset
   527
            ].
1878
6ae0cf83738f Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents: 1872
diff changeset
   528
        ].
2395
9f9cf71a311c *** empty log message ***
ca
parents: 2392
diff changeset
   529
        view realized ifFalse:[
9f9cf71a311c *** empty log message ***
ca
parents: 2392
diff changeset
   530
            view realize.
9f9cf71a311c *** empty log message ***
ca
parents: 2392
diff changeset
   531
        ].
1878
6ae0cf83738f Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents: 1872
diff changeset
   532
        newSel add:view.
776
1df0525eeec9 reuse methods provided by the model
ca
parents: 770
diff changeset
   533
    ].
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   534
2537
12e3b32befe4 handle changes
Claus Gittinger <cg@exept.de>
parents: 2526
diff changeset
   535
    self 
12e3b32befe4 handle changes
Claus Gittinger <cg@exept.de>
parents: 2526
diff changeset
   536
        withinTransaction:#paste 
12e3b32befe4 handle changes
Claus Gittinger <cg@exept.de>
parents: 2526
diff changeset
   537
        objects:newSel 
12e3b32befe4 handle changes
Claus Gittinger <cg@exept.de>
parents: 2526
diff changeset
   538
        do:[
12e3b32befe4 handle changes
Claus Gittinger <cg@exept.de>
parents: 2526
diff changeset
   539
            undoHistory 
12e3b32befe4 handle changes
Claus Gittinger <cg@exept.de>
parents: 2526
diff changeset
   540
                addUndoSelector:#undoCreate:
12e3b32befe4 handle changes
Claus Gittinger <cg@exept.de>
parents: 2526
diff changeset
   541
                withArgs:(newSel collect:[:v| (self propertyOfView:v) identifier]).
12e3b32befe4 handle changes
Claus Gittinger <cg@exept.de>
parents: 2526
diff changeset
   542
            self undoHistoryChanged.
12e3b32befe4 handle changes
Claus Gittinger <cg@exept.de>
parents: 2526
diff changeset
   543
        ].
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   544
776
1df0525eeec9 reuse methods provided by the model
ca
parents: 770
diff changeset
   545
    self realizeAllSubViews.
2395
9f9cf71a311c *** empty log message ***
ca
parents: 2392
diff changeset
   546
    "/ newSel do:[:v| v raise].
1744
c59a91953b64 paste with no container selected: search for a good one
Claus Gittinger <cg@exept.de>
parents: 1733
diff changeset
   547
    self elementChangedSize:containerToPasteInto.
134
d5ab85ec27fd undo history; keep view identifier
ca
parents: 131
diff changeset
   548
2818
6d5a0ea87cb7 changed: #pasteSpecifications:into:beforeIndex:keepLayout:keepPosition:at:
Claus Gittinger <cg@exept.de>
parents: 2716
diff changeset
   549
    "/ nil wg if embedded in a browser
6d5a0ea87cb7 changed: #pasteSpecifications:into:beforeIndex:keepLayout:keepPosition:at:
Claus Gittinger <cg@exept.de>
parents: 2716
diff changeset
   550
    self windowGroup notNil ifTrue:[
6d5a0ea87cb7 changed: #pasteSpecifications:into:beforeIndex:keepLayout:keepPosition:at:
Claus Gittinger <cg@exept.de>
parents: 2716
diff changeset
   551
        "/ because the new-created view will destroy the handles, when it redraws itself,
6d5a0ea87cb7 changed: #pasteSpecifications:into:beforeIndex:keepLayout:keepPosition:at:
Claus Gittinger <cg@exept.de>
parents: 2716
diff changeset
   552
        "/ give it a chance to do so, before we return. (bail out after half a second, in case of trouble)
6d5a0ea87cb7 changed: #pasteSpecifications:into:beforeIndex:keepLayout:keepPosition:at:
Claus Gittinger <cg@exept.de>
parents: 2716
diff changeset
   553
        count := 0.
6d5a0ea87cb7 changed: #pasteSpecifications:into:beforeIndex:keepLayout:keepPosition:at:
Claus Gittinger <cg@exept.de>
parents: 2716
diff changeset
   554
        [ (newSel conform:[:v | v shown]) or:[count > 50] ] whileFalse:[
6d5a0ea87cb7 changed: #pasteSpecifications:into:beforeIndex:keepLayout:keepPosition:at:
Claus Gittinger <cg@exept.de>
parents: 2716
diff changeset
   555
            self windowGroup repairDamage.
6d5a0ea87cb7 changed: #pasteSpecifications:into:beforeIndex:keepLayout:keepPosition:at:
Claus Gittinger <cg@exept.de>
parents: 2716
diff changeset
   556
            Delay waitForSeconds:0.01.
6d5a0ea87cb7 changed: #pasteSpecifications:into:beforeIndex:keepLayout:keepPosition:at:
Claus Gittinger <cg@exept.de>
parents: 2716
diff changeset
   557
            count := count+1.
6d5a0ea87cb7 changed: #pasteSpecifications:into:beforeIndex:keepLayout:keepPosition:at:
Claus Gittinger <cg@exept.de>
parents: 2716
diff changeset
   558
        ].
6d5a0ea87cb7 changed: #pasteSpecifications:into:beforeIndex:keepLayout:keepPosition:at:
Claus Gittinger <cg@exept.de>
parents: 2716
diff changeset
   559
        Delay waitForSeconds:0.01.
2560
efad0ef440c7 oops - need repairDamage for shown to be set (under unix; it used to
Michael Beyl <mb@exept.de>
parents: 2537
diff changeset
   560
        self windowGroup repairDamage.
2537
12e3b32befe4 handle changes
Claus Gittinger <cg@exept.de>
parents: 2526
diff changeset
   561
    ].
12e3b32befe4 handle changes
Claus Gittinger <cg@exept.de>
parents: 2526
diff changeset
   562
776
1df0525eeec9 reuse methods provided by the model
ca
parents: 770
diff changeset
   563
    newSel size == 1 ifTrue:[newSel := newSel at:1].
223
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
   564
    ^ newSel
1500
36c0b4b268b8 use new translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents: 1494
diff changeset
   565
2818
6d5a0ea87cb7 changed: #pasteSpecifications:into:beforeIndex:keepLayout:keepPosition:at:
Claus Gittinger <cg@exept.de>
parents: 2716
diff changeset
   566
    "Modified: / 03-11-2010 / 07:20:06 / cg"
89
35c5711729c2 so far so good
ca
parents: 86
diff changeset
   567
!
35c5711729c2 so far so good
ca
parents: 86
diff changeset
   568
3055
db492f86c9b1 class: UIPainterView
Claus Gittinger <cg@exept.de>
parents: 3038
diff changeset
   569
pasteSpecifications:aSpecificationOrList into:aContainerOrNil keepLayout:keepLayout keepPosition:keepPosition at:aPointOrNilOrKeep 
2395
9f9cf71a311c *** empty log message ***
ca
parents: 2392
diff changeset
   570
    "add the specs to the object view; returns list of pasted widgets"
3055
db492f86c9b1 class: UIPainterView
Claus Gittinger <cg@exept.de>
parents: 3038
diff changeset
   571
    
db492f86c9b1 class: UIPainterView
Claus Gittinger <cg@exept.de>
parents: 3038
diff changeset
   572
    ^ self 
db492f86c9b1 class: UIPainterView
Claus Gittinger <cg@exept.de>
parents: 3038
diff changeset
   573
        pasteSpecifications:aSpecificationOrList
db492f86c9b1 class: UIPainterView
Claus Gittinger <cg@exept.de>
parents: 3038
diff changeset
   574
        into:aContainerOrNil
db492f86c9b1 class: UIPainterView
Claus Gittinger <cg@exept.de>
parents: 3038
diff changeset
   575
        beforeIndex:nil
db492f86c9b1 class: UIPainterView
Claus Gittinger <cg@exept.de>
parents: 3038
diff changeset
   576
        keepLayout:keepLayout
db492f86c9b1 class: UIPainterView
Claus Gittinger <cg@exept.de>
parents: 3038
diff changeset
   577
        keepPosition:keepPosition
db492f86c9b1 class: UIPainterView
Claus Gittinger <cg@exept.de>
parents: 3038
diff changeset
   578
        at:aPointOrNilOrKeep
2395
9f9cf71a311c *** empty log message ***
ca
parents: 2392
diff changeset
   579
!
9f9cf71a311c *** empty log message ***
ca
parents: 2392
diff changeset
   580
2387
050c6d4d427d bugfix - replaceSelectionBy: (1)
ca
parents: 2386
diff changeset
   581
pasteSpecifications:aSpecificationOrList keepLayout:keepLayout
050c6d4d427d bugfix - replaceSelectionBy: (1)
ca
parents: 2386
diff changeset
   582
    "add the specs to the object view; returns list of pasted widgets"
050c6d4d427d bugfix - replaceSelectionBy: (1)
ca
parents: 2386
diff changeset
   583
050c6d4d427d bugfix - replaceSelectionBy: (1)
ca
parents: 2386
diff changeset
   584
    ^ self
050c6d4d427d bugfix - replaceSelectionBy: (1)
ca
parents: 2386
diff changeset
   585
        pasteSpecifications:aSpecificationOrList
050c6d4d427d bugfix - replaceSelectionBy: (1)
ca
parents: 2386
diff changeset
   586
        keepLayout:keepLayout
050c6d4d427d bugfix - replaceSelectionBy: (1)
ca
parents: 2386
diff changeset
   587
        keepPosition:true
2627
07d40cde2ac9 changed: #pasteSpecifications:keepLayout:
Claus Gittinger <cg@exept.de>
parents: 2583
diff changeset
   588
        at:#keep "/ nil
2387
050c6d4d427d bugfix - replaceSelectionBy: (1)
ca
parents: 2386
diff changeset
   589
050c6d4d427d bugfix - replaceSelectionBy: (1)
ca
parents: 2386
diff changeset
   590
    "Modified: 11.8.1997 / 01:00:35 / cg"
050c6d4d427d bugfix - replaceSelectionBy: (1)
ca
parents: 2386
diff changeset
   591
!
050c6d4d427d bugfix - replaceSelectionBy: (1)
ca
parents: 2386
diff changeset
   592
050c6d4d427d bugfix - replaceSelectionBy: (1)
ca
parents: 2386
diff changeset
   593
pasteSpecifications:aSpecificationOrList keepLayout:keepLayout at:aPointOrNil
050c6d4d427d bugfix - replaceSelectionBy: (1)
ca
parents: 2386
diff changeset
   594
    "add the specs to the object view; returns list of pasted widgets"
050c6d4d427d bugfix - replaceSelectionBy: (1)
ca
parents: 2386
diff changeset
   595
050c6d4d427d bugfix - replaceSelectionBy: (1)
ca
parents: 2386
diff changeset
   596
    ^ self
050c6d4d427d bugfix - replaceSelectionBy: (1)
ca
parents: 2386
diff changeset
   597
        pasteSpecifications:aSpecificationOrList
050c6d4d427d bugfix - replaceSelectionBy: (1)
ca
parents: 2386
diff changeset
   598
        keepLayout:keepLayout
050c6d4d427d bugfix - replaceSelectionBy: (1)
ca
parents: 2386
diff changeset
   599
        keepPosition:true
050c6d4d427d bugfix - replaceSelectionBy: (1)
ca
parents: 2386
diff changeset
   600
        at:aPointOrNil
050c6d4d427d bugfix - replaceSelectionBy: (1)
ca
parents: 2386
diff changeset
   601
!
050c6d4d427d bugfix - replaceSelectionBy: (1)
ca
parents: 2386
diff changeset
   602
050c6d4d427d bugfix - replaceSelectionBy: (1)
ca
parents: 2386
diff changeset
   603
pasteSpecifications:aSpecificationOrList keepLayout:keepLayout keepPosition:keepPosition at:aPointOrNilOrKeep
050c6d4d427d bugfix - replaceSelectionBy: (1)
ca
parents: 2386
diff changeset
   604
    "add the specs to the object view; returns list of pasted widgets"
050c6d4d427d bugfix - replaceSelectionBy: (1)
ca
parents: 2386
diff changeset
   605
050c6d4d427d bugfix - replaceSelectionBy: (1)
ca
parents: 2386
diff changeset
   606
    ^ self pasteSpecifications:aSpecificationOrList
050c6d4d427d bugfix - replaceSelectionBy: (1)
ca
parents: 2386
diff changeset
   607
        into:nil
2395
9f9cf71a311c *** empty log message ***
ca
parents: 2392
diff changeset
   608
        beforeIndex:nil
2387
050c6d4d427d bugfix - replaceSelectionBy: (1)
ca
parents: 2386
diff changeset
   609
        keepLayout:keepLayout
050c6d4d427d bugfix - replaceSelectionBy: (1)
ca
parents: 2386
diff changeset
   610
        keepPosition:keepPosition
050c6d4d427d bugfix - replaceSelectionBy: (1)
ca
parents: 2386
diff changeset
   611
        at:aPointOrNilOrKeep
050c6d4d427d bugfix - replaceSelectionBy: (1)
ca
parents: 2386
diff changeset
   612
!
050c6d4d427d bugfix - replaceSelectionBy: (1)
ca
parents: 2386
diff changeset
   613
2315
c301d0caf97b changed #pasteWithLayout
Stefan Vogel <sv@exept.de>
parents: 2312
diff changeset
   614
pasteWithLayout
2369
Claus Gittinger <cg@exept.de>
parents: 2367
diff changeset
   615
    "add the objects in the paste-buffer to the object view - keep the old layout"
2315
c301d0caf97b changed #pasteWithLayout
Stefan Vogel <sv@exept.de>
parents: 2312
diff changeset
   616
c301d0caf97b changed #pasteWithLayout
Stefan Vogel <sv@exept.de>
parents: 2312
diff changeset
   617
    |sel|
c301d0caf97b changed #pasteWithLayout
Stefan Vogel <sv@exept.de>
parents: 2312
diff changeset
   618
2366
Claus Gittinger <cg@exept.de>
parents: 2362
diff changeset
   619
    sel := self 
Claus Gittinger <cg@exept.de>
parents: 2362
diff changeset
   620
            pasteSpecifications:(self getClipboardObject)
Claus Gittinger <cg@exept.de>
parents: 2362
diff changeset
   621
            keepLayout:true
Claus Gittinger <cg@exept.de>
parents: 2362
diff changeset
   622
            keepPosition:true
Claus Gittinger <cg@exept.de>
parents: 2362
diff changeset
   623
            at:#keep.
2315
c301d0caf97b changed #pasteWithLayout
Stefan Vogel <sv@exept.de>
parents: 2312
diff changeset
   624
    self changeSelectionAfterPasteOf:sel.
c301d0caf97b changed #pasteWithLayout
Stefan Vogel <sv@exept.de>
parents: 2312
diff changeset
   625
!
c301d0caf97b changed #pasteWithLayout
Stefan Vogel <sv@exept.de>
parents: 2312
diff changeset
   626
2311
67811bdeb0f5 Support sorting of items in tree
Stefan Vogel <sv@exept.de>
parents: 2295
diff changeset
   627
pasteWithoutLayout
2369
Claus Gittinger <cg@exept.de>
parents: 2367
diff changeset
   628
    "add the objects in the paste-buffer to the object view - do not keep the old layout"
1959
fd6bf76e712a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1954
diff changeset
   629
223
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
   630
    |sel|
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
   631
2367
6684f50b22cd changed #pasteWithoutLayout
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
   632
    sel := self 
6684f50b22cd changed #pasteWithoutLayout
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
   633
            pasteSpecifications:(self getClipboardObject)
6684f50b22cd changed #pasteWithoutLayout
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
   634
            keepLayout:false
6684f50b22cd changed #pasteWithoutLayout
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
   635
            keepPosition:true
6684f50b22cd changed #pasteWithoutLayout
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
   636
            at:#keep.
2221
8ac60d4545ad selection after paste
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   637
    self changeSelectionAfterPasteOf:sel.
2257
badd429a2a2a code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents: 2250
diff changeset
   638
!
badd429a2a2a code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents: 2250
diff changeset
   639
badd429a2a2a code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents: 2250
diff changeset
   640
replaceSelectionBy:aNewSpec
badd429a2a2a code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents: 2250
diff changeset
   641
    "replace the selected widget by another one."
badd429a2a2a code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents: 2250
diff changeset
   642
3360
b7f7e48455dd #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 3348
diff changeset
   643
    |oldSelection treeModel newView oldView container specs index|
2387
050c6d4d427d bugfix - replaceSelectionBy: (1)
ca
parents: 2386
diff changeset
   644
050c6d4d427d bugfix - replaceSelectionBy: (1)
ca
parents: 2386
diff changeset
   645
    (self singleSelection notNil and:[treeView askForSelectionChangeAllowed]) ifFalse:[
050c6d4d427d bugfix - replaceSelectionBy: (1)
ca
parents: 2386
diff changeset
   646
        ^ self
050c6d4d427d bugfix - replaceSelectionBy: (1)
ca
parents: 2386
diff changeset
   647
    ].
3360
b7f7e48455dd #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 3348
diff changeset
   648
    
2387
050c6d4d427d bugfix - replaceSelectionBy: (1)
ca
parents: 2386
diff changeset
   649
    treeModel    := treeView model.
2257
badd429a2a2a code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents: 2250
diff changeset
   650
    oldSelection := treeModel selectedNodes at:1 ifAbsent: nil.
2387
050c6d4d427d bugfix - replaceSelectionBy: (1)
ca
parents: 2386
diff changeset
   651
    oldSelection isNil ifTrue:[^ self].
050c6d4d427d bugfix - replaceSelectionBy: (1)
ca
parents: 2386
diff changeset
   652
2395
9f9cf71a311c *** empty log message ***
ca
parents: 2392
diff changeset
   653
    oldView := oldSelection contents view.
9f9cf71a311c *** empty log message ***
ca
parents: 2392
diff changeset
   654
9f9cf71a311c *** empty log message ***
ca
parents: 2392
diff changeset
   655
    (oldSelection hasChildren and:[aNewSpec class supportsSubComponents]) ifTrue:[
3360
b7f7e48455dd #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 3348
diff changeset
   656
        specs := 
b7f7e48455dd #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 3348
diff changeset
   657
            oldSelection children collect:[:each|
b7f7e48455dd #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 3348
diff changeset
   658
                self fullSpecWithAbsolutePositionFor:(each contents view)
b7f7e48455dd #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 3348
diff changeset
   659
            ].
2395
9f9cf71a311c *** empty log message ***
ca
parents: 2392
diff changeset
   660
    ].
2387
050c6d4d427d bugfix - replaceSelectionBy: (1)
ca
parents: 2386
diff changeset
   661
050c6d4d427d bugfix - replaceSelectionBy: (1)
ca
parents: 2386
diff changeset
   662
    aNewSpec
050c6d4d427d bugfix - replaceSelectionBy: (1)
ca
parents: 2386
diff changeset
   663
        otherAttributeAt:#uiPainterAttributes 
050c6d4d427d bugfix - replaceSelectionBy: (1)
ca
parents: 2386
diff changeset
   664
        put:(Dictionary new
050c6d4d427d bugfix - replaceSelectionBy: (1)
ca
parents: 2386
diff changeset
   665
                at:#origin put:oldView origin;
050c6d4d427d bugfix - replaceSelectionBy: (1)
ca
parents: 2386
diff changeset
   666
                at:#extent put:oldView extent;
050c6d4d427d bugfix - replaceSelectionBy: (1)
ca
parents: 2386
diff changeset
   667
                at:#absOrigin put:(oldView originRelativeTo:self);
050c6d4d427d bugfix - replaceSelectionBy: (1)
ca
parents: 2386
diff changeset
   668
                yourself).
050c6d4d427d bugfix - replaceSelectionBy: (1)
ca
parents: 2386
diff changeset
   669
3360
b7f7e48455dd #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 3348
diff changeset
   670
    index := oldSelection parent children identityIndexOf:oldSelection.
2387
050c6d4d427d bugfix - replaceSelectionBy: (1)
ca
parents: 2386
diff changeset
   671
    container := self singleSelection container.
3360
b7f7e48455dd #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 3348
diff changeset
   672
    
2387
050c6d4d427d bugfix - replaceSelectionBy: (1)
ca
parents: 2386
diff changeset
   673
    self withinTransaction:#replaceBy objects:(Array with:oldView) do:[
2395
9f9cf71a311c *** empty log message ***
ca
parents: 2392
diff changeset
   674
        self withSelectionHiddenDo:[
9f9cf71a311c *** empty log message ***
ca
parents: 2392
diff changeset
   675
            newView := self 
9f9cf71a311c *** empty log message ***
ca
parents: 2392
diff changeset
   676
                    pasteSpecifications:(Array with:aNewSpec)
9f9cf71a311c *** empty log message ***
ca
parents: 2392
diff changeset
   677
                    into:container
3360
b7f7e48455dd #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 3348
diff changeset
   678
                    beforeIndex:index
2395
9f9cf71a311c *** empty log message ***
ca
parents: 2392
diff changeset
   679
                    keepLayout:true
9f9cf71a311c *** empty log message ***
ca
parents: 2392
diff changeset
   680
                    keepPosition:true
9f9cf71a311c *** empty log message ***
ca
parents: 2392
diff changeset
   681
                    at:#keep.
9f9cf71a311c *** empty log message ***
ca
parents: 2392
diff changeset
   682
9f9cf71a311c *** empty log message ***
ca
parents: 2392
diff changeset
   683
            self deleteSelectionBuffered:false.
9f9cf71a311c *** empty log message ***
ca
parents: 2392
diff changeset
   684
9f9cf71a311c *** empty log message ***
ca
parents: 2392
diff changeset
   685
            specs size > 0 ifTrue:[
9f9cf71a311c *** empty log message ***
ca
parents: 2392
diff changeset
   686
                self pasteSpecifications:specs 
9f9cf71a311c *** empty log message ***
ca
parents: 2392
diff changeset
   687
                            into:newView
9f9cf71a311c *** empty log message ***
ca
parents: 2392
diff changeset
   688
                            keepLayout:(aNewSpec class canResizeSubComponents)
9f9cf71a311c *** empty log message ***
ca
parents: 2392
diff changeset
   689
                            keepPosition:(aNewSpec class isLayoutContainer not)
3360
b7f7e48455dd #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 3348
diff changeset
   690
                            at:index.
2395
9f9cf71a311c *** empty log message ***
ca
parents: 2392
diff changeset
   691
            ].
9f9cf71a311c *** empty log message ***
ca
parents: 2392
diff changeset
   692
            self select:newView.
9f9cf71a311c *** empty log message ***
ca
parents: 2392
diff changeset
   693
       ].
2387
050c6d4d427d bugfix - replaceSelectionBy: (1)
ca
parents: 2386
diff changeset
   694
    ].
2395
9f9cf71a311c *** empty log message ***
ca
parents: 2392
diff changeset
   695
    ^ newView.
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   696
! !
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   697
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   698
!UIPainterView methodsFor:'drag & drop'!
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   699
2116
90fc11105f36 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 2112
diff changeset
   700
canDrop:aDropContext
90fc11105f36 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 2112
diff changeset
   701
    ^ self canDropObjects:aDropContext dropObjects
90fc11105f36 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 2112
diff changeset
   702
90fc11105f36 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 2112
diff changeset
   703
    "Created: / 13-10-2006 / 17:46:11 / cg"
90fc11105f36 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 2112
diff changeset
   704
!
90fc11105f36 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 2112
diff changeset
   705
90fc11105f36 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 2112
diff changeset
   706
canDropObjects:aCollectionOfDropObjects
1914
229b3e455c98 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1894
diff changeset
   707
    "returns true if something can be dropped"
229b3e455c98 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1894
diff changeset
   708
2362
a6a7ef98fdc3 can resize - allow resizing all;
Claus Gittinger <cg@exept.de>
parents: 2358
diff changeset
   709
    ^ (true "aCollectionOfDropObjects size == 1" 
2112
74dfb69c88d4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2039
diff changeset
   710
    and:[ self enabled 
2362
a6a7ef98fdc3 can resize - allow resizing all;
Claus Gittinger <cg@exept.de>
parents: 2358
diff changeset
   711
    and:[ true "self numberOfSelections <= 1"
a6a7ef98fdc3 can resize - allow resizing all;
Claus Gittinger <cg@exept.de>
parents: 2358
diff changeset
   712
    and:[ aCollectionOfDropObjects conform:[:each| each theObject isKindOf:UISpecification]
a6a7ef98fdc3 can resize - allow resizing all;
Claus Gittinger <cg@exept.de>
parents: 2358
diff changeset
   713
              ]]])
2112
74dfb69c88d4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2039
diff changeset
   714
2116
90fc11105f36 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 2112
diff changeset
   715
    "Created: / 13-10-2006 / 16:09:24 / cg"
223
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
   716
!
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
   717
285
d80b3c6a4373 don't use superView instead parent properties derived
ca
parents: 281
diff changeset
   718
canPaste
1914
229b3e455c98 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1894
diff changeset
   719
    "returns true if there is something which can be pasted in the clipboard"
229b3e455c98 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1894
diff changeset
   720
1872
ab5cc43b193a get selection interface changed
ca
parents: 1870
diff changeset
   721
    ^ self canPaste:(self getClipboardObject)
285
d80b3c6a4373 don't use superView instead parent properties derived
ca
parents: 281
diff changeset
   722
!
d80b3c6a4373 don't use superView instead parent properties derived
ca
parents: 281
diff changeset
   723
223
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
   724
canPaste:something
1914
229b3e455c98 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1894
diff changeset
   725
    "returns true if something could be pasted"
229b3e455c98 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1894
diff changeset
   726
2221
8ac60d4545ad selection after paste
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   727
    ^ self canPaste:something into:(self singleSelection)
8ac60d4545ad selection after paste
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   728
!
8ac60d4545ad selection after paste
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   729
8ac60d4545ad selection after paste
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   730
canPaste:something into:containerToPasteInto
8ac60d4545ad selection after paste
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   731
    "returns true if something could be pasted"
8ac60d4545ad selection after paste
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   732
2276
485bda17023f more changes to allow for non-class/selector (i.e. spec-only) use
Claus Gittinger <cg@exept.de>
parents: 2265
diff changeset
   733
    (self enabled) ifFalse:[
1914
229b3e455c98 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1894
diff changeset
   734
        ^ false
223
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
   735
    ].
2276
485bda17023f more changes to allow for non-class/selector (i.e. spec-only) use
Claus Gittinger <cg@exept.de>
parents: 2265
diff changeset
   736
    something isCollection ifTrue:[
485bda17023f more changes to allow for non-class/selector (i.e. spec-only) use
Claus Gittinger <cg@exept.de>
parents: 2265
diff changeset
   737
        something isEmpty ifTrue:[ ^ false].
485bda17023f more changes to allow for non-class/selector (i.e. spec-only) use
Claus Gittinger <cg@exept.de>
parents: 2265
diff changeset
   738
        ^ something conform:[:el | (self canPaste:el into:containerToPasteInto)]
485bda17023f more changes to allow for non-class/selector (i.e. spec-only) use
Claus Gittinger <cg@exept.de>
parents: 2265
diff changeset
   739
    ].
485bda17023f more changes to allow for non-class/selector (i.e. spec-only) use
Claus Gittinger <cg@exept.de>
parents: 2265
diff changeset
   740
485bda17023f more changes to allow for non-class/selector (i.e. spec-only) use
Claus Gittinger <cg@exept.de>
parents: 2265
diff changeset
   741
    (something isKindOf:UISpecification) ifFalse:[
1914
229b3e455c98 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1894
diff changeset
   742
        ^ false
223
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
   743
    ].
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
   744
2276
485bda17023f more changes to allow for non-class/selector (i.e. spec-only) use
Claus Gittinger <cg@exept.de>
parents: 2265
diff changeset
   745
    ^ self canPasteInto:containerToPasteInto
223
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
   746
!
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
   747
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
   748
canPasteInto:aView
1914
229b3e455c98 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1894
diff changeset
   749
    "return true, if I can paste into a view"
229b3e455c98 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1894
diff changeset
   750
285
d80b3c6a4373 don't use superView instead parent properties derived
ca
parents: 281
diff changeset
   751
    |prop|
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   752
1870
771fcc38ecb8 set selection interface changed
ca
parents: 1869
diff changeset
   753
    aView isNil ifTrue:[ ^ false ].
2265
f6fbbcdd3764 still debugging replaceBy:
Claus Gittinger <cg@exept.de>
parents: 2257
diff changeset
   754
    aView == self ifTrue:[ ^ true ].
1870
771fcc38ecb8 set selection interface changed
ca
parents: 1869
diff changeset
   755
771fcc38ecb8 set selection interface changed
ca
parents: 1869
diff changeset
   756
    (prop := self propertyOfView:aView) notNil ifTrue:[
771fcc38ecb8 set selection interface changed
ca
parents: 1869
diff changeset
   757
        ^ prop spec class supportsSubComponents
89
35c5711729c2 so far so good
ca
parents: 86
diff changeset
   758
    ].
1870
771fcc38ecb8 set selection interface changed
ca
parents: 1869
diff changeset
   759
    ^ aView specClass supportsSubComponents.
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   760
!
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   761
2116
90fc11105f36 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 2112
diff changeset
   762
dropObjects:aCollectionOfDropObjects at:aPoint
2537
12e3b32befe4 handle changes
Claus Gittinger <cg@exept.de>
parents: 2526
diff changeset
   763
    |spec newSel oldSel dragOffset dropPoint widg|
12e3b32befe4 handle changes
Claus Gittinger <cg@exept.de>
parents: 2526
diff changeset
   764
288
675327dd4d7d change drop mechanism:
ca
parents: 285
diff changeset
   765
    self selection notNil ifTrue:[
1953
3b5022bccca4 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 1914
diff changeset
   766
        oldSel := self singleSelection.
3b5022bccca4 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 1914
diff changeset
   767
3b5022bccca4 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 1914
diff changeset
   768
        "/ search selections hierarchy for a widget into which we can paste
3b5022bccca4 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 1914
diff changeset
   769
        widg := oldSel.
3b5022bccca4 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 1914
diff changeset
   770
        [widg isNil or:[self canPasteInto:widg]] whileFalse:[
3b5022bccca4 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 1914
diff changeset
   771
            widg notNil ifTrue:[
3b5022bccca4 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 1914
diff changeset
   772
                widg := widg container
3b5022bccca4 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 1914
diff changeset
   773
            ].
3b5022bccca4 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 1914
diff changeset
   774
        ].
3b5022bccca4 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 1914
diff changeset
   775
3b5022bccca4 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 1914
diff changeset
   776
        oldSel := nil.
3b5022bccca4 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 1914
diff changeset
   777
        self setSelection:widg withRedraw:true.
231
75de472d579f check whether selection is a view or a collection
ca
parents: 223
diff changeset
   778
    ].
1953
3b5022bccca4 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 1914
diff changeset
   779
    spec := (aCollectionOfDropObjects at:1) theObject.
2537
12e3b32befe4 handle changes
Claus Gittinger <cg@exept.de>
parents: 2526
diff changeset
   780
12e3b32befe4 handle changes
Claus Gittinger <cg@exept.de>
parents: 2526
diff changeset
   781
    dragOffset := DragAndDropManager dragOffsetQuerySignal query.
12e3b32befe4 handle changes
Claus Gittinger <cg@exept.de>
parents: 2526
diff changeset
   782
    aPoint isNil ifTrue:[
12e3b32befe4 handle changes
Claus Gittinger <cg@exept.de>
parents: 2526
diff changeset
   783
        dropPoint := #keep.
12e3b32befe4 handle changes
Claus Gittinger <cg@exept.de>
parents: 2526
diff changeset
   784
    ] ifFalse:[
12e3b32befe4 handle changes
Claus Gittinger <cg@exept.de>
parents: 2526
diff changeset
   785
        dropPoint := aPoint - dragOffset.
1833
6ad211a201cf *** empty log message ***
werner
parents: 1832
diff changeset
   786
    ].
2537
12e3b32befe4 handle changes
Claus Gittinger <cg@exept.de>
parents: 2526
diff changeset
   787
    newSel := self pasteSpecifications:spec keepLayout:false keepPosition:false at:dropPoint.
12e3b32befe4 handle changes
Claus Gittinger <cg@exept.de>
parents: 2526
diff changeset
   788
12e3b32befe4 handle changes
Claus Gittinger <cg@exept.de>
parents: 2526
diff changeset
   789
    self select:(oldSel ? newSel).
1060
0332a41de5c5 Use #query instead of #raise when invoking QuerySignals
Stefan Vogel <sv@exept.de>
parents: 1058
diff changeset
   790
2116
90fc11105f36 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 2112
diff changeset
   791
    "Modified: / 18-03-1999 / 18:29:43 / stefan"
90fc11105f36 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 2112
diff changeset
   792
    "Created: / 13-10-2006 / 16:09:27 / cg"
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   793
! !
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   794
2244
580cac31c444 changed #initialize
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
   795
!UIPainterView methodsFor:'drawing'!
580cac31c444 changed #initialize
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
   796
580cac31c444 changed #initialize
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
   797
clearRectangle:visRect
580cac31c444 changed #initialize
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
   798
    super clearRectangle:visRect.
580cac31c444 changed #initialize
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
   799
    sketchPainter notNil ifTrue:[
580cac31c444 changed #initialize
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
   800
        sketchPainter redrawInTargetView
580cac31c444 changed #initialize
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
   801
    ].
580cac31c444 changed #initialize
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
   802
580cac31c444 changed #initialize
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
   803
    "Created: / 16-01-2008 / 17:52:27 / cg"
580cac31c444 changed #initialize
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
   804
!
580cac31c444 changed #initialize
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
   805
580cac31c444 changed #initialize
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
   806
clearView
580cac31c444 changed #initialize
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
   807
    super clearView.
580cac31c444 changed #initialize
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
   808
    sketchPainter notNil ifTrue:[
580cac31c444 changed #initialize
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
   809
        sketchPainter redrawInTargetView
580cac31c444 changed #initialize
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
   810
    ].
580cac31c444 changed #initialize
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
   811
580cac31c444 changed #initialize
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
   812
    "Created: / 16-01-2008 / 17:46:08 / cg"
580cac31c444 changed #initialize
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
   813
!
580cac31c444 changed #initialize
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
   814
2248
720b0784c6f2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2244
diff changeset
   815
useSketchFile:aFilename 
2443
a181aa6d60b4 comment
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   816
    "a little neat goody: allow for a tablet-sketch file (WALTROP digital notepad)
a181aa6d60b4 comment
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   817
     to be used as a background of the UIPainter window. This allows for sketches to
a181aa6d60b4 comment
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   818
     be drawn, shown in the UIPainter, and then used as a placement hint (manual placement)
a181aa6d60b4 comment
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   819
     for the user. Not a high-tech solution, but helped a lot, when we protoyped GUIs."
a181aa6d60b4 comment
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   820
2248
720b0784c6f2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2244
diff changeset
   821
    |mime sketchPainterClass|
720b0784c6f2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2244
diff changeset
   822
720b0784c6f2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2244
diff changeset
   823
    mime := aFilename asFilename mimeTypeFromName.
720b0784c6f2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2244
diff changeset
   824
    mime isNil ifTrue:[
720b0784c6f2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2244
diff changeset
   825
        mime := aFilename asFilename mimeTypeOfContents.
720b0784c6f2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2244
diff changeset
   826
    ].
720b0784c6f2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2244
diff changeset
   827
720b0784c6f2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2244
diff changeset
   828
    mime notNil ifTrue:[
2278
8ff3bd6f0820 Allow to load background from image file #useSketchFile:
Stefan Vogel <sv@exept.de>
parents: 2276
diff changeset
   829
        (mime startsWith:'image') ifTrue:[
8ff3bd6f0820 Allow to load background from image file #useSketchFile:
Stefan Vogel <sv@exept.de>
parents: 2276
diff changeset
   830
            self viewBackground:(ImageReader fromFile:aFilename).
8ff3bd6f0820 Allow to load background from image file #useSketchFile:
Stefan Vogel <sv@exept.de>
parents: 2276
diff changeset
   831
            ^ self.
8ff3bd6f0820 Allow to load background from image file #useSketchFile:
Stefan Vogel <sv@exept.de>
parents: 2276
diff changeset
   832
        ].
2444
3e1e97529487 comment
Claus Gittinger <cg@exept.de>
parents: 2443
diff changeset
   833
        mime = 'application/x-waltop-digital-notepad' ifTrue:[
3e1e97529487 comment
Claus Gittinger <cg@exept.de>
parents: 2443
diff changeset
   834
            sketchPainterClass := TOPFileDrawer.
3e1e97529487 comment
Claus Gittinger <cg@exept.de>
parents: 2443
diff changeset
   835
        ].
2248
720b0784c6f2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2244
diff changeset
   836
    ].
720b0784c6f2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2244
diff changeset
   837
    sketchPainterClass isNil ifTrue:[
2444
3e1e97529487 comment
Claus Gittinger <cg@exept.de>
parents: 2443
diff changeset
   838
        self error:'Unsupported sketch file format'
2248
720b0784c6f2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2244
diff changeset
   839
    ].
720b0784c6f2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2244
diff changeset
   840
720b0784c6f2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2244
diff changeset
   841
    sketchPainter := sketchPainterClass new.
2244
580cac31c444 changed #initialize
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
   842
    sketchPainter targetView:self.
580cac31c444 changed #initialize
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
   843
    sketchPainter readFile:aFilename.
580cac31c444 changed #initialize
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
   844
    sketchPainter ajustSketch.
580cac31c444 changed #initialize
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
   845
    self invalidate.
580cac31c444 changed #initialize
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
   846
580cac31c444 changed #initialize
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
   847
    "Created: / 16-01-2008 / 17:46:26 / cg"
580cac31c444 changed #initialize
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
   848
! !
580cac31c444 changed #initialize
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
   849
361
6624bb5d9a1a configuration of grid parameters
ca
parents: 352
diff changeset
   850
!UIPainterView methodsFor:'event handling'!
6624bb5d9a1a configuration of grid parameters
ca
parents: 352
diff changeset
   851
6624bb5d9a1a configuration of grid parameters
ca
parents: 352
diff changeset
   852
keyPress:key x:x y:y view:aView
376
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
   853
    "a delegated keyEvent from aView"
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
   854
361
6624bb5d9a1a configuration of grid parameters
ca
parents: 352
diff changeset
   855
    self keyPress:key x:x y:y
6624bb5d9a1a configuration of grid parameters
ca
parents: 352
diff changeset
   856
376
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
   857
    "Modified: / 31.10.1997 / 20:27:22 / cg"
361
6624bb5d9a1a configuration of grid parameters
ca
parents: 352
diff changeset
   858
!
6624bb5d9a1a configuration of grid parameters
ca
parents: 352
diff changeset
   859
6624bb5d9a1a configuration of grid parameters
ca
parents: 352
diff changeset
   860
keyRelease:key x:x y:y view:aView
376
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
   861
    "a delegated keyEvent from aView"
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
   862
361
6624bb5d9a1a configuration of grid parameters
ca
parents: 352
diff changeset
   863
    self keyRelease:key x:x y:y
6624bb5d9a1a configuration of grid parameters
ca
parents: 352
diff changeset
   864
376
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
   865
    "Modified: / 31.10.1997 / 20:27:32 / cg"
754
04e802a6a920 color master selection in red + grid background colored
tz
parents: 744
diff changeset
   866
!
04e802a6a920 color master selection in red + grid background colored
tz
parents: 744
diff changeset
   867
04e802a6a920 color master selection in red + grid background colored
tz
parents: 744
diff changeset
   868
sizeChanged:how
04e802a6a920 color master selection in red + grid background colored
tz
parents: 744
diff changeset
   869
1834
2c640b5f7fa9 *** empty log message ***
werner
parents: 1833
diff changeset
   870
    super sizeChanged:how.
754
04e802a6a920 color master selection in red + grid background colored
tz
parents: 744
diff changeset
   871
04e802a6a920 color master selection in red + grid background colored
tz
parents: 744
diff changeset
   872
    self layoutChanged
361
6624bb5d9a1a configuration of grid parameters
ca
parents: 352
diff changeset
   873
! !
6624bb5d9a1a configuration of grid parameters
ca
parents: 352
diff changeset
   874
78
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
   875
!UIPainterView methodsFor:'generating output'!
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
   876
352
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   877
aspectMethods
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   878
    "extract a list of aspect methods - for browsing"
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   879
1683
f95658463570 added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   880
    |cls methods|
352
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   881
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   882
    className isNil ifTrue:[
1834
2c640b5f7fa9 *** empty log message ***
werner
parents: 1833
diff changeset
   883
	self warn:'No class defined !!'.
2c640b5f7fa9 *** empty log message ***
werner
parents: 1833
diff changeset
   884
	^ #()
352
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   885
    ].
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   886
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   887
    cls := self resolveName:className.
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   888
    methods := IdentitySet new.
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   889
1683
f95658463570 added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   890
    self aspectSelectorsAndTypesDo:
1834
2c640b5f7fa9 *** empty log message ***
werner
parents: 1833
diff changeset
   891
	[:selector :typeSymbol |
2c640b5f7fa9 *** empty log message ***
werner
parents: 1833
diff changeset
   892
	    |skip|
2c640b5f7fa9 *** empty log message ***
werner
parents: 1833
diff changeset
   893
2c640b5f7fa9 *** empty log message ***
werner
parents: 1833
diff changeset
   894
	    (cls includesSelector:selector) ifTrue:[
2c640b5f7fa9 *** empty log message ***
werner
parents: 1833
diff changeset
   895
2c640b5f7fa9 *** empty log message ***
werner
parents: 1833
diff changeset
   896
		skip := false.
2c640b5f7fa9 *** empty log message ***
werner
parents: 1833
diff changeset
   897
		(typeSymbol == #modelAspect) ifTrue:[
2c640b5f7fa9 *** empty log message ***
werner
parents: 1833
diff changeset
   898
		    (cls isSubclassOf:SimpleDialog) ifTrue:[
2c640b5f7fa9 *** empty log message ***
werner
parents: 1833
diff changeset
   899
			skip := SimpleDialog includesSelector:(selector asSymbol)
2c640b5f7fa9 *** empty log message ***
werner
parents: 1833
diff changeset
   900
		    ].
2c640b5f7fa9 *** empty log message ***
werner
parents: 1833
diff changeset
   901
		].
2c640b5f7fa9 *** empty log message ***
werner
parents: 1833
diff changeset
   902
		skip ifFalse:[
2c640b5f7fa9 *** empty log message ***
werner
parents: 1833
diff changeset
   903
		    methods add:(cls compiledMethodAt:selector)
2c640b5f7fa9 *** empty log message ***
werner
parents: 1833
diff changeset
   904
		].
2c640b5f7fa9 *** empty log message ***
werner
parents: 1833
diff changeset
   905
	    ]
2c640b5f7fa9 *** empty log message ***
werner
parents: 1833
diff changeset
   906
	].
1683
f95658463570 added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   907
f95658463570 added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   908
    ^ methods
f95658463570 added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   909
f95658463570 added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   910
    "Created: / 25.10.1997 / 18:58:25 / cg"
f95658463570 added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   911
    "Modified: / 26.10.1997 / 15:06:18 / cg"
f95658463570 added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   912
!
f95658463570 added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   913
f95658463570 added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   914
aspectSelectorsAndTypesDo:aTwoArgBlock
f95658463570 added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   915
    "evaluate aBlock for every aspect methods selector; 2nd arg describes the aspects type"
f95658463570 added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   916
1726
7117789f3020 Remove unused vars
Stefan Vogel <sv@exept.de>
parents: 1714
diff changeset
   917
    |cls selector protoSpec|
1683
f95658463570 added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   918
f95658463570 added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   919
    className isNil ifTrue:[
2195
bb6de5f8fd03 Take care of true or false as pseudo-aspect-selectors
Stefan Vogel <sv@exept.de>
parents: 2191
diff changeset
   920
        self warn:'No class defined !!'.
bb6de5f8fd03 Take care of true or false as pseudo-aspect-selectors
Stefan Vogel <sv@exept.de>
parents: 2191
diff changeset
   921
        ^ self
1683
f95658463570 added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   922
    ].
f95658463570 added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   923
f95658463570 added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   924
    cls := self resolveName:className.
f95658463570 added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   925
352
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   926
    treeView propertiesDo:[:aProp|
2195
bb6de5f8fd03 Take care of true or false as pseudo-aspect-selectors
Stefan Vogel <sv@exept.de>
parents: 2191
diff changeset
   927
        |selector|
bb6de5f8fd03 Take care of true or false as pseudo-aspect-selectors
Stefan Vogel <sv@exept.de>
parents: 2191
diff changeset
   928
bb6de5f8fd03 Take care of true or false as pseudo-aspect-selectors
Stefan Vogel <sv@exept.de>
parents: 2191
diff changeset
   929
        (selector := aProp model) notNil ifTrue:[
bb6de5f8fd03 Take care of true or false as pseudo-aspect-selectors
Stefan Vogel <sv@exept.de>
parents: 2191
diff changeset
   930
            selector isArray ifFalse:[
bb6de5f8fd03 Take care of true or false as pseudo-aspect-selectors
Stefan Vogel <sv@exept.de>
parents: 2191
diff changeset
   931
                aTwoArgBlock value:(selector asSymbol) value:#modelAspect
bb6de5f8fd03 Take care of true or false as pseudo-aspect-selectors
Stefan Vogel <sv@exept.de>
parents: 2191
diff changeset
   932
            ].
bb6de5f8fd03 Take care of true or false as pseudo-aspect-selectors
Stefan Vogel <sv@exept.de>
parents: 2191
diff changeset
   933
        ].
bb6de5f8fd03 Take care of true or false as pseudo-aspect-selectors
Stefan Vogel <sv@exept.de>
parents: 2191
diff changeset
   934
bb6de5f8fd03 Take care of true or false as pseudo-aspect-selectors
Stefan Vogel <sv@exept.de>
parents: 2191
diff changeset
   935
        (selector := aProp menu) notNil ifTrue:[
bb6de5f8fd03 Take care of true or false as pseudo-aspect-selectors
Stefan Vogel <sv@exept.de>
parents: 2191
diff changeset
   936
            selector isArray ifFalse:[
bb6de5f8fd03 Take care of true or false as pseudo-aspect-selectors
Stefan Vogel <sv@exept.de>
parents: 2191
diff changeset
   937
                aTwoArgBlock value:(selector asSymbol) value:#menu
bb6de5f8fd03 Take care of true or false as pseudo-aspect-selectors
Stefan Vogel <sv@exept.de>
parents: 2191
diff changeset
   938
            ].
bb6de5f8fd03 Take care of true or false as pseudo-aspect-selectors
Stefan Vogel <sv@exept.de>
parents: 2191
diff changeset
   939
        ].
bb6de5f8fd03 Take care of true or false as pseudo-aspect-selectors
Stefan Vogel <sv@exept.de>
parents: 2191
diff changeset
   940
bb6de5f8fd03 Take care of true or false as pseudo-aspect-selectors
Stefan Vogel <sv@exept.de>
parents: 2191
diff changeset
   941
        (aProp spec aspectSelectors) do:[:aSel |
2250
e65b8bf6224b care for non-symbolic aspects (false)
Claus Gittinger <cg@exept.de>
parents: 2248
diff changeset
   942
            (aSel isString or:[aSel isSymbol]) ifTrue:[
2195
bb6de5f8fd03 Take care of true or false as pseudo-aspect-selectors
Stefan Vogel <sv@exept.de>
parents: 2191
diff changeset
   943
                aTwoArgBlock value:(aSel asSymbol) value:#channelAspect
bb6de5f8fd03 Take care of true or false as pseudo-aspect-selectors
Stefan Vogel <sv@exept.de>
parents: 2191
diff changeset
   944
            ].
bb6de5f8fd03 Take care of true or false as pseudo-aspect-selectors
Stefan Vogel <sv@exept.de>
parents: 2191
diff changeset
   945
        ].
bb6de5f8fd03 Take care of true or false as pseudo-aspect-selectors
Stefan Vogel <sv@exept.de>
parents: 2191
diff changeset
   946
        aProp spec actionSelectors do:[:aSel|
2250
e65b8bf6224b care for non-symbolic aspects (false)
Claus Gittinger <cg@exept.de>
parents: 2248
diff changeset
   947
            (aSel isString or:[aSel isSymbol]) ifTrue:[
2195
bb6de5f8fd03 Take care of true or false as pseudo-aspect-selectors
Stefan Vogel <sv@exept.de>
parents: 2191
diff changeset
   948
                aTwoArgBlock value:(aSel asSymbol) value:#actionSelector
bb6de5f8fd03 Take care of true or false as pseudo-aspect-selectors
Stefan Vogel <sv@exept.de>
parents: 2191
diff changeset
   949
            ].
bb6de5f8fd03 Take care of true or false as pseudo-aspect-selectors
Stefan Vogel <sv@exept.de>
parents: 2191
diff changeset
   950
        ].
bb6de5f8fd03 Take care of true or false as pseudo-aspect-selectors
Stefan Vogel <sv@exept.de>
parents: 2191
diff changeset
   951
        aProp spec valueSelectors do:[:aSel|
2250
e65b8bf6224b care for non-symbolic aspects (false)
Claus Gittinger <cg@exept.de>
parents: 2248
diff changeset
   952
            (aSel isString or:[aSel isSymbol]) ifTrue:[
2195
bb6de5f8fd03 Take care of true or false as pseudo-aspect-selectors
Stefan Vogel <sv@exept.de>
parents: 2191
diff changeset
   953
                aTwoArgBlock value:(aSel asSymbol) value:#valueSelector
bb6de5f8fd03 Take care of true or false as pseudo-aspect-selectors
Stefan Vogel <sv@exept.de>
parents: 2191
diff changeset
   954
            ].
bb6de5f8fd03 Take care of true or false as pseudo-aspect-selectors
Stefan Vogel <sv@exept.de>
parents: 2191
diff changeset
   955
        ]
352
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   956
    ].
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   957
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   958
    protoSpec := treeView canvasSpec.
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   959
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   960
    (selector := protoSpec menu) notNil ifTrue:[
2195
bb6de5f8fd03 Take care of true or false as pseudo-aspect-selectors
Stefan Vogel <sv@exept.de>
parents: 2191
diff changeset
   961
        selector isArray ifFalse:[
bb6de5f8fd03 Take care of true or false as pseudo-aspect-selectors
Stefan Vogel <sv@exept.de>
parents: 2191
diff changeset
   962
            aTwoArgBlock value:(selector asSymbol) value:#menu
bb6de5f8fd03 Take care of true or false as pseudo-aspect-selectors
Stefan Vogel <sv@exept.de>
parents: 2191
diff changeset
   963
        ].
352
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   964
    ].
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   965
!
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   966
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   967
generateActionMethodFor:aspect spec:protoSpec inClass:targetClass
2244
580cac31c444 changed #initialize
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
   968
    |selector args showIt codeStream alreadyInSuperclass numArgs method|
288
675327dd4d7d change drop mechanism:
ca
parents: 285
diff changeset
   969
675327dd4d7d change drop mechanism:
ca
parents: 285
diff changeset
   970
    selector := aspect asSymbol.
141
d06c04391233 generate actions with argument
ca
parents: 137
diff changeset
   971
288
675327dd4d7d change drop mechanism:
ca
parents: 285
diff changeset
   972
    alreadyInSuperclass := targetClass superclass canUnderstand:selector.
675327dd4d7d change drop mechanism:
ca
parents: 285
diff changeset
   973
568
7c4482bf37cf allow more than 1 numArg for an action
ca
parents: 511
diff changeset
   974
    numArgs := selector numArgs.
7c4482bf37cf allow more than 1 numArg for an action
ca
parents: 511
diff changeset
   975
    method  := aspect.
7c4482bf37cf allow more than 1 numArg for an action
ca
parents: 511
diff changeset
   976
7c4482bf37cf allow more than 1 numArg for an action
ca
parents: 511
diff changeset
   977
    numArgs == 1 ifTrue:[
2244
580cac31c444 changed #initialize
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
   978
        args := 'anArgument'.
2295
79edbe5882c6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2278
diff changeset
   979
        showIt := ''' , anArgument printString , ''...''.'.
1834
2c640b5f7fa9 *** empty log message ***
werner
parents: 1833
diff changeset
   980
    ] ifFalse:[
2244
580cac31c444 changed #initialize
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
   981
        args := ''.
580cac31c444 changed #initialize
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
   982
        showIt := ' ...''.'.
580cac31c444 changed #initialize
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
   983
580cac31c444 changed #initialize
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
   984
        numArgs ~~ 0 ifTrue:[
580cac31c444 changed #initialize
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
   985
            method := ''.
580cac31c444 changed #initialize
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
   986
580cac31c444 changed #initialize
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
   987
            selector keywords keysAndValuesDo:[:i :key|
580cac31c444 changed #initialize
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
   988
                method := method, key, 'arg', i printString, ' '
580cac31c444 changed #initialize
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
   989
            ]
580cac31c444 changed #initialize
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
   990
        ]
149
e652608690b1 help ...
ca
parents: 146
diff changeset
   991
    ].
2244
580cac31c444 changed #initialize
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
   992
    codeStream := WriteStream on:(String new:100).
580cac31c444 changed #initialize
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
   993
    codeStream  
580cac31c444 changed #initialize
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
   994
        nextPutLine:('!!',targetClass name,' methodsFor:''actions''!!');
580cac31c444 changed #initialize
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
   995
        nextPutLine:(method,args);
580cac31c444 changed #initialize
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
   996
        nextPutLine:'    <resource: #uiCallback>';
580cac31c444 changed #initialize
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
   997
        cr.
580cac31c444 changed #initialize
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
   998
580cac31c444 changed #initialize
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
   999
    self class generateCommentedCode ifTrue:[
580cac31c444 changed #initialize
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
  1000
        codeStream
2295
79edbe5882c6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2278
diff changeset
  1001
            nextPutAll:'    "automatically generated by UIPainter..."
2244
580cac31c444 changed #initialize
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
  1002
580cac31c444 changed #initialize
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
  1003
    "*** the code below performs no action"
580cac31c444 changed #initialize
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
  1004
    "*** (except for some feedback on the Transcript)"
580cac31c444 changed #initialize
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
  1005
    "*** Please change as required and accept in the browser."
580cac31c444 changed #initialize
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
  1006
    "*** (and replace this comment by something more useful ;-)"
580cac31c444 changed #initialize
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
  1007
580cac31c444 changed #initialize
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
  1008
'.
580cac31c444 changed #initialize
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
  1009
580cac31c444 changed #initialize
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
  1010
        alreadyInSuperclass ifTrue:[
580cac31c444 changed #initialize
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
  1011
            codeStream  
580cac31c444 changed #initialize
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
  1012
                nextPutLine:'    "action for ' , aspect , ' is already provided in a superclass."';
580cac31c444 changed #initialize
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
  1013
                nextPutLine:'    "It may be redefined here..."';
580cac31c444 changed #initialize
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
  1014
                cr.
580cac31c444 changed #initialize
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
  1015
        ] ifFalse:[
580cac31c444 changed #initialize
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
  1016
            codeStream  
580cac31c444 changed #initialize
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
  1017
                nextPutLine:'    "action to be defined here..."';
580cac31c444 changed #initialize
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
  1018
                cr.
580cac31c444 changed #initialize
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
  1019
        ].
580cac31c444 changed #initialize
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
  1020
    ].
580cac31c444 changed #initialize
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
  1021
580cac31c444 changed #initialize
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
  1022
    codeStream  
3304
eb8835656382 #QUALITY by stefan
Stefan Vogel <sv@exept.de>
parents: 3293
diff changeset
  1023
        nextPutAll:'    Logger info:'''.
288
675327dd4d7d change drop mechanism:
ca
parents: 285
diff changeset
  1024
675327dd4d7d change drop mechanism:
ca
parents: 285
diff changeset
  1025
    alreadyInSuperclass ifTrue:[
2244
580cac31c444 changed #initialize
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
  1026
        codeStream  
580cac31c444 changed #initialize
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
  1027
            nextPutAll:'inherited '.
288
675327dd4d7d change drop mechanism:
ca
parents: 285
diff changeset
  1028
    ].
2244
580cac31c444 changed #initialize
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
  1029
    codeStream  
580cac31c444 changed #initialize
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
  1030
        nextPutAll:'action for ';
580cac31c444 changed #initialize
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
  1031
        nextPutAll:aspect;
580cac31c444 changed #initialize
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
  1032
        nextPutLine:showIt.
288
675327dd4d7d change drop mechanism:
ca
parents: 285
diff changeset
  1033
675327dd4d7d change drop mechanism:
ca
parents: 285
diff changeset
  1034
    alreadyInSuperclass ifTrue:[
2244
580cac31c444 changed #initialize
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
  1035
        codeStream  
580cac31c444 changed #initialize
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
  1036
            nextPutAll:'    super ';
580cac31c444 changed #initialize
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
  1037
            nextPutAll:aspect;
580cac31c444 changed #initialize
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
  1038
            nextPutAll:args;
580cac31c444 changed #initialize
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
  1039
            nextPutLine:'.'.
288
675327dd4d7d change drop mechanism:
ca
parents: 285
diff changeset
  1040
    ].
675327dd4d7d change drop mechanism:
ca
parents: 285
diff changeset
  1041
2244
580cac31c444 changed #initialize
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
  1042
    codeStream  
580cac31c444 changed #initialize
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
  1043
        nextPutLine:'!! !!'; cr.
580cac31c444 changed #initialize
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
  1044
580cac31c444 changed #initialize
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
  1045
    ^ codeStream contents.
580cac31c444 changed #initialize
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
  1046
580cac31c444 changed #initialize
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
  1047
    "Modified: / 12-01-2008 / 10:21:52 / cg"
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
  1048
!
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
  1049
1683
f95658463570 added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
  1050
generateAspectMethodCode
f95658463570 added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
  1051
    "generate aspect, action & menu methods
f95658463570 added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
  1052
     - but do not overwrite existing ones.
2714
abaae556bec8 commentCode flags now in userPrefs
Claus Gittinger <cg@exept.de>
parents: 2627
diff changeset
  1053
     Return a string ready to compile into the application class.
abaae556bec8 commentCode flags now in userPrefs
Claus Gittinger <cg@exept.de>
parents: 2627
diff changeset
  1054
     TODO: refactor and move to CodeGenerator"
1683
f95658463570 added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
  1055
f95658463570 added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
  1056
    ^ self generateAspectMethodCodeFiltering:nil
f95658463570 added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
  1057
!
f95658463570 added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
  1058
f95658463570 added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
  1059
generateAspectMethodCodeFiltering:aFilterOrEmpty
f95658463570 added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
  1060
    "generate aspect, action & menu methods
f95658463570 added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
  1061
     - but do not overwrite existing ones.
2714
abaae556bec8 commentCode flags now in userPrefs
Claus Gittinger <cg@exept.de>
parents: 2627
diff changeset
  1062
     Return a string ready to compile into the application class.
abaae556bec8 commentCode flags now in userPrefs
Claus Gittinger <cg@exept.de>
parents: 2627
diff changeset
  1063
     TODO: refactor and move to CodeGenerator"
1683
f95658463570 added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
  1064
f95658463570 added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
  1065
    |cls codePieces skip protoSpec thisCode
f95658463570 added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
  1066
     definedMethodSelectors iVars t exportSels|
f95658463570 added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
  1067
f95658463570 added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
  1068
    cls := self targetClass.
f95658463570 added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
  1069
    cls isNil ifTrue:[
2024
6e9f614d6c9e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1977
diff changeset
  1070
        ^ nil
1683
f95658463570 added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
  1071
    ].
f95658463570 added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
  1072
f95658463570 added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
  1073
    codePieces := OrderedCollection new.
f95658463570 added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
  1074
    definedMethodSelectors := IdentitySet new.
f95658463570 added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
  1075
f95658463570 added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
  1076
    treeView propertiesDo:[:aProp|
2024
6e9f614d6c9e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1977
diff changeset
  1077
        |modelSelector|
6e9f614d6c9e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1977
diff changeset
  1078
6e9f614d6c9e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1977
diff changeset
  1079
        protoSpec := aProp spec.
6e9f614d6c9e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1977
diff changeset
  1080
6e9f614d6c9e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1977
diff changeset
  1081
        (modelSelector := aProp model) notNil ifTrue:[
6e9f614d6c9e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1977
diff changeset
  1082
            self generateCodeFrom:(Array with:modelSelector) in:cls
6e9f614d6c9e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1977
diff changeset
  1083
                do:[:aSel|
6e9f614d6c9e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1977
diff changeset
  1084
                    (aFilterOrEmpty isNil or:[aFilterOrEmpty includes:aSel]) ifTrue:[
6e9f614d6c9e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1977
diff changeset
  1085
                        skip := false.
6e9f614d6c9e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1977
diff changeset
  1086
6e9f614d6c9e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1977
diff changeset
  1087
                        (cls isSubclassOf:SimpleDialog) ifTrue:[
6e9f614d6c9e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1977
diff changeset
  1088
                            skip := SimpleDialog includesSelector:aSel
6e9f614d6c9e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1977
diff changeset
  1089
                        ].
6e9f614d6c9e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1977
diff changeset
  1090
                        (definedMethodSelectors includes:aSel) ifTrue:[
6e9f614d6c9e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1977
diff changeset
  1091
                            skip := true.
6e9f614d6c9e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1977
diff changeset
  1092
                        ].
6e9f614d6c9e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1977
diff changeset
  1093
6e9f614d6c9e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1977
diff changeset
  1094
                        skip ifFalse:[
6e9f614d6c9e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1977
diff changeset
  1095
                            "/ kludge ..
6e9f614d6c9e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1977
diff changeset
  1096
                            "/ (protoSpec isKindOf:ActionButtonSpec)
6e9f614d6c9e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1977
diff changeset
  1097
                            (protoSpec defaultModelIsCallBackMethodSelector:aSel)
6e9f614d6c9e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1977
diff changeset
  1098
                            ifTrue:[
6e9f614d6c9e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1977
diff changeset
  1099
                                thisCode := (self generateActionMethodFor:aSel spec:protoSpec inClass:cls).
6e9f614d6c9e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1977
diff changeset
  1100
                            ] ifFalse:[
6e9f614d6c9e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1977
diff changeset
  1101
                                thisCode := (self generateAspectMethodFor:aSel spec:protoSpec inClass:cls).
6e9f614d6c9e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1977
diff changeset
  1102
                            ].
6e9f614d6c9e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1977
diff changeset
  1103
                            codePieces add:thisCode.
6e9f614d6c9e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1977
diff changeset
  1104
                            definedMethodSelectors add:aSel.
6e9f614d6c9e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1977
diff changeset
  1105
                            Transcript showCR:'code generated for aspect: ' , aSel
6e9f614d6c9e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1977
diff changeset
  1106
                        ] ifTrue:[
6e9f614d6c9e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1977
diff changeset
  1107
                            Transcript showCR:'*** no code generated for aspect: ' , aSel , ' (method already exists)'
6e9f614d6c9e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1977
diff changeset
  1108
                        ].
6e9f614d6c9e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1977
diff changeset
  1109
                    ].
6e9f614d6c9e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1977
diff changeset
  1110
                ].
6e9f614d6c9e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1977
diff changeset
  1111
        ].
6e9f614d6c9e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1977
diff changeset
  1112
6e9f614d6c9e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1977
diff changeset
  1113
        "/ for each aspect, generate getter (if not yet implemented)
6e9f614d6c9e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1977
diff changeset
  1114
        self generateCodeFrom:(aProp spec aspectSelectors) in:cls
6e9f614d6c9e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1977
diff changeset
  1115
                do:[:aSel|
6e9f614d6c9e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1977
diff changeset
  1116
                    (aFilterOrEmpty isNil or:[aFilterOrEmpty includes:aSel]) ifTrue:[
6e9f614d6c9e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1977
diff changeset
  1117
                        (definedMethodSelectors includes:aSel) ifFalse:[
6e9f614d6c9e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1977
diff changeset
  1118
                            thisCode := (self generateAspectMethodFor:aSel spec:protoSpec inClass:cls).
6e9f614d6c9e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1977
diff changeset
  1119
                            codePieces add:thisCode.
6e9f614d6c9e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1977
diff changeset
  1120
                            definedMethodSelectors add:aSel.
6e9f614d6c9e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1977
diff changeset
  1121
                            Transcript showCR:'code generated for aspect: ' , aSel
6e9f614d6c9e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1977
diff changeset
  1122
                        ]
6e9f614d6c9e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1977
diff changeset
  1123
                    ]
6e9f614d6c9e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1977
diff changeset
  1124
                ].
6e9f614d6c9e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1977
diff changeset
  1125
6e9f614d6c9e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1977
diff changeset
  1126
        "/ exported aspects - need setter methods
3092
c327e636e6a3 class: UIPainterView
Claus Gittinger <cg@exept.de>
parents: 3083
diff changeset
  1127
        exportSels := (treeView exportedAspects ? #()) collect:[:entry | (entry subAspect) asMutator].
2024
6e9f614d6c9e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1977
diff changeset
  1128
        self generateCodeFrom:exportSels in:cls
6e9f614d6c9e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1977
diff changeset
  1129
                do:[:aSel|
6e9f614d6c9e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1977
diff changeset
  1130
                    |aspect|
6e9f614d6c9e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1977
diff changeset
  1131
6e9f614d6c9e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1977
diff changeset
  1132
                    (aFilterOrEmpty isNil or:[aFilterOrEmpty includes:aSel]) ifTrue:[
6e9f614d6c9e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1977
diff changeset
  1133
                        (definedMethodSelectors includes:aSel) ifFalse:[
3136
146b6f9e139c class: UIPainterView
Claus Gittinger <cg@exept.de>
parents: 3129
diff changeset
  1134
                            aspect := (aSel copyButLast) asSymbol.
2024
6e9f614d6c9e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1977
diff changeset
  1135
                            thisCode := (self generateAspectSetMethodFor:aspect spec:protoSpec inClass:cls).
6e9f614d6c9e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1977
diff changeset
  1136
                            codePieces add:thisCode.
6e9f614d6c9e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1977
diff changeset
  1137
                            definedMethodSelectors add:aSel.
6e9f614d6c9e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1977
diff changeset
  1138
                            Transcript showCR:'export code generated for aspect: ' , aSel
6e9f614d6c9e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1977
diff changeset
  1139
                        ]
6e9f614d6c9e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1977
diff changeset
  1140
                    ]
6e9f614d6c9e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1977
diff changeset
  1141
                ].
6e9f614d6c9e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1977
diff changeset
  1142
6e9f614d6c9e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1977
diff changeset
  1143
        self generateCodeFrom:(aProp spec actionSelectors) in:cls
6e9f614d6c9e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1977
diff changeset
  1144
                do:[:aSel|
6e9f614d6c9e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1977
diff changeset
  1145
                    (aFilterOrEmpty isNil or:[aFilterOrEmpty includes:aSel]) ifTrue:[
6e9f614d6c9e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1977
diff changeset
  1146
                        (definedMethodSelectors includes:aSel) ifFalse:[
6e9f614d6c9e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1977
diff changeset
  1147
                            thisCode := (self generateActionMethodFor:aSel spec:protoSpec inClass:cls).
6e9f614d6c9e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1977
diff changeset
  1148
                            codePieces add:thisCode.
6e9f614d6c9e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1977
diff changeset
  1149
                            definedMethodSelectors add:aSel.
6e9f614d6c9e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1977
diff changeset
  1150
                            Transcript showCR:'action generated for aspect: ' , aSel
6e9f614d6c9e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1977
diff changeset
  1151
                        ]
6e9f614d6c9e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1977
diff changeset
  1152
                    ]
6e9f614d6c9e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1977
diff changeset
  1153
                ].
6e9f614d6c9e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1977
diff changeset
  1154
6e9f614d6c9e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1977
diff changeset
  1155
        self generateCodeFrom:(aProp spec valueSelectors) in:cls
6e9f614d6c9e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1977
diff changeset
  1156
                do:[:aSel|
6e9f614d6c9e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1977
diff changeset
  1157
                    (aFilterOrEmpty isNil or:[aFilterOrEmpty includes:aSel]) ifTrue:[
6e9f614d6c9e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1977
diff changeset
  1158
                        (definedMethodSelectors includes:aSel) ifFalse:[
6e9f614d6c9e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1977
diff changeset
  1159
                            "/ uppercase: - assume its a globals name.
6e9f614d6c9e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1977
diff changeset
  1160
                            aSel isUppercaseFirst ifFalse:[
6e9f614d6c9e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1977
diff changeset
  1161
                                thisCode := (self generateValueMethodFor:aSel spec:protoSpec inClass:cls).
6e9f614d6c9e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1977
diff changeset
  1162
                                codePieces add:thisCode.
6e9f614d6c9e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1977
diff changeset
  1163
                                definedMethodSelectors add:aSel.
6e9f614d6c9e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1977
diff changeset
  1164
                                Transcript showCR:'code generated for aspect: ' , aSel
6e9f614d6c9e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1977
diff changeset
  1165
                            ]
6e9f614d6c9e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1977
diff changeset
  1166
                        ]
6e9f614d6c9e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1977
diff changeset
  1167
                    ]
6e9f614d6c9e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1977
diff changeset
  1168
                ].
1683
f95658463570 added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
  1169
    ].
f95658463570 added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
  1170
f95658463570 added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
  1171
    AspectsAsInstances ifTrue:[
2024
6e9f614d6c9e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1977
diff changeset
  1172
        iVars := cls instVarNames asOrderedCollection.
6e9f614d6c9e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1977
diff changeset
  1173
        definedMethodSelectors do:[:ivar |
6e9f614d6c9e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1977
diff changeset
  1174
            (iVars includes:ivar) ifFalse:[
6e9f614d6c9e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1977
diff changeset
  1175
                iVars add:ivar
6e9f614d6c9e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1977
diff changeset
  1176
            ]
6e9f614d6c9e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1977
diff changeset
  1177
        ].
6e9f614d6c9e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1977
diff changeset
  1178
        iVars := iVars asArray.
6e9f614d6c9e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1977
diff changeset
  1179
        t := cls shallowCopy.
6e9f614d6c9e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1977
diff changeset
  1180
        t setInstanceVariableString:iVars asStringCollection asString.
6e9f614d6c9e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1977
diff changeset
  1181
        codePieces addFirst:(t definition , '!!\' withCRs).
1683
f95658463570 added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
  1182
    ].
f95658463570 added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
  1183
1834
2c640b5f7fa9 *** empty log message ***
werner
parents: 1833
diff changeset
  1184
    ^ String
2024
6e9f614d6c9e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1977
diff changeset
  1185
        streamContents:
6e9f614d6c9e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1977
diff changeset
  1186
            [:codeStream |
6e9f614d6c9e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1977
diff changeset
  1187
                codePieces do:[:eachPiece | codeStream nextPutAll:eachPiece].
6e9f614d6c9e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1977
diff changeset
  1188
            ].
1683
f95658463570 added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
  1189
f95658463570 added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
  1190
    "Modified: / 29.7.1998 / 12:21:19 / cg"
f95658463570 added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
  1191
!
f95658463570 added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
  1192
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
  1193
generateAspectMethodFor:aspect spec:protoSpec inClass:targetClass
2244
580cac31c444 changed #initialize
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
  1194
    |modelClass modelValueString modelValue modelGen codeStream|
134
d5ab85ec27fd undo history; keep view identifier
ca
parents: 131
diff changeset
  1195
149
e652608690b1 help ...
ca
parents: 146
diff changeset
  1196
    modelClass := protoSpec defaultModelClassFor:aspect.
1257
acb8c0a58ef3 dataSPec defaultValue when generating aspects
Claus Gittinger <cg@exept.de>
parents: 1252
diff changeset
  1197
    modelValueString := protoSpec defaultModelValueStringFor:aspect.
acb8c0a58ef3 dataSPec defaultValue when generating aspects
Claus Gittinger <cg@exept.de>
parents: 1252
diff changeset
  1198
    modelValueString notNil ifTrue:[
2244
580cac31c444 changed #initialize
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
  1199
        modelGen := modelValueString
1257
acb8c0a58ef3 dataSPec defaultValue when generating aspects
Claus Gittinger <cg@exept.de>
parents: 1252
diff changeset
  1200
    ] ifFalse:[
2244
580cac31c444 changed #initialize
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
  1201
        modelValue := protoSpec defaultModelValueFor:aspect.
580cac31c444 changed #initialize
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
  1202
        modelValue isNil ifTrue:[
580cac31c444 changed #initialize
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
  1203
            modelGen := modelClass name , ' new'
580cac31c444 changed #initialize
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
  1204
        ] ifFalse:[
580cac31c444 changed #initialize
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
  1205
            modelGen := modelValue storeString , ' asValue'
580cac31c444 changed #initialize
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
  1206
        ].
352
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
  1207
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
  1208
    ].
134
d5ab85ec27fd undo history; keep view identifier
ca
parents: 131
diff changeset
  1209
2244
580cac31c444 changed #initialize
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
  1210
    codeStream := WriteStream on:(String new:100).
580cac31c444 changed #initialize
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
  1211
    codeStream  
580cac31c444 changed #initialize
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
  1212
        nextPutLine:('!!' , targetClass name , ' methodsFor:''aspects''!!');
580cac31c444 changed #initialize
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
  1213
        nextPutLine:aspect;
580cac31c444 changed #initialize
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
  1214
        nextPutLine:'    <resource: #uiAspect>';
580cac31c444 changed #initialize
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
  1215
        cr.
580cac31c444 changed #initialize
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
  1216
580cac31c444 changed #initialize
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
  1217
    self class generateCommentedCode ifTrue:[
580cac31c444 changed #initialize
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
  1218
        codeStream  
580cac31c444 changed #initialize
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
  1219
            nextPutAll:'    "automatically generated by UIPainter ..."
580cac31c444 changed #initialize
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
  1220
580cac31c444 changed #initialize
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
  1221
    "*** the code below creates a default model when invoked."
580cac31c444 changed #initialize
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
  1222
    "*** (which may not be the one you wanted)"
580cac31c444 changed #initialize
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
  1223
    "*** Please change as required and accept it in the browser."
580cac31c444 changed #initialize
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
  1224
    "*** (and replace this comment by something more useful ;-)"
580cac31c444 changed #initialize
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
  1225
580cac31c444 changed #initialize
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
  1226
'.
580cac31c444 changed #initialize
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
  1227
    ].
1474
d2ee565fa32a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1467
diff changeset
  1228
925
e6ddd46581c3 added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents: 887
diff changeset
  1229
    AspectsAsInstances ifTrue:[
2244
580cac31c444 changed #initialize
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
  1230
        codeStream
580cac31c444 changed #initialize
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
  1231
            nextPutLine:('    ',aspect,' isNil ifTrue:[');
580cac31c444 changed #initialize
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
  1232
            nextPutLine:('        ',aspect,' := ',modelGen,'.').
580cac31c444 changed #initialize
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
  1233
580cac31c444 changed #initialize
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
  1234
        modelClass ~~ TriggerValue ifTrue:[
580cac31c444 changed #initialize
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
  1235
            self class generateCommentedCode ifTrue:[
580cac31c444 changed #initialize
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
  1236
                codeStream
580cac31c444 changed #initialize
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
  1237
                    nextPutLine:'"/ if your app needs to be notified of changes, uncomment one of the lines below:'.
580cac31c444 changed #initialize
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
  1238
            ].
580cac31c444 changed #initialize
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
  1239
            codeStream
580cac31c444 changed #initialize
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
  1240
                nextPutLine:'"/       ',aspect,' addDependent:self.';
580cac31c444 changed #initialize
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
  1241
                nextPutLine:'"/       ',aspect,' onChangeSend:#',aspect,'Changed to:self.'.
580cac31c444 changed #initialize
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset