ImageEditView.st
author tz
Tue, 04 Aug 1998 18:25:03 +0200
changeset 1053 8d839dff68a9
parent 1050 85ee282325fc
child 1060 690045fd9032
permissions -rw-r--r--
fixed box emphasis
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
636
d53428252193 revised version
tz
parents: 633
diff changeset
     1
"
704
01140e14c065 Fix copyright.
Stefan Vogel <sv@exept.de>
parents: 694
diff changeset
     2
 COPYRIGHT (c) 1997 by eXept Software AG
636
d53428252193 revised version
tz
parents: 633
diff changeset
     3
              All Rights Reserved
d53428252193 revised version
tz
parents: 633
diff changeset
     4
d53428252193 revised version
tz
parents: 633
diff changeset
     5
 This software is furnished under a license and may be used
d53428252193 revised version
tz
parents: 633
diff changeset
     6
 only in accordance with the terms of that license and with the
d53428252193 revised version
tz
parents: 633
diff changeset
     7
 inclusion of the above copyright notice. This software may not
d53428252193 revised version
tz
parents: 633
diff changeset
     8
 be provided or otherwise made available to, or used by, any
d53428252193 revised version
tz
parents: 633
diff changeset
     9
 other person. No title to or ownership of the software is
d53428252193 revised version
tz
parents: 633
diff changeset
    10
 hereby transferred.
d53428252193 revised version
tz
parents: 633
diff changeset
    11
"
d53428252193 revised version
tz
parents: 633
diff changeset
    12
1
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
    13
ImageView subclass:#ImageEditView
1035
5da83bdbd65e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1031
diff changeset
    14
	instanceVariableNames:'magnification selectColors imageReaderClass resourceClass
5da83bdbd65e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1031
diff changeset
    15
		resourceSelector mouseKeyColorMode undoImages modified
5da83bdbd65e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1031
diff changeset
    16
		masterApplication editMode lastPastePoint imageInfoHolder
5da83bdbd65e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1031
diff changeset
    17
		activityInfoHolder pickedColorHolder'
5da83bdbd65e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1031
diff changeset
    18
	classVariableNames:'Clipboard LastMagnification ClipboardMagnification
5da83bdbd65e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1031
diff changeset
    19
		GridMagnification MaxUndos'
5da83bdbd65e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1031
diff changeset
    20
	poolDictionaries:''
5da83bdbd65e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1031
diff changeset
    21
	category:'Views-Misc'
1
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
    22
!
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
    23
636
d53428252193 revised version
tz
parents: 633
diff changeset
    24
!ImageEditView class methodsFor:'documentation'!
d53428252193 revised version
tz
parents: 633
diff changeset
    25
d53428252193 revised version
tz
parents: 633
diff changeset
    26
copyright
d53428252193 revised version
tz
parents: 633
diff changeset
    27
"
704
01140e14c065 Fix copyright.
Stefan Vogel <sv@exept.de>
parents: 694
diff changeset
    28
 COPYRIGHT (c) 1997 by eXept Software AG
636
d53428252193 revised version
tz
parents: 633
diff changeset
    29
              All Rights Reserved
d53428252193 revised version
tz
parents: 633
diff changeset
    30
d53428252193 revised version
tz
parents: 633
diff changeset
    31
 This software is furnished under a license and may be used
d53428252193 revised version
tz
parents: 633
diff changeset
    32
 only in accordance with the terms of that license and with the
d53428252193 revised version
tz
parents: 633
diff changeset
    33
 inclusion of the above copyright notice. This software may not
d53428252193 revised version
tz
parents: 633
diff changeset
    34
 be provided or otherwise made available to, or used by, any
d53428252193 revised version
tz
parents: 633
diff changeset
    35
 other person. No title to or ownership of the software is
d53428252193 revised version
tz
parents: 633
diff changeset
    36
 hereby transferred.
d53428252193 revised version
tz
parents: 633
diff changeset
    37
"
d53428252193 revised version
tz
parents: 633
diff changeset
    38
!
d53428252193 revised version
tz
parents: 633
diff changeset
    39
d53428252193 revised version
tz
parents: 633
diff changeset
    40
documentation
d53428252193 revised version
tz
parents: 633
diff changeset
    41
"
d53428252193 revised version
tz
parents: 633
diff changeset
    42
    The ImageEditView is a view class which can be used by applications
d53428252193 revised version
tz
parents: 633
diff changeset
    43
    like the Image Editor for modifying or inspecting images.
d53428252193 revised version
tz
parents: 633
diff changeset
    44
d53428252193 revised version
tz
parents: 633
diff changeset
    45
    [see also:]
d53428252193 revised version
tz
parents: 633
diff changeset
    46
        ImageEditor Image
d53428252193 revised version
tz
parents: 633
diff changeset
    47
d53428252193 revised version
tz
parents: 633
diff changeset
    48
    [author:]
d53428252193 revised version
tz
parents: 633
diff changeset
    49
        Thomas Zwick
d53428252193 revised version
tz
parents: 633
diff changeset
    50
"
d53428252193 revised version
tz
parents: 633
diff changeset
    51
! !
353
0442fc169b82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
    52
7
19b36b78ee01 *** empty log message ***
claus
parents: 5
diff changeset
    53
!ImageEditView methodsFor:'accessing'!
19b36b78ee01 *** empty log message ***
claus
parents: 5
diff changeset
    54
1031
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
    55
activityInfoHolder
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
    56
    "return the value of the instance variable 'activityInfoHolder' (automatically generated)"
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
    57
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
    58
    ^ activityInfoHolder
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
    59
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
    60
    "Created: / 29.7.1998 / 18:49:39 / cg"
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
    61
!
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
    62
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
    63
activityInfoHolder:something
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
    64
    "set the value of the instance variable 'activityInfoHolder' (automatically generated)"
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
    65
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
    66
    activityInfoHolder := something.
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
    67
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
    68
    "Created: / 29.7.1998 / 18:49:39 / cg"
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
    69
!
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
    70
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
    71
imageInfoHolder
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
    72
    "return the value of the instance variable 'imageInfoHolder' (automatically generated)"
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
    73
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
    74
    ^ imageInfoHolder
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
    75
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
    76
    "Created: / 29.7.1998 / 18:29:50 / cg"
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
    77
!
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
    78
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
    79
imageInfoHolder:something
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
    80
    "set the value of the instance variable 'imageInfoHolder' (automatically generated)"
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
    81
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
    82
    imageInfoHolder := something.
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
    83
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
    84
    "Created: / 29.7.1998 / 18:29:50 / cg"
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
    85
!
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
    86
624
d98fe4700fc2 checkin from browser
tz
parents: 606
diff changeset
    87
magnification
d98fe4700fc2 checkin from browser
tz
parents: 606
diff changeset
    88
d98fe4700fc2 checkin from browser
tz
parents: 606
diff changeset
    89
    ^magnification
d98fe4700fc2 checkin from browser
tz
parents: 606
diff changeset
    90
255
1dfa8deddaef checkin from browser
Claus Gittinger <cg@exept.de>
parents: 251
diff changeset
    91
!
1dfa8deddaef checkin from browser
Claus Gittinger <cg@exept.de>
parents: 251
diff changeset
    92
636
d53428252193 revised version
tz
parents: 633
diff changeset
    93
magnification: aPoint
1037
3735af6b5b24 remmeber scrollOffset
Claus Gittinger <cg@exept.de>
parents: 1036
diff changeset
    94
    |oldOrg|
255
1dfa8deddaef checkin from browser
Claus Gittinger <cg@exept.de>
parents: 251
diff changeset
    95
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
    96
    magnification ~= aPoint
624
d98fe4700fc2 checkin from browser
tz
parents: 606
diff changeset
    97
    ifTrue:
d98fe4700fc2 checkin from browser
tz
parents: 606
diff changeset
    98
    [
1037
3735af6b5b24 remmeber scrollOffset
Claus Gittinger <cg@exept.de>
parents: 1036
diff changeset
    99
        oldOrg := self viewOrigin / magnification.
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   100
        magnification := aPoint asPoint.
1037
3735af6b5b24 remmeber scrollOffset
Claus Gittinger <cg@exept.de>
parents: 1036
diff changeset
   101
3735af6b5b24 remmeber scrollOffset
Claus Gittinger <cg@exept.de>
parents: 1036
diff changeset
   102
        self scrollTo:(oldOrg * magnification) rounded redraw:false.        
3735af6b5b24 remmeber scrollOffset
Claus Gittinger <cg@exept.de>
parents: 1036
diff changeset
   103
"/        self scrollToTopLeft.
624
d98fe4700fc2 checkin from browser
tz
parents: 606
diff changeset
   104
        self contentsChanged.
995
cd84d6f8c449 several undos
tz
parents: 994
diff changeset
   105
        self invalidate.
cd84d6f8c449 several undos
tz
parents: 994
diff changeset
   106
        ClipboardMagnification := nil.
686
33833bcbb5cd some cleans
tz
parents: 678
diff changeset
   107
    ]
1037
3735af6b5b24 remmeber scrollOffset
Claus Gittinger <cg@exept.de>
parents: 1036
diff changeset
   108
3735af6b5b24 remmeber scrollOffset
Claus Gittinger <cg@exept.de>
parents: 1036
diff changeset
   109
    "Modified: / 31.7.1998 / 02:38:47 / cg"
624
d98fe4700fc2 checkin from browser
tz
parents: 606
diff changeset
   110
!
255
1dfa8deddaef checkin from browser
Claus Gittinger <cg@exept.de>
parents: 251
diff changeset
   111
662
61b7601829ea with modal support
tz
parents: 636
diff changeset
   112
masterApplication
61b7601829ea with modal support
tz
parents: 636
diff changeset
   113
61b7601829ea with modal support
tz
parents: 636
diff changeset
   114
    ^masterApplication
61b7601829ea with modal support
tz
parents: 636
diff changeset
   115
!
61b7601829ea with modal support
tz
parents: 636
diff changeset
   116
61b7601829ea with modal support
tz
parents: 636
diff changeset
   117
masterApplication: anApplicationModel
61b7601829ea with modal support
tz
parents: 636
diff changeset
   118
61b7601829ea with modal support
tz
parents: 636
diff changeset
   119
    masterApplication := anApplicationModel
61b7601829ea with modal support
tz
parents: 636
diff changeset
   120
!
61b7601829ea with modal support
tz
parents: 636
diff changeset
   121
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   122
resourceClass
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   123
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   124
    ^resourceClass
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   125
!
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   126
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   127
resourceClass: aClassOrSymbol
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   128
686
33833bcbb5cd some cleans
tz
parents: 678
diff changeset
   129
    resourceClass := aClassOrSymbol isClass ifTrue: [aClassOrSymbol name] ifFalse: [aClassOrSymbol asSymbol]
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   130
!
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   131
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   132
resourceMessage
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   133
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   134
    ^resourceClass, ' ', resourceSelector
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   135
!
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   136
636
d53428252193 revised version
tz
parents: 633
diff changeset
   137
resourceMessage: aString
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   138
636
d53428252193 revised version
tz
parents: 633
diff changeset
   139
    (aString isString and: [aString trimBlanks size > 0])
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   140
    ifTrue:
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   141
    [
636
d53428252193 revised version
tz
parents: 633
diff changeset
   142
        resourceClass := (aString readStream upTo: Character space) asSymbol.
686
33833bcbb5cd some cleans
tz
parents: 678
diff changeset
   143
        resourceSelector := (aString copy reverse readStream upTo: Character space) reverse asSymbol
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   144
    ]
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   145
    ifFalse:
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   146
    [
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   147
        ^nil
686
33833bcbb5cd some cleans
tz
parents: 678
diff changeset
   148
    ]
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   149
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   150
   
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   151
!
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   152
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   153
resourceSelector
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   154
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   155
    ^resourceSelector
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   156
!
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   157
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   158
resourceSelector: aStringOrSymbol
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   159
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   160
    resourceSelector := aStringOrSymbol asSymbol
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   161
!
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   162
840
93f209fc0f7a selectColors
tz
parents: 839
diff changeset
   163
selectColors
93f209fc0f7a selectColors
tz
parents: 839
diff changeset
   164
93f209fc0f7a selectColors
tz
parents: 839
diff changeset
   165
    ^selectColors
93f209fc0f7a selectColors
tz
parents: 839
diff changeset
   166
!
93f209fc0f7a selectColors
tz
parents: 839
diff changeset
   167
93f209fc0f7a selectColors
tz
parents: 839
diff changeset
   168
selectColors: anArrayTwoColors
633
594edef86630 revised version
tz
parents: 632
diff changeset
   169
594edef86630 revised version
tz
parents: 632
diff changeset
   170
    selectColors := anArrayTwoColors
594edef86630 revised version
tz
parents: 632
diff changeset
   171
!
594edef86630 revised version
tz
parents: 632
diff changeset
   172
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   173
selectedColor
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   174
633
594edef86630 revised version
tz
parents: 632
diff changeset
   175
   ^selectColors at: mouseKeyColorMode
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   176
!
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   177
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   178
selectedColor: aColor
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   179
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   180
    selectColors at: mouseKeyColorMode put: aColor
995
cd84d6f8c449 several undos
tz
parents: 994
diff changeset
   181
!
cd84d6f8c449 several undos
tz
parents: 994
diff changeset
   182
cd84d6f8c449 several undos
tz
parents: 994
diff changeset
   183
undoImages
cd84d6f8c449 several undos
tz
parents: 994
diff changeset
   184
cd84d6f8c449 several undos
tz
parents: 994
diff changeset
   185
   ^undoImages
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   186
! !
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   187
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   188
!ImageEditView methodsFor:'drawing'!
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   189
1036
d860072f3b49 gridMag default.
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   190
drawFrame
d860072f3b49 gridMag default.
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   191
d860072f3b49 gridMag default.
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   192
    self paint:Color black.
d860072f3b49 gridMag default.
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   193
    self lineWidth: (magnification x//3 min: 3).
d860072f3b49 gridMag default.
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   194
    self displayRectangle: ((0@0) extent:(image extent * magnification) + 2).
d860072f3b49 gridMag default.
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   195
    self lineWidth:1.
d860072f3b49 gridMag default.
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   196
!
d860072f3b49 gridMag default.
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   197
d860072f3b49 gridMag default.
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   198
drawFramesIn: aRectangle
d860072f3b49 gridMag default.
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   199
d860072f3b49 gridMag default.
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   200
    magnification >= GridMagnification
d860072f3b49 gridMag default.
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   201
    ifTrue:
d860072f3b49 gridMag default.
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   202
    [   
d860072f3b49 gridMag default.
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   203
        |origin lineStartingPoint lineEndingPoint oldColor|
d860072f3b49 gridMag default.
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   204
        origin := aRectangle origin - 1.
d860072f3b49 gridMag default.
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   205
        lineStartingPoint := origin + (0@magnification y).
d860072f3b49 gridMag default.
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   206
        lineEndingPoint   := lineStartingPoint + (aRectangle width@0).
d860072f3b49 gridMag default.
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   207
        oldColor := self paint.
d860072f3b49 gridMag default.
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   208
        self xoring:
d860072f3b49 gridMag default.
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   209
        [
d860072f3b49 gridMag default.
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   210
            self displayLineFrom: lineStartingPoint to: lineEndingPoint.
d860072f3b49 gridMag default.
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   211
            lineStartingPoint x to: lineStartingPoint x + aRectangle width - magnification x by: magnification x do:
d860072f3b49 gridMag default.
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   212
            [:x|   
d860072f3b49 gridMag default.
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   213
                self displayLineFrom: x@(origin y) to: x@(origin y + magnification y)
d860072f3b49 gridMag default.
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   214
            ].
d860072f3b49 gridMag default.
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   215
        ].
d860072f3b49 gridMag default.
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   216
        self paint: oldColor.
d860072f3b49 gridMag default.
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   217
    ]
d860072f3b49 gridMag default.
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   218
d860072f3b49 gridMag default.
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   219
d860072f3b49 gridMag default.
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   220
d860072f3b49 gridMag default.
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   221
!
d860072f3b49 gridMag default.
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   222
662
61b7601829ea with modal support
tz
parents: 636
diff changeset
   223
fillFramedRectangle: aRectangle
61b7601829ea with modal support
tz
parents: 636
diff changeset
   224
61b7601829ea with modal support
tz
parents: 636
diff changeset
   225
    self fillRectangle: aRectangle.
61b7601829ea with modal support
tz
parents: 636
diff changeset
   226
    self drawFramesIn: aRectangle
61b7601829ea with modal support
tz
parents: 636
diff changeset
   227
!
61b7601829ea with modal support
tz
parents: 636
diff changeset
   228
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   229
redrawImageX:x y:y width:w height:h
636
d53428252193 revised version
tz
parents: 633
diff changeset
   230
1037
3735af6b5b24 remmeber scrollOffset
Claus Gittinger <cg@exept.de>
parents: 1036
diff changeset
   231
    |ih iw magX magY minX maxX minY maxY 
3735af6b5b24 remmeber scrollOffset
Claus Gittinger <cg@exept.de>
parents: 1036
diff changeset
   232
     color lastColor lastY runW x0 xI yI maskColor mask
3735af6b5b24 remmeber scrollOffset
Claus Gittinger <cg@exept.de>
parents: 1036
diff changeset
   233
     sizeOfMaskPoint|
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   234
1037
3735af6b5b24 remmeber scrollOffset
Claus Gittinger <cg@exept.de>
parents: 1036
diff changeset
   235
    mask := image mask.
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   236
    ih := image height.
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   237
    iw := image width.
662
61b7601829ea with modal support
tz
parents: 636
diff changeset
   238
    magX := magnification x.
61b7601829ea with modal support
tz
parents: 636
diff changeset
   239
    magY := magnification y.
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   240
662
61b7601829ea with modal support
tz
parents: 636
diff changeset
   241
    minX := (x // magX - 1) max: 0.
725
0e051202859d checkin from browser
tz
parents: 724
diff changeset
   242
    minX >= iw ifTrue:[minX := (iw - 1) max: 0].
662
61b7601829ea with modal support
tz
parents: 636
diff changeset
   243
    minY := (y // magY - 1) max: 0.
725
0e051202859d checkin from browser
tz
parents: 724
diff changeset
   244
    minY >= ih ifTrue:[minY := (ih - 1) max: 0].
662
61b7601829ea with modal support
tz
parents: 636
diff changeset
   245
    maxX := (x + w) // magX + 1.
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   246
    maxX > iw ifTrue:[maxX := iw].
662
61b7601829ea with modal support
tz
parents: 636
diff changeset
   247
    maxY := (y + h) // magY + 1.
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   248
    maxY > ih ifTrue:[maxY := ih].
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   249
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   250
    lastY := -1.
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   251
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   252
    x0 := minX.
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   253
    runW := 0.
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   254
    maskColor := false.
662
61b7601829ea with modal support
tz
parents: 636
diff changeset
   255
    sizeOfMaskPoint := magnification//3.
61b7601829ea with modal support
tz
parents: 636
diff changeset
   256
    image colorsFromX: minX y: minY toX: maxX-1 y: maxY-1 do:
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   257
    [:xx :yy :color|
633
594edef86630 revised version
tz
parents: 632
diff changeset
   258
        yy ~~ lastY
594edef86630 revised version
tz
parents: 632
diff changeset
   259
        ifTrue:
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   260
        [
633
594edef86630 revised version
tz
parents: 632
diff changeset
   261
            runW ~~ 0
594edef86630 revised version
tz
parents: 632
diff changeset
   262
            ifTrue:
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   263
            [
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   264
                |origin|
662
61b7601829ea with modal support
tz
parents: 636
diff changeset
   265
                origin := (x0 * magX + margin)@(lastY * magY + margin).
61b7601829ea with modal support
tz
parents: 636
diff changeset
   266
                self fillFramedRectangle: (origin extent: (runW@magY)).                    
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   267
                maskColor ifTrue:
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   268
                [
662
61b7601829ea with modal support
tz
parents: 636
diff changeset
   269
                    self xoring: [self fillRectangle: (origin + sizeOfMaskPoint extent: sizeOfMaskPoint)]
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   270
                ].
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   271
                runW := 0.
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   272
            ]. 
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   273
            x0 := xx.
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   274
            lastY := yy.
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   275
        ]. 
624
d98fe4700fc2 checkin from browser
tz
parents: 606
diff changeset
   276
662
61b7601829ea with modal support
tz
parents: 636
diff changeset
   277
        color ~~ lastColor
633
594edef86630 revised version
tz
parents: 632
diff changeset
   278
        ifTrue:
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   279
        [
633
594edef86630 revised version
tz
parents: 632
diff changeset
   280
            runW ~~ 0
594edef86630 revised version
tz
parents: 632
diff changeset
   281
            ifTrue:
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   282
            [
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   283
                |origin|
662
61b7601829ea with modal support
tz
parents: 636
diff changeset
   284
                origin := (x0 * magX + margin)@(yy * magY + margin).
61b7601829ea with modal support
tz
parents: 636
diff changeset
   285
                self fillFramedRectangle: (origin extent: (runW@magY)).
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   286
                maskColor ifTrue:
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   287
                [
662
61b7601829ea with modal support
tz
parents: 636
diff changeset
   288
                    self xoring: [self fillRectangle: (origin + sizeOfMaskPoint extent: sizeOfMaskPoint)]
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   289
                ].
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   290
                runW := 0.
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   291
            ].
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   292
662
61b7601829ea with modal support
tz
parents: 636
diff changeset
   293
            self paint: (lastColor := color).
1037
3735af6b5b24 remmeber scrollOffset
Claus Gittinger <cg@exept.de>
parents: 1036
diff changeset
   294
            mask notNil ifTrue:
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   295
            [  
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   296
                maskColor := false.
1037
3735af6b5b24 remmeber scrollOffset
Claus Gittinger <cg@exept.de>
parents: 1036
diff changeset
   297
                (mask colorAtX:xx y:yy) = Color black ifTrue:
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   298
                [
662
61b7601829ea with modal support
tz
parents: 636
diff changeset
   299
                    self paint: (lastColor := self viewBackground).
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   300
                    maskColor := true.
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   301
                ].
662
61b7601829ea with modal support
tz
parents: 636
diff changeset
   302
                lastColor := nil.
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   303
            ].
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   304
            runW := 0.
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   305
            x0 := xx.
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   306
        ].  
662
61b7601829ea with modal support
tz
parents: 636
diff changeset
   307
        runW := runW + magX
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   308
    ].
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   309
    runW ~~ 0 ifTrue:
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   310
    [
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   311
        |origin|
662
61b7601829ea with modal support
tz
parents: 636
diff changeset
   312
        origin := (x0 * magX + margin)@(lastY * magY + margin).
61b7601829ea with modal support
tz
parents: 636
diff changeset
   313
        self fillFramedRectangle: (origin extent: runW@magY).
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   314
        maskColor ifTrue:
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   315
        [
662
61b7601829ea with modal support
tz
parents: 636
diff changeset
   316
            self xoring: [self fillRectangle: (origin + sizeOfMaskPoint extent: sizeOfMaskPoint)]
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   317
        ].
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   318
        runW := 0.
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   319
    ].
1037
3735af6b5b24 remmeber scrollOffset
Claus Gittinger <cg@exept.de>
parents: 1036
diff changeset
   320
3735af6b5b24 remmeber scrollOffset
Claus Gittinger <cg@exept.de>
parents: 1036
diff changeset
   321
    "Modified: / 31.7.1998 / 02:33:42 / cg"
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   322
!
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   323
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   324
redrawX:x y:y width:w height:h
636
d53428252193 revised version
tz
parents: 633
diff changeset
   325
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   326
    |ih iw xI yI|
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   327
1037
3735af6b5b24 remmeber scrollOffset
Claus Gittinger <cg@exept.de>
parents: 1036
diff changeset
   328
    image isNil ifTrue:[^self].
662
61b7601829ea with modal support
tz
parents: 636
diff changeset
   329
1037
3735af6b5b24 remmeber scrollOffset
Claus Gittinger <cg@exept.de>
parents: 1036
diff changeset
   330
    magnification = (1@1) ifTrue: [
3735af6b5b24 remmeber scrollOffset
Claus Gittinger <cg@exept.de>
parents: 1036
diff changeset
   331
        ^ super redrawX:x y:y width:w height:h
3735af6b5b24 remmeber scrollOffset
Claus Gittinger <cg@exept.de>
parents: 1036
diff changeset
   332
    ].
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   333
662
61b7601829ea with modal support
tz
parents: 636
diff changeset
   334
    self clippingRectangle: (x@y extent: w@h).
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   335
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   336
    self redrawImageX:x y:y width:w height:h.
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   337
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   338
    "/ right of image ?
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   339
    adjust == #center ifTrue:
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   340
    [
633
594edef86630 revised version
tz
parents: 632
diff changeset
   341
        xI := (width - ih) // 2 - margin.
594edef86630 revised version
tz
parents: 632
diff changeset
   342
        yI := (height - iw) // 2 - margin.
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   343
    ]
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   344
    ifFalse:
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   345
    [
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   346
        xI := yI := margin
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   347
    ].
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   348
    (x + w - 1) > (xI + (magnification x * image width)) ifTrue:
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   349
    [
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   350
        self clearRectangleX:(xI + (magnification x * image width))
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   351
                           y:y
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   352
                       width:(x + w - (magnification x * image width) - xI)
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   353
                      height:h
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   354
    ].
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   355
    (y + h - 1) > (yI + (magnification y * image height)) ifTrue:
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   356
    [
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   357
        self clearRectangleX:margin
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   358
                           y:(yI + (magnification y * image height))
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   359
                       width:w
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   360
                      height:(y + h - (magnification y * image height) - yI)  
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   361
    ].
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   362
    self drawFrame.
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   363
    self clippingRectangle: nil.
1037
3735af6b5b24 remmeber scrollOffset
Claus Gittinger <cg@exept.de>
parents: 1036
diff changeset
   364
3735af6b5b24 remmeber scrollOffset
Claus Gittinger <cg@exept.de>
parents: 1036
diff changeset
   365
    "Modified: / 31.7.1998 / 02:22:45 / cg"
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   366
! !
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   367
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   368
!ImageEditView methodsFor:'edit modes'!
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   369
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   370
editMode
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   371
737
b703128f2f60 no class var EditMode
tz
parents: 725
diff changeset
   372
    ^editMode ? (editMode := 'point')
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   373
!
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   374
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   375
editMode:aMode
1031
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   376
    "this is concatenated with 'At:' to form the click-
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   377
     operation. I.e. any of 'point', 'box', 'filledBox' ..."
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   378
737
b703128f2f60 no class var EditMode
tz
parents: 725
diff changeset
   379
    editMode := aMode
1031
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   380
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   381
    "Modified: / 29.7.1998 / 18:36:30 / cg"
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   382
!
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   383
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   384
mouseKeyColorMode
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   385
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   386
    ^mouseKeyColorMode printString
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   387
!
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   388
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   389
mouseKeyColorMode:aMode
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   390
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   391
    mouseKeyColorMode := aMode asInteger
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   392
! !
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   393
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   394
!ImageEditView methodsFor:'event handling'!
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   395
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   396
buttonMotion:state x:x y:y
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   397
632
be1ac8ea33a7 checkin from browser
tz
parents: 628
diff changeset
   398
    self drawCursorAt: x@y.
1011
325d334e93c8 added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents: 1006
diff changeset
   399
    state ~~ 0 ifTrue: [
995
cd84d6f8c449 several undos
tz
parents: 994
diff changeset
   400
        (self selectedColor notNil and: [(self imageContainsPoint: x@y) and: [editMode = 'point']])
686
33833bcbb5cd some cleans
tz
parents: 678
diff changeset
   401
            ifTrue: [^self pointAt: x@y]
1011
325d334e93c8 added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents: 1006
diff changeset
   402
    ] ifFalse:[
325d334e93c8 added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents: 1006
diff changeset
   403
        (editMode = 'paste' or:[editMode = 'pasteUnder']) ifTrue: [
325d334e93c8 added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents: 1006
diff changeset
   404
            (self selectedColor notNil and: [self imageContainsPastePoint: x@y]) 
325d334e93c8 added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents: 1006
diff changeset
   405
                ifTrue:  [self drawPasteRectangleAt: x@y]
1019
e68414752bc9 only change the cursor for myself.
Claus Gittinger <cg@exept.de>
parents: 1013
diff changeset
   406
                ifFalse: [self cursor:Cursor stop. self releasePasteDrawing]
1011
325d334e93c8 added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents: 1006
diff changeset
   407
        ]
686
33833bcbb5cd some cleans
tz
parents: 678
diff changeset
   408
    ]
1019
e68414752bc9 only change the cursor for myself.
Claus Gittinger <cg@exept.de>
parents: 1013
diff changeset
   409
e68414752bc9 only change the cursor for myself.
Claus Gittinger <cg@exept.de>
parents: 1013
diff changeset
   410
    "Modified: / 27.7.1998 / 17:45:20 / cg"
624
d98fe4700fc2 checkin from browser
tz
parents: 606
diff changeset
   411
!
255
1dfa8deddaef checkin from browser
Claus Gittinger <cg@exept.de>
parents: 251
diff changeset
   412
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   413
buttonPress:button x:x y:y
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   414
632
be1ac8ea33a7 checkin from browser
tz
parents: 628
diff changeset
   415
    self drawCursorAt: x@y.
995
cd84d6f8c449 several undos
tz
parents: 994
diff changeset
   416
    (self selectedColor notNil and: [self imageContainsPoint: x@y])
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   417
    ifTrue:
822
cace81f0a86b do not overwrite method categories + toggle between mouse button colors
tz
parents: 796
diff changeset
   418
    [   
1011
325d334e93c8 added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents: 1006
diff changeset
   419
        |mouseButtonColorToolBar clr|
325d334e93c8 added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents: 1006
diff changeset
   420
325d334e93c8 added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents: 1006
diff changeset
   421
        self sensor shiftDown ifTrue:[
1031
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   422
            pickedColorHolder notNil ifTrue:[
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   423
                "/ select the color under the cursor, place it into the
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   424
                "/ pickedColorHolder/
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   425
                clr := image colorAt:((x@y)//magnification).
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   426
                pickedColorHolder value:clr
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   427
            ].
1011
325d334e93c8 added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents: 1006
diff changeset
   428
        ] ifFalse:[
325d334e93c8 added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents: 1006
diff changeset
   429
            "/ cg: what a kludge - please change to use a valueHolder,
325d334e93c8 added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents: 1006
diff changeset
   430
            "/ which gets the information ...
325d334e93c8 added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents: 1006
diff changeset
   431
325d334e93c8 added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents: 1006
diff changeset
   432
            mouseKeyColorMode := button.
325d334e93c8 added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents: 1006
diff changeset
   433
            mouseButtonColorToolBar := masterApplication builder componentAt: #MouseButtonColorToolBar.
325d334e93c8 added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents: 1006
diff changeset
   434
            self makeUndo.
325d334e93c8 added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents: 1006
diff changeset
   435
            masterApplication valueOfCanUndo value: true.
325d334e93c8 added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents: 1006
diff changeset
   436
            (mouseButtonColorToolBar itemAt: mouseKeyColorMode) toggleIndication.
325d334e93c8 added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents: 1006
diff changeset
   437
            mouseButtonColorToolBar do: [:i| i updateIndicators].
325d334e93c8 added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents: 1006
diff changeset
   438
            self perform: (editMode, 'At:') asSymbol with: x@y
325d334e93c8 added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents: 1006
diff changeset
   439
        ]
686
33833bcbb5cd some cleans
tz
parents: 678
diff changeset
   440
    ]
995
cd84d6f8c449 several undos
tz
parents: 994
diff changeset
   441
1031
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   442
    "Modified: / 29.7.1998 / 18:39:05 / cg"
632
be1ac8ea33a7 checkin from browser
tz
parents: 628
diff changeset
   443
!
be1ac8ea33a7 checkin from browser
tz
parents: 628
diff changeset
   444
994
5727c2484ecd bugs fixed in undo/mask and point painting/preview and pasting
tz
parents: 877
diff changeset
   445
buttonRelease:button x:x y:y
5727c2484ecd bugs fixed in undo/mask and point painting/preview and pasting
tz
parents: 877
diff changeset
   446
5727c2484ecd bugs fixed in undo/mask and point painting/preview and pasting
tz
parents: 877
diff changeset
   447
    self drawCursorAt: x@y.
995
cd84d6f8c449 several undos
tz
parents: 994
diff changeset
   448
    (self selectedColor notNil and: [self imageContainsPoint: x@y])
994
5727c2484ecd bugs fixed in undo/mask and point painting/preview and pasting
tz
parents: 877
diff changeset
   449
    ifTrue:
5727c2484ecd bugs fixed in undo/mask and point painting/preview and pasting
tz
parents: 877
diff changeset
   450
    [   
5727c2484ecd bugs fixed in undo/mask and point painting/preview and pasting
tz
parents: 877
diff changeset
   451
        image restored.
1011
325d334e93c8 added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents: 1006
diff changeset
   452
325d334e93c8 added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents: 1006
diff changeset
   453
        "/ cg: what a kludge - please change to use a valueHolder,
325d334e93c8 added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents: 1006
diff changeset
   454
        "/ which gets the information ...
994
5727c2484ecd bugs fixed in undo/mask and point painting/preview and pasting
tz
parents: 877
diff changeset
   455
        masterApplication imagePreView invalidate
5727c2484ecd bugs fixed in undo/mask and point painting/preview and pasting
tz
parents: 877
diff changeset
   456
    ]
5727c2484ecd bugs fixed in undo/mask and point painting/preview and pasting
tz
parents: 877
diff changeset
   457
!
5727c2484ecd bugs fixed in undo/mask and point painting/preview and pasting
tz
parents: 877
diff changeset
   458
686
33833bcbb5cd some cleans
tz
parents: 678
diff changeset
   459
pointerLeave:state
33833bcbb5cd some cleans
tz
parents: 678
diff changeset
   460
688
e1c30adb37bf updates coord info label while defining boxes
tz
parents: 686
diff changeset
   461
    super pointerLeave: state.
686
33833bcbb5cd some cleans
tz
parents: 678
diff changeset
   462
1031
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   463
    self updateImageInfo: self imageInfoString.
1019
e68414752bc9 only change the cursor for myself.
Claus Gittinger <cg@exept.de>
parents: 1013
diff changeset
   464
    self cursor:Cursor normal.
995
cd84d6f8c449 several undos
tz
parents: 994
diff changeset
   465
1013
758cfa70edc5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1011
diff changeset
   466
    (editMode = 'paste' or:[editMode = 'pasteUnder']) ifTrue: [self releasePasteDrawing]
995
cd84d6f8c449 several undos
tz
parents: 994
diff changeset
   467
1031
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   468
    "Modified: / 29.7.1998 / 18:27:42 / cg"
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   469
! !
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   470
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   471
!ImageEditView methodsFor:'image - dragging & info'!
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   472
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   473
drawCursorAt: aPoint
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   474
    |clr|
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   475
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   476
    image isNil ifTrue: [
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   477
        self updateImageInfo: self imageInfoString. 
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   478
        self cursor:Cursor stop.
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   479
        ^ self
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   480
    ].
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   481
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   482
    (aPoint x < (image width * magnification) 
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   483
    and:[aPoint y < (image height * magnification)])
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   484
    ifFalse:[
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   485
        self updateImageInfo: self imageInfoString. 
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   486
        self cursor:Cursor stop.
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   487
    ] ifTrue: [
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   488
        clr := image colorAt:aPoint//magnification.
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   489
        self updateImageInfo: (aPoint//magnification) printString 
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   490
                        , ' (red:' 
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   491
                        , clr redByte printString
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   492
                        , ' green:' , clr greenByte printString
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   493
                        , ' blue:' , clr blueByte printString
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   494
                        , ')'.
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   495
        self cursor:Cursor crossHair
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   496
    ].
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   497
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   498
    "Modified: / 29.7.1998 / 18:26:01 / cg"
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   499
!
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   500
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   501
drawCursorAt: aPoint withLabel: aLabel
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   502
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   503
    ((0@0 extent: image extent * magnification) containsPoint: aPoint)
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   504
         ifFalse:[self cursor:Cursor stop]
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   505
         ifTrue: [self cursor:Cursor crossHair].
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   506
     self updateImageInfo: aLabel.
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   507
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   508
    "Modified: / 29.7.1998 / 18:26:04 / cg"
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   509
!
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   510
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   511
updateActivity: something
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   512
    |msg|
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   513
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   514
    msg := something printString.
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   515
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   516
    "/ cg: new code:
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   517
    activityInfoHolder notNil ifTrue:[
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   518
        activityInfoHolder value:msg.
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   519
    ].
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   520
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   521
    "Modified: / 29.7.1998 / 18:41:47 / cg"
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   522
!
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   523
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   524
updateImageInfo: something
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   525
    |msg coordLabel|
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   526
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   527
    msg := something printString.
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   528
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   529
    "/ cg: new code:
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   530
    imageInfoHolder notNil ifTrue:[
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   531
        msg ~= imageInfoHolder value ifTrue:[
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   532
            imageInfoHolder value:msg.
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   533
        ].
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   534
        ^ self
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   535
    ].
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   536
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   537
"/    "/ cg: what a kludge - please change to use a valueHolder,
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   538
"/    "/ which gets the coordinate ...
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   539
"/
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   540
"/    (masterApplication respondsTo: #coordLabel)
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   541
"/    ifTrue:[  
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   542
"/        coordLabel := masterApplication coordLabel.
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   543
"/
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   544
"/        coordLabel label ~= msg
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   545
"/        ifTrue:[         
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   546
"/            coordLabel label: msg.
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   547
"/            "/ coordLabel redraw
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   548
"/        ]
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   549
"/    ]
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   550
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   551
    "Modified: / 29.7.1998 / 19:00:21 / cg"
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   552
! !
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   553
636
d53428252193 revised version
tz
parents: 633
diff changeset
   554
!ImageEditView methodsFor:'image editing'!
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   555
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   556
boxAt: aPoint
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   557
662
61b7601829ea with modal support
tz
parents: 636
diff changeset
   558
    |choosedBox imageBox|
636
d53428252193 revised version
tz
parents: 633
diff changeset
   559
    choosedBox := self drawRectangleStartingAt: aPoint emphasis: #box.
662
61b7601829ea with modal support
tz
parents: 636
diff changeset
   560
    image rectangle: (imageBox := choosedBox origin//magnification extent: (choosedBox extent//magnification)) withColor: self selectedColor.
632
be1ac8ea33a7 checkin from browser
tz
parents: 628
diff changeset
   561
    image restored.
662
61b7601829ea with modal support
tz
parents: 636
diff changeset
   562
    self redraw: (choosedBox expandedBy: 1).
1038
6c0bb03e88a1 no need to invalidate after assign of new image.
Claus Gittinger <cg@exept.de>
parents: 1037
diff changeset
   563
6c0bb03e88a1 no need to invalidate after assign of new image.
Claus Gittinger <cg@exept.de>
parents: 1037
diff changeset
   564
    "/ cg: what a kludge - please change to use a valueHolder,
6c0bb03e88a1 no need to invalidate after assign of new image.
Claus Gittinger <cg@exept.de>
parents: 1037
diff changeset
   565
    "/ which gets the information ...
724
d6f4b89940ed undo disabling
tz
parents: 704
diff changeset
   566
    masterApplication imagePreView redraw: (imageBox expandedBy: 1).
676
fd7918a3e6e6 load + preview redraw errors removed
tz
parents: 674
diff changeset
   567
    modified := true
1038
6c0bb03e88a1 no need to invalidate after assign of new image.
Claus Gittinger <cg@exept.de>
parents: 1037
diff changeset
   568
6c0bb03e88a1 no need to invalidate after assign of new image.
Claus Gittinger <cg@exept.de>
parents: 1037
diff changeset
   569
    "Modified: / 31.7.1998 / 02:46:02 / cg"
632
be1ac8ea33a7 checkin from browser
tz
parents: 628
diff changeset
   570
!
be1ac8ea33a7 checkin from browser
tz
parents: 628
diff changeset
   571
1002
5d2e4c03a78e grid magnification can be changed
tz
parents: 996
diff changeset
   572
changeGridMagnification
5d2e4c03a78e grid magnification can be changed
tz
parents: 996
diff changeset
   573
5d2e4c03a78e grid magnification can be changed
tz
parents: 996
diff changeset
   574
    |box newGridMagnification|
5d2e4c03a78e grid magnification can be changed
tz
parents: 996
diff changeset
   575
    box := EnterBox new.
5d2e4c03a78e grid magnification can be changed
tz
parents: 996
diff changeset
   576
    box title:'Grid Magnification:'.
5d2e4c03a78e grid magnification can be changed
tz
parents: 996
diff changeset
   577
    box okText:'OK'.
5d2e4c03a78e grid magnification can be changed
tz
parents: 996
diff changeset
   578
    box abortText:'Cancel'.
5d2e4c03a78e grid magnification can be changed
tz
parents: 996
diff changeset
   579
    box initialText:GridMagnification x printString.
5d2e4c03a78e grid magnification can be changed
tz
parents: 996
diff changeset
   580
    box showAtPointer.
5d2e4c03a78e grid magnification can be changed
tz
parents: 996
diff changeset
   581
    (box accepted and: [(newGridMagnification := Number readFromString: box contents onError:[2]) notNil])
5d2e4c03a78e grid magnification can be changed
tz
parents: 996
diff changeset
   582
    ifTrue:
5d2e4c03a78e grid magnification can be changed
tz
parents: 996
diff changeset
   583
    [
5d2e4c03a78e grid magnification can be changed
tz
parents: 996
diff changeset
   584
        GridMagnification := (99 min: (2 max: newGridMagnification)) asPoint.
5d2e4c03a78e grid magnification can be changed
tz
parents: 996
diff changeset
   585
        self invalidate
5d2e4c03a78e grid magnification can be changed
tz
parents: 996
diff changeset
   586
    ]
5d2e4c03a78e grid magnification can be changed
tz
parents: 996
diff changeset
   587
!
5d2e4c03a78e grid magnification can be changed
tz
parents: 996
diff changeset
   588
632
be1ac8ea33a7 checkin from browser
tz
parents: 628
diff changeset
   589
copyAt: aPoint
be1ac8ea33a7 checkin from browser
tz
parents: 628
diff changeset
   590
be1ac8ea33a7 checkin from browser
tz
parents: 628
diff changeset
   591
    |choosedBox|
636
d53428252193 revised version
tz
parents: 633
diff changeset
   592
    choosedBox := self drawRectangleStartingAt: aPoint emphasis: #inverseFilledBox.
995
cd84d6f8c449 several undos
tz
parents: 994
diff changeset
   593
    ClipboardMagnification := nil.
632
be1ac8ea33a7 checkin from browser
tz
parents: 628
diff changeset
   594
    Clipboard := image subImageIn: (choosedBox origin//magnification extent: (choosedBox extent//magnification)).
662
61b7601829ea with modal support
tz
parents: 636
diff changeset
   595
    self redraw: (choosedBox expandedBy: 1)    
632
be1ac8ea33a7 checkin from browser
tz
parents: 628
diff changeset
   596
be1ac8ea33a7 checkin from browser
tz
parents: 628
diff changeset
   597
!
be1ac8ea33a7 checkin from browser
tz
parents: 628
diff changeset
   598
1035
5da83bdbd65e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1031
diff changeset
   599
drawPasteRectangleAt: aPoint
5da83bdbd65e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1031
diff changeset
   600
5da83bdbd65e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1031
diff changeset
   601
    |currentPoint gridCorrection extent|
5da83bdbd65e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1031
diff changeset
   602
5da83bdbd65e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1031
diff changeset
   603
    magnification >= GridMagnification ifFalse: [gridCorrection := 0] ifTrue: [gridCorrection := 1].
5da83bdbd65e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1031
diff changeset
   604
    currentPoint := aPoint//magnification*magnification + margin. 
5da83bdbd65e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1031
diff changeset
   605
5da83bdbd65e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1031
diff changeset
   606
    currentPoint ~= lastPastePoint
5da83bdbd65e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1031
diff changeset
   607
    ifTrue:
5da83bdbd65e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1031
diff changeset
   608
    [              
5da83bdbd65e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1031
diff changeset
   609
        ClipboardMagnification isNil ifTrue: [ClipboardMagnification := (Clipboard magnifiedBy: magnification) onDevice: device].   
5da83bdbd65e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1031
diff changeset
   610
5da83bdbd65e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1031
diff changeset
   611
        extent       := ClipboardMagnification extent.
5da83bdbd65e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1031
diff changeset
   612
5da83bdbd65e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1031
diff changeset
   613
        currentPoint := currentPoint - self viewOrigin.
5da83bdbd65e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1031
diff changeset
   614
5da83bdbd65e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1031
diff changeset
   615
        self redraw: ((lastPastePoint ? currentPoint) extent: extent).
5da83bdbd65e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1031
diff changeset
   616
5da83bdbd65e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1031
diff changeset
   617
        (extent x > 200 or: [extent y > 200])
5da83bdbd65e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1031
diff changeset
   618
        ifTrue:
5da83bdbd65e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1031
diff changeset
   619
        [
5da83bdbd65e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1031
diff changeset
   620
            self xoring: [self fillRectangle: (currentPoint extent: extent)]   
5da83bdbd65e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1031
diff changeset
   621
        ]
5da83bdbd65e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1031
diff changeset
   622
        ifFalse:
5da83bdbd65e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1031
diff changeset
   623
        [
5da83bdbd65e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1031
diff changeset
   624
            self displayDeviceForm: ClipboardMagnification x: currentPoint x y: currentPoint y
5da83bdbd65e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1031
diff changeset
   625
        ]  
5da83bdbd65e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1031
diff changeset
   626
    ]. 
5da83bdbd65e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1031
diff changeset
   627
    lastPastePoint := currentPoint.
5da83bdbd65e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1031
diff changeset
   628
5da83bdbd65e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1031
diff changeset
   629
    "Modified: / 29.7.1998 / 02:18:11 / cg"
5da83bdbd65e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1031
diff changeset
   630
!
5da83bdbd65e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1031
diff changeset
   631
5da83bdbd65e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1031
diff changeset
   632
drawRectangleStartingAt: aPoint emphasis: emphasis
5da83bdbd65e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1031
diff changeset
   633
5da83bdbd65e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1031
diff changeset
   634
    |currentPoint currentExtent firstPoint lastCurrentPoint gridCorrection p whichQuarter|
5da83bdbd65e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1031
diff changeset
   635
    firstPoint := currentPoint := lastCurrentPoint := aPoint//magnification*magnification.
5da83bdbd65e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1031
diff changeset
   636
    magnification >= GridMagnification ifFalse: [gridCorrection := 0] ifTrue: [gridCorrection := 1].
5da83bdbd65e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1031
diff changeset
   637
    [device anyButtonPressed]
5da83bdbd65e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1031
diff changeset
   638
    whileTrue:
5da83bdbd65e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1031
diff changeset
   639
    [                                                  
5da83bdbd65e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1031
diff changeset
   640
        currentPoint := (0@0) max: (image extent * magnification min: (p :=  self translation negated + (device translatePoint: self sensor mousePoint from:device rootView id to:self id))).
1053
8d839dff68a9 fixed box emphasis
tz
parents: 1050
diff changeset
   641
        currentPoint := currentPoint//magnification*magnification.
1035
5da83bdbd65e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1031
diff changeset
   642
        currentExtent := (firstPoint - currentPoint) abs.
5da83bdbd65e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1031
diff changeset
   643
        whichQuarter := (firstPoint x - currentPoint x) > 0 
5da83bdbd65e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1031
diff changeset
   644
             ifTrue:  [(firstPoint y - currentPoint y) > 0 ifTrue: ["4"1@1] ifFalse: ["3"1@0]]
5da83bdbd65e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1031
diff changeset
   645
             ifFalse: [(firstPoint y - currentPoint y) > 0 ifTrue: ["1"0@1] ifFalse: ["2"0@0]].
5da83bdbd65e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1031
diff changeset
   646
5da83bdbd65e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1031
diff changeset
   647
        self drawCursorAt: p withLabel: 
5da83bdbd65e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1031
diff changeset
   648
            ((firstPoint//magnification - whichQuarter + 1) printString, 
5da83bdbd65e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1031
diff changeset
   649
            ' to: ', 
5da83bdbd65e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1031
diff changeset
   650
            (currentPoint//magnification + whichQuarter) printString),
5da83bdbd65e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1031
diff changeset
   651
            ' (extent: ',
5da83bdbd65e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1031
diff changeset
   652
            (currentExtent//magnification) printString, ')'.
5da83bdbd65e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1031
diff changeset
   653
5da83bdbd65e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1031
diff changeset
   654
        currentPoint ~= lastCurrentPoint ifTrue:
5da83bdbd65e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1031
diff changeset
   655
        [   
5da83bdbd65e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1031
diff changeset
   656
            emphasis = #inverseFilledBox
5da83bdbd65e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1031
diff changeset
   657
            ifTrue:
5da83bdbd65e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1031
diff changeset
   658
            [
5da83bdbd65e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1031
diff changeset
   659
                self redraw: ((firstPoint min: lastCurrentPoint) - 1 extent: (firstPoint - lastCurrentPoint) abs + 2).
5da83bdbd65e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1031
diff changeset
   660
                self xoring: [self fillRectangle: ((firstPoint min: currentPoint) + margin extent: currentExtent - gridCorrection)]
5da83bdbd65e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1031
diff changeset
   661
            ].
5da83bdbd65e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1031
diff changeset
   662
            emphasis = #box
5da83bdbd65e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1031
diff changeset
   663
            ifTrue:
5da83bdbd65e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1031
diff changeset
   664
            [
5da83bdbd65e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1031
diff changeset
   665
                |origin extent lineWidthY lineWidthX|
5da83bdbd65e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1031
diff changeset
   666
                origin := (firstPoint min: lastCurrentPoint) - 1.
5da83bdbd65e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1031
diff changeset
   667
                extent := (firstPoint - lastCurrentPoint) abs + 2.
5da83bdbd65e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1031
diff changeset
   668
                lineWidthY := extent y min: (magnification y + 2).
5da83bdbd65e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1031
diff changeset
   669
                lineWidthX := extent x min: (magnification x + 2).
5da83bdbd65e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1031
diff changeset
   670
                self redraw: (origin extent: (extent x@lineWidthY)).
5da83bdbd65e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1031
diff changeset
   671
                self redraw: ((origin x@(origin y + extent y - lineWidthY)) extent: (extent x@lineWidthY)).
5da83bdbd65e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1031
diff changeset
   672
                self redraw: ((origin x@(origin y + lineWidthY)) extent: (lineWidthX@(0 max: (extent y - (lineWidthY * 2))))).
5da83bdbd65e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1031
diff changeset
   673
                self redraw: (((origin x + extent x - lineWidthX)@(origin y + lineWidthY)) extent: (lineWidthX@(extent y - (lineWidthY * 2)))).
5da83bdbd65e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1031
diff changeset
   674
                self selectedColor ~= Color noColor
5da83bdbd65e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1031
diff changeset
   675
                    ifTrue: [self paint: self selectedColor]
5da83bdbd65e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1031
diff changeset
   676
                    ifFalse: [self paint: self viewBackground]. 
5da83bdbd65e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1031
diff changeset
   677
                origin := (firstPoint min: currentPoint) + margin.
5da83bdbd65e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1031
diff changeset
   678
                extent := currentExtent - gridCorrection.
5da83bdbd65e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1031
diff changeset
   679
                lineWidthY := extent y min: magnification y.
5da83bdbd65e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1031
diff changeset
   680
                lineWidthX := extent x min: magnification x.
5da83bdbd65e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1031
diff changeset
   681
                (lineWidthY > 0 and: [lineWidthX > 0])
5da83bdbd65e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1031
diff changeset
   682
                ifTrue:
5da83bdbd65e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1031
diff changeset
   683
                [
5da83bdbd65e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1031
diff changeset
   684
                    self fillRectangle: (origin extent: (extent x@lineWidthY)).
5da83bdbd65e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1031
diff changeset
   685
                    self fillRectangle: ((origin x@(origin y + extent y - lineWidthY)) extent: (extent x@lineWidthY)).
5da83bdbd65e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1031
diff changeset
   686
                    self fillRectangle: ((origin x@(origin y + lineWidthY)) extent: (lineWidthX@(0 max: (extent y - (lineWidthY * 2))))).
5da83bdbd65e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1031
diff changeset
   687
                    self fillRectangle: (((origin x + extent x - lineWidthX)@(origin y + lineWidthY)) extent: (lineWidthX@(extent y - (lineWidthY * 2)))).
5da83bdbd65e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1031
diff changeset
   688
                ]
5da83bdbd65e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1031
diff changeset
   689
            ].
5da83bdbd65e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1031
diff changeset
   690
            emphasis = #filledBox
5da83bdbd65e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1031
diff changeset
   691
            ifTrue:
5da83bdbd65e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1031
diff changeset
   692
            [
5da83bdbd65e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1031
diff changeset
   693
                self redraw: ((firstPoint min: lastCurrentPoint) - 1 extent: (firstPoint - lastCurrentPoint) abs + 2).
5da83bdbd65e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1031
diff changeset
   694
                self selectedColor ~= Color noColor
5da83bdbd65e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1031
diff changeset
   695
                    ifTrue: [self paint: self selectedColor]
5da83bdbd65e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1031
diff changeset
   696
                    ifFalse: [self paint: self viewBackground].
5da83bdbd65e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1031
diff changeset
   697
                self fillRectangle: ((firstPoint min: currentPoint) + margin extent: currentExtent - gridCorrection).
5da83bdbd65e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1031
diff changeset
   698
            ].
5da83bdbd65e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1031
diff changeset
   699
        ]. 
5da83bdbd65e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1031
diff changeset
   700
        lastCurrentPoint := currentPoint.
5da83bdbd65e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1031
diff changeset
   701
    ].                  
5da83bdbd65e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1031
diff changeset
   702
5da83bdbd65e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1031
diff changeset
   703
    ^((0@0) max: (firstPoint min: currentPoint)) extent: (firstPoint - currentPoint) abs
5da83bdbd65e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1031
diff changeset
   704
!
5da83bdbd65e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1031
diff changeset
   705
632
be1ac8ea33a7 checkin from browser
tz
parents: 628
diff changeset
   706
fillAt: aPoint
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   707
1047
95f10ea8653d use #withExecuteCursorDo:
Claus Gittinger <cg@exept.de>
parents: 1038
diff changeset
   708
    windowGroup withExecuteCursorDo:
632
be1ac8ea33a7 checkin from browser
tz
parents: 628
diff changeset
   709
    [
be1ac8ea33a7 checkin from browser
tz
parents: 628
diff changeset
   710
        |filledPoints|
1002
5d2e4c03a78e grid magnification can be changed
tz
parents: 996
diff changeset
   711
1031
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   712
        self updateActivity:'Flood filling - press CTRL-y to abort ...'.
632
be1ac8ea33a7 checkin from browser
tz
parents: 628
diff changeset
   713
        [
1031
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   714
            filledPoints := image floodFillAt: aPoint//magnification withColor: self selectedColor.
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   715
            image restored.
1038
6c0bb03e88a1 no need to invalidate after assign of new image.
Claus Gittinger <cg@exept.de>
parents: 1037
diff changeset
   716
6c0bb03e88a1 no need to invalidate after assign of new image.
Claus Gittinger <cg@exept.de>
parents: 1037
diff changeset
   717
            "/ animation effect ...    
1031
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   718
            filledPoints size < 300
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   719
            ifTrue:
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   720
            [
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   721
                filledPoints do: [:p| self redraw: ((p * magnification extent: magnification) expandedBy: 1)]
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   722
            ]
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   723
            ifFalse:
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   724
            [
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   725
                self invalidate
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   726
            ].
1038
6c0bb03e88a1 no need to invalidate after assign of new image.
Claus Gittinger <cg@exept.de>
parents: 1037
diff changeset
   727
            "/ cg: what a kludge - please change to use a valueHolder,
6c0bb03e88a1 no need to invalidate after assign of new image.
Claus Gittinger <cg@exept.de>
parents: 1037
diff changeset
   728
            "/ which gets the information ...
1031
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   729
            masterApplication imagePreView invalidate.
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   730
            modified := true
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   731
        ] valueOnUnwindDo:[
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   732
            self updateActivity:'Flood fill aborted.'
632
be1ac8ea33a7 checkin from browser
tz
parents: 628
diff changeset
   733
        ].
1031
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   734
        self updateActivity:''
632
be1ac8ea33a7 checkin from browser
tz
parents: 628
diff changeset
   735
    ]
1031
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   736
1047
95f10ea8653d use #withExecuteCursorDo:
Claus Gittinger <cg@exept.de>
parents: 1038
diff changeset
   737
    "Modified: / 31.7.1998 / 20:12:45 / cg"
632
be1ac8ea33a7 checkin from browser
tz
parents: 628
diff changeset
   738
!
be1ac8ea33a7 checkin from browser
tz
parents: 628
diff changeset
   739
be1ac8ea33a7 checkin from browser
tz
parents: 628
diff changeset
   740
filledBoxAt: aPoint
be1ac8ea33a7 checkin from browser
tz
parents: 628
diff changeset
   741
662
61b7601829ea with modal support
tz
parents: 636
diff changeset
   742
    |choosedBox imageBox|
636
d53428252193 revised version
tz
parents: 633
diff changeset
   743
    choosedBox := self drawRectangleStartingAt: aPoint emphasis: #filledBox.
662
61b7601829ea with modal support
tz
parents: 636
diff changeset
   744
    image fillRectangle: (imageBox := choosedBox origin//magnification extent: (choosedBox extent//magnification)) withColor: self selectedColor.
632
be1ac8ea33a7 checkin from browser
tz
parents: 628
diff changeset
   745
    image restored.
662
61b7601829ea with modal support
tz
parents: 636
diff changeset
   746
    self redraw: (choosedBox expandedBy: 1).
1038
6c0bb03e88a1 no need to invalidate after assign of new image.
Claus Gittinger <cg@exept.de>
parents: 1037
diff changeset
   747
    "/ cg: what a kludge - please change to use a valueHolder,
6c0bb03e88a1 no need to invalidate after assign of new image.
Claus Gittinger <cg@exept.de>
parents: 1037
diff changeset
   748
    "/ which gets the information ...
724
d6f4b89940ed undo disabling
tz
parents: 704
diff changeset
   749
    masterApplication imagePreView redraw: (imageBox expandedBy: 1).
686
33833bcbb5cd some cleans
tz
parents: 678
diff changeset
   750
    modified := true
1038
6c0bb03e88a1 no need to invalidate after assign of new image.
Claus Gittinger <cg@exept.de>
parents: 1037
diff changeset
   751
6c0bb03e88a1 no need to invalidate after assign of new image.
Claus Gittinger <cg@exept.de>
parents: 1037
diff changeset
   752
    "Modified: / 31.7.1998 / 02:46:20 / cg"
632
be1ac8ea33a7 checkin from browser
tz
parents: 628
diff changeset
   753
!
be1ac8ea33a7 checkin from browser
tz
parents: 628
diff changeset
   754
636
d53428252193 revised version
tz
parents: 633
diff changeset
   755
flipHorizontal
d53428252193 revised version
tz
parents: 633
diff changeset
   756
995
cd84d6f8c449 several undos
tz
parents: 994
diff changeset
   757
    self makeUndo.
725
0e051202859d checkin from browser
tz
parents: 724
diff changeset
   758
    self image: image copy flipHorizontal
636
d53428252193 revised version
tz
parents: 633
diff changeset
   759
d53428252193 revised version
tz
parents: 633
diff changeset
   760
!
d53428252193 revised version
tz
parents: 633
diff changeset
   761
d53428252193 revised version
tz
parents: 633
diff changeset
   762
flipVertical
d53428252193 revised version
tz
parents: 633
diff changeset
   763
995
cd84d6f8c449 several undos
tz
parents: 994
diff changeset
   764
    self makeUndo.
725
0e051202859d checkin from browser
tz
parents: 724
diff changeset
   765
    self image: image copy flipVertical
636
d53428252193 revised version
tz
parents: 633
diff changeset
   766
d53428252193 revised version
tz
parents: 633
diff changeset
   767
!
d53428252193 revised version
tz
parents: 633
diff changeset
   768
d53428252193 revised version
tz
parents: 633
diff changeset
   769
magnifyImage
d53428252193 revised version
tz
parents: 633
diff changeset
   770
d53428252193 revised version
tz
parents: 633
diff changeset
   771
    |box newSize|
d53428252193 revised version
tz
parents: 633
diff changeset
   772
    box := EnterBox new.
d53428252193 revised version
tz
parents: 633
diff changeset
   773
    box title:'Image new size:'.
d53428252193 revised version
tz
parents: 633
diff changeset
   774
    box okText:'OK'.
d53428252193 revised version
tz
parents: 633
diff changeset
   775
    box abortText:'Cancel'.
d53428252193 revised version
tz
parents: 633
diff changeset
   776
    box initialText:image extent printString.
d53428252193 revised version
tz
parents: 633
diff changeset
   777
    box showAtPointer.
d53428252193 revised version
tz
parents: 633
diff changeset
   778
    (box accepted and: [(newSize := Object readFromString: box contents onError:nil) notNil])
d53428252193 revised version
tz
parents: 633
diff changeset
   779
    ifTrue:
d53428252193 revised version
tz
parents: 633
diff changeset
   780
    [
995
cd84d6f8c449 several undos
tz
parents: 994
diff changeset
   781
        self makeUndo.
636
d53428252193 revised version
tz
parents: 633
diff changeset
   782
        self image: (image magnifiedBy: newSize/image extent)
686
33833bcbb5cd some cleans
tz
parents: 678
diff changeset
   783
    ]
636
d53428252193 revised version
tz
parents: 633
diff changeset
   784
!
d53428252193 revised version
tz
parents: 633
diff changeset
   785
d53428252193 revised version
tz
parents: 633
diff changeset
   786
negativeImage
d53428252193 revised version
tz
parents: 633
diff changeset
   787
995
cd84d6f8c449 several undos
tz
parents: 994
diff changeset
   788
    self makeUndo.
725
0e051202859d checkin from browser
tz
parents: 724
diff changeset
   789
    self image: image copy negative
636
d53428252193 revised version
tz
parents: 633
diff changeset
   790
!
d53428252193 revised version
tz
parents: 633
diff changeset
   791
d53428252193 revised version
tz
parents: 633
diff changeset
   792
pasteAt: aPoint
1011
325d334e93c8 added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents: 1006
diff changeset
   793
    "paste the image in the clipboard at aPoint"
325d334e93c8 added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents: 1006
diff changeset
   794
325d334e93c8 added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents: 1006
diff changeset
   795
    self pasteAt:aPoint modeUnder:false.
325d334e93c8 added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents: 1006
diff changeset
   796
!
325d334e93c8 added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents: 1006
diff changeset
   797
325d334e93c8 added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents: 1006
diff changeset
   798
pasteAt: aPoint modeUnder:modeUnder
325d334e93c8 added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents: 1006
diff changeset
   799
    "paste the image in the clipboard at aPoint"
636
d53428252193 revised version
tz
parents: 633
diff changeset
   800
995
cd84d6f8c449 several undos
tz
parents: 994
diff changeset
   801
    ClipboardMagnification isNil ifTrue: [^self].
cd84d6f8c449 several undos
tz
parents: 994
diff changeset
   802
636
d53428252193 revised version
tz
parents: 633
diff changeset
   803
    Object errorSignal handle:
d53428252193 revised version
tz
parents: 633
diff changeset
   804
    [:ex|
1011
325d334e93c8 added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents: 1006
diff changeset
   805
        ex signal == Image unrepresentableColorSignal ifFalse:[
325d334e93c8 added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents: 1006
diff changeset
   806
            ex reject
325d334e93c8 added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents: 1006
diff changeset
   807
        ].
995
cd84d6f8c449 several undos
tz
parents: 994
diff changeset
   808
        self undo.
1011
325d334e93c8 added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents: 1006
diff changeset
   809
        self warn: 'Paste failed!!\Increasing the images depth might help.' withCRs. 
636
d53428252193 revised version
tz
parents: 633
diff changeset
   810
    ] 
d53428252193 revised version
tz
parents: 633
diff changeset
   811
    do:
d53428252193 revised version
tz
parents: 633
diff changeset
   812
    [   
1047
95f10ea8653d use #withExecuteCursorDo:
Claus Gittinger <cg@exept.de>
parents: 1038
diff changeset
   813
        windowGroup withExecuteCursorDo:[
1028
4dfe1c6cbc48 fixed paste-drag display (when scrolled)
Claus Gittinger <cg@exept.de>
parents: 1027
diff changeset
   814
            |choosedBox imagePoint imgX imgY copiedImage imageBox presentClr newColorMap|
995
cd84d6f8c449 several undos
tz
parents: 994
diff changeset
   815
cd84d6f8c449 several undos
tz
parents: 994
diff changeset
   816
1011
325d334e93c8 added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents: 1006
diff changeset
   817
            choosedBox := self drawRectangleStartingAt: aPoint emphasis: #inverseFilledBox.
325d334e93c8 added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents: 1006
diff changeset
   818
325d334e93c8 added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents: 1006
diff changeset
   819
            imagePoint := choosedBox origin//magnification.
325d334e93c8 added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents: 1006
diff changeset
   820
325d334e93c8 added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents: 1006
diff changeset
   821
            copiedImage := Clipboard copy.
325d334e93c8 added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents: 1006
diff changeset
   822
325d334e93c8 added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents: 1006
diff changeset
   823
            copiedImage usedValues do:[:pixel |
1028
4dfe1c6cbc48 fixed paste-drag display (when scrolled)
Claus Gittinger <cg@exept.de>
parents: 1027
diff changeset
   824
                |pastedColor oldColorMap|
995
cd84d6f8c449 several undos
tz
parents: 994
diff changeset
   825
1011
325d334e93c8 added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents: 1006
diff changeset
   826
                pastedColor := (copiedImage colorMap at: pixel+1).
1028
4dfe1c6cbc48 fixed paste-drag display (when scrolled)
Claus Gittinger <cg@exept.de>
parents: 1027
diff changeset
   827
                oldColorMap := image colorMap.
4dfe1c6cbc48 fixed paste-drag display (when scrolled)
Claus Gittinger <cg@exept.de>
parents: 1027
diff changeset
   828
4dfe1c6cbc48 fixed paste-drag display (when scrolled)
Claus Gittinger <cg@exept.de>
parents: 1027
diff changeset
   829
                (oldColorMap detect: [:clr| clr = pastedColor] ifNone: nil) isNil
1011
325d334e93c8 added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents: 1006
diff changeset
   830
                ifTrue:
325d334e93c8 added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents: 1006
diff changeset
   831
                [        
1028
4dfe1c6cbc48 fixed paste-drag display (when scrolled)
Claus Gittinger <cg@exept.de>
parents: 1027
diff changeset
   832
                    oldColorMap size < (1 bitShift:image depth) ifTrue:[
1011
325d334e93c8 added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents: 1006
diff changeset
   833
                        "/ add to colormap
325d334e93c8 added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents: 1006
diff changeset
   834
                        newColorMap isNil ifTrue:[
1028
4dfe1c6cbc48 fixed paste-drag display (when scrolled)
Claus Gittinger <cg@exept.de>
parents: 1027
diff changeset
   835
                            newColorMap := oldColorMap asOrderedCollection.
1011
325d334e93c8 added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents: 1006
diff changeset
   836
                        ].
325d334e93c8 added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents: 1006
diff changeset
   837
                        newColorMap add:pastedColor.
325d334e93c8 added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents: 1006
diff changeset
   838
"/                        Transcript showCR:'adding color:' , pastedColor displayString , ' to targets colorMap'.
325d334e93c8 added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents: 1006
diff changeset
   839
                    ] ifFalse:[
325d334e93c8 added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents: 1006
diff changeset
   840
"/                        Transcript showCR:'color:' , pastedColor displayString , ' not found in targets colorMap'.
325d334e93c8 added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents: 1006
diff changeset
   841
                        copiedImage colorMap at: pixel+1 put: Color black
325d334e93c8 added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents: 1006
diff changeset
   842
                    ]
325d334e93c8 added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents: 1006
diff changeset
   843
                ]
325d334e93c8 added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents: 1006
diff changeset
   844
            ].
995
cd84d6f8c449 several undos
tz
parents: 994
diff changeset
   845
1011
325d334e93c8 added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents: 1006
diff changeset
   846
            newColorMap notNil ifTrue:[
325d334e93c8 added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents: 1006
diff changeset
   847
                image colorMap:(Colormap fromColors:newColorMap).
325d334e93c8 added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents: 1006
diff changeset
   848
            ].
325d334e93c8 added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents: 1006
diff changeset
   849
325d334e93c8 added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents: 1006
diff changeset
   850
            copiedImage := image class fromImage: copiedImage.
325d334e93c8 added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents: 1006
diff changeset
   851
            (newColorMap isNil and:[modeUnder not]) ifTrue:[
325d334e93c8 added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents: 1006
diff changeset
   852
                image copyFrom: copiedImage x:0 y:0 toX: imagePoint x y: imagePoint y width: copiedImage width height: copiedImage height.
325d334e93c8 added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents: 1006
diff changeset
   853
            ] ifFalse:[
994
5727c2484ecd bugs fixed in undo/mask and point painting/preview and pasting
tz
parents: 877
diff changeset
   854
1028
4dfe1c6cbc48 fixed paste-drag display (when scrolled)
Claus Gittinger <cg@exept.de>
parents: 1027
diff changeset
   855
                imgX := imagePoint x.
4dfe1c6cbc48 fixed paste-drag display (when scrolled)
Claus Gittinger <cg@exept.de>
parents: 1027
diff changeset
   856
                imgY := imagePoint y.
4dfe1c6cbc48 fixed paste-drag display (when scrolled)
Claus Gittinger <cg@exept.de>
parents: 1027
diff changeset
   857
1011
325d334e93c8 added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents: 1006
diff changeset
   858
                0 to:copiedImage height-1 do:[:y |
325d334e93c8 added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents: 1006
diff changeset
   859
                    0 to:copiedImage width-1 do:[:x |
325d334e93c8 added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents: 1006
diff changeset
   860
                        |wasMasked newMasked dstX dstY oldColor|
325d334e93c8 added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents: 1006
diff changeset
   861
1028
4dfe1c6cbc48 fixed paste-drag display (when scrolled)
Claus Gittinger <cg@exept.de>
parents: 1027
diff changeset
   862
                        dstX := imgX + x.
4dfe1c6cbc48 fixed paste-drag display (when scrolled)
Claus Gittinger <cg@exept.de>
parents: 1027
diff changeset
   863
                        dstY := imgY + y.
1011
325d334e93c8 added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents: 1006
diff changeset
   864
                        wasMasked := (image maskAtX:dstX y:dstY) == 0.
325d334e93c8 added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents: 1006
diff changeset
   865
                        newMasked := (copiedImage maskAtX:x y:y) == 0.
994
5727c2484ecd bugs fixed in undo/mask and point painting/preview and pasting
tz
parents: 877
diff changeset
   866
1011
325d334e93c8 added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents: 1006
diff changeset
   867
                        "/ with modeUnder, 
325d334e93c8 added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents: 1006
diff changeset
   868
                        "/ only replace, if its either unmasked,
325d334e93c8 added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents: 1006
diff changeset
   869
                        "/ or the current drawing color.
325d334e93c8 added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents: 1006
diff changeset
   870
                        (modeUnder not
325d334e93c8 added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents: 1006
diff changeset
   871
                        or:[wasMasked
325d334e93c8 added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents: 1006
diff changeset
   872
                        or:[(oldColor := image colorAtX:dstX y:dstY) = (selectColors at:1)]])
325d334e93c8 added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents: 1006
diff changeset
   873
                        ifTrue:[
325d334e93c8 added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents: 1006
diff changeset
   874
                            image 
325d334e93c8 added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents: 1006
diff changeset
   875
                                colorAtX:dstX
325d334e93c8 added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents: 1006
diff changeset
   876
                                       y:dstY
325d334e93c8 added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents: 1006
diff changeset
   877
                                     put:(copiedImage colorAtX:x y:y).
325d334e93c8 added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents: 1006
diff changeset
   878
                            (wasMasked and:[newMasked not]) ifTrue:[
325d334e93c8 added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents: 1006
diff changeset
   879
                                image mask pixelAtX:dstX y:dstY put:1
325d334e93c8 added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents: 1006
diff changeset
   880
                            ].
325d334e93c8 added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents: 1006
diff changeset
   881
                        ]
325d334e93c8 added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents: 1006
diff changeset
   882
                    ]
325d334e93c8 added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents: 1006
diff changeset
   883
                ].
325d334e93c8 added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents: 1006
diff changeset
   884
            ].
325d334e93c8 added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents: 1006
diff changeset
   885
            image restored.
325d334e93c8 added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents: 1006
diff changeset
   886
            self redraw: (imageBox := (imagePoint * magnification extent: (Clipboard extent * magnification)) expandedBy: 1@1).
1028
4dfe1c6cbc48 fixed paste-drag display (when scrolled)
Claus Gittinger <cg@exept.de>
parents: 1027
diff changeset
   887
"/            masterApplication imagePreView redraw: (imageBox expandedBy: 1).
1011
325d334e93c8 added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents: 1006
diff changeset
   888
            modified := true
325d334e93c8 added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents: 1006
diff changeset
   889
        ]
1028
4dfe1c6cbc48 fixed paste-drag display (when scrolled)
Claus Gittinger <cg@exept.de>
parents: 1027
diff changeset
   890
   ]
4dfe1c6cbc48 fixed paste-drag display (when scrolled)
Claus Gittinger <cg@exept.de>
parents: 1027
diff changeset
   891
1047
95f10ea8653d use #withExecuteCursorDo:
Claus Gittinger <cg@exept.de>
parents: 1038
diff changeset
   892
    "Modified: / 31.7.1998 / 20:12:49 / cg"
636
d53428252193 revised version
tz
parents: 633
diff changeset
   893
!
d53428252193 revised version
tz
parents: 633
diff changeset
   894
1011
325d334e93c8 added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents: 1006
diff changeset
   895
pasteUnderAt: aPoint
325d334e93c8 added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents: 1006
diff changeset
   896
    "pasteUnder the image in the clipboard at aPoint.
325d334e93c8 added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents: 1006
diff changeset
   897
     In this mode, only pixels which are not equal to
325d334e93c8 added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents: 1006
diff changeset
   898
     the current color or masked are pasted."
325d334e93c8 added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents: 1006
diff changeset
   899
325d334e93c8 added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents: 1006
diff changeset
   900
    self pasteAt:aPoint modeUnder:true.
325d334e93c8 added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents: 1006
diff changeset
   901
!
325d334e93c8 added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents: 1006
diff changeset
   902
636
d53428252193 revised version
tz
parents: 633
diff changeset
   903
pointAt: aPoint
d53428252193 revised version
tz
parents: 633
diff changeset
   904
662
61b7601829ea with modal support
tz
parents: 636
diff changeset
   905
    |imagePoint imageBox|
636
d53428252193 revised version
tz
parents: 633
diff changeset
   906
    imagePoint := aPoint//magnification.
d53428252193 revised version
tz
parents: 633
diff changeset
   907
    image atImageAndMask: imagePoint put: self selectedColor.
662
61b7601829ea with modal support
tz
parents: 636
diff changeset
   908
    self redraw: (imageBox := (imagePoint * magnification extent: magnification) expandedBy: 1).
796
b68b09ddc62b preview redrawing
tz
parents: 783
diff changeset
   909
    modified := true.
b68b09ddc62b preview redrawing
tz
parents: 783
diff changeset
   910
636
d53428252193 revised version
tz
parents: 633
diff changeset
   911
!
d53428252193 revised version
tz
parents: 633
diff changeset
   912
d53428252193 revised version
tz
parents: 633
diff changeset
   913
resizeImage
d53428252193 revised version
tz
parents: 633
diff changeset
   914
d53428252193 revised version
tz
parents: 633
diff changeset
   915
    |box newSize|
d53428252193 revised version
tz
parents: 633
diff changeset
   916
    box := EnterBox new.
d53428252193 revised version
tz
parents: 633
diff changeset
   917
    box title:'Image new size:'.
d53428252193 revised version
tz
parents: 633
diff changeset
   918
    box okText:'OK'.
d53428252193 revised version
tz
parents: 633
diff changeset
   919
    box abortText:'Cancel'.
d53428252193 revised version
tz
parents: 633
diff changeset
   920
    box initialText:image extent printString.
d53428252193 revised version
tz
parents: 633
diff changeset
   921
    box showAtPointer.
d53428252193 revised version
tz
parents: 633
diff changeset
   922
    (box accepted and: [(newSize := Object readFromString: box contents onError:nil) notNil])
d53428252193 revised version
tz
parents: 633
diff changeset
   923
    ifTrue:
d53428252193 revised version
tz
parents: 633
diff changeset
   924
    [
d53428252193 revised version
tz
parents: 633
diff changeset
   925
        |newImage|
d53428252193 revised version
tz
parents: 633
diff changeset
   926
        newImage := image class width: newSize x height: newSize y depth: image depth.
d53428252193 revised version
tz
parents: 633
diff changeset
   927
        newImage photometric:image photometric.
d53428252193 revised version
tz
parents: 633
diff changeset
   928
        newImage colorMap:image colorMap copy.
d53428252193 revised version
tz
parents: 633
diff changeset
   929
        newImage bits: (ByteArray new: newImage bytesPerRow * newSize y).
d53428252193 revised version
tz
parents: 633
diff changeset
   930
d53428252193 revised version
tz
parents: 633
diff changeset
   931
        image mask notNil
d53428252193 revised version
tz
parents: 633
diff changeset
   932
        ifTrue: 
d53428252193 revised version
tz
parents: 633
diff changeset
   933
        [
d53428252193 revised version
tz
parents: 633
diff changeset
   934
            |newMaskImage|
d53428252193 revised version
tz
parents: 633
diff changeset
   935
            newMaskImage := Depth1Image width: newSize x height: newSize y.
d53428252193 revised version
tz
parents: 633
diff changeset
   936
            newMaskImage photometric: image mask photometric.
d53428252193 revised version
tz
parents: 633
diff changeset
   937
            newMaskImage colorMap: image mask colorMap copy.
d53428252193 revised version
tz
parents: 633
diff changeset
   938
            newMaskImage bits:(ByteArray new: newMaskImage bytesPerRow * newSize y).
d53428252193 revised version
tz
parents: 633
diff changeset
   939
            newImage mask: newMaskImage
d53428252193 revised version
tz
parents: 633
diff changeset
   940
        ].
d53428252193 revised version
tz
parents: 633
diff changeset
   941
d53428252193 revised version
tz
parents: 633
diff changeset
   942
        newImage copyFrom:image x:0 y:0 toX:0 y:0 width: (image width min:newSize x) height: (image height min:newSize y).
995
cd84d6f8c449 several undos
tz
parents: 994
diff changeset
   943
        self makeUndo.
827
155b4ed10c7c remember the file name if changed
tz
parents: 823
diff changeset
   944
        self image: newImage.
686
33833bcbb5cd some cleans
tz
parents: 678
diff changeset
   945
    ]
636
d53428252193 revised version
tz
parents: 633
diff changeset
   946
!
d53428252193 revised version
tz
parents: 633
diff changeset
   947
d53428252193 revised version
tz
parents: 633
diff changeset
   948
rotateImage
d53428252193 revised version
tz
parents: 633
diff changeset
   949
d53428252193 revised version
tz
parents: 633
diff changeset
   950
    |box rotation|
d53428252193 revised version
tz
parents: 633
diff changeset
   951
    box := EnterBox new.
1031
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   952
    box title:'Rotate by (degrees, clockwise):'.
636
d53428252193 revised version
tz
parents: 633
diff changeset
   953
    box okText:'OK'.
d53428252193 revised version
tz
parents: 633
diff changeset
   954
    box abortText:'Cancel'.
d53428252193 revised version
tz
parents: 633
diff changeset
   955
    box initialText: '0'.
d53428252193 revised version
tz
parents: 633
diff changeset
   956
    box showAtPointer.
d53428252193 revised version
tz
parents: 633
diff changeset
   957
    (box accepted and: [(rotation := Object readFromString: box contents onError:nil) notNil])
d53428252193 revised version
tz
parents: 633
diff changeset
   958
    ifTrue:
d53428252193 revised version
tz
parents: 633
diff changeset
   959
    [   Object errorSignal handle:
d53428252193 revised version
tz
parents: 633
diff changeset
   960
        [:ex|
1031
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   961
            self warn: 'Image rotation failed!!\' withCRs, 'Increaing the image depth could help.'
636
d53428252193 revised version
tz
parents: 633
diff changeset
   962
        ] 
d53428252193 revised version
tz
parents: 633
diff changeset
   963
        do:
d53428252193 revised version
tz
parents: 633
diff changeset
   964
        [   
995
cd84d6f8c449 several undos
tz
parents: 994
diff changeset
   965
            self makeUndo.
636
d53428252193 revised version
tz
parents: 633
diff changeset
   966
            self image: (image hardRotated: rotation)
d53428252193 revised version
tz
parents: 633
diff changeset
   967
        ]
686
33833bcbb5cd some cleans
tz
parents: 678
diff changeset
   968
    ]
1031
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   969
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   970
    "Modified: / 29.7.1998 / 18:21:14 / cg"
636
d53428252193 revised version
tz
parents: 633
diff changeset
   971
!
d53428252193 revised version
tz
parents: 633
diff changeset
   972
d53428252193 revised version
tz
parents: 633
diff changeset
   973
undo
d53428252193 revised version
tz
parents: 633
diff changeset
   974
995
cd84d6f8c449 several undos
tz
parents: 994
diff changeset
   975
    undoImages notEmpty
636
d53428252193 revised version
tz
parents: 633
diff changeset
   976
    ifTrue:
725
0e051202859d checkin from browser
tz
parents: 724
diff changeset
   977
    [           
1047
95f10ea8653d use #withExecuteCursorDo:
Claus Gittinger <cg@exept.de>
parents: 1038
diff changeset
   978
        windowGroup withExecuteCursorDo:[
1031
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   979
            modified := false. 
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   980
            self image: undoImages removeLast.
1038
6c0bb03e88a1 no need to invalidate after assign of new image.
Claus Gittinger <cg@exept.de>
parents: 1037
diff changeset
   981
            "/ cg: what a kludge - please change to use a valueHolder,
6c0bb03e88a1 no need to invalidate after assign of new image.
Claus Gittinger <cg@exept.de>
parents: 1037
diff changeset
   982
            masterApplication notNil ifTrue:[
6c0bb03e88a1 no need to invalidate after assign of new image.
Claus Gittinger <cg@exept.de>
parents: 1037
diff changeset
   983
                masterApplication listOfColors contents: image colorMap.
6c0bb03e88a1 no need to invalidate after assign of new image.
Claus Gittinger <cg@exept.de>
parents: 1037
diff changeset
   984
                masterApplication findColorMapMode.
6c0bb03e88a1 no need to invalidate after assign of new image.
Claus Gittinger <cg@exept.de>
parents: 1037
diff changeset
   985
                undoImages isEmpty ifTrue: [masterApplication valueOfCanUndo value: false].
6c0bb03e88a1 no need to invalidate after assign of new image.
Claus Gittinger <cg@exept.de>
parents: 1037
diff changeset
   986
            ].
6c0bb03e88a1 no need to invalidate after assign of new image.
Claus Gittinger <cg@exept.de>
parents: 1037
diff changeset
   987
            "/ cg: not needed - image: already does it.
6c0bb03e88a1 no need to invalidate after assign of new image.
Claus Gittinger <cg@exept.de>
parents: 1037
diff changeset
   988
"/            self invalidate
688
e1c30adb37bf updates coord info label while defining boxes
tz
parents: 686
diff changeset
   989
        ]
636
d53428252193 revised version
tz
parents: 633
diff changeset
   990
    ]
1038
6c0bb03e88a1 no need to invalidate after assign of new image.
Claus Gittinger <cg@exept.de>
parents: 1037
diff changeset
   991
1047
95f10ea8653d use #withExecuteCursorDo:
Claus Gittinger <cg@exept.de>
parents: 1038
diff changeset
   992
    "Modified: / 31.7.1998 / 20:12:58 / cg"
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   993
! !
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   994
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   995
!ImageEditView methodsFor:'image setting'!
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   996
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   997
image:anImage
1031
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   998
    |retVal|
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   999
688
e1c30adb37bf updates coord info label while defining boxes
tz
parents: 686
diff changeset
  1000
    anImage isImage
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
  1001
    ifTrue:
725
0e051202859d checkin from browser
tz
parents: 724
diff changeset
  1002
    [           
688
e1c30adb37bf updates coord info label while defining boxes
tz
parents: 686
diff changeset
  1003
        (image isNil or: [self checkModified])
e1c30adb37bf updates coord info label while defining boxes
tz
parents: 686
diff changeset
  1004
        ifTrue:
e1c30adb37bf updates coord info label while defining boxes
tz
parents: 686
diff changeset
  1005
        [
827
155b4ed10c7c remember the file name if changed
tz
parents: 823
diff changeset
  1006
            |fileName|
796
b68b09ddc62b preview redrawing
tz
parents: 783
diff changeset
  1007
            masterApplication notNil 
b68b09ddc62b preview redrawing
tz
parents: 783
diff changeset
  1008
            ifTrue: 
b68b09ddc62b preview redrawing
tz
parents: 783
diff changeset
  1009
            [
995
cd84d6f8c449 several undos
tz
parents: 994
diff changeset
  1010
                undoImages notEmpty ifTrue: [masterApplication valueOfCanUndo value: true].
796
b68b09ddc62b preview redrawing
tz
parents: 783
diff changeset
  1011
                masterApplication imagePreView image: anImage
b68b09ddc62b preview redrawing
tz
parents: 783
diff changeset
  1012
            ].
827
155b4ed10c7c remember the file name if changed
tz
parents: 823
diff changeset
  1013
            image notNil
155b4ed10c7c remember the file name if changed
tz
parents: 823
diff changeset
  1014
            ifTrue:
155b4ed10c7c remember the file name if changed
tz
parents: 823
diff changeset
  1015
            [
155b4ed10c7c remember the file name if changed
tz
parents: 823
diff changeset
  1016
                fileName := image fileName.
155b4ed10c7c remember the file name if changed
tz
parents: 823
diff changeset
  1017
                anImage fileName isNil ifTrue: [anImage fileName: fileName].
155b4ed10c7c remember the file name if changed
tz
parents: 823
diff changeset
  1018
            ].
688
e1c30adb37bf updates coord info label while defining boxes
tz
parents: 686
diff changeset
  1019
            super image: anImage.
1031
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
  1020
            retVal := self.
688
e1c30adb37bf updates coord info label while defining boxes
tz
parents: 686
diff changeset
  1021
        ].
674
f24ca336b717 if none image found for loading clear image
tz
parents: 662
diff changeset
  1022
    ]
f24ca336b717 if none image found for loading clear image
tz
parents: 662
diff changeset
  1023
    ifFalse:
f24ca336b717 if none image found for loading clear image
tz
parents: 662
diff changeset
  1024
    [
f24ca336b717 if none image found for loading clear image
tz
parents: 662
diff changeset
  1025
        super image: nil.
1031
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
  1026
    ].
1025
4470f3ad349f update the image label, when a new image is assigned.
Claus Gittinger <cg@exept.de>
parents: 1019
diff changeset
  1027
1031
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
  1028
    self updateImageInfo: self imageInfoString. 
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
  1029
    ^ retVal
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
  1030
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
  1031
    "Modified: / 29.7.1998 / 18:27:31 / cg"
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
  1032
!
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
  1033
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
  1034
loadFromFile: aFileName
624
d98fe4700fc2 checkin from browser
tz
parents: 606
diff changeset
  1035
676
fd7918a3e6e6 load + preview redraw errors removed
tz
parents: 674
diff changeset
  1036
    aFileName isNil ifTrue: [^nil].
624
d98fe4700fc2 checkin from browser
tz
parents: 606
diff changeset
  1037
    Object errorSignal handle:
d98fe4700fc2 checkin from browser
tz
parents: 606
diff changeset
  1038
    [:exeption|
674
f24ca336b717 if none image found for loading clear image
tz
parents: 662
diff changeset
  1039
        modified := false.
632
be1ac8ea33a7 checkin from browser
tz
parents: 628
diff changeset
  1040
        self warn: exeption errorString.
624
d98fe4700fc2 checkin from browser
tz
parents: 606
diff changeset
  1041
        ^nil
d98fe4700fc2 checkin from browser
tz
parents: 606
diff changeset
  1042
    ] 
d98fe4700fc2 checkin from browser
tz
parents: 606
diff changeset
  1043
    do:
676
fd7918a3e6e6 load + preview redraw errors removed
tz
parents: 674
diff changeset
  1044
    [ 
fd7918a3e6e6 load + preview redraw errors removed
tz
parents: 674
diff changeset
  1045
        |imageFromFile|
fd7918a3e6e6 load + preview redraw errors removed
tz
parents: 674
diff changeset
  1046
        (imageFromFile := Image fromFile: aFileName) notNil
632
be1ac8ea33a7 checkin from browser
tz
parents: 628
diff changeset
  1047
        ifTrue:
be1ac8ea33a7 checkin from browser
tz
parents: 628
diff changeset
  1048
        [
995
cd84d6f8c449 several undos
tz
parents: 994
diff changeset
  1049
            self releaseUndos.
676
fd7918a3e6e6 load + preview redraw errors removed
tz
parents: 674
diff changeset
  1050
            self image: imageFromFile. 
632
be1ac8ea33a7 checkin from browser
tz
parents: 628
diff changeset
  1051
            imageReaderClass := ImageReader allSubclasses
be1ac8ea33a7 checkin from browser
tz
parents: 628
diff changeset
  1052
                detect: [:cls| cls isValidImageFile: aFileName]
be1ac8ea33a7 checkin from browser
tz
parents: 628
diff changeset
  1053
                ifNone: [self error: 'Unknown image file format!!']
be1ac8ea33a7 checkin from browser
tz
parents: 628
diff changeset
  1054
        ]
be1ac8ea33a7 checkin from browser
tz
parents: 628
diff changeset
  1055
        ifFalse:
be1ac8ea33a7 checkin from browser
tz
parents: 628
diff changeset
  1056
        [
1031
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
  1057
            self error: 'Not an image file (or unrecognized format) !!'
632
be1ac8ea33a7 checkin from browser
tz
parents: 628
diff changeset
  1058
        ]
676
fd7918a3e6e6 load + preview redraw errors removed
tz
parents: 674
diff changeset
  1059
    ]
1031
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
  1060
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
  1061
    "Modified: / 29.7.1998 / 18:09:13 / cg"
624
d98fe4700fc2 checkin from browser
tz
parents: 606
diff changeset
  1062
!
255
1dfa8deddaef checkin from browser
Claus Gittinger <cg@exept.de>
parents: 251
diff changeset
  1063
633
594edef86630 revised version
tz
parents: 632
diff changeset
  1064
loadFromMessage: aMessage
594edef86630 revised version
tz
parents: 632
diff changeset
  1065
594edef86630 revised version
tz
parents: 632
diff changeset
  1066
    (self resourceMessage: aMessage) isNil
594edef86630 revised version
tz
parents: 632
diff changeset
  1067
    ifTrue:
594edef86630 revised version
tz
parents: 632
diff changeset
  1068
    [
594edef86630 revised version
tz
parents: 632
diff changeset
  1069
        ^nil
594edef86630 revised version
tz
parents: 632
diff changeset
  1070
    ].
624
d98fe4700fc2 checkin from browser
tz
parents: 606
diff changeset
  1071
633
594edef86630 revised version
tz
parents: 632
diff changeset
  1072
    ^self loadfromClass: resourceClass andSelector: resourceSelector
594edef86630 revised version
tz
parents: 632
diff changeset
  1073
594edef86630 revised version
tz
parents: 632
diff changeset
  1074
   
594edef86630 revised version
tz
parents: 632
diff changeset
  1075
!
594edef86630 revised version
tz
parents: 632
diff changeset
  1076
594edef86630 revised version
tz
parents: 632
diff changeset
  1077
loadfromClass: aClassOrSymbol andSelector: aStringOrSymbol
594edef86630 revised version
tz
parents: 632
diff changeset
  1078
678
9afa8810a8be image must not be nil after load failure
tz
parents: 676
diff changeset
  1079
    |aClass| 
9afa8810a8be image must not be nil after load failure
tz
parents: 676
diff changeset
  1080
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
  1081
    imageReaderClass := nil.
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
  1082
    self resourceClass: aClassOrSymbol.
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
  1083
    self resourceSelector: aStringOrSymbol.
678
9afa8810a8be image must not be nil after load failure
tz
parents: 676
diff changeset
  1084
9afa8810a8be image must not be nil after load failure
tz
parents: 676
diff changeset
  1085
    ((aClass := Smalltalk at: resourceClass) isClass and: 
9afa8810a8be image must not be nil after load failure
tz
parents: 676
diff changeset
  1086
    [aClass class implements: resourceSelector])
624
d98fe4700fc2 checkin from browser
tz
parents: 606
diff changeset
  1087
    ifTrue:
d98fe4700fc2 checkin from browser
tz
parents: 606
diff changeset
  1088
    [ 
995
cd84d6f8c449 several undos
tz
parents: 994
diff changeset
  1089
        self releaseUndos.
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
  1090
        ^self image: (aClass perform: resourceSelector) copy
674
f24ca336b717 if none image found for loading clear image
tz
parents: 662
diff changeset
  1091
    ]
f24ca336b717 if none image found for loading clear image
tz
parents: 662
diff changeset
  1092
    ifFalse:
f24ca336b717 if none image found for loading clear image
tz
parents: 662
diff changeset
  1093
    [
f24ca336b717 if none image found for loading clear image
tz
parents: 662
diff changeset
  1094
        modified := false.
f24ca336b717 if none image found for loading clear image
tz
parents: 662
diff changeset
  1095
        ^nil
f24ca336b717 if none image found for loading clear image
tz
parents: 662
diff changeset
  1096
    ]
f24ca336b717 if none image found for loading clear image
tz
parents: 662
diff changeset
  1097
161
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
  1098
! !
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
  1099
1
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
  1100
!ImageEditView methodsFor:'initialization'!
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
  1101
161
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
  1102
initialize
624
d98fe4700fc2 checkin from browser
tz
parents: 606
diff changeset
  1103
161
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
  1104
    super initialize.
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
  1105
686
33833bcbb5cd some cleans
tz
parents: 678
diff changeset
  1106
    self enableMotionEvents.
995
cd84d6f8c449 several undos
tz
parents: 994
diff changeset
  1107
1036
d860072f3b49 gridMag default.
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
  1108
    GridMagnification := GridMagnification ? (8@8).
995
cd84d6f8c449 several undos
tz
parents: 994
diff changeset
  1109
    MaxUndos          := MaxUndos ? 3.
cd84d6f8c449 several undos
tz
parents: 994
diff changeset
  1110
    undoImages        := OrderedCollection new: MaxUndos.
1003
c0958fda9993 remember the old magnification
tz
parents: 1002
diff changeset
  1111
    magnification     := LastMagnification ? GridMagnification.
995
cd84d6f8c449 several undos
tz
parents: 994
diff changeset
  1112
    modified          := false.
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
  1113
    mouseKeyColorMode := 1.
995
cd84d6f8c449 several undos
tz
parents: 994
diff changeset
  1114
    resourceClass     := resourceSelector := ''.
cd84d6f8c449 several undos
tz
parents: 994
diff changeset
  1115
    selectColors      := Array with: nil with: nil.
1036
d860072f3b49 gridMag default.
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
  1116
d860072f3b49 gridMag default.
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
  1117
    "Modified: / 31.7.1998 / 02:15:14 / cg"
1
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
  1118
! !
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
  1119
636
d53428252193 revised version
tz
parents: 633
diff changeset
  1120
!ImageEditView methodsFor:'printing & storing'!
1
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
  1121
724
d6f4b89940ed undo disabling
tz
parents: 704
diff changeset
  1122
loadFromClass
404
322e32d8f099 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 398
diff changeset
  1123
676
fd7918a3e6e6 load + preview redraw errors removed
tz
parents: 674
diff changeset
  1124
    ^self loadFromMessage: 
636
d53428252193 revised version
tz
parents: 633
diff changeset
  1125
        (ResourceSelectionBrowser
662
61b7601829ea with modal support
tz
parents: 636
diff changeset
  1126
            request: 'Load Image From Class'
724
d6f4b89940ed undo disabling
tz
parents: 704
diff changeset
  1127
            onSuperclass: nil
636
d53428252193 revised version
tz
parents: 633
diff changeset
  1128
            andClass: self resourceClass
d53428252193 revised version
tz
parents: 633
diff changeset
  1129
            andSelector: self resourceSelector
d53428252193 revised version
tz
parents: 633
diff changeset
  1130
            withResourceTypes: #(image fileImage))
d53428252193 revised version
tz
parents: 633
diff changeset
  1131
            
477
37f12d35c359 added #resize.
Claus Gittinger <cg@exept.de>
parents: 430
diff changeset
  1132
161
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
  1133
!
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
  1134
995
cd84d6f8c449 several undos
tz
parents: 994
diff changeset
  1135
makeUndo
cd84d6f8c449 several undos
tz
parents: 994
diff changeset
  1136
cd84d6f8c449 several undos
tz
parents: 994
diff changeset
  1137
    image notNil
cd84d6f8c449 several undos
tz
parents: 994
diff changeset
  1138
    ifTrue:
cd84d6f8c449 several undos
tz
parents: 994
diff changeset
  1139
    [       
cd84d6f8c449 several undos
tz
parents: 994
diff changeset
  1140
        MaxUndos <= undoImages size
cd84d6f8c449 several undos
tz
parents: 994
diff changeset
  1141
            ifTrue:  [undoImages contents: (undoImages copyFrom: 2 to: MaxUndos)].
cd84d6f8c449 several undos
tz
parents: 994
diff changeset
  1142
        undoImages add: image copy
cd84d6f8c449 several undos
tz
parents: 994
diff changeset
  1143
    ]
cd84d6f8c449 several undos
tz
parents: 994
diff changeset
  1144
!
cd84d6f8c449 several undos
tz
parents: 994
diff changeset
  1145
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
  1146
print
624
d98fe4700fc2 checkin from browser
tz
parents: 606
diff changeset
  1147
686
33833bcbb5cd some cleans
tz
parents: 678
diff changeset
  1148
    image notNil 
33833bcbb5cd some cleans
tz
parents: 678
diff changeset
  1149
    ifTrue: 
636
d53428252193 revised version
tz
parents: 633
diff changeset
  1150
    [
686
33833bcbb5cd some cleans
tz
parents: 678
diff changeset
  1151
        |stream|
33833bcbb5cd some cleans
tz
parents: 678
diff changeset
  1152
        Printer supportsPostscript ifFalse:
33833bcbb5cd some cleans
tz
parents: 678
diff changeset
  1153
        [
33833bcbb5cd some cleans
tz
parents: 678
diff changeset
  1154
            ^self warn:'No postscript printer detected!!'
33833bcbb5cd some cleans
tz
parents: 678
diff changeset
  1155
        ].
33833bcbb5cd some cleans
tz
parents: 678
diff changeset
  1156
        stream := Printer newNative.
33833bcbb5cd some cleans
tz
parents: 678
diff changeset
  1157
        stream isNil ifTrue:
33833bcbb5cd some cleans
tz
parents: 678
diff changeset
  1158
        [
33833bcbb5cd some cleans
tz
parents: 678
diff changeset
  1159
            ^self warn:'Cannot open printer stream!!'
33833bcbb5cd some cleans
tz
parents: 678
diff changeset
  1160
        ].
33833bcbb5cd some cleans
tz
parents: 678
diff changeset
  1161
        self withWaitCursorDo:
33833bcbb5cd some cleans
tz
parents: 678
diff changeset
  1162
        [
33833bcbb5cd some cleans
tz
parents: 678
diff changeset
  1163
            |psgc|
823
a290d145a09f resource method comment
tz
parents: 822
diff changeset
  1164
            psgc := PSGraphicsContext on:stream.  
686
33833bcbb5cd some cleans
tz
parents: 678
diff changeset
  1165
            psgc displayForm: (image magnifiedBy: magnification) x:0 y:0.
33833bcbb5cd some cleans
tz
parents: 678
diff changeset
  1166
            psgc close
33833bcbb5cd some cleans
tz
parents: 678
diff changeset
  1167
        ]
398
7b7255a4db0d show a wait cursor while printing
Claus Gittinger <cg@exept.de>
parents: 362
diff changeset
  1168
    ]
624
d98fe4700fc2 checkin from browser
tz
parents: 606
diff changeset
  1169
!
d98fe4700fc2 checkin from browser
tz
parents: 606
diff changeset
  1170
d98fe4700fc2 checkin from browser
tz
parents: 606
diff changeset
  1171
save
d98fe4700fc2 checkin from browser
tz
parents: 606
diff changeset
  1172
632
be1ac8ea33a7 checkin from browser
tz
parents: 628
diff changeset
  1173
    self saveImageOrMask: #image.
be1ac8ea33a7 checkin from browser
tz
parents: 628
diff changeset
  1174
624
d98fe4700fc2 checkin from browser
tz
parents: 606
diff changeset
  1175
!
d98fe4700fc2 checkin from browser
tz
parents: 606
diff changeset
  1176
297
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
  1177
saveAs
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
  1178
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
  1179
    self saveImageFileAs
297
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
  1180
!
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
  1181
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
  1182
saveImageFileAs
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
  1183
633
594edef86630 revised version
tz
parents: 632
diff changeset
  1184
    self saveImageFileAs:
594edef86630 revised version
tz
parents: 632
diff changeset
  1185
        (FileSelectionBrowser
822
cace81f0a86b do not overwrite method categories + toggle between mouse button colors
tz
parents: 796
diff changeset
  1186
            request: 'Save Image To File'
827
155b4ed10c7c remember the file name if changed
tz
parents: 823
diff changeset
  1187
            fileName: self image fileName
155b4ed10c7c remember the file name if changed
tz
parents: 823
diff changeset
  1188
            withFileFilters: FileSelectionBrowser saveImageFileNameFilters)
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
  1189
!
297
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
  1190
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
  1191
saveImageFileAs: aFileName
297
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
  1192
633
594edef86630 revised version
tz
parents: 632
diff changeset
  1193
    aFileName isNil ifTrue: [^nil].
636
d53428252193 revised version
tz
parents: 633
diff changeset
  1194
    image notNil
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
  1195
    ifTrue:
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
  1196
    [
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
  1197
        image fileName: aFileName.
632
be1ac8ea33a7 checkin from browser
tz
parents: 628
diff changeset
  1198
        self saveImageOrMask: #image
be1ac8ea33a7 checkin from browser
tz
parents: 628
diff changeset
  1199
    ]
be1ac8ea33a7 checkin from browser
tz
parents: 628
diff changeset
  1200
    ifFalse:
be1ac8ea33a7 checkin from browser
tz
parents: 628
diff changeset
  1201
    [
633
594edef86630 revised version
tz
parents: 632
diff changeset
  1202
        self warn: 'No image or file name for saving detected!!'
632
be1ac8ea33a7 checkin from browser
tz
parents: 628
diff changeset
  1203
    ]
be1ac8ea33a7 checkin from browser
tz
parents: 628
diff changeset
  1204
!
be1ac8ea33a7 checkin from browser
tz
parents: 628
diff changeset
  1205
be1ac8ea33a7 checkin from browser
tz
parents: 628
diff changeset
  1206
saveImageMaskFileAs
be1ac8ea33a7 checkin from browser
tz
parents: 628
diff changeset
  1207
633
594edef86630 revised version
tz
parents: 632
diff changeset
  1208
    self saveImageMaskFileAs:
636
d53428252193 revised version
tz
parents: 633
diff changeset
  1209
        (FileSelectionBrowser
822
cace81f0a86b do not overwrite method categories + toggle between mouse button colors
tz
parents: 796
diff changeset
  1210
            request: 'Save Image Mask To File'
827
155b4ed10c7c remember the file name if changed
tz
parents: 823
diff changeset
  1211
            fileName: self image fileName 
155b4ed10c7c remember the file name if changed
tz
parents: 823
diff changeset
  1212
            withFileFilters: FileSelectionBrowser saveImageFileNameFilters)
632
be1ac8ea33a7 checkin from browser
tz
parents: 628
diff changeset
  1213
!
be1ac8ea33a7 checkin from browser
tz
parents: 628
diff changeset
  1214
be1ac8ea33a7 checkin from browser
tz
parents: 628
diff changeset
  1215
saveImageMaskFileAs: aFileName
be1ac8ea33a7 checkin from browser
tz
parents: 628
diff changeset
  1216
633
594edef86630 revised version
tz
parents: 632
diff changeset
  1217
    aFileName isNil ifTrue: [^nil].
632
be1ac8ea33a7 checkin from browser
tz
parents: 628
diff changeset
  1218
    (image notNil and: [image mask notNil])
be1ac8ea33a7 checkin from browser
tz
parents: 628
diff changeset
  1219
    ifTrue:
be1ac8ea33a7 checkin from browser
tz
parents: 628
diff changeset
  1220
    [
be1ac8ea33a7 checkin from browser
tz
parents: 628
diff changeset
  1221
        image mask fileName: aFileName.
be1ac8ea33a7 checkin from browser
tz
parents: 628
diff changeset
  1222
        self saveImageOrMask: #mask
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
  1223
    ]
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
  1224
    ifFalse:
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
  1225
    [
632
be1ac8ea33a7 checkin from browser
tz
parents: 628
diff changeset
  1226
        self warn: 'No image or image mask detected!!'
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
  1227
    ]
628
7f36d8a7735f popup menu starts image editor
tz
parents: 627
diff changeset
  1228
!
7f36d8a7735f popup menu starts image editor
tz
parents: 627
diff changeset
  1229
632
be1ac8ea33a7 checkin from browser
tz
parents: 628
diff changeset
  1230
saveImageOrMask: what
628
7f36d8a7735f popup menu starts image editor
tz
parents: 627
diff changeset
  1231
632
be1ac8ea33a7 checkin from browser
tz
parents: 628
diff changeset
  1232
    Object errorSignal handle:
be1ac8ea33a7 checkin from browser
tz
parents: 628
diff changeset
  1233
    [:ex|
be1ac8ea33a7 checkin from browser
tz
parents: 628
diff changeset
  1234
        self warn: ex errorString.
be1ac8ea33a7 checkin from browser
tz
parents: 628
diff changeset
  1235
        ^nil                                 
be1ac8ea33a7 checkin from browser
tz
parents: 628
diff changeset
  1236
    ] 
be1ac8ea33a7 checkin from browser
tz
parents: 628
diff changeset
  1237
    do:
be1ac8ea33a7 checkin from browser
tz
parents: 628
diff changeset
  1238
    [   
be1ac8ea33a7 checkin from browser
tz
parents: 628
diff changeset
  1239
        |fileName|
1027
5bffbe90b8e2 show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents: 1025
diff changeset
  1240
5bffbe90b8e2 show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents: 1025
diff changeset
  1241
        windowGroup withCursor:Cursor write do:[
632
be1ac8ea33a7 checkin from browser
tz
parents: 628
diff changeset
  1242
1027
5bffbe90b8e2 show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents: 1025
diff changeset
  1243
            image isNil ifTrue: [^self error: 'No image to save!!'].
5bffbe90b8e2 show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents: 1025
diff changeset
  1244
            what = #image
5bffbe90b8e2 show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents: 1025
diff changeset
  1245
            ifTrue:
5bffbe90b8e2 show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents: 1025
diff changeset
  1246
            [   
5bffbe90b8e2 show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents: 1025
diff changeset
  1247
                image fileName isNil ifTrue: [^self error: 'No file name for image detected!!'].
5bffbe90b8e2 show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents: 1025
diff changeset
  1248
                fileName := image fileName asFilename
5bffbe90b8e2 show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents: 1025
diff changeset
  1249
            ].
5bffbe90b8e2 show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents: 1025
diff changeset
  1250
            what = #mask
5bffbe90b8e2 show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents: 1025
diff changeset
  1251
            ifTrue:
5bffbe90b8e2 show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents: 1025
diff changeset
  1252
            [   
5bffbe90b8e2 show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents: 1025
diff changeset
  1253
                image mask isNil ifTrue: [^self error: 'No image mask to save!!'].
5bffbe90b8e2 show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents: 1025
diff changeset
  1254
                image mask fileName isNil ifTrue: [^self error: 'No file name for image mask detected!!'].
5bffbe90b8e2 show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents: 1025
diff changeset
  1255
                fileName := image mask fileName asFilename
5bffbe90b8e2 show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents: 1025
diff changeset
  1256
            ].
5bffbe90b8e2 show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents: 1025
diff changeset
  1257
            fileName name size = 0 ifTrue: [^self error: 'No file name detected!!'].
5bffbe90b8e2 show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents: 1025
diff changeset
  1258
            (fileName suffix = 'tiff') | (fileName suffix = 'tif') ifTrue: [imageReaderClass := TIFFReader].
5bffbe90b8e2 show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents: 1025
diff changeset
  1259
            fileName suffix = 'xpm' ifTrue: [imageReaderClass := XPMReader].
5bffbe90b8e2 show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents: 1025
diff changeset
  1260
            fileName suffix = 'xbm' ifTrue: [imageReaderClass := XBMReader].
5bffbe90b8e2 show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents: 1025
diff changeset
  1261
            fileName suffix = 'gif' ifTrue: [imageReaderClass := GIFReader].
5bffbe90b8e2 show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents: 1025
diff changeset
  1262
            (fileName suffix = 'jpg') | (fileName suffix = 'jpeg') ifTrue: [imageReaderClass := JPEGReader].
5bffbe90b8e2 show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents: 1025
diff changeset
  1263
            imageReaderClass isNil ifTrue: [imageReaderClass := XPMReader. image fileName: image fileName, '.xpm'].
5bffbe90b8e2 show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents: 1025
diff changeset
  1264
            what = #image ifTrue: [image saveOn: image fileName using: imageReaderClass. modified := false].
5bffbe90b8e2 show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents: 1025
diff changeset
  1265
            what = #mask ifTrue: [image mask saveOn: image mask fileName using: imageReaderClass].
5bffbe90b8e2 show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents: 1025
diff changeset
  1266
        ]   
5bffbe90b8e2 show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents: 1025
diff changeset
  1267
    ]
5bffbe90b8e2 show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents: 1025
diff changeset
  1268
5bffbe90b8e2 show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents: 1025
diff changeset
  1269
    "Modified: / 28.7.1998 / 21:57:14 / cg"
633
594edef86630 revised version
tz
parents: 632
diff changeset
  1270
!
594edef86630 revised version
tz
parents: 632
diff changeset
  1271
594edef86630 revised version
tz
parents: 632
diff changeset
  1272
saveMethod
594edef86630 revised version
tz
parents: 632
diff changeset
  1273
594edef86630 revised version
tz
parents: 632
diff changeset
  1274
    Object errorSignal handle:
594edef86630 revised version
tz
parents: 632
diff changeset
  1275
    [:ex|
594edef86630 revised version
tz
parents: 632
diff changeset
  1276
        self warn: ex errorString.
594edef86630 revised version
tz
parents: 632
diff changeset
  1277
        ^nil                                 
594edef86630 revised version
tz
parents: 632
diff changeset
  1278
    ] 
594edef86630 revised version
tz
parents: 632
diff changeset
  1279
    do:
594edef86630 revised version
tz
parents: 632
diff changeset
  1280
    [   
822
cace81f0a86b do not overwrite method categories + toggle between mouse button colors
tz
parents: 796
diff changeset
  1281
        |category imageStoreStream cls sel mthd imageKey|
cace81f0a86b do not overwrite method categories + toggle between mouse button colors
tz
parents: 796
diff changeset
  1282
1050
85ee282325fc checkin from browser
tz
parents: 1049
diff changeset
  1283
        windowGroup withExecuteCursorDo:[
1027
5bffbe90b8e2 show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents: 1025
diff changeset
  1284
            (self resourceSelector trimBlanks size = 0) | (cls := Smalltalk at: self resourceClass) isClass not 
5bffbe90b8e2 show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents: 1025
diff changeset
  1285
                ifTrue: [^self saveMethodAs].
822
cace81f0a86b do not overwrite method categories + toggle between mouse button colors
tz
parents: 796
diff changeset
  1286
1027
5bffbe90b8e2 show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents: 1025
diff changeset
  1287
            self image storeOn: (imageStoreStream := WriteStream on: '').
5bffbe90b8e2 show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents: 1025
diff changeset
  1288
            sel := self resourceSelector.
5bffbe90b8e2 show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents: 1025
diff changeset
  1289
5bffbe90b8e2 show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents: 1025
diff changeset
  1290
            "/ if that method already exists, do not overwrite the category
5bffbe90b8e2 show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents: 1025
diff changeset
  1291
            category := 'image specs'.
5bffbe90b8e2 show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents: 1025
diff changeset
  1292
            (mthd := cls class compiledMethodAt:sel) notNil ifTrue:[
5bffbe90b8e2 show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents: 1025
diff changeset
  1293
                category := mthd category.
5bffbe90b8e2 show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents: 1025
diff changeset
  1294
            ].
822
cace81f0a86b do not overwrite method categories + toggle between mouse button colors
tz
parents: 796
diff changeset
  1295
1027
5bffbe90b8e2 show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents: 1025
diff changeset
  1296
            imageKey :=  (cls name, ' ', sel) asSymbol.
5bffbe90b8e2 show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents: 1025
diff changeset
  1297
            Icon constantNamed: imageKey put:nil.
5bffbe90b8e2 show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents: 1025
diff changeset
  1298
            ByteCodeCompiler 
5bffbe90b8e2 show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents: 1025
diff changeset
  1299
                compile: ((sel,
5bffbe90b8e2 show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents: 1025
diff changeset
  1300
                    '\', (ResourceSpecEditor codeGenerationCommentForClass: ImageEditor),
5bffbe90b8e2 show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents: 1025
diff changeset
  1301
                    '\\' , 
5bffbe90b8e2 show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents: 1025
diff changeset
  1302
                    '    "\',
5bffbe90b8e2 show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents: 1025
diff changeset
  1303
                    '     self ' , self resourceSelector , ' inspect\',
5bffbe90b8e2 show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents: 1025
diff changeset
  1304
                    '     ImageEditor openOnClass:self andSelector:#', self resourceSelector, 
5bffbe90b8e2 show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents: 1025
diff changeset
  1305
                    '\    "',
5bffbe90b8e2 show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents: 1025
diff changeset
  1306
                    '\\',
5bffbe90b8e2 show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents: 1025
diff changeset
  1307
                    '    <resource: #image>',
5bffbe90b8e2 show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents: 1025
diff changeset
  1308
                    '\\',
5bffbe90b8e2 show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents: 1025
diff changeset
  1309
                    '    ^Icon\') withCRs, 
5bffbe90b8e2 show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents: 1025
diff changeset
  1310
                    '        constantNamed:#''', imageKey, '''\' withCRs,
5bffbe90b8e2 show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents: 1025
diff changeset
  1311
                    '        ifAbsentPut:[', imageStoreStream contents, ']')
5bffbe90b8e2 show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents: 1025
diff changeset
  1312
                forClass: cls class inCategory: category.
5bffbe90b8e2 show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents: 1025
diff changeset
  1313
            modified := false.
5bffbe90b8e2 show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents: 1025
diff changeset
  1314
        ]
633
594edef86630 revised version
tz
parents: 632
diff changeset
  1315
    ]
1027
5bffbe90b8e2 show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents: 1025
diff changeset
  1316
1047
95f10ea8653d use #withExecuteCursorDo:
Claus Gittinger <cg@exept.de>
parents: 1038
diff changeset
  1317
    "Modified: / 31.7.1998 / 20:12:54 / cg"
633
594edef86630 revised version
tz
parents: 632
diff changeset
  1318
!
594edef86630 revised version
tz
parents: 632
diff changeset
  1319
594edef86630 revised version
tz
parents: 632
diff changeset
  1320
saveMethodAs
594edef86630 revised version
tz
parents: 632
diff changeset
  1321
636
d53428252193 revised version
tz
parents: 633
diff changeset
  1322
    (self resourceMessage:
d53428252193 revised version
tz
parents: 633
diff changeset
  1323
        (ResourceSelectionBrowser
822
cace81f0a86b do not overwrite method categories + toggle between mouse button colors
tz
parents: 796
diff changeset
  1324
            request: 'Save Image In Class'
693
e229810e61fb save method as with superclass #Object
tz
parents: 691
diff changeset
  1325
            onSuperclass: #Object
636
d53428252193 revised version
tz
parents: 633
diff changeset
  1326
            andClass: self resourceClass
d53428252193 revised version
tz
parents: 633
diff changeset
  1327
            andSelector: self resourceSelector
d53428252193 revised version
tz
parents: 633
diff changeset
  1328
            withResourceTypes: #(image fileImage))) notNil
633
594edef86630 revised version
tz
parents: 632
diff changeset
  1329
    ifTrue:
674
f24ca336b717 if none image found for loading clear image
tz
parents: 662
diff changeset
  1330
    [   
633
594edef86630 revised version
tz
parents: 632
diff changeset
  1331
        ^self saveMethod
674
f24ca336b717 if none image found for loading clear image
tz
parents: 662
diff changeset
  1332
    ].  
633
594edef86630 revised version
tz
parents: 632
diff changeset
  1333
    ^nil
1
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
  1334
! !
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
  1335
161
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
  1336
!ImageEditView methodsFor:'queries'!
5
be72e6ba4822 *** empty log message ***
claus
parents: 1
diff changeset
  1337
161
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
  1338
heightOfContents
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
  1339
686
33833bcbb5cd some cleans
tz
parents: 678
diff changeset
  1340
    image isNil ifTrue:[^0].
33833bcbb5cd some cleans
tz
parents: 678
diff changeset
  1341
    ^(image height * magnification y) rounded
5
be72e6ba4822 *** empty log message ***
claus
parents: 1
diff changeset
  1342
!
be72e6ba4822 *** empty log message ***
claus
parents: 1
diff changeset
  1343
995
cd84d6f8c449 several undos
tz
parents: 994
diff changeset
  1344
imageContainsPastePoint: aPoint
cd84d6f8c449 several undos
tz
parents: 994
diff changeset
  1345
cd84d6f8c449 several undos
tz
parents: 994
diff changeset
  1346
    ^image notNil and: 
cd84d6f8c449 several undos
tz
parents: 994
diff changeset
  1347
        [Clipboard notNil and:
cd84d6f8c449 several undos
tz
parents: 994
diff changeset
  1348
        [((0@0 corner:(image extent) "- 1" - Clipboard extent) containsPoint: (((aPoint - margin + 1) / magnification) floor))]]
cd84d6f8c449 several undos
tz
parents: 994
diff changeset
  1349
!
cd84d6f8c449 several undos
tz
parents: 994
diff changeset
  1350
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
  1351
imageContainsPoint: aPoint
632
be1ac8ea33a7 checkin from browser
tz
parents: 628
diff changeset
  1352
be1ac8ea33a7 checkin from browser
tz
parents: 628
diff changeset
  1353
    ^image notNil and:
be1ac8ea33a7 checkin from browser
tz
parents: 628
diff changeset
  1354
        [((0@0 corner:(image extent) - 1) containsPoint: (((aPoint - margin + 1) / magnification) floor))]
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
  1355
!
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
  1356
783
c81a097b84b8 revised version
tz
parents: 747
diff changeset
  1357
imageInfoString
c81a097b84b8 revised version
tz
parents: 747
diff changeset
  1358
c81a097b84b8 revised version
tz
parents: 747
diff changeset
  1359
    |imageInfoString usedColors|
1011
325d334e93c8 added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents: 1006
diff changeset
  1360
325d334e93c8 added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents: 1006
diff changeset
  1361
    image isNil ifTrue: [imageInfoString := 'No image loaded.'] 
325d334e93c8 added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents: 1006
diff changeset
  1362
    ifFalse: [
325d334e93c8 added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents: 1006
diff changeset
  1363
        image colorMap isNil ifTrue: [usedColors := '?'] ifFalse: [usedColors := image usedColors size].
325d334e93c8 added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents: 1006
diff changeset
  1364
        imageInfoString := image width printString, 'x'
325d334e93c8 added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents: 1006
diff changeset
  1365
            , image height printString, 'x'
325d334e93c8 added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents: 1006
diff changeset
  1366
            , (2 raisedTo: image depth) printString
325d334e93c8 added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents: 1006
diff changeset
  1367
            , (image mask notNil ifTrue: [' (mask + '] ifFalse: ['('])
325d334e93c8 added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents: 1006
diff changeset
  1368
            , usedColors printString
325d334e93c8 added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents: 1006
diff changeset
  1369
            , ' used colors)'].
783
c81a097b84b8 revised version
tz
parents: 747
diff changeset
  1370
c81a097b84b8 revised version
tz
parents: 747
diff changeset
  1371
    ^imageInfoString
c81a097b84b8 revised version
tz
parents: 747
diff changeset
  1372
!
c81a097b84b8 revised version
tz
parents: 747
diff changeset
  1373
161
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
  1374
widthOfContents
5
be72e6ba4822 *** empty log message ***
claus
parents: 1
diff changeset
  1375
686
33833bcbb5cd some cleans
tz
parents: 678
diff changeset
  1376
    image isNil ifTrue:[^0].
33833bcbb5cd some cleans
tz
parents: 678
diff changeset
  1377
    ^(image width * magnification x) rounded
5
be72e6ba4822 *** empty log message ***
claus
parents: 1
diff changeset
  1378
! !
be72e6ba4822 *** empty log message ***
claus
parents: 1
diff changeset
  1379
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
  1380
!ImageEditView methodsFor:'release'!
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
  1381
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
  1382
destroy
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
  1383
996
f3674765d8fb releases
tz
parents: 995
diff changeset
  1384
    ClipboardMagnification := Clipboard := nil.
1003
c0958fda9993 remember the old magnification
tz
parents: 1002
diff changeset
  1385
    LastMagnification      := magnification.
686
33833bcbb5cd some cleans
tz
parents: 678
diff changeset
  1386
33833bcbb5cd some cleans
tz
parents: 678
diff changeset
  1387
    super destroy
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
  1388
995
cd84d6f8c449 several undos
tz
parents: 994
diff changeset
  1389
!
cd84d6f8c449 several undos
tz
parents: 994
diff changeset
  1390
cd84d6f8c449 several undos
tz
parents: 994
diff changeset
  1391
releasePasteDrawing
cd84d6f8c449 several undos
tz
parents: 994
diff changeset
  1392
cd84d6f8c449 several undos
tz
parents: 994
diff changeset
  1393
    (lastPastePoint notNil and: [ClipboardMagnification notNil]) 
cd84d6f8c449 several undos
tz
parents: 994
diff changeset
  1394
    ifTrue: 
cd84d6f8c449 several undos
tz
parents: 994
diff changeset
  1395
    [ 
cd84d6f8c449 several undos
tz
parents: 994
diff changeset
  1396
        self redraw: (lastPastePoint extent: (ClipboardMagnification extent)). 
cd84d6f8c449 several undos
tz
parents: 994
diff changeset
  1397
    ].
cd84d6f8c449 several undos
tz
parents: 994
diff changeset
  1398
    lastPastePoint := ClipboardMagnification := nil
cd84d6f8c449 several undos
tz
parents: 994
diff changeset
  1399
!
cd84d6f8c449 several undos
tz
parents: 994
diff changeset
  1400
cd84d6f8c449 several undos
tz
parents: 994
diff changeset
  1401
releaseUndos
cd84d6f8c449 several undos
tz
parents: 994
diff changeset
  1402
cd84d6f8c449 several undos
tz
parents: 994
diff changeset
  1403
    undoImages removeAll.
1038
6c0bb03e88a1 no need to invalidate after assign of new image.
Claus Gittinger <cg@exept.de>
parents: 1037
diff changeset
  1404
    "/ cg: what a kludge - please change to use a valueHolder,
995
cd84d6f8c449 several undos
tz
parents: 994
diff changeset
  1405
    masterApplication valueOfCanUndo value: false.
1038
6c0bb03e88a1 no need to invalidate after assign of new image.
Claus Gittinger <cg@exept.de>
parents: 1037
diff changeset
  1406
6c0bb03e88a1 no need to invalidate after assign of new image.
Claus Gittinger <cg@exept.de>
parents: 1037
diff changeset
  1407
    "Modified: / 31.7.1998 / 02:47:21 / cg"
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
  1408
! !
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
  1409
632
be1ac8ea33a7 checkin from browser
tz
parents: 628
diff changeset
  1410
!ImageEditView methodsFor:'testing'!
be1ac8ea33a7 checkin from browser
tz
parents: 628
diff changeset
  1411
be1ac8ea33a7 checkin from browser
tz
parents: 628
diff changeset
  1412
checkModified
be1ac8ea33a7 checkin from browser
tz
parents: 628
diff changeset
  1413
be1ac8ea33a7 checkin from browser
tz
parents: 628
diff changeset
  1414
    modified
be1ac8ea33a7 checkin from browser
tz
parents: 628
diff changeset
  1415
    ifTrue:
be1ac8ea33a7 checkin from browser
tz
parents: 628
diff changeset
  1416
    [
1031
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
  1417
        ((YesNoBox title:(resources string:'Image was modified !!'))
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
  1418
            noText:(resources string:'Cancel');
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
  1419
            yesText:(resources string:'Forget it and proceed');
632
be1ac8ea33a7 checkin from browser
tz
parents: 628
diff changeset
  1420
            showAtPointer;
be1ac8ea33a7 checkin from browser
tz
parents: 628
diff changeset
  1421
            accepted) ifFalse: [^false].
be1ac8ea33a7 checkin from browser
tz
parents: 628
diff changeset
  1422
        modified := false
be1ac8ea33a7 checkin from browser
tz
parents: 628
diff changeset
  1423
    ].
be1ac8ea33a7 checkin from browser
tz
parents: 628
diff changeset
  1424
    ^true
1031
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
  1425
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
  1426
    "Modified: / 29.7.1998 / 18:55:24 / cg"
632
be1ac8ea33a7 checkin from browser
tz
parents: 628
diff changeset
  1427
! !
be1ac8ea33a7 checkin from browser
tz
parents: 628
diff changeset
  1428
255
1dfa8deddaef checkin from browser
Claus Gittinger <cg@exept.de>
parents: 251
diff changeset
  1429
!ImageEditView class methodsFor:'documentation'!
161
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
  1430
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
  1431
version
1053
8d839dff68a9 fixed box emphasis
tz
parents: 1050
diff changeset
  1432
    ^ '$Header: /cvs/stx/stx/libwidg2/ImageEditView.st,v 1.98 1998-08-04 16:25:03 tz Exp $'
161
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
  1433
! !