ImageEditView.st
author Claus Gittinger <cg@exept.de>
Wed, 19 Apr 2000 13:18:21 +0200
changeset 1764 3dd553f8d9f0
parent 1763 7d6d64622ee4
child 1774 3e9f6af51746
permissions -rw-r--r--
oops - leftover halts
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
1116
441ff42c1472 fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents: 1106
diff changeset
     3
	      All Rights Reserved
636
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
1763
7d6d64622ee4 change & updates fixed (monochrome bitmaps)
Claus Gittinger <cg@exept.de>
parents: 1706
diff changeset
    13
"{ Package: 'stx:libwidg2' }"
7d6d64622ee4 change & updates fixed (monochrome bitmaps)
Claus Gittinger <cg@exept.de>
parents: 1706
diff changeset
    14
1
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
    15
ImageView subclass:#ImageEditView
1246
0cd36bffc789 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
    16
	instanceVariableNames:'magnification imageReaderClass resourceClass resourceSelector
0cd36bffc789 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
    17
		mouseKeyColorMode undoImages modified masterApplication editMode
0cd36bffc789 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
    18
		lastPastePoint imageInfoHolder activityInfoHolder
1693
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
    19
		pickedColorHolder drawingColors drawingPixels clickInfoCallBack'
1035
5da83bdbd65e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1031
diff changeset
    20
	classVariableNames:'Clipboard LastMagnification ClipboardMagnification
1706
a954781f4440 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
    21
		GridMagnificationLimit MaxUndos'
1035
5da83bdbd65e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1031
diff changeset
    22
	poolDictionaries:''
1706
a954781f4440 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
    23
	category:'Views-Misc'
1
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
    24
!
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
    25
636
d53428252193 revised version
tz
parents: 633
diff changeset
    26
!ImageEditView class methodsFor:'documentation'!
d53428252193 revised version
tz
parents: 633
diff changeset
    27
d53428252193 revised version
tz
parents: 633
diff changeset
    28
copyright
d53428252193 revised version
tz
parents: 633
diff changeset
    29
"
704
01140e14c065 Fix copyright.
Stefan Vogel <sv@exept.de>
parents: 694
diff changeset
    30
 COPYRIGHT (c) 1997 by eXept Software AG
1116
441ff42c1472 fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents: 1106
diff changeset
    31
	      All Rights Reserved
636
d53428252193 revised version
tz
parents: 633
diff changeset
    32
d53428252193 revised version
tz
parents: 633
diff changeset
    33
 This software is furnished under a license and may be used
d53428252193 revised version
tz
parents: 633
diff changeset
    34
 only in accordance with the terms of that license and with the
d53428252193 revised version
tz
parents: 633
diff changeset
    35
 inclusion of the above copyright notice. This software may not
d53428252193 revised version
tz
parents: 633
diff changeset
    36
 be provided or otherwise made available to, or used by, any
d53428252193 revised version
tz
parents: 633
diff changeset
    37
 other person. No title to or ownership of the software is
d53428252193 revised version
tz
parents: 633
diff changeset
    38
 hereby transferred.
d53428252193 revised version
tz
parents: 633
diff changeset
    39
"
d53428252193 revised version
tz
parents: 633
diff changeset
    40
!
d53428252193 revised version
tz
parents: 633
diff changeset
    41
d53428252193 revised version
tz
parents: 633
diff changeset
    42
documentation
d53428252193 revised version
tz
parents: 633
diff changeset
    43
"
d53428252193 revised version
tz
parents: 633
diff changeset
    44
    The ImageEditView is a view class which can be used by applications
d53428252193 revised version
tz
parents: 633
diff changeset
    45
    like the Image Editor for modifying or inspecting images.
d53428252193 revised version
tz
parents: 633
diff changeset
    46
d53428252193 revised version
tz
parents: 633
diff changeset
    47
    [see also:]
1116
441ff42c1472 fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents: 1106
diff changeset
    48
	ImageEditor Image
636
d53428252193 revised version
tz
parents: 633
diff changeset
    49
d53428252193 revised version
tz
parents: 633
diff changeset
    50
    [author:]
1116
441ff42c1472 fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents: 1106
diff changeset
    51
	Thomas Zwick
636
d53428252193 revised version
tz
parents: 633
diff changeset
    52
"
d53428252193 revised version
tz
parents: 633
diff changeset
    53
! !
353
0442fc169b82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
    54
1245
68581e6aaf23 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1228
diff changeset
    55
!ImageEditView class methodsFor:'initialization'!
68581e6aaf23 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1228
diff changeset
    56
68581e6aaf23 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1228
diff changeset
    57
initialize
68581e6aaf23 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1228
diff changeset
    58
    MaxUndos := 5.
1706
a954781f4440 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
    59
    GridMagnificationLimit := 8 @ 8.
1245
68581e6aaf23 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1228
diff changeset
    60
68581e6aaf23 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1228
diff changeset
    61
    "
68581e6aaf23 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1228
diff changeset
    62
     self initialize
68581e6aaf23 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1228
diff changeset
    63
    "
68581e6aaf23 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1228
diff changeset
    64
! !
68581e6aaf23 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1228
diff changeset
    65
1706
a954781f4440 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
    66
!ImageEditView class methodsFor:'accessing'!
a954781f4440 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
    67
a954781f4440 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
    68
gridMagnificationLimit
a954781f4440 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
    69
    ^ GridMagnificationLimit
a954781f4440 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
    70
!
a954781f4440 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
    71
a954781f4440 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
    72
gridMagnificationLimit:anInteger
a954781f4440 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
    73
    GridMagnificationLimit := anInteger
a954781f4440 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
    74
! !
a954781f4440 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
    75
7
19b36b78ee01 *** empty log message ***
claus
parents: 5
diff changeset
    76
!ImageEditView methodsFor:'accessing'!
19b36b78ee01 *** empty log message ***
claus
parents: 5
diff changeset
    77
1031
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
    78
activityInfoHolder
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
    79
    "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
    80
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
    81
    ^ activityInfoHolder
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
    82
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
    83
    "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
    84
!
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
activityInfoHolder:something
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
    87
    "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
    88
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
    89
    activityInfoHolder := something.
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
    90
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
    91
    "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
    92
!
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
    93
1693
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
    94
clickInfoCallBack:aTwoArgBlock
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
    95
     clickInfoCallBack := aTwoArgBlock
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
    96
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
    97
    "Created: / 10.2.2000 / 23:07:14 / cg"
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
    98
!
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
    99
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   100
clickInfoHolder:aValueHolderOrBlock
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   101
     clickInfoHolder := aValueHolderOrBlock
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   102
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   103
    "Created: / 10.2.2000 / 23:05:34 / cg"
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   104
!
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   105
1031
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   106
imageInfoHolder
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   107
    "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
   108
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   109
    ^ imageInfoHolder
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   110
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   111
    "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
   112
!
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   113
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   114
imageInfoHolder:something
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   115
    "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
   116
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   117
    imageInfoHolder := something.
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   118
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   119
    "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
   120
!
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   121
624
d98fe4700fc2 checkin from browser
tz
parents: 606
diff changeset
   122
magnification
d98fe4700fc2 checkin from browser
tz
parents: 606
diff changeset
   123
d98fe4700fc2 checkin from browser
tz
parents: 606
diff changeset
   124
    ^magnification
d98fe4700fc2 checkin from browser
tz
parents: 606
diff changeset
   125
255
1dfa8deddaef checkin from browser
Claus Gittinger <cg@exept.de>
parents: 251
diff changeset
   126
!
1dfa8deddaef checkin from browser
Claus Gittinger <cg@exept.de>
parents: 251
diff changeset
   127
636
d53428252193 revised version
tz
parents: 633
diff changeset
   128
magnification: aPoint
1037
3735af6b5b24 remmeber scrollOffset
Claus Gittinger <cg@exept.de>
parents: 1036
diff changeset
   129
    |oldOrg|
255
1dfa8deddaef checkin from browser
Claus Gittinger <cg@exept.de>
parents: 251
diff changeset
   130
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   131
    magnification ~= aPoint
624
d98fe4700fc2 checkin from browser
tz
parents: 606
diff changeset
   132
    ifTrue:
d98fe4700fc2 checkin from browser
tz
parents: 606
diff changeset
   133
    [
1116
441ff42c1472 fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents: 1106
diff changeset
   134
	oldOrg := self viewOrigin / magnification.
441ff42c1472 fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents: 1106
diff changeset
   135
	magnification := aPoint asPoint.
1037
3735af6b5b24 remmeber scrollOffset
Claus Gittinger <cg@exept.de>
parents: 1036
diff changeset
   136
1116
441ff42c1472 fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents: 1106
diff changeset
   137
	self scrollTo:(oldOrg * magnification) rounded redraw:false.        
1037
3735af6b5b24 remmeber scrollOffset
Claus Gittinger <cg@exept.de>
parents: 1036
diff changeset
   138
"/        self scrollToTopLeft.
1116
441ff42c1472 fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents: 1106
diff changeset
   139
	self contentsChanged.
441ff42c1472 fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents: 1106
diff changeset
   140
	self invalidate.
441ff42c1472 fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents: 1106
diff changeset
   141
	ClipboardMagnification := nil.
686
33833bcbb5cd some cleans
tz
parents: 678
diff changeset
   142
    ]
1037
3735af6b5b24 remmeber scrollOffset
Claus Gittinger <cg@exept.de>
parents: 1036
diff changeset
   143
3735af6b5b24 remmeber scrollOffset
Claus Gittinger <cg@exept.de>
parents: 1036
diff changeset
   144
    "Modified: / 31.7.1998 / 02:38:47 / cg"
624
d98fe4700fc2 checkin from browser
tz
parents: 606
diff changeset
   145
!
255
1dfa8deddaef checkin from browser
Claus Gittinger <cg@exept.de>
parents: 251
diff changeset
   146
662
61b7601829ea with modal support
tz
parents: 636
diff changeset
   147
masterApplication
61b7601829ea with modal support
tz
parents: 636
diff changeset
   148
61b7601829ea with modal support
tz
parents: 636
diff changeset
   149
    ^masterApplication
61b7601829ea with modal support
tz
parents: 636
diff changeset
   150
!
61b7601829ea with modal support
tz
parents: 636
diff changeset
   151
61b7601829ea with modal support
tz
parents: 636
diff changeset
   152
masterApplication: anApplicationModel
61b7601829ea with modal support
tz
parents: 636
diff changeset
   153
61b7601829ea with modal support
tz
parents: 636
diff changeset
   154
    masterApplication := anApplicationModel
61b7601829ea with modal support
tz
parents: 636
diff changeset
   155
!
61b7601829ea with modal support
tz
parents: 636
diff changeset
   156
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   157
resourceClass
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   158
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   159
    ^resourceClass
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   160
!
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   161
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   162
resourceClass: aClassOrSymbol
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   163
686
33833bcbb5cd some cleans
tz
parents: 678
diff changeset
   164
    resourceClass := aClassOrSymbol isClass ifTrue: [aClassOrSymbol name] ifFalse: [aClassOrSymbol asSymbol]
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   165
!
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   166
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   167
resourceMessage
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   168
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   169
    ^resourceClass, ' ', resourceSelector
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   170
!
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   171
636
d53428252193 revised version
tz
parents: 633
diff changeset
   172
resourceMessage: aString
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   173
636
d53428252193 revised version
tz
parents: 633
diff changeset
   174
    (aString isString and: [aString trimBlanks size > 0])
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   175
    ifTrue:
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   176
    [
1116
441ff42c1472 fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents: 1106
diff changeset
   177
	resourceClass := (aString readStream upTo: Character space) asSymbol.
441ff42c1472 fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents: 1106
diff changeset
   178
	resourceSelector := (aString copy reverse readStream upTo: Character space) reverse asSymbol
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   179
    ]
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   180
    ifFalse:
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   181
    [
1116
441ff42c1472 fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents: 1106
diff changeset
   182
	^nil
686
33833bcbb5cd some cleans
tz
parents: 678
diff changeset
   183
    ]
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   184
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   185
   
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
resourceSelector
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   189
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   190
    ^resourceSelector
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   191
!
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   192
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   193
resourceSelector: aStringOrSymbol
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   194
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   195
    resourceSelector := aStringOrSymbol asSymbol
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   196
!
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   197
840
93f209fc0f7a selectColors
tz
parents: 839
diff changeset
   198
selectColors
93f209fc0f7a selectColors
tz
parents: 839
diff changeset
   199
1246
0cd36bffc789 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
   200
    ^drawingColors
840
93f209fc0f7a selectColors
tz
parents: 839
diff changeset
   201
!
93f209fc0f7a selectColors
tz
parents: 839
diff changeset
   202
93f209fc0f7a selectColors
tz
parents: 839
diff changeset
   203
selectColors: anArrayTwoColors
633
594edef86630 revised version
tz
parents: 632
diff changeset
   204
1246
0cd36bffc789 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
   205
    drawingColors := anArrayTwoColors
633
594edef86630 revised version
tz
parents: 632
diff changeset
   206
!
594edef86630 revised version
tz
parents: 632
diff changeset
   207
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   208
selectedColor
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   209
1246
0cd36bffc789 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
   210
   ^drawingColors at: mouseKeyColorMode
0cd36bffc789 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
   211
!
0cd36bffc789 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
   212
0cd36bffc789 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
   213
selectedColor: aColor
0cd36bffc789 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
   214
0cd36bffc789 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
   215
    drawingColors at: mouseKeyColorMode put: aColor
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   216
!
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   217
1246
0cd36bffc789 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
   218
selectedColorIndex
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   219
1246
0cd36bffc789 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
   220
   ^ drawingPixels at: mouseKeyColorMode
0cd36bffc789 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
   221
!
0cd36bffc789 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
   222
0cd36bffc789 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
   223
selectedColorIndex: aPixelIndex
0cd36bffc789 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
   224
0cd36bffc789 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
   225
    drawingPixels at: mouseKeyColorMode put: aPixelIndex
995
cd84d6f8c449 several undos
tz
parents: 994
diff changeset
   226
!
cd84d6f8c449 several undos
tz
parents: 994
diff changeset
   227
cd84d6f8c449 several undos
tz
parents: 994
diff changeset
   228
undoImages
cd84d6f8c449 several undos
tz
parents: 994
diff changeset
   229
cd84d6f8c449 several undos
tz
parents: 994
diff changeset
   230
   ^undoImages
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   231
! !
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   232
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   233
!ImageEditView methodsFor:'drawing'!
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   234
1036
d860072f3b49 gridMag default.
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   235
drawFrame
d860072f3b49 gridMag default.
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   236
d860072f3b49 gridMag default.
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   237
    self paint:Color black.
d860072f3b49 gridMag default.
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   238
    self lineWidth: (magnification x//3 min: 3).
1104
a7101d656dab use margin in #drawFrame
tz
parents: 1103
diff changeset
   239
    self displayRectangle: ((0@0) extent:(image extent * magnification) + margin).
1036
d860072f3b49 gridMag default.
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   240
    self lineWidth:1.
d860072f3b49 gridMag default.
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   241
!
d860072f3b49 gridMag default.
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   242
d860072f3b49 gridMag default.
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   243
drawFramesIn: aRectangle
d860072f3b49 gridMag default.
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   244
1706
a954781f4440 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   245
    magnification >= GridMagnificationLimit
1036
d860072f3b49 gridMag default.
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   246
    ifTrue:
d860072f3b49 gridMag default.
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   247
    [   
1706
a954781f4440 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   248
        |origin lineStartingPoint lineEndingPoint oldColor|
a954781f4440 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   249
        origin := aRectangle origin - 1.
a954781f4440 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   250
        lineStartingPoint := origin + (0@magnification y).
a954781f4440 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   251
        lineEndingPoint   := lineStartingPoint + (aRectangle width@0).
a954781f4440 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   252
        oldColor := self paint.
a954781f4440 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   253
        self xoring:
a954781f4440 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   254
        [
a954781f4440 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   255
            self displayLineFrom: lineStartingPoint to: lineEndingPoint.
a954781f4440 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   256
            lineStartingPoint x to: lineStartingPoint x + aRectangle width - magnification x by: magnification x do:
a954781f4440 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   257
            [:x|   
a954781f4440 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   258
                self displayLineFrom: x@(origin y) to: x@(origin y + magnification y)
a954781f4440 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   259
            ].
a954781f4440 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   260
        ].
a954781f4440 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   261
        self paint: oldColor.
1036
d860072f3b49 gridMag default.
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   262
    ]
d860072f3b49 gridMag default.
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   263
d860072f3b49 gridMag default.
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   264
d860072f3b49 gridMag default.
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   265
d860072f3b49 gridMag default.
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   266
!
d860072f3b49 gridMag default.
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   267
1380
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   268
drawPasteRectangleAt: aPoint
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   269
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   270
    |currentPoint gridCorrection extent org|
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   271
1706
a954781f4440 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   272
    magnification >= GridMagnificationLimit ifFalse: [gridCorrection := 0] ifTrue: [gridCorrection := 1].
1449
e5852c20c18a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   273
    currentPoint := aPoint // magnification*magnification + margin. 
1380
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   274
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   275
    currentPoint ~= lastPastePoint ifTrue:[              
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   276
        ClipboardMagnification isNil ifTrue:[
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   277
            ClipboardMagnification := (Clipboard magnifiedBy: magnification) onDevice: device
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   278
        ].   
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   279
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   280
        extent       := ClipboardMagnification extent.
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   281
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   282
        currentPoint := currentPoint - self viewOrigin.
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   283
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   284
        self redraw: ((lastPastePoint ? currentPoint) extent: extent).
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   285
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   286
        (extent x > 200 or: [extent y > 200]) ifTrue:[
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   287
            self xoring: [
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   288
                self fillRectangle: (currentPoint extent: extent)
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   289
            ]   
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   290
        ] ifFalse:[
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   291
            self displayDeviceForm: ClipboardMagnification x: currentPoint x y: currentPoint y.
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   292
            editMode == #pasteUnder ifTrue:[
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   293
                self redrawImageX:currentPoint x y:currentPoint y width:extent x height:extent y unmaskedOnly:true
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   294
            ]
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   295
        ]  
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   296
    ]. 
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   297
    lastPastePoint := currentPoint.
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   298
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   299
    "Modified: / 18.5.1999 / 20:23:33 / cg"
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   300
!
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   301
662
61b7601829ea with modal support
tz
parents: 636
diff changeset
   302
fillFramedRectangle: aRectangle
61b7601829ea with modal support
tz
parents: 636
diff changeset
   303
61b7601829ea with modal support
tz
parents: 636
diff changeset
   304
    self fillRectangle: aRectangle.
61b7601829ea with modal support
tz
parents: 636
diff changeset
   305
    self drawFramesIn: aRectangle
61b7601829ea with modal support
tz
parents: 636
diff changeset
   306
!
61b7601829ea with modal support
tz
parents: 636
diff changeset
   307
1449
e5852c20c18a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   308
redraw:aRectangle
e5852c20c18a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   309
    super redraw:(aRectangle origin + self viewOrigin extent:aRectangle extent). 
e5852c20c18a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   310
e5852c20c18a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   311
!
e5852c20c18a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   312
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   313
redrawImageX:x y:y width:w height:h
1380
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   314
    self redrawImageX:x y:y width:w height:h unmaskedOnly:false
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   315
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   316
    "Modified: / 18.5.1999 / 20:14:03 / cg"
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   317
!
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   318
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   319
redrawImageX:x y:y width:w height:h unmaskedOnly:unmaskedOnly
636
d53428252193 revised version
tz
parents: 633
diff changeset
   320
1037
3735af6b5b24 remmeber scrollOffset
Claus Gittinger <cg@exept.de>
parents: 1036
diff changeset
   321
    |ih iw magX magY minX maxX minY maxY 
3735af6b5b24 remmeber scrollOffset
Claus Gittinger <cg@exept.de>
parents: 1036
diff changeset
   322
     color lastColor lastY runW x0 xI yI maskColor mask
1180
dcb9dede5128 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1160
diff changeset
   323
     sizeOfMaskPoint useNearestColor|
dcb9dede5128 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1160
diff changeset
   324
dcb9dede5128 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1160
diff changeset
   325
    useNearestColor := device visualType == #PseudoColor.
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   326
1037
3735af6b5b24 remmeber scrollOffset
Claus Gittinger <cg@exept.de>
parents: 1036
diff changeset
   327
    mask := image mask.
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   328
    ih := image height.
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   329
    iw := image width.
662
61b7601829ea with modal support
tz
parents: 636
diff changeset
   330
    magX := magnification x.
61b7601829ea with modal support
tz
parents: 636
diff changeset
   331
    magY := magnification y.
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   332
662
61b7601829ea with modal support
tz
parents: 636
diff changeset
   333
    minX := (x // magX - 1) max: 0.
725
0e051202859d checkin from browser
tz
parents: 724
diff changeset
   334
    minX >= iw ifTrue:[minX := (iw - 1) max: 0].
662
61b7601829ea with modal support
tz
parents: 636
diff changeset
   335
    minY := (y // magY - 1) max: 0.
725
0e051202859d checkin from browser
tz
parents: 724
diff changeset
   336
    minY >= ih ifTrue:[minY := (ih - 1) max: 0].
662
61b7601829ea with modal support
tz
parents: 636
diff changeset
   337
    maxX := (x + w) // magX + 1.
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   338
    maxX > iw ifTrue:[maxX := iw].
662
61b7601829ea with modal support
tz
parents: 636
diff changeset
   339
    maxY := (y + h) // magY + 1.
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   340
    maxY > ih ifTrue:[maxY := ih].
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   341
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   342
    lastY := -1.
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   343
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   344
    x0 := minX.
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   345
    runW := 0.
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   346
    maskColor := false.
662
61b7601829ea with modal support
tz
parents: 636
diff changeset
   347
    sizeOfMaskPoint := magnification//3.
1380
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   348
    image 
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   349
        colorsFromX:minX y:minY toX:maxX-1 y:maxY-1 
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   350
        do:[:xx :yy :color|
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   351
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   352
            shown ifFalse:[^ self].
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   353
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   354
            yy ~~ lastY ifTrue:[
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   355
                runW ~~ 0 ifTrue:[
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   356
                    |origin|
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   357
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   358
                    origin := (x0 * magX + margin)@(lastY * magY + margin).
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   359
                    (unmaskedOnly not or:[maskColor not]) ifTrue:[
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   360
                        self fillFramedRectangle: (origin extent: (runW@magY)).                    
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   361
                        maskColor ifTrue:[
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   362
                            self xoring: [self fillRectangle: (origin + sizeOfMaskPoint extent: sizeOfMaskPoint)]
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   363
                        ]
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   364
                    ].
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   365
                    runW := 0.
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   366
                ]. 
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   367
                x0 := xx.
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   368
                lastY := yy.
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   369
            ]. 
1160
5d89296c4b04 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1158
diff changeset
   370
1380
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   371
            color ~= lastColor ifTrue:[
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   372
                runW ~~ 0 ifTrue:[
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   373
                    |origin|
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   374
                    origin := (x0 * magX + margin)@(yy * magY + margin).
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   375
                    (unmaskedOnly not or:[maskColor not]) ifTrue:[
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   376
                        self fillFramedRectangle: (origin extent: (runW@magY)).
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   377
                        maskColor ifTrue:[
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   378
                            self xoring: [self fillRectangle: (origin + sizeOfMaskPoint extent: sizeOfMaskPoint)]
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   379
                        ].
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   380
                    ].
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   381
                    runW := 0.
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   382
                ].
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   383
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   384
                lastColor := color.
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   385
                useNearestColor ifTrue:[
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   386
                    lastColor := lastColor nearestOn:device
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   387
                ].
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   388
                self paint:lastColor.
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   389
                mask notNil ifTrue:[  
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   390
                    maskColor := false.
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   391
                    (mask pixelAtX:xx y:yy) == 0 ifTrue:[
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   392
                        unmaskedOnly ifFalse:[
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   393
                            self paint: (lastColor := self viewBackground).
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   394
                        ].
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   395
                        maskColor := true.
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   396
                    ].
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   397
                    lastColor := nil.
1160
5d89296c4b04 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1158
diff changeset
   398
                ].
5d89296c4b04 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1158
diff changeset
   399
                runW := 0.
1380
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   400
                x0 := xx.
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   401
            ].  
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   402
            runW := runW + magX
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   403
        ].
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   404
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   405
    runW ~~ 0 ifTrue:[
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   406
        |origin|
624
d98fe4700fc2 checkin from browser
tz
parents: 606
diff changeset
   407
1380
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   408
        origin := (x0 * magX + margin)@(lastY * magY + margin).
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   409
        (unmaskedOnly not or:[maskColor not]) ifTrue:[
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   410
            self fillFramedRectangle: (origin extent: runW@magY).
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   411
            maskColor ifTrue:[
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   412
                self xoring:[
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   413
                    self fillRectangle: (origin + sizeOfMaskPoint extent: sizeOfMaskPoint)
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   414
                ]
1180
dcb9dede5128 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1160
diff changeset
   415
            ].
1380
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   416
        ]
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   417
    ].
1037
3735af6b5b24 remmeber scrollOffset
Claus Gittinger <cg@exept.de>
parents: 1036
diff changeset
   418
1380
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   419
    "Created: / 18.5.1999 / 20:13:39 / cg"
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
   420
    "Modified: / 18.5.1999 / 20:36:20 / cg"
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   421
!
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   422
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   423
redrawX:x y:y width:w height:h
636
d53428252193 revised version
tz
parents: 633
diff changeset
   424
1763
7d6d64622ee4 change & updates fixed (monochrome bitmaps)
Claus Gittinger <cg@exept.de>
parents: 1706
diff changeset
   425
    |ih iw xI yI devImage|
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   426
1037
3735af6b5b24 remmeber scrollOffset
Claus Gittinger <cg@exept.de>
parents: 1036
diff changeset
   427
    image isNil ifTrue:[^self].
662
61b7601829ea with modal support
tz
parents: 636
diff changeset
   428
1037
3735af6b5b24 remmeber scrollOffset
Claus Gittinger <cg@exept.de>
parents: 1036
diff changeset
   429
    magnification = (1@1) ifTrue: [
1510
fd0cd6065dc6 catch image conversion errors.
Claus Gittinger <cg@exept.de>
parents: 1449
diff changeset
   430
        Object errorSignal handle:[:ex |
fd0cd6065dc6 catch image conversion errors.
Claus Gittinger <cg@exept.de>
parents: 1449
diff changeset
   431
            Transcript showCR:'cannot convert image'.
fd0cd6065dc6 catch image conversion errors.
Claus Gittinger <cg@exept.de>
parents: 1449
diff changeset
   432
        ] do:[
1763
7d6d64622ee4 change & updates fixed (monochrome bitmaps)
Claus Gittinger <cg@exept.de>
parents: 1706
diff changeset
   433
            devImage := image onDevice:device.
7d6d64622ee4 change & updates fixed (monochrome bitmaps)
Claus Gittinger <cg@exept.de>
parents: 1706
diff changeset
   434
            devImage ~~ image ifTrue:[
7d6d64622ee4 change & updates fixed (monochrome bitmaps)
Claus Gittinger <cg@exept.de>
parents: 1706
diff changeset
   435
                image := devImage.
1764
3dd553f8d9f0 oops - leftover halts
Claus Gittinger <cg@exept.de>
parents: 1763
diff changeset
   436
                self changed:#image.
1763
7d6d64622ee4 change & updates fixed (monochrome bitmaps)
Claus Gittinger <cg@exept.de>
parents: 1706
diff changeset
   437
            ].
1510
fd0cd6065dc6 catch image conversion errors.
Claus Gittinger <cg@exept.de>
parents: 1449
diff changeset
   438
        ].
fd0cd6065dc6 catch image conversion errors.
Claus Gittinger <cg@exept.de>
parents: 1449
diff changeset
   439
        image device == device ifTrue:[
fd0cd6065dc6 catch image conversion errors.
Claus Gittinger <cg@exept.de>
parents: 1449
diff changeset
   440
            ^ super redrawX:x y:y width:w height:h
fd0cd6065dc6 catch image conversion errors.
Claus Gittinger <cg@exept.de>
parents: 1449
diff changeset
   441
        ].
1037
3735af6b5b24 remmeber scrollOffset
Claus Gittinger <cg@exept.de>
parents: 1036
diff changeset
   442
    ].
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   443
1449
e5852c20c18a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   444
    self clippingRectangle: (x@y extent:w@h).
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   445
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   446
    self redrawImageX:x y:y width:w height:h.
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   447
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   448
    "/ right of image ?
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   449
    adjust == #center ifTrue:
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   450
    [
1449
e5852c20c18a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   451
        xI := (width - ih) // 2 - margin.
e5852c20c18a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   452
        yI := (height - iw) // 2 - margin.
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   453
    ]
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   454
    ifFalse:
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   455
    [
1449
e5852c20c18a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   456
        xI := yI := margin
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   457
    ].
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   458
    (x + w - 1) > (xI + (magnification x * image width)) ifTrue:
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   459
    [
1449
e5852c20c18a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   460
        self clearRectangleX:(xI + (magnification x * image width))
e5852c20c18a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   461
                           y:y
e5852c20c18a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   462
                       width:(x + w - (magnification x * image width) - xI)
e5852c20c18a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   463
                      height:h
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   464
    ].
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   465
    (y + h - 1) > (yI + (magnification y * image height)) ifTrue:
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   466
    [
1449
e5852c20c18a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   467
        self clearRectangleX:margin
e5852c20c18a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   468
                           y:(yI + (magnification y * image height))
e5852c20c18a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   469
                       width:w
e5852c20c18a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   470
                      height:(y + h - (magnification y * image height) - yI)  
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   471
    ].
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   472
    self drawFrame.
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   473
    self clippingRectangle: nil.
1037
3735af6b5b24 remmeber scrollOffset
Claus Gittinger <cg@exept.de>
parents: 1036
diff changeset
   474
3735af6b5b24 remmeber scrollOffset
Claus Gittinger <cg@exept.de>
parents: 1036
diff changeset
   475
    "Modified: / 31.7.1998 / 02:22:45 / cg"
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   476
! !
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   477
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   478
!ImageEditView methodsFor:'edit modes'!
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   479
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   480
editMode
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   481
1106
57c41df67ae5 support radio buttons of the ImageEditor
tz
parents: 1104
diff changeset
   482
    ^editMode
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   483
!
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   484
1106
57c41df67ae5 support radio buttons of the ImageEditor
tz
parents: 1104
diff changeset
   485
editMode: anEditMode
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   486
1106
57c41df67ae5 support radio buttons of the ImageEditor
tz
parents: 1104
diff changeset
   487
    editMode := anEditMode
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   488
!
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   489
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   490
mouseKeyColorMode
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   491
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   492
    ^mouseKeyColorMode printString
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   493
!
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   494
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   495
mouseKeyColorMode:aMode
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   496
1106
57c41df67ae5 support radio buttons of the ImageEditor
tz
parents: 1104
diff changeset
   497
    mouseKeyColorMode := aMode
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   498
! !
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   499
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   500
!ImageEditView methodsFor:'event handling'!
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   501
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   502
buttonMotion:state x:x y:y
1246
0cd36bffc789 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
   503
1693
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   504
    |p|
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   505
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   506
    p := x@y.
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   507
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   508
    state ~~ 0 ifTrue:[
1245
68581e6aaf23 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1228
diff changeset
   509
        ("self selectedColor notNil" true 
1693
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   510
        and:[(self imageContainsPoint:p) 
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   511
        and:[editMode == #point]])
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   512
        ifTrue:[
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   513
            self pointAt:p.
1246
0cd36bffc789 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
   514
            ^ self
0cd36bffc789 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
   515
        ].
1693
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   516
        self drawCursorAt:p.
1011
325d334e93c8 added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents: 1006
diff changeset
   517
    ] ifFalse:[
1693
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   518
        self drawCursorAt:p.
1246
0cd36bffc789 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
   519
        (editMode == #paste or:[editMode == #pasteUnder]) ifTrue: [
1693
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   520
            ("self selectedColor notNil" true and: [self imageContainsPastePoint:p]) 
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   521
                ifTrue:  [self drawPasteRectangleAt:p]
1245
68581e6aaf23 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1228
diff changeset
   522
                ifFalse: [self cursor:Cursor stop. self releasePasteDrawing]
68581e6aaf23 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1228
diff changeset
   523
        ]
686
33833bcbb5cd some cleans
tz
parents: 678
diff changeset
   524
    ]
1019
e68414752bc9 only change the cursor for myself.
Claus Gittinger <cg@exept.de>
parents: 1013
diff changeset
   525
1693
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   526
    "Modified: / 10.2.2000 / 22:03:18 / cg"
624
d98fe4700fc2 checkin from browser
tz
parents: 606
diff changeset
   527
!
255
1dfa8deddaef checkin from browser
Claus Gittinger <cg@exept.de>
parents: 251
diff changeset
   528
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   529
buttonPress:button x:x y:y
1693
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   530
    |p mouseButtonColorToolBar clr|
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   531
1693
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   532
    p := x@y.
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   533
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   534
    self drawCursorAt:p.
1011
325d334e93c8 added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents: 1006
diff changeset
   535
1246
0cd36bffc789 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
   536
    ("self selectedColor notNil" true 
1693
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   537
    and: [self imageContainsPoint:p])
1246
0cd36bffc789 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
   538
    ifTrue:[   
0cd36bffc789 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
   539
        self sensor shiftDown ifTrue:[
0cd36bffc789 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
   540
            pickedColorHolder notNil ifTrue:[
0cd36bffc789 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
   541
                "/ select the color under the cursor, place it into the
0cd36bffc789 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
   542
                "/ pickedColorHolder/
1693
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   543
                clr := image colorAt:(p // magnification).
1246
0cd36bffc789 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
   544
                pickedColorHolder value:clr
0cd36bffc789 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
   545
            ].
0cd36bffc789 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
   546
        ] ifFalse:[
0cd36bffc789 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
   547
            mouseKeyColorMode := button.
0cd36bffc789 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
   548
            self makeUndo.
1693
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   549
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   550
"/            "/ cg: what a kludge - please change to use a valueHolder,
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   551
"/            "/ which gets the information ...
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   552
"/            mouseButtonColorToolBar := masterApplication builder componentAt: #MouseButtonColorToolBar.
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   553
"/            mouseButtonColorToolBar notNil ifTrue:[
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   554
"/                (mouseButtonColorToolBar itemAt: mouseKeyColorMode) toggleIndication.
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   555
"/                mouseButtonColorToolBar do: [:i| i updateIndicators].
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   556
"/            ].
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   557
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   558
            clickInfoCallBack notNil ifTrue:[
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   559
                "/ still a kludge, but less ugly ...
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   560
                clickInfoCallBack value:button value:p
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   561
            ].
1246
0cd36bffc789 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
   562
0cd36bffc789 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
   563
            "/ editMode is something like #point, #rectangle etc.
1693
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   564
            self perform: (editMode, 'At:') asSymbol with:p
1246
0cd36bffc789 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
   565
        ]
686
33833bcbb5cd some cleans
tz
parents: 678
diff changeset
   566
    ]
995
cd84d6f8c449 several undos
tz
parents: 994
diff changeset
   567
1693
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   568
    "Modified: / 10.2.2000 / 23:11:33 / cg"
632
be1ac8ea33a7 checkin from browser
tz
parents: 628
diff changeset
   569
!
be1ac8ea33a7 checkin from browser
tz
parents: 628
diff changeset
   570
994
5727c2484ecd bugs fixed in undo/mask and point painting/preview and pasting
tz
parents: 877
diff changeset
   571
buttonRelease:button x:x y:y
5727c2484ecd bugs fixed in undo/mask and point painting/preview and pasting
tz
parents: 877
diff changeset
   572
5727c2484ecd bugs fixed in undo/mask and point painting/preview and pasting
tz
parents: 877
diff changeset
   573
    self drawCursorAt: x@y.
1246
0cd36bffc789 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
   574
1116
441ff42c1472 fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents: 1106
diff changeset
   575
    ("self selectedColor notNil" true and: [self imageContainsPoint: x@y])
1246
0cd36bffc789 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
   576
    ifTrue: [   
1763
7d6d64622ee4 change & updates fixed (monochrome bitmaps)
Claus Gittinger <cg@exept.de>
parents: 1706
diff changeset
   577
        image release.
1011
325d334e93c8 added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents: 1006
diff changeset
   578
1693
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   579
"/        "/ cg: what a kludge - please change to use a valueHolder,
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   580
"/        "/ which gets the information ...
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   581
"/        masterApplication imagePreView invalidate.
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   582
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   583
        "/ cg: still a kludge - but less ugly
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   584
        self changed:#subImageIn with:(image bounds).
994
5727c2484ecd bugs fixed in undo/mask and point painting/preview and pasting
tz
parents: 877
diff changeset
   585
    ]
1116
441ff42c1472 fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents: 1106
diff changeset
   586
1693
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   587
    "Modified: / 10.2.2000 / 23:41:41 / cg"
994
5727c2484ecd bugs fixed in undo/mask and point painting/preview and pasting
tz
parents: 877
diff changeset
   588
!
5727c2484ecd bugs fixed in undo/mask and point painting/preview and pasting
tz
parents: 877
diff changeset
   589
686
33833bcbb5cd some cleans
tz
parents: 678
diff changeset
   590
pointerLeave:state
33833bcbb5cd some cleans
tz
parents: 678
diff changeset
   591
688
e1c30adb37bf updates coord info label while defining boxes
tz
parents: 686
diff changeset
   592
    super pointerLeave: state.
686
33833bcbb5cd some cleans
tz
parents: 678
diff changeset
   593
1031
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   594
    self updateImageInfo: self imageInfoString.
1019
e68414752bc9 only change the cursor for myself.
Claus Gittinger <cg@exept.de>
parents: 1013
diff changeset
   595
    self cursor:Cursor normal.
995
cd84d6f8c449 several undos
tz
parents: 994
diff changeset
   596
1246
0cd36bffc789 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
   597
    (editMode == #paste or:[editMode == #pasteUnder]) ifTrue: [
0cd36bffc789 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
   598
        self releasePasteDrawing
0cd36bffc789 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
   599
    ]
995
cd84d6f8c449 several undos
tz
parents: 994
diff changeset
   600
1031
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   601
    "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
   602
! !
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   603
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   604
!ImageEditView methodsFor:'image - dragging & info'!
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   605
1449
e5852c20c18a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   606
dragRectangleStartingAt: aPointIn emphasis: emphasis
1084
87c661e6c333 scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents: 1060
diff changeset
   607
    "drag a rectangle (filled or unfilled)"
87c661e6c333 scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents: 1060
diff changeset
   608
87c661e6c333 scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents: 1060
diff changeset
   609
    |currentPoint currentExtent firstPoint lastCurrentPoint gridCorrection 
1449
e5852c20c18a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   610
     mp lastMp p whichQuarter scrollX scrollY aPoint|
1084
87c661e6c333 scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents: 1060
diff changeset
   611
1693
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   612
    aPoint := aPointIn.
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   613
    firstPoint := currentPoint := lastCurrentPoint :=  aPoint//magnification*magnification.
1706
a954781f4440 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   614
    magnification >= GridMagnificationLimit ifFalse: [gridCorrection := 0] ifTrue: [gridCorrection := 1].
1084
87c661e6c333 scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents: 1060
diff changeset
   615
87c661e6c333 scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents: 1060
diff changeset
   616
    [device anyButtonPressed] whileTrue: [                                                  
1449
e5852c20c18a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   617
        mp := self sensor mousePoint.
e5852c20c18a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   618
        mp = lastMp ifTrue:[
e5852c20c18a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   619
            Delay waitForSeconds:0.05
e5852c20c18a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   620
        ] ifFalse:[
e5852c20c18a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   621
            lastMp := mp.
e5852c20c18a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   622
            mp := device translatePoint:mp from:device rootView id to:self id.
1693
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   623
            "/ mp is a device coordinate here ...
1449
e5852c20c18a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   624
            scrollX := 0.
e5852c20c18a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   625
            mp x > width ifTrue:[
e5852c20c18a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   626
                scrollX := mp x - width.
e5852c20c18a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   627
            ] ifFalse:[
e5852c20c18a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   628
                mp x < 0 ifTrue:[
e5852c20c18a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   629
                    scrollX := mp x.
e5852c20c18a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   630
                ]
e5852c20c18a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   631
            ].
e5852c20c18a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   632
            scrollY := 0.
e5852c20c18a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   633
            mp y > height ifTrue:[
e5852c20c18a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   634
                scrollY := mp y - height.
e5852c20c18a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   635
            ] ifFalse:[
e5852c20c18a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   636
                mp y < 0 ifTrue:[
e5852c20c18a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   637
                    scrollY := mp y.
e5852c20c18a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   638
                ]
e5852c20c18a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   639
            ].
e5852c20c18a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   640
            (scrollX + scrollY) ~~ 0 ifTrue:[
e5852c20c18a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   641
                self scrollTo:(self viewOrigin + (scrollX @ scrollY)).
e5852c20c18a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   642
                lastMp := nil.
e5852c20c18a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   643
            ].
1084
87c661e6c333 scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents: 1060
diff changeset
   644
1693
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   645
            mp := mp + self viewOrigin.
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   646
            "/ mp is now a logical coordinate.
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   647
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   648
            currentPoint := (0@0) max: (image extent * magnification min: (p := mp)).
1449
e5852c20c18a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   649
            currentPoint := currentPoint//magnification*magnification.
e5852c20c18a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   650
            currentExtent := (firstPoint - currentPoint) abs.
e5852c20c18a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   651
            whichQuarter := (firstPoint x - currentPoint x) > 0 
e5852c20c18a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   652
                 ifTrue:  [(firstPoint y - currentPoint y) > 0 ifTrue: ["4"1@1] ifFalse: ["3"1@0]]
e5852c20c18a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   653
                 ifFalse: [(firstPoint y - currentPoint y) > 0 ifTrue: ["1"0@1] ifFalse: ["2"0@0]].
1084
87c661e6c333 scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents: 1060
diff changeset
   654
1449
e5852c20c18a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   655
            self drawCursorAt: p withLabel: 
e5852c20c18a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   656
                ((firstPoint//magnification - whichQuarter + 1) printString, 
e5852c20c18a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   657
                ' to: ', 
e5852c20c18a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   658
                (currentPoint//magnification + whichQuarter) printString),
e5852c20c18a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   659
                ' (extent: ',
e5852c20c18a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   660
                (currentExtent//magnification) printString, ')'.
1084
87c661e6c333 scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents: 1060
diff changeset
   661
1693
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   662
            currentPoint ~= lastCurrentPoint ifTrue:[   
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   663
                emphasis = #inverseFilledBox ifTrue: [
1449
e5852c20c18a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   664
                    self redraw: ((firstPoint min: lastCurrentPoint) - 1 extent: (firstPoint - lastCurrentPoint) abs + 2).
e5852c20c18a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   665
                    self xoring: [self fillRectangle: ((firstPoint min: currentPoint) + margin extent: currentExtent - gridCorrection)]
e5852c20c18a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   666
                ].
e5852c20c18a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   667
                emphasis = #box
1693
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   668
                ifTrue:[
1449
e5852c20c18a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   669
                    |origin extent lineWidthY lineWidthX|
e5852c20c18a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   670
                    origin := (firstPoint min: lastCurrentPoint) - 1.
e5852c20c18a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   671
                    extent := (firstPoint - lastCurrentPoint) abs + 2.
e5852c20c18a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   672
                    lineWidthY := extent y min: (magnification y + 2).
e5852c20c18a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   673
                    lineWidthX := extent x min: (magnification x + 2).
e5852c20c18a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   674
                    self redraw: (origin extent: (extent x@lineWidthY)).
e5852c20c18a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   675
                    self redraw: ((origin x@(origin y + extent y - lineWidthY)) extent: (extent x@lineWidthY)).
e5852c20c18a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   676
                    self redraw: ((origin x@(origin y + lineWidthY)) extent: (lineWidthX@(0 max: (extent y - (lineWidthY * 2))))).
e5852c20c18a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   677
                    self redraw: (((origin x + extent x - lineWidthX)@(origin y + lineWidthY)) extent: (lineWidthX@(extent y - (lineWidthY * 2)))).
e5852c20c18a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   678
                    self selectedColor ~= Color noColor
e5852c20c18a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   679
                        ifTrue: [self paint: self selectedColor]
e5852c20c18a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   680
                        ifFalse: [self paint: self viewBackground]. 
e5852c20c18a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   681
                    origin := (firstPoint min: currentPoint) + margin.
e5852c20c18a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   682
                    extent := currentExtent - gridCorrection.
e5852c20c18a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   683
                    lineWidthY := extent y min: magnification y.
e5852c20c18a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   684
                    lineWidthX := extent x min: magnification x.
e5852c20c18a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   685
                    (lineWidthY > 0 and: [lineWidthX > 0])
1693
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   686
                    ifTrue:[
1449
e5852c20c18a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   687
                        self fillRectangle: (origin extent: (extent x@lineWidthY)).
e5852c20c18a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   688
                        self fillRectangle: ((origin x@(origin y + extent y - lineWidthY)) extent: (extent x@lineWidthY)).
e5852c20c18a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   689
                        self fillRectangle: ((origin x@(origin y + lineWidthY)) extent: (lineWidthX@(0 max: (extent y - (lineWidthY * 2))))).
e5852c20c18a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   690
                        self fillRectangle: (((origin x + extent x - lineWidthX)@(origin y + lineWidthY)) extent: (lineWidthX@(extent y - (lineWidthY * 2)))).
e5852c20c18a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   691
                    ]
e5852c20c18a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   692
                ].
e5852c20c18a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   693
                emphasis = #filledBox
1693
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   694
                ifTrue:[
1449
e5852c20c18a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   695
                    self redraw: ((firstPoint min: lastCurrentPoint) - 1 extent: (firstPoint - lastCurrentPoint) abs + 2).
e5852c20c18a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   696
                    self selectedColor ~= Color noColor
e5852c20c18a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   697
                        ifTrue: [self paint: self selectedColor]
e5852c20c18a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   698
                        ifFalse: [self paint: self viewBackground].
e5852c20c18a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   699
                    self fillRectangle: ((firstPoint min: currentPoint) + margin extent: currentExtent - gridCorrection).
e5852c20c18a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   700
                ].
e5852c20c18a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   701
            ]. 
e5852c20c18a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   702
            lastCurrentPoint := currentPoint.
e5852c20c18a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   703
        ].                  
1084
87c661e6c333 scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents: 1060
diff changeset
   704
    ].                  
87c661e6c333 scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents: 1060
diff changeset
   705
87c661e6c333 scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents: 1060
diff changeset
   706
    ^((0@0) max: (firstPoint min: currentPoint)) extent: (firstPoint - currentPoint) abs
87c661e6c333 scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents: 1060
diff changeset
   707
87c661e6c333 scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents: 1060
diff changeset
   708
    "Created: / 21.8.1998 / 20:17:07 / cg"
1693
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   709
    "Modified: / 10.2.2000 / 21:46:05 / cg"
1084
87c661e6c333 scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents: 1060
diff changeset
   710
!
87c661e6c333 scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents: 1060
diff changeset
   711
1245
68581e6aaf23 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1228
diff changeset
   712
drawCursorAt:aPoint
68581e6aaf23 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1228
diff changeset
   713
    |clr imgPoint|
1031
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   714
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   715
    image isNil ifTrue: [
1245
68581e6aaf23 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1228
diff changeset
   716
        self updateImageInfo: self imageInfoString. 
68581e6aaf23 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1228
diff changeset
   717
        self cursor:Cursor stop.
68581e6aaf23 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1228
diff changeset
   718
        ^ self
1031
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   719
    ].
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
    (aPoint x < (image width * magnification) 
1060
690045fd9032 drag rect with bad point
tz
parents: 1053
diff changeset
   722
    and:[aPoint y < (image height * magnification)
690045fd9032 drag rect with bad point
tz
parents: 1053
diff changeset
   723
    and:[aPoint x >= 0
690045fd9032 drag rect with bad point
tz
parents: 1053
diff changeset
   724
    and:[aPoint y >= 0]]])
1031
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   725
    ifFalse:[
1245
68581e6aaf23 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1228
diff changeset
   726
        self updateImageInfo: self imageInfoString. 
68581e6aaf23 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1228
diff changeset
   727
        self cursor:Cursor stop.
1031
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   728
    ] ifTrue: [
1245
68581e6aaf23 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1228
diff changeset
   729
        imgPoint := aPoint // magnification.
68581e6aaf23 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1228
diff changeset
   730
        clr := image colorAt:imgPoint.
68581e6aaf23 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1228
diff changeset
   731
        self updateImageInfo: imgPoint printString 
68581e6aaf23 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1228
diff changeset
   732
                        , ' (r:' 
68581e6aaf23 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1228
diff changeset
   733
                        , clr redByte printString
68581e6aaf23 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1228
diff changeset
   734
                        , ' g:' , clr greenByte printString
68581e6aaf23 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1228
diff changeset
   735
                        , ' b:' , clr blueByte printString
68581e6aaf23 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1228
diff changeset
   736
                        , ' pixel:' , (image pixelAt:imgPoint) printString
68581e6aaf23 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1228
diff changeset
   737
                        , ')'.
68581e6aaf23 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1228
diff changeset
   738
        self cursor:Cursor crossHair
1031
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   739
    ].
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   740
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   741
    "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
   742
!
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   743
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   744
drawCursorAt: aPoint withLabel: aLabel
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   745
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   746
    ((0@0 extent: image extent * magnification) containsPoint: aPoint)
1116
441ff42c1472 fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents: 1106
diff changeset
   747
	 ifFalse:[self cursor:Cursor stop]
441ff42c1472 fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents: 1106
diff changeset
   748
	 ifTrue: [self cursor:Cursor crossHair].
1031
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   749
     self updateImageInfo: aLabel.
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   750
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   751
    "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
   752
!
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   753
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   754
updateActivity: something
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   755
    |msg|
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   756
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   757
    msg := something printString.
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   758
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   759
    "/ cg: new code:
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   760
    activityInfoHolder notNil ifTrue:[
1116
441ff42c1472 fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents: 1106
diff changeset
   761
	activityInfoHolder value:msg.
1031
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   762
    ].
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   763
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   764
    "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
   765
!
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   766
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   767
updateImageInfo: something
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   768
    |msg coordLabel|
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   769
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   770
    msg := something printString.
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   771
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   772
    "/ cg: new code:
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   773
    imageInfoHolder notNil ifTrue:[
1116
441ff42c1472 fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents: 1106
diff changeset
   774
	msg ~= imageInfoHolder value ifTrue:[
441ff42c1472 fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents: 1106
diff changeset
   775
	    imageInfoHolder value:msg.
441ff42c1472 fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents: 1106
diff changeset
   776
	].
441ff42c1472 fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents: 1106
diff changeset
   777
	^ self
1031
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   778
    ].
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   779
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   780
"/    "/ 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
   781
"/    "/ which gets the coordinate ...
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   782
"/
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   783
"/    (masterApplication respondsTo: #coordLabel)
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   784
"/    ifTrue:[  
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   785
"/        coordLabel := masterApplication coordLabel.
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   786
"/
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   787
"/        coordLabel label ~= msg
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   788
"/        ifTrue:[         
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   789
"/            coordLabel label: msg.
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   790
"/            "/ coordLabel redraw
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   791
"/        ]
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   792
"/    ]
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   793
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   794
    "Modified: / 29.7.1998 / 19:00:21 / cg"
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   795
! !
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   796
636
d53428252193 revised version
tz
parents: 633
diff changeset
   797
!ImageEditView methodsFor:'image editing'!
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   798
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   799
boxAt: aPoint
1116
441ff42c1472 fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents: 1106
diff changeset
   800
    "draw a rectangular outline with the currently selected color"
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   801
1116
441ff42c1472 fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents: 1106
diff changeset
   802
    |choosedBox imageBox clr|
1038
6c0bb03e88a1 no need to invalidate after assign of new image.
Claus Gittinger <cg@exept.de>
parents: 1037
diff changeset
   803
1116
441ff42c1472 fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents: 1106
diff changeset
   804
    (clr := self selectedColor) notNil ifTrue:[
1693
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   805
        choosedBox := self dragRectangleStartingAt: aPoint emphasis: #box.
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   806
        imageBox := choosedBox origin//magnification extent: (choosedBox extent//magnification).
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   807
        image rectangle:imageBox withColor:clr.
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   808
        image restored.
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   809
        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
   810
1693
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   811
"/        "/ cg: what a kludge - please change to use a valueHolder,
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   812
"/        "/ which gets the information ...
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   813
"/        masterApplication imagePreView redraw: (imageBox expandedBy: 1).
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   814
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   815
        "/ cg: still a kludge - but less ugly
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   816
        self changed:#subImageIn with:(imageBox expandedBy: 1).
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   817
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   818
        modified := true
1116
441ff42c1472 fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents: 1106
diff changeset
   819
    ].
441ff42c1472 fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents: 1106
diff changeset
   820
1693
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   821
    "Modified: / 10.2.2000 / 23:42:08 / cg"
632
be1ac8ea33a7 checkin from browser
tz
parents: 628
diff changeset
   822
!
be1ac8ea33a7 checkin from browser
tz
parents: 628
diff changeset
   823
be1ac8ea33a7 checkin from browser
tz
parents: 628
diff changeset
   824
copyAt: aPoint
be1ac8ea33a7 checkin from browser
tz
parents: 628
diff changeset
   825
1449
e5852c20c18a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   826
    |choosenBox r|
1084
87c661e6c333 scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents: 1060
diff changeset
   827
1449
e5852c20c18a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   828
    choosenBox := self dragRectangleStartingAt: aPoint emphasis: #inverseFilledBox.
995
cd84d6f8c449 several undos
tz
parents: 994
diff changeset
   829
    ClipboardMagnification := nil.
1449
e5852c20c18a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   830
    Clipboard := image subImageIn: (choosenBox origin//magnification extent: (choosenBox extent//magnification)).
e5852c20c18a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   831
    r := (choosenBox expandedBy:1).
e5852c20c18a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   832
    self redraw:r
632
be1ac8ea33a7 checkin from browser
tz
parents: 628
diff changeset
   833
1084
87c661e6c333 scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents: 1060
diff changeset
   834
    "Modified: / 21.8.1998 / 20:16:41 / cg"
632
be1ac8ea33a7 checkin from browser
tz
parents: 628
diff changeset
   835
!
be1ac8ea33a7 checkin from browser
tz
parents: 628
diff changeset
   836
1228
0aae4f7389ca renamed - crob -> crop
Claus Gittinger <cg@exept.de>
parents: 1184
diff changeset
   837
cropLeft:doLeft right:doRight top:doTop bottom:doBottom
1121
af09c616fb7b added crob operations.
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
   838
    |yMinNew yMaxNew xMinNew xMaxNew
af09c616fb7b added crob operations.
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
   839
     pix stillCrobbing xMax yMax x y|
af09c616fb7b added crob operations.
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
   840
af09c616fb7b added crob operations.
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
   841
    xMax := image width - 1.
af09c616fb7b added crob operations.
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
   842
    yMax := image height - 1.
af09c616fb7b added crob operations.
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
   843
af09c616fb7b added crob operations.
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
   844
    xMinNew := 0.
af09c616fb7b added crob operations.
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
   845
    doLeft ifTrue:[
af09c616fb7b added crob operations.
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
   846
        pix := image pixelAtX:xMinNew y:0.
af09c616fb7b added crob operations.
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
   847
        stillCrobbing := true.
af09c616fb7b added crob operations.
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
   848
        [stillCrobbing] whileTrue:[
af09c616fb7b added crob operations.
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
   849
            0 to:yMax do:[:y |
af09c616fb7b added crob operations.
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
   850
                (image pixelAtX:xMinNew y:y) ~~ pix ifTrue:[
af09c616fb7b added crob operations.
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
   851
                    stillCrobbing := false
af09c616fb7b added crob operations.
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
   852
                ]
af09c616fb7b added crob operations.
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
   853
            ].
af09c616fb7b added crob operations.
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
   854
            stillCrobbing ifTrue:[
af09c616fb7b added crob operations.
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
   855
                xMinNew := xMinNew + 1.
af09c616fb7b added crob operations.
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
   856
                xMinNew >= image width ifTrue:[
af09c616fb7b added crob operations.
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
   857
                    self warn:'Image is all the same color - no crob.'.
af09c616fb7b added crob operations.
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
   858
                    ^ self
af09c616fb7b added crob operations.
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
   859
                ]
af09c616fb7b added crob operations.
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
   860
            ].
af09c616fb7b added crob operations.
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
   861
        ].
af09c616fb7b added crob operations.
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
   862
    ].
af09c616fb7b added crob operations.
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
   863
af09c616fb7b added crob operations.
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
   864
    xMaxNew := xMax.
af09c616fb7b added crob operations.
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
   865
    doRight ifTrue:[
af09c616fb7b added crob operations.
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
   866
        stillCrobbing := true.
af09c616fb7b added crob operations.
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
   867
        pix := image pixelAtX:xMaxNew y:0.
af09c616fb7b added crob operations.
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
   868
        [stillCrobbing] whileTrue:[
af09c616fb7b added crob operations.
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
   869
            0 to:yMax do:[:y |
af09c616fb7b added crob operations.
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
   870
                (image pixelAtX:xMaxNew y:y) ~~ pix ifTrue:[
af09c616fb7b added crob operations.
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
   871
                    stillCrobbing := false
af09c616fb7b added crob operations.
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
   872
                ]
af09c616fb7b added crob operations.
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
   873
            ].
af09c616fb7b added crob operations.
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
   874
            stillCrobbing ifTrue:[
af09c616fb7b added crob operations.
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
   875
                xMaxNew := xMaxNew - 1.
af09c616fb7b added crob operations.
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
   876
            ].
af09c616fb7b added crob operations.
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
   877
        ].
af09c616fb7b added crob operations.
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
   878
    ].
af09c616fb7b added crob operations.
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
   879
af09c616fb7b added crob operations.
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
   880
    yMinNew := 0.
af09c616fb7b added crob operations.
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
   881
    doTop ifTrue:[
af09c616fb7b added crob operations.
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
   882
        pix := image pixelAtX:xMinNew y:yMinNew.
af09c616fb7b added crob operations.
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
   883
        stillCrobbing := true.
af09c616fb7b added crob operations.
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
   884
        [stillCrobbing] whileTrue:[
af09c616fb7b added crob operations.
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
   885
            xMinNew to:xMaxNew do:[:x |
af09c616fb7b added crob operations.
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
   886
                (image pixelAtX:x y:yMinNew) ~~ pix ifTrue:[
af09c616fb7b added crob operations.
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
   887
                    stillCrobbing := false
af09c616fb7b added crob operations.
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
   888
                ]
af09c616fb7b added crob operations.
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
   889
            ].
af09c616fb7b added crob operations.
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
   890
            stillCrobbing ifTrue:[
af09c616fb7b added crob operations.
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
   891
                yMinNew := yMinNew + 1.
af09c616fb7b added crob operations.
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
   892
            ].
af09c616fb7b added crob operations.
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
   893
        ].
af09c616fb7b added crob operations.
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
   894
    ].
af09c616fb7b added crob operations.
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
   895
af09c616fb7b added crob operations.
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
   896
    yMaxNew := yMax.
af09c616fb7b added crob operations.
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
   897
    doRight ifTrue:[
af09c616fb7b added crob operations.
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
   898
        stillCrobbing := true.
af09c616fb7b added crob operations.
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
   899
        pix := image pixelAtX:xMaxNew y:yMaxNew.
af09c616fb7b added crob operations.
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
   900
        [stillCrobbing] whileTrue:[
af09c616fb7b added crob operations.
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
   901
            xMinNew to:xMaxNew do:[:x |
af09c616fb7b added crob operations.
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
   902
                (image pixelAtX:x y:yMaxNew) ~~ pix ifTrue:[
af09c616fb7b added crob operations.
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
   903
                    stillCrobbing := false
af09c616fb7b added crob operations.
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
   904
                ]
af09c616fb7b added crob operations.
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
   905
            ].
af09c616fb7b added crob operations.
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
   906
            stillCrobbing ifTrue:[
af09c616fb7b added crob operations.
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
   907
                yMaxNew := yMaxNew - 1.
af09c616fb7b added crob operations.
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
   908
            ].
af09c616fb7b added crob operations.
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
   909
        ].
af09c616fb7b added crob operations.
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
   910
    ].
af09c616fb7b added crob operations.
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
   911
af09c616fb7b added crob operations.
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
   912
    (xMinNew == 0
af09c616fb7b added crob operations.
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
   913
    and:[xMaxNew == (image width - 1)
af09c616fb7b added crob operations.
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
   914
    and:[yMinNew == 0
af09c616fb7b added crob operations.
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
   915
    and:[yMaxNew == (image height - 1)]]]) ifTrue:[
af09c616fb7b added crob operations.
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
   916
        self warn:'No border found - no crob.'.
af09c616fb7b added crob operations.
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
   917
        ^ self
af09c616fb7b added crob operations.
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
   918
    ].
af09c616fb7b added crob operations.
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
   919
af09c616fb7b added crob operations.
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
   920
"/    self warn:'extract subImage ' 
af09c616fb7b added crob operations.
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
   921
"/              , (xMinNew @ yMinNew) printString
af09c616fb7b added crob operations.
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
   922
"/              , ' -> '
af09c616fb7b added crob operations.
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
   923
"/              , (xMaxNew @ yMaxNew) printString.
af09c616fb7b added crob operations.
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
   924
af09c616fb7b added crob operations.
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
   925
    self 
af09c616fb7b added crob operations.
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
   926
        makeSubImageX:xMinNew y:yMinNew 
af09c616fb7b added crob operations.
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
   927
        width:(xMaxNew - xMinNew + 1)
af09c616fb7b added crob operations.
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
   928
        height:(yMaxNew - yMinNew + 1)
af09c616fb7b added crob operations.
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
   929
af09c616fb7b added crob operations.
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
   930
    "Created: / 7.9.1998 / 14:25:52 / cg"
af09c616fb7b added crob operations.
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
   931
    "Modified: / 7.9.1998 / 16:35:35 / cg"
af09c616fb7b added crob operations.
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
   932
!
af09c616fb7b added crob operations.
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
   933
632
be1ac8ea33a7 checkin from browser
tz
parents: 628
diff changeset
   934
fillAt: aPoint
1116
441ff42c1472 fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents: 1106
diff changeset
   935
    "perform a flood-fill with the currently selected color"
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
   936
1116
441ff42c1472 fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents: 1106
diff changeset
   937
    windowGroup withExecuteCursorDo:[
1693
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   938
        |filledPoints clr|
1002
5d2e4c03a78e grid magnification can be changed
tz
parents: 996
diff changeset
   939
1693
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   940
        (clr := self selectedColor) notNil ifTrue:[
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   941
            self updateActivity:'Flood filling - press CTRL-y to abort ...'.
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   942
            [
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   943
                filledPoints := image floodFillAt: aPoint//magnification withColor:clr.
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   944
                image restored.
1038
6c0bb03e88a1 no need to invalidate after assign of new image.
Claus Gittinger <cg@exept.de>
parents: 1037
diff changeset
   945
1693
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   946
                "/ animation effect ...    
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   947
                filledPoints size < 300 ifTrue: [
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   948
                    filledPoints do: [:p| self redraw: ((p * magnification extent: magnification) expandedBy: 1)]
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   949
                ] ifFalse: [
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   950
                    self invalidate
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   951
                ].
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   952
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   953
"/                "/ cg: what a kludge - please change to use a valueHolder,
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   954
"/                "/ which gets the information ...
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   955
"/                masterApplication imagePreView invalidate.
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   956
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   957
                "/ cg: still a kludge - but less ugly
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   958
                self changed:#subImageIn with:(image bounds).
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   959
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   960
                modified := true
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   961
            ] valueOnUnwindDo:[
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   962
                self updateActivity:'Flood fill aborted.'
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   963
            ].
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   964
        ].
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   965
        self updateActivity:''
632
be1ac8ea33a7 checkin from browser
tz
parents: 628
diff changeset
   966
    ]
1031
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   967
1693
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   968
    "Modified: / 10.2.2000 / 23:40:58 / cg"
632
be1ac8ea33a7 checkin from browser
tz
parents: 628
diff changeset
   969
!
be1ac8ea33a7 checkin from browser
tz
parents: 628
diff changeset
   970
be1ac8ea33a7 checkin from browser
tz
parents: 628
diff changeset
   971
filledBoxAt: aPoint
1116
441ff42c1472 fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents: 1106
diff changeset
   972
    "fill a rectangular area with the currently selected color"
632
be1ac8ea33a7 checkin from browser
tz
parents: 628
diff changeset
   973
1116
441ff42c1472 fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents: 1106
diff changeset
   974
    |choosedBox imageBox clr|
1038
6c0bb03e88a1 no need to invalidate after assign of new image.
Claus Gittinger <cg@exept.de>
parents: 1037
diff changeset
   975
1116
441ff42c1472 fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents: 1106
diff changeset
   976
    (clr := self selectedColor) notNil ifTrue:[
1693
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   977
        choosedBox := self dragRectangleStartingAt: aPoint emphasis: #filledBox.
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   978
        imageBox := choosedBox origin//magnification extent: (choosedBox extent//magnification).
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   979
        image fillRectangle:imageBox withColor:clr.
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   980
        image restored.
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   981
        self redraw: (choosedBox expandedBy: 1).
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   982
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   983
"/        "/ cg: what a kludge - please change to use a valueHolder,
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   984
"/        "/ which gets the information ...
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   985
"/        masterApplication imagePreView redraw: (imageBox expandedBy: 1).
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   986
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   987
        "/ cg: still a kludge - but less ugly
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   988
        self changed:#subImageIn with:(imageBox expandedBy: 1).
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   989
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   990
        modified := true
1116
441ff42c1472 fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents: 1106
diff changeset
   991
    ]
441ff42c1472 fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents: 1106
diff changeset
   992
1693
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   993
    "Modified: / 10.2.2000 / 23:37:04 / cg"
632
be1ac8ea33a7 checkin from browser
tz
parents: 628
diff changeset
   994
!
be1ac8ea33a7 checkin from browser
tz
parents: 628
diff changeset
   995
636
d53428252193 revised version
tz
parents: 633
diff changeset
   996
flipHorizontal
d53428252193 revised version
tz
parents: 633
diff changeset
   997
995
cd84d6f8c449 several undos
tz
parents: 994
diff changeset
   998
    self makeUndo.
725
0e051202859d checkin from browser
tz
parents: 724
diff changeset
   999
    self image: image copy flipHorizontal
636
d53428252193 revised version
tz
parents: 633
diff changeset
  1000
d53428252193 revised version
tz
parents: 633
diff changeset
  1001
!
d53428252193 revised version
tz
parents: 633
diff changeset
  1002
d53428252193 revised version
tz
parents: 633
diff changeset
  1003
flipVertical
d53428252193 revised version
tz
parents: 633
diff changeset
  1004
995
cd84d6f8c449 several undos
tz
parents: 994
diff changeset
  1005
    self makeUndo.
725
0e051202859d checkin from browser
tz
parents: 724
diff changeset
  1006
    self image: image copy flipVertical
636
d53428252193 revised version
tz
parents: 633
diff changeset
  1007
d53428252193 revised version
tz
parents: 633
diff changeset
  1008
!
d53428252193 revised version
tz
parents: 633
diff changeset
  1009
1706
a954781f4440 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
  1010
magnifyImageTo:newSize
a954781f4440 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
  1011
    self makeUndo.
a954781f4440 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
  1012
    self image: (image magnifiedBy: newSize/image extent)
636
d53428252193 revised version
tz
parents: 633
diff changeset
  1013
!
d53428252193 revised version
tz
parents: 633
diff changeset
  1014
1121
af09c616fb7b added crob operations.
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
  1015
makeSubImageX:oldX y:oldY width:newWidth height:newHeight
af09c616fb7b added crob operations.
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
  1016
    |newImage|
af09c616fb7b added crob operations.
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
  1017
af09c616fb7b added crob operations.
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
  1018
    newImage := image class width:newWidth height:newHeight depth:image depth.
af09c616fb7b added crob operations.
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
  1019
    newImage photometric:image photometric.
af09c616fb7b added crob operations.
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
  1020
    newImage colorMap:image colorMap copy.
af09c616fb7b added crob operations.
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
  1021
    newImage bits:(ByteArray new:(newImage bytesPerRow * newHeight)).
af09c616fb7b added crob operations.
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
  1022
af09c616fb7b added crob operations.
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
  1023
    image mask notNil
af09c616fb7b added crob operations.
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
  1024
    ifTrue:[
af09c616fb7b added crob operations.
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
  1025
        |newMaskImage|
af09c616fb7b added crob operations.
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
  1026
af09c616fb7b added crob operations.
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
  1027
        newMaskImage := Depth1Image width:newWidth height:newHeight.
af09c616fb7b added crob operations.
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
  1028
        newMaskImage photometric: image mask photometric.
af09c616fb7b added crob operations.
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
  1029
        newMaskImage colorMap: image mask colorMap copy.
af09c616fb7b added crob operations.
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
  1030
        newMaskImage bits:(ByteArray new: newMaskImage bytesPerRow * newHeight).
af09c616fb7b added crob operations.
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
  1031
        newImage mask: newMaskImage
af09c616fb7b added crob operations.
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
  1032
    ].
af09c616fb7b added crob operations.
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
  1033
af09c616fb7b added crob operations.
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
  1034
    newImage copyFrom:image x:oldX y:oldY toX:0 y:0 width:newWidth height:newHeight.
af09c616fb7b added crob operations.
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
  1035
    self makeUndo.
af09c616fb7b added crob operations.
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
  1036
    self image: newImage.
af09c616fb7b added crob operations.
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
  1037
af09c616fb7b added crob operations.
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
  1038
    "Created: / 7.9.1998 / 13:00:16 / cg"
af09c616fb7b added crob operations.
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
  1039
    "Modified: / 7.9.1998 / 14:15:32 / cg"
af09c616fb7b added crob operations.
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
  1040
!
af09c616fb7b added crob operations.
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
  1041
636
d53428252193 revised version
tz
parents: 633
diff changeset
  1042
negativeImage
d53428252193 revised version
tz
parents: 633
diff changeset
  1043
995
cd84d6f8c449 several undos
tz
parents: 994
diff changeset
  1044
    self makeUndo.
1411
05ffc8ae696e methode negativeImage ivert bits of image
tm
parents: 1380
diff changeset
  1045
    self image: (image copy bits:(image bits invert))
636
d53428252193 revised version
tz
parents: 633
diff changeset
  1046
!
d53428252193 revised version
tz
parents: 633
diff changeset
  1047
d53428252193 revised version
tz
parents: 633
diff changeset
  1048
pasteAt: aPoint
1011
325d334e93c8 added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents: 1006
diff changeset
  1049
    "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
  1050
325d334e93c8 added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents: 1006
diff changeset
  1051
    self pasteAt:aPoint modeUnder:false.
325d334e93c8 added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents: 1006
diff changeset
  1052
!
325d334e93c8 added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents: 1006
diff changeset
  1053
325d334e93c8 added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents: 1006
diff changeset
  1054
pasteAt: aPoint modeUnder:modeUnder
325d334e93c8 added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents: 1006
diff changeset
  1055
    "paste the image in the clipboard at aPoint"
636
d53428252193 revised version
tz
parents: 633
diff changeset
  1056
995
cd84d6f8c449 several undos
tz
parents: 994
diff changeset
  1057
    ClipboardMagnification isNil ifTrue: [^self].
cd84d6f8c449 several undos
tz
parents: 994
diff changeset
  1058
636
d53428252193 revised version
tz
parents: 633
diff changeset
  1059
    Object errorSignal handle:
d53428252193 revised version
tz
parents: 633
diff changeset
  1060
    [:ex|
1246
0cd36bffc789 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
  1061
        ex signal == Image unrepresentableColorSignal ifFalse:[
0cd36bffc789 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
  1062
            ex reject
0cd36bffc789 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
  1063
        ].
0cd36bffc789 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
  1064
        self undo.
0cd36bffc789 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
  1065
        self warn: 'Paste failed !!\Increasing the images depth might help.' withCRs. 
636
d53428252193 revised version
tz
parents: 633
diff changeset
  1066
    ] 
d53428252193 revised version
tz
parents: 633
diff changeset
  1067
    do:
d53428252193 revised version
tz
parents: 633
diff changeset
  1068
    [   
1246
0cd36bffc789 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
  1069
        windowGroup withExecuteCursorDo:[
0cd36bffc789 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
  1070
            |choosedBox imagePoint imgX imgY copiedImage imageBox presentClr newColorMap|
995
cd84d6f8c449 several undos
tz
parents: 994
diff changeset
  1071
cd84d6f8c449 several undos
tz
parents: 994
diff changeset
  1072
1246
0cd36bffc789 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
  1073
            choosedBox := self dragRectangleStartingAt: aPoint emphasis: #inverseFilledBox.
1011
325d334e93c8 added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents: 1006
diff changeset
  1074
1246
0cd36bffc789 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
  1075
            imagePoint := choosedBox origin//magnification.
1011
325d334e93c8 added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents: 1006
diff changeset
  1076
1246
0cd36bffc789 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
  1077
            copiedImage := Clipboard copy.
0cd36bffc789 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
  1078
            image photometric == #palette ifTrue:[
0cd36bffc789 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
  1079
                "/ for all colors in the pasted image,
0cd36bffc789 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
  1080
                "/ check, if its in the colormap of the
0cd36bffc789 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
  1081
                "/ target image.
995
cd84d6f8c449 several undos
tz
parents: 994
diff changeset
  1082
1246
0cd36bffc789 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
  1083
                copiedImage usedValues do:[:pixel |
0cd36bffc789 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
  1084
                    |pastedColor oldColorMap|
1116
441ff42c1472 fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents: 1106
diff changeset
  1085
1246
0cd36bffc789 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
  1086
                    pastedColor := copiedImage colorFromValue:pixel.
0cd36bffc789 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
  1087
                    oldColorMap := image colorMap.
1028
4dfe1c6cbc48 fixed paste-drag display (when scrolled)
Claus Gittinger <cg@exept.de>
parents: 1027
diff changeset
  1088
1246
0cd36bffc789 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
  1089
                    (oldColorMap detect: [:clr| clr = pastedColor] ifNone: nil) isNil
0cd36bffc789 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
  1090
                    ifTrue:
0cd36bffc789 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
  1091
                    [        
0cd36bffc789 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
  1092
                        oldColorMap size < (1 bitShift:image depth) ifTrue:[
0cd36bffc789 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
  1093
                            "/ add to colormap
0cd36bffc789 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
  1094
                            newColorMap isNil ifTrue:[
0cd36bffc789 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
  1095
                                newColorMap := oldColorMap asOrderedCollection.
0cd36bffc789 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
  1096
                            ].
0cd36bffc789 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
  1097
                            newColorMap add:pastedColor.
1116
441ff42c1472 fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents: 1106
diff changeset
  1098
    "/                        Transcript showCR:'adding color:' , pastedColor displayString , ' to targets colorMap'.
1246
0cd36bffc789 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
  1099
                        ] ifFalse:[
1116
441ff42c1472 fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents: 1106
diff changeset
  1100
    "/                        Transcript showCR:'color:' , pastedColor displayString , ' not found in targets colorMap'.
1246
0cd36bffc789 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
  1101
                            copiedImage colorMap at: pixel+1 put: Color black
0cd36bffc789 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
  1102
                        ]
0cd36bffc789 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
  1103
                    ]
0cd36bffc789 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
  1104
                ].
995
cd84d6f8c449 several undos
tz
parents: 994
diff changeset
  1105
1246
0cd36bffc789 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
  1106
                newColorMap notNil ifTrue:[
0cd36bffc789 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
  1107
                    image colorMap:(Colormap fromColors:newColorMap).
0cd36bffc789 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
  1108
                ].
0cd36bffc789 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
  1109
            ].
1011
325d334e93c8 added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents: 1006
diff changeset
  1110
1246
0cd36bffc789 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
  1111
            copiedImage := image class fromImage: copiedImage.
1380
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
  1112
            (newColorMap isNil 
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
  1113
            and:[modeUnder not
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
  1114
            and:[copiedImage mask isNil]]) ifTrue:[
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
  1115
                "/ use images copy functionality
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
  1116
                "/ however, this copies the mask as well,
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
  1117
                "/ which is not useful here
1246
0cd36bffc789 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
  1118
                image copyFrom: copiedImage x:0 y:0 toX: imagePoint x y: imagePoint y width: copiedImage width height: copiedImage height.
0cd36bffc789 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
  1119
            ] ifFalse:[
994
5727c2484ecd bugs fixed in undo/mask and point painting/preview and pasting
tz
parents: 877
diff changeset
  1120
1246
0cd36bffc789 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
  1121
                imgX := imagePoint x.
0cd36bffc789 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
  1122
                imgY := imagePoint y.
1028
4dfe1c6cbc48 fixed paste-drag display (when scrolled)
Claus Gittinger <cg@exept.de>
parents: 1027
diff changeset
  1123
1246
0cd36bffc789 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
  1124
                0 to:copiedImage height-1 do:[:y |
0cd36bffc789 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
  1125
                    0 to:copiedImage width-1 do:[:x |
0cd36bffc789 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
  1126
                        |wasMasked newMasked dstX dstY oldColor|
1011
325d334e93c8 added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents: 1006
diff changeset
  1127
1246
0cd36bffc789 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
  1128
                        dstX := imgX + x.
0cd36bffc789 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
  1129
                        dstY := imgY + y.
0cd36bffc789 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
  1130
                        wasMasked := (image maskAtX:dstX y:dstY) == 0.
0cd36bffc789 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
  1131
                        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
  1132
1246
0cd36bffc789 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
  1133
                        "/ with modeUnder, 
0cd36bffc789 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
  1134
                        "/ only replace, if its either unmasked,
0cd36bffc789 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
  1135
                        "/ or the current drawing color.
0cd36bffc789 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
  1136
                        (modeUnder not
0cd36bffc789 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
  1137
                        or:[wasMasked
0cd36bffc789 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
  1138
                        or:[(oldColor := image colorAtX:dstX y:dstY) = (drawingColors at:1)]])
0cd36bffc789 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
  1139
                        ifTrue:[
1380
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
  1140
                            newMasked ifFalse:[
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
  1141
                                image 
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
  1142
                                    colorAtX:dstX
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
  1143
                                           y:dstY
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
  1144
                                         put:(copiedImage colorAtX:x y:y).
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
  1145
                                (wasMasked and:[newMasked not]) ifTrue:[
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
  1146
                                    image mask pixelAtX:dstX y:dstY put:1
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
  1147
                                ].
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
  1148
                            ]
1246
0cd36bffc789 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
  1149
                        ]
0cd36bffc789 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
  1150
                    ]
0cd36bffc789 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
  1151
                ].
0cd36bffc789 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
  1152
            ].
0cd36bffc789 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
  1153
            image restored.
0cd36bffc789 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
  1154
            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
  1155
"/            masterApplication imagePreView redraw: (imageBox expandedBy: 1).
1246
0cd36bffc789 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
  1156
            modified := true
0cd36bffc789 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
  1157
        ]
1028
4dfe1c6cbc48 fixed paste-drag display (when scrolled)
Claus Gittinger <cg@exept.de>
parents: 1027
diff changeset
  1158
   ]
4dfe1c6cbc48 fixed paste-drag display (when scrolled)
Claus Gittinger <cg@exept.de>
parents: 1027
diff changeset
  1159
1380
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
  1160
    "Modified: / 18.5.1999 / 20:40:37 / cg"
636
d53428252193 revised version
tz
parents: 633
diff changeset
  1161
!
d53428252193 revised version
tz
parents: 633
diff changeset
  1162
1011
325d334e93c8 added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents: 1006
diff changeset
  1163
pasteUnderAt: aPoint
325d334e93c8 added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents: 1006
diff changeset
  1164
    "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
  1165
     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
  1166
     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
  1167
325d334e93c8 added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents: 1006
diff changeset
  1168
    self pasteAt:aPoint modeUnder:true.
325d334e93c8 added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents: 1006
diff changeset
  1169
!
325d334e93c8 added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents: 1006
diff changeset
  1170
636
d53428252193 revised version
tz
parents: 633
diff changeset
  1171
pointAt: aPoint
1116
441ff42c1472 fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents: 1106
diff changeset
  1172
    "draw a single pixel with the currently selected color"
636
d53428252193 revised version
tz
parents: 633
diff changeset
  1173
1246
0cd36bffc789 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
  1174
    |imagePoint clr pix|
796
b68b09ddc62b preview redrawing
tz
parents: 783
diff changeset
  1175
1246
0cd36bffc789 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
  1176
    imagePoint := aPoint // magnification.
1277
8c74c9cc6e22 fixed point-drawing
Claus Gittinger <cg@exept.de>
parents: 1261
diff changeset
  1177
    (clr := self selectedColor) isNil ifTrue:[
8c74c9cc6e22 fixed point-drawing
Claus Gittinger <cg@exept.de>
parents: 1261
diff changeset
  1178
        pix := self selectedColorIndex
1246
0cd36bffc789 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
  1179
    ].
0cd36bffc789 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
  1180
    pix notNil ifTrue:[
1277
8c74c9cc6e22 fixed point-drawing
Claus Gittinger <cg@exept.de>
parents: 1261
diff changeset
  1181
        image colorMap atImageAndMask:imagePoint putValue:pix.
1245
68581e6aaf23 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1228
diff changeset
  1182
        modified := true.
1277
8c74c9cc6e22 fixed point-drawing
Claus Gittinger <cg@exept.de>
parents: 1261
diff changeset
  1183
    ] ifFalse:[     
8c74c9cc6e22 fixed point-drawing
Claus Gittinger <cg@exept.de>
parents: 1261
diff changeset
  1184
        clr notNil ifTrue:[
8c74c9cc6e22 fixed point-drawing
Claus Gittinger <cg@exept.de>
parents: 1261
diff changeset
  1185
            image atImageAndMask:imagePoint put:clr.
8c74c9cc6e22 fixed point-drawing
Claus Gittinger <cg@exept.de>
parents: 1261
diff changeset
  1186
            modified := true.
8c74c9cc6e22 fixed point-drawing
Claus Gittinger <cg@exept.de>
parents: 1261
diff changeset
  1187
        ].
1246
0cd36bffc789 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
  1188
    ].
1277
8c74c9cc6e22 fixed point-drawing
Claus Gittinger <cg@exept.de>
parents: 1261
diff changeset
  1189
    self invalidate:((imagePoint * magnification extent: magnification) expandedBy: 1).
1116
441ff42c1472 fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents: 1106
diff changeset
  1190
441ff42c1472 fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents: 1106
diff changeset
  1191
    "Modified: / 5.9.1998 / 13:25:29 / cg"
636
d53428252193 revised version
tz
parents: 633
diff changeset
  1192
!
d53428252193 revised version
tz
parents: 633
diff changeset
  1193
1374
44f511c341c0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1373
diff changeset
  1194
reduceColorResolutionBy:numBits
44f511c341c0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1373
diff changeset
  1195
    |xMax yMax r g b n_r n_g n_b clr n_clr mask anyChange|
44f511c341c0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1373
diff changeset
  1196
44f511c341c0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1373
diff changeset
  1197
    anyChange := false.
44f511c341c0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1373
diff changeset
  1198
44f511c341c0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1373
diff changeset
  1199
    xMax := image width - 1.
44f511c341c0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1373
diff changeset
  1200
    yMax := image height - 1.
44f511c341c0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1373
diff changeset
  1201
    mask := 16rFF bitShift:numBits.
44f511c341c0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1373
diff changeset
  1202
44f511c341c0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1373
diff changeset
  1203
    0 to:yMax do:[:y |
44f511c341c0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1373
diff changeset
  1204
        0 to:xMax do:[:x |
44f511c341c0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1373
diff changeset
  1205
            clr := image colorAtX:x y:y.
44f511c341c0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1373
diff changeset
  1206
            n_r := (r := clr redByte) bitAnd:mask.
44f511c341c0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1373
diff changeset
  1207
            n_g := (g := clr greenByte) bitAnd:mask.
44f511c341c0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1373
diff changeset
  1208
            n_b := (b := clr blueByte) bitAnd:mask.
44f511c341c0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1373
diff changeset
  1209
            n_clr := Color redByte:n_r greenByte:n_g blueByte:n_b.
44f511c341c0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1373
diff changeset
  1210
            (n_r ~~ r
44f511c341c0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1373
diff changeset
  1211
            or:[n_g ~~ g
44f511c341c0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1373
diff changeset
  1212
            or:[n_b ~~ b]]) ifTrue:[
44f511c341c0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1373
diff changeset
  1213
                image colorAtX:x y:y put:n_clr.
44f511c341c0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1373
diff changeset
  1214
                anyChange := true.
44f511c341c0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1373
diff changeset
  1215
            ]
44f511c341c0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1373
diff changeset
  1216
        ]
44f511c341c0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1373
diff changeset
  1217
    ].
44f511c341c0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1373
diff changeset
  1218
    ^ anyChange
44f511c341c0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1373
diff changeset
  1219
!
44f511c341c0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1373
diff changeset
  1220
1706
a954781f4440 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
  1221
resizeImageTo:newSize
a954781f4440 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
  1222
a954781f4440 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
  1223
    |newImage newMaskImage|
a954781f4440 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
  1224
a954781f4440 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
  1225
    newImage := image class width: newSize x height: newSize y depth: image depth.
a954781f4440 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
  1226
    newImage photometric:image photometric.
a954781f4440 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
  1227
    newImage colorMap:image colorMap copy.
a954781f4440 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
  1228
    newImage bits: (ByteArray new: newImage bytesPerRow * newSize y).
636
d53428252193 revised version
tz
parents: 633
diff changeset
  1229
1706
a954781f4440 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
  1230
    image mask notNil ifTrue:[
a954781f4440 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
  1231
        newMaskImage := Depth1Image width: newSize x height: newSize y.
a954781f4440 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
  1232
        newMaskImage photometric: image mask photometric.
a954781f4440 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
  1233
        newMaskImage colorMap: image mask colorMap copy.
a954781f4440 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
  1234
        newMaskImage bits:(ByteArray new: newMaskImage bytesPerRow * newSize y).
a954781f4440 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
  1235
        newImage mask: newMaskImage
a954781f4440 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
  1236
    ].
636
d53428252193 revised version
tz
parents: 633
diff changeset
  1237
1706
a954781f4440 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
  1238
    newImage copyFrom:image x:0 y:0 toX:0 y:0 width: (image width min:newSize x) height: (image height min:newSize y).
a954781f4440 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
  1239
    self makeUndo.
a954781f4440 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
  1240
    self image: newImage.
636
d53428252193 revised version
tz
parents: 633
diff changeset
  1241
!
d53428252193 revised version
tz
parents: 633
diff changeset
  1242
1706
a954781f4440 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
  1243
rotateImageBy:rotation
a954781f4440 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
  1244
    "rotate by (degrees)"
636
d53428252193 revised version
tz
parents: 633
diff changeset
  1245
1706
a954781f4440 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
  1246
    Object errorSignal handle:[:ex|
a954781f4440 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
  1247
        self warn: 'Image rotation failed!!\' withCRs, 'Increaing the image depth could help.'
a954781f4440 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
  1248
    ] do:[   
a954781f4440 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
  1249
        self makeUndo.
a954781f4440 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
  1250
        self image: (image hardRotated: rotation)
686
33833bcbb5cd some cleans
tz
parents: 678
diff changeset
  1251
    ]
1031
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
  1252
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
  1253
    "Modified: / 29.7.1998 / 18:21:14 / cg"
636
d53428252193 revised version
tz
parents: 633
diff changeset
  1254
!
d53428252193 revised version
tz
parents: 633
diff changeset
  1255
d53428252193 revised version
tz
parents: 633
diff changeset
  1256
undo
d53428252193 revised version
tz
parents: 633
diff changeset
  1257
1693
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
  1258
    undoImages notEmpty ifTrue:[           
1374
44f511c341c0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1373
diff changeset
  1259
        windowGroup withExecuteCursorDo:[
44f511c341c0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1373
diff changeset
  1260
            modified := false. 
44f511c341c0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1373
diff changeset
  1261
            self image: undoImages removeLast.
1693
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
  1262
"/            "/ cg: what a kludge - please change to use a valueHolder,
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
  1263
"/            masterApplication notNil ifTrue:[
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
  1264
"/                masterApplication listOfColors contents: image colorMap.
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
  1265
"/                masterApplication findColorMapMode.
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
  1266
"/"/                undoImages isEmpty ifTrue: [
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
  1267
"/"/                    masterApplication valueOfCanUndo value: false
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
  1268
"/"/                ].
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
  1269
"/            ].
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
  1270
            self changed:#image.
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
  1271
1374
44f511c341c0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1373
diff changeset
  1272
            "/ cg: not needed - image: already does it.
1038
6c0bb03e88a1 no need to invalidate after assign of new image.
Claus Gittinger <cg@exept.de>
parents: 1037
diff changeset
  1273
"/            self invalidate
1374
44f511c341c0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1373
diff changeset
  1274
        ]
636
d53428252193 revised version
tz
parents: 633
diff changeset
  1275
    ]
1038
6c0bb03e88a1 no need to invalidate after assign of new image.
Claus Gittinger <cg@exept.de>
parents: 1037
diff changeset
  1276
1693
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
  1277
    "Modified: / 10.2.2000 / 23:21:24 / cg"
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
  1278
! !
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
  1279
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
  1280
!ImageEditView methodsFor:'image setting'!
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
  1281
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
  1282
image:anImage
1256
c4e0b9024475 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1246
diff changeset
  1283
    |retVal fileName|
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
  1284
1256
c4e0b9024475 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1246
diff changeset
  1285
    anImage isImage ifTrue:[           
c4e0b9024475 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1246
diff changeset
  1286
        (image isNil or: [self checkModified]) ifTrue: [
1693
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
  1287
"/ cg: that is too ugly ...
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
  1288
"/            masterApplication notNil ifTrue: [
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
  1289
"/"/                undoImages notEmpty ifTrue: [
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
  1290
"/"/                    masterApplication valueOfCanUndo value: true
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
  1291
"/"/                ].
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
  1292
"/                masterApplication imagePreView image: anImage
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
  1293
"/            ].
1256
c4e0b9024475 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1246
diff changeset
  1294
            image notNil ifTrue: [
c4e0b9024475 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1246
diff changeset
  1295
                fileName := image fileName.
c4e0b9024475 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1246
diff changeset
  1296
                anImage fileName isNil ifTrue: [anImage fileName: fileName].
c4e0b9024475 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1246
diff changeset
  1297
            ].
c4e0b9024475 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1246
diff changeset
  1298
            super image: anImage.
c4e0b9024475 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1246
diff changeset
  1299
            retVal := self.
c4e0b9024475 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1246
diff changeset
  1300
        ].
c4e0b9024475 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1246
diff changeset
  1301
    ] ifFalse: [
c4e0b9024475 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1246
diff changeset
  1302
        super image: nil.
1031
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
  1303
    ].
1763
7d6d64622ee4 change & updates fixed (monochrome bitmaps)
Claus Gittinger <cg@exept.de>
parents: 1706
diff changeset
  1304
    "/cg: still a kludge, but less ugly
7d6d64622ee4 change & updates fixed (monochrome bitmaps)
Claus Gittinger <cg@exept.de>
parents: 1706
diff changeset
  1305
    self changed:#image.
1025
4470f3ad349f update the image label, when a new image is assigned.
Claus Gittinger <cg@exept.de>
parents: 1019
diff changeset
  1306
1031
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
  1307
    self updateImageInfo: self imageInfoString. 
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
  1308
    ^ retVal
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
  1309
1693
5f8be1b4f856 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
  1310
    "Modified: / 10.2.2000 / 23:33:12 / cg"
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
  1311
!
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
  1312
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
  1313
loadFromFile: aFileName
624
d98fe4700fc2 checkin from browser
tz
parents: 606
diff changeset
  1314
676
fd7918a3e6e6 load + preview redraw errors removed
tz
parents: 674
diff changeset
  1315
    aFileName isNil ifTrue: [^nil].
624
d98fe4700fc2 checkin from browser
tz
parents: 606
diff changeset
  1316
    Object errorSignal handle:
d98fe4700fc2 checkin from browser
tz
parents: 606
diff changeset
  1317
    [:exeption|
1116
441ff42c1472 fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents: 1106
diff changeset
  1318
	modified := false.
441ff42c1472 fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents: 1106
diff changeset
  1319
	self warn: exeption errorString.
441ff42c1472 fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents: 1106
diff changeset
  1320
	^nil
624
d98fe4700fc2 checkin from browser
tz
parents: 606
diff changeset
  1321
    ] 
d98fe4700fc2 checkin from browser
tz
parents: 606
diff changeset
  1322
    do:
676
fd7918a3e6e6 load + preview redraw errors removed
tz
parents: 674
diff changeset
  1323
    [ 
1116
441ff42c1472 fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents: 1106
diff changeset
  1324
	|imageFromFile|
441ff42c1472 fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents: 1106
diff changeset
  1325
	(imageFromFile := Image fromFile: aFileName) notNil
441ff42c1472 fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents: 1106
diff changeset
  1326
	ifTrue:
441ff42c1472 fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents: 1106
diff changeset
  1327
	[
441ff42c1472 fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents: 1106
diff changeset
  1328
	    self releaseUndos.
441ff42c1472 fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents: 1106
diff changeset
  1329
	    self image: imageFromFile. 
441ff42c1472 fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents: 1106
diff changeset
  1330
	    imageReaderClass := ImageReader allSubclasses
441ff42c1472 fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents: 1106
diff changeset
  1331
		detect: [:cls| cls isValidImageFile: aFileName]
441ff42c1472 fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents: 1106
diff changeset
  1332
		ifNone: [self error: 'Unknown image file format!!']
441ff42c1472 fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents: 1106
diff changeset
  1333
	]
441ff42c1472 fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents: 1106
diff changeset
  1334
	ifFalse:
441ff42c1472 fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents: 1106
diff changeset
  1335
	[
441ff42c1472 fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents: 1106
diff changeset
  1336
	    self error: 'Not an image file (or unrecognized format) !!'
441ff42c1472 fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents: 1106
diff changeset
  1337
	]
676
fd7918a3e6e6 load + preview redraw errors removed
tz
parents: 674
diff changeset
  1338
    ]
1031
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
  1339
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
  1340
    "Modified: / 29.7.1998 / 18:09:13 / cg"
624
d98fe4700fc2 checkin from browser
tz
parents: 606
diff changeset
  1341
!
255
1dfa8deddaef checkin from browser
Claus Gittinger <cg@exept.de>
parents: 251
diff changeset
  1342
633
594edef86630 revised version
tz
parents: 632
diff changeset
  1343
loadFromMessage: aMessage
594edef86630 revised version
tz
parents: 632
diff changeset
  1344
594edef86630 revised version
tz
parents: 632
diff changeset
  1345
    (self resourceMessage: aMessage) isNil
594edef86630 revised version
tz
parents: 632
diff changeset
  1346
    ifTrue:
594edef86630 revised version
tz
parents: 632
diff changeset
  1347
    [
1116
441ff42c1472 fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents: 1106
diff changeset
  1348
	^nil
633
594edef86630 revised version
tz
parents: 632
diff changeset
  1349
    ].
624
d98fe4700fc2 checkin from browser
tz
parents: 606
diff changeset
  1350
633
594edef86630 revised version
tz
parents: 632
diff changeset
  1351
    ^self loadfromClass: resourceClass andSelector: resourceSelector
594edef86630 revised version
tz
parents: 632
diff changeset
  1352
594edef86630 revised version
tz
parents: 632
diff changeset
  1353
   
594edef86630 revised version
tz
parents: 632
diff changeset
  1354
!
594edef86630 revised version
tz
parents: 632
diff changeset
  1355
594edef86630 revised version
tz
parents: 632
diff changeset
  1356
loadfromClass: aClassOrSymbol andSelector: aStringOrSymbol
594edef86630 revised version
tz
parents: 632
diff changeset
  1357
678
9afa8810a8be image must not be nil after load failure
tz
parents: 676
diff changeset
  1358
    |aClass| 
9afa8810a8be image must not be nil after load failure
tz
parents: 676
diff changeset
  1359
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
  1360
    imageReaderClass := nil.
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
  1361
    self resourceClass: aClassOrSymbol.
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
  1362
    self resourceSelector: aStringOrSymbol.
678
9afa8810a8be image must not be nil after load failure
tz
parents: 676
diff changeset
  1363
9afa8810a8be image must not be nil after load failure
tz
parents: 676
diff changeset
  1364
    ((aClass := Smalltalk at: resourceClass) isClass and: 
9afa8810a8be image must not be nil after load failure
tz
parents: 676
diff changeset
  1365
    [aClass class implements: resourceSelector])
624
d98fe4700fc2 checkin from browser
tz
parents: 606
diff changeset
  1366
    ifTrue:
d98fe4700fc2 checkin from browser
tz
parents: 606
diff changeset
  1367
    [ 
1116
441ff42c1472 fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents: 1106
diff changeset
  1368
	self releaseUndos.
441ff42c1472 fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents: 1106
diff changeset
  1369
	^self image: (aClass perform: resourceSelector) copy
674
f24ca336b717 if none image found for loading clear image
tz
parents: 662
diff changeset
  1370
    ]
f24ca336b717 if none image found for loading clear image
tz
parents: 662
diff changeset
  1371
    ifFalse:
f24ca336b717 if none image found for loading clear image
tz
parents: 662
diff changeset
  1372
    [
1116
441ff42c1472 fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents: 1106
diff changeset
  1373
	modified := false.
441ff42c1472 fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents: 1106
diff changeset
  1374
	^nil
674
f24ca336b717 if none image found for loading clear image
tz
parents: 662
diff changeset
  1375
    ]
f24ca336b717 if none image found for loading clear image
tz
parents: 662
diff changeset
  1376
161
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
  1377
! !
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
  1378
1327
ab99aad206dc category change
Claus Gittinger <cg@exept.de>
parents: 1277
diff changeset
  1379
!ImageEditView methodsFor:'initialize / release'!
ab99aad206dc category change
Claus Gittinger <cg@exept.de>
parents: 1277
diff changeset
  1380
ab99aad206dc category change
Claus Gittinger <cg@exept.de>
parents: 1277
diff changeset
  1381
destroy
ab99aad206dc category change
Claus Gittinger <cg@exept.de>
parents: 1277
diff changeset
  1382
ab99aad206dc category change
Claus Gittinger <cg@exept.de>
parents: 1277
diff changeset
  1383
    ClipboardMagnification := Clipboard := nil.
ab99aad206dc category change
Claus Gittinger <cg@exept.de>
parents: 1277
diff changeset
  1384
    LastMagnification      := magnification.
ab99aad206dc category change
Claus Gittinger <cg@exept.de>
parents: 1277
diff changeset
  1385
ab99aad206dc category change
Claus Gittinger <cg@exept.de>
parents: 1277
diff changeset
  1386
    super destroy
ab99aad206dc category change
Claus Gittinger <cg@exept.de>
parents: 1277
diff changeset
  1387
ab99aad206dc category change
Claus Gittinger <cg@exept.de>
parents: 1277
diff changeset
  1388
!
1
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
  1389
161
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
  1390
initialize
624
d98fe4700fc2 checkin from browser
tz
parents: 606
diff changeset
  1391
161
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
  1392
    super initialize.
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
  1393
686
33833bcbb5cd some cleans
tz
parents: 678
diff changeset
  1394
    self enableMotionEvents.
995
cd84d6f8c449 several undos
tz
parents: 994
diff changeset
  1395
1374
44f511c341c0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1373
diff changeset
  1396
    undoImages        := List new: MaxUndos.
1706
a954781f4440 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
  1397
    magnification     := LastMagnification ? (8@8).
995
cd84d6f8c449 several undos
tz
parents: 994
diff changeset
  1398
    modified          := false.
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
  1399
    mouseKeyColorMode := 1.
995
cd84d6f8c449 several undos
tz
parents: 994
diff changeset
  1400
    resourceClass     := resourceSelector := ''.
1246
0cd36bffc789 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
  1401
    drawingColors     := Array with: nil with: nil.   "/ left/right mouse colors
0cd36bffc789 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
  1402
    drawingPixels     := Array with: nil with: nil.   "/ left/right mouse colors
1106
57c41df67ae5 support radio buttons of the ImageEditor
tz
parents: 1104
diff changeset
  1403
    editMode          := #point.
1036
d860072f3b49 gridMag default.
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
  1404
1
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
  1405
! !
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
  1406
636
d53428252193 revised version
tz
parents: 633
diff changeset
  1407
!ImageEditView methodsFor:'printing & storing'!
1
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
  1408
724
d6f4b89940ed undo disabling
tz
parents: 704
diff changeset
  1409
loadFromClass
404
322e32d8f099 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 398
diff changeset
  1410
676
fd7918a3e6e6 load + preview redraw errors removed
tz
parents: 674
diff changeset
  1411
    ^self loadFromMessage: 
1184
58e399d8c312 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1180
diff changeset
  1412
        (ResourceSelectionBrowser
58e399d8c312 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1180
diff changeset
  1413
            request: 'Load Image From Class'
58e399d8c312 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1180
diff changeset
  1414
            onSuperclass: nil
58e399d8c312 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1180
diff changeset
  1415
            andClass: self resourceClass
58e399d8c312 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1180
diff changeset
  1416
            andSelector: self resourceSelector
58e399d8c312 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1180
diff changeset
  1417
            withResourceTypes: #(image fileImage programImage))
636
d53428252193 revised version
tz
parents: 633
diff changeset
  1418
            
477
37f12d35c359 added #resize.
Claus Gittinger <cg@exept.de>
parents: 430
diff changeset
  1419
161
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
  1420
!
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
  1421
995
cd84d6f8c449 several undos
tz
parents: 994
diff changeset
  1422
makeUndo
cd84d6f8c449 several undos
tz
parents: 994
diff changeset
  1423
1374
44f511c341c0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1373
diff changeset
  1424
    image notNil ifTrue:[       
44f511c341c0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1373
diff changeset
  1425
        undoImages size >= MaxUndos ifTrue:[
44f511c341c0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1373
diff changeset
  1426
            undoImages removeFirst.
44f511c341c0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1373
diff changeset
  1427
        ].
44f511c341c0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1373
diff changeset
  1428
        undoImages add: image copy
995
cd84d6f8c449 several undos
tz
parents: 994
diff changeset
  1429
    ]
cd84d6f8c449 several undos
tz
parents: 994
diff changeset
  1430
!
cd84d6f8c449 several undos
tz
parents: 994
diff changeset
  1431
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
  1432
print
624
d98fe4700fc2 checkin from browser
tz
parents: 606
diff changeset
  1433
686
33833bcbb5cd some cleans
tz
parents: 678
diff changeset
  1434
    image notNil 
33833bcbb5cd some cleans
tz
parents: 678
diff changeset
  1435
    ifTrue: 
636
d53428252193 revised version
tz
parents: 633
diff changeset
  1436
    [
1116
441ff42c1472 fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents: 1106
diff changeset
  1437
	|stream|
441ff42c1472 fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents: 1106
diff changeset
  1438
	Printer supportsPostscript ifFalse:
441ff42c1472 fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents: 1106
diff changeset
  1439
	[
441ff42c1472 fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents: 1106
diff changeset
  1440
	    ^self warn:'No postscript printer detected!!'
441ff42c1472 fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents: 1106
diff changeset
  1441
	].
441ff42c1472 fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents: 1106
diff changeset
  1442
	stream := Printer newNative.
441ff42c1472 fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents: 1106
diff changeset
  1443
	stream isNil ifTrue:
441ff42c1472 fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents: 1106
diff changeset
  1444
	[
441ff42c1472 fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents: 1106
diff changeset
  1445
	    ^self warn:'Cannot open printer stream!!'
441ff42c1472 fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents: 1106
diff changeset
  1446
	].
441ff42c1472 fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents: 1106
diff changeset
  1447
	self withWaitCursorDo:
441ff42c1472 fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents: 1106
diff changeset
  1448
	[
441ff42c1472 fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents: 1106
diff changeset
  1449
	    |psgc|
441ff42c1472 fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents: 1106
diff changeset
  1450
	    psgc := PSGraphicsContext on:stream.  
441ff42c1472 fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents: 1106
diff changeset
  1451
	    psgc displayForm: (image magnifiedBy: magnification) x:0 y:0.
441ff42c1472 fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents: 1106
diff changeset
  1452
	    psgc close
441ff42c1472 fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents: 1106
diff changeset
  1453
	]
398
7b7255a4db0d show a wait cursor while printing
Claus Gittinger <cg@exept.de>
parents: 362
diff changeset
  1454
    ]
624
d98fe4700fc2 checkin from browser
tz
parents: 606
diff changeset
  1455
!
d98fe4700fc2 checkin from browser
tz
parents: 606
diff changeset
  1456
d98fe4700fc2 checkin from browser
tz
parents: 606
diff changeset
  1457
save
d98fe4700fc2 checkin from browser
tz
parents: 606
diff changeset
  1458
632
be1ac8ea33a7 checkin from browser
tz
parents: 628
diff changeset
  1459
    self saveImageOrMask: #image.
be1ac8ea33a7 checkin from browser
tz
parents: 628
diff changeset
  1460
624
d98fe4700fc2 checkin from browser
tz
parents: 606
diff changeset
  1461
!
d98fe4700fc2 checkin from browser
tz
parents: 606
diff changeset
  1462
297
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
  1463
saveAs
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
  1464
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
  1465
    self saveImageFileAs
297
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
  1466
!
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
  1467
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
  1468
saveImageFileAs
1158
9b413954d34d issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents: 1121
diff changeset
  1469
    "ask for a fileName and save the image"
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
  1470
633
594edef86630 revised version
tz
parents: 632
diff changeset
  1471
    self saveImageFileAs:
1158
9b413954d34d issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents: 1121
diff changeset
  1472
        (FileSelectionBrowser
9b413954d34d issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents: 1121
diff changeset
  1473
            request: 'Save Image To File'
9b413954d34d issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents: 1121
diff changeset
  1474
            fileName: self image fileName
9b413954d34d issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents: 1121
diff changeset
  1475
            withFileFilters: FileSelectionBrowser saveImageFileNameFilters)
9b413954d34d issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents: 1121
diff changeset
  1476
9b413954d34d issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents: 1121
diff changeset
  1477
    "Modified: / 30.9.1998 / 23:05:19 / cg"
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
  1478
!
297
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
  1479
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
  1480
saveImageFileAs: aFileName
1158
9b413954d34d issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents: 1121
diff changeset
  1481
    "save the image in aFileName"
297
d733af1b0ffe better saving functions;
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
  1482
633
594edef86630 revised version
tz
parents: 632
diff changeset
  1483
    aFileName isNil ifTrue: [^nil].
1158
9b413954d34d issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents: 1121
diff changeset
  1484
    image notNil ifTrue:[
9b413954d34d issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents: 1121
diff changeset
  1485
        image fileName: aFileName.
9b413954d34d issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents: 1121
diff changeset
  1486
        self saveImageOrMask: #image
9b413954d34d issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents: 1121
diff changeset
  1487
    ] ifFalse:[
9b413954d34d issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents: 1121
diff changeset
  1488
        self warn: 'No image or file name for saving detected!!'
632
be1ac8ea33a7 checkin from browser
tz
parents: 628
diff changeset
  1489
    ]
1158
9b413954d34d issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents: 1121
diff changeset
  1490
9b413954d34d issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents: 1121
diff changeset
  1491
    "Modified: / 30.9.1998 / 23:04:55 / cg"
632
be1ac8ea33a7 checkin from browser
tz
parents: 628
diff changeset
  1492
!
be1ac8ea33a7 checkin from browser
tz
parents: 628
diff changeset
  1493
be1ac8ea33a7 checkin from browser
tz
parents: 628
diff changeset
  1494
saveImageMaskFileAs
1158
9b413954d34d issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents: 1121
diff changeset
  1495
    "ask for a fileName and save the mask only"
632
be1ac8ea33a7 checkin from browser
tz
parents: 628
diff changeset
  1496
633
594edef86630 revised version
tz
parents: 632
diff changeset
  1497
    self saveImageMaskFileAs:
1158
9b413954d34d issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents: 1121
diff changeset
  1498
        (FileSelectionBrowser
9b413954d34d issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents: 1121
diff changeset
  1499
            request: 'Save Image Mask To File'
9b413954d34d issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents: 1121
diff changeset
  1500
            fileName: self image fileName 
9b413954d34d issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents: 1121
diff changeset
  1501
            withFileFilters: FileSelectionBrowser saveImageFileNameFilters)
9b413954d34d issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents: 1121
diff changeset
  1502
9b413954d34d issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents: 1121
diff changeset
  1503
    "Modified: / 30.9.1998 / 23:04:11 / cg"
632
be1ac8ea33a7 checkin from browser
tz
parents: 628
diff changeset
  1504
!
be1ac8ea33a7 checkin from browser
tz
parents: 628
diff changeset
  1505
be1ac8ea33a7 checkin from browser
tz
parents: 628
diff changeset
  1506
saveImageMaskFileAs: aFileName
1158
9b413954d34d issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents: 1121
diff changeset
  1507
    "save the mask only in aFileName"
632
be1ac8ea33a7 checkin from browser
tz
parents: 628
diff changeset
  1508
633
594edef86630 revised version
tz
parents: 632
diff changeset
  1509
    aFileName isNil ifTrue: [^nil].
1158
9b413954d34d issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents: 1121
diff changeset
  1510
    (image notNil and:[image mask notNil]) ifTrue:[
9b413954d34d issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents: 1121
diff changeset
  1511
        image mask fileName:aFileName.
9b413954d34d issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents: 1121
diff changeset
  1512
        self saveImageOrMask: #mask
9b413954d34d issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents: 1121
diff changeset
  1513
    ] ifFalse:[
9b413954d34d issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents: 1121
diff changeset
  1514
        self warn: 'No image or image mask detected!!'
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
  1515
    ]
1158
9b413954d34d issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents: 1121
diff changeset
  1516
9b413954d34d issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents: 1121
diff changeset
  1517
    "Modified: / 30.9.1998 / 23:06:24 / cg"
628
7f36d8a7735f popup menu starts image editor
tz
parents: 627
diff changeset
  1518
!
7f36d8a7735f popup menu starts image editor
tz
parents: 627
diff changeset
  1519
632
be1ac8ea33a7 checkin from browser
tz
parents: 628
diff changeset
  1520
saveImageOrMask: what
1158
9b413954d34d issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents: 1121
diff changeset
  1521
    "save the image or the mask only (if what == #mask)"
628
7f36d8a7735f popup menu starts image editor
tz
parents: 627
diff changeset
  1522
1380
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
  1523
    |fileName|
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
  1524
1158
9b413954d34d issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents: 1121
diff changeset
  1525
    Object errorSignal handle:[:ex|
1380
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
  1526
        |msg|
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
  1527
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
  1528
        ex signal == Image fileCreationErrorSignal ifTrue:[
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
  1529
            msg := resources string:'Cannot create file: ''%1''' with:fileName asFilename pathName asText allBold
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
  1530
        ] ifFalse:[
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
  1531
            msg := ex errorString.
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
  1532
        ].
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
  1533
        Dialog warn:msg.
1158
9b413954d34d issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents: 1121
diff changeset
  1534
    ] do:[   
9b413954d34d issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents: 1121
diff changeset
  1535
        Image informationLostQuerySignal handle:[:ex|
9b413954d34d issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents: 1121
diff changeset
  1536
            "/ should make those warnings visible ...
9b413954d34d issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents: 1121
diff changeset
  1537
            (self confirm:(ex errorString , '\\Save anyway ?') withCRs) ifTrue:[
9b413954d34d issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents: 1121
diff changeset
  1538
                ex proceed.
9b413954d34d issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents: 1121
diff changeset
  1539
            ]
9b413954d34d issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents: 1121
diff changeset
  1540
        ] do:[   
9b413954d34d issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents: 1121
diff changeset
  1541
            windowGroup withCursor:Cursor write do:[
1380
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
  1542
                |suff fn|
1027
5bffbe90b8e2 show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents: 1025
diff changeset
  1543
1158
9b413954d34d issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents: 1121
diff changeset
  1544
                image isNil ifTrue:[
9b413954d34d issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents: 1121
diff changeset
  1545
                    ^ self error: 'No image to save!!'
9b413954d34d issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents: 1121
diff changeset
  1546
                ].
632
be1ac8ea33a7 checkin from browser
tz
parents: 628
diff changeset
  1547
1158
9b413954d34d issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents: 1121
diff changeset
  1548
                what = #image ifTrue:[   
9b413954d34d issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents: 1121
diff changeset
  1549
                    (fileName := image fileName) isNil ifTrue: [^self error: 'No file name for image detected!!'].
9b413954d34d issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents: 1121
diff changeset
  1550
                ].
9b413954d34d issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents: 1121
diff changeset
  1551
                what = #mask ifTrue:[   
9b413954d34d issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents: 1121
diff changeset
  1552
                    image mask isNil ifTrue: [^self error: 'No image mask to save!!'].
9b413954d34d issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents: 1121
diff changeset
  1553
                    (fileName := image mask fileName) isNil ifTrue: [^self error: 'No file name for image mask detected!!'].
9b413954d34d issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents: 1121
diff changeset
  1554
                ].
9b413954d34d issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents: 1121
diff changeset
  1555
                fileName := fileName asFilename.
9b413954d34d issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents: 1121
diff changeset
  1556
9b413954d34d issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents: 1121
diff changeset
  1557
                fileName name size = 0 ifTrue: [^self error: 'No file name detected!!'].
9b413954d34d issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents: 1121
diff changeset
  1558
                suff := fileName suffix asLowercase.
1373
c949e9f7757c give a warning, if saving in the given file-format is not
Claus Gittinger <cg@exept.de>
parents: 1327
diff changeset
  1559
                imageReaderClass := nil.
c949e9f7757c give a warning, if saving in the given file-format is not
Claus Gittinger <cg@exept.de>
parents: 1327
diff changeset
  1560
                imageReaderClass := MIMETypes imageReaderForSuffix:suff.
c949e9f7757c give a warning, if saving in the given file-format is not
Claus Gittinger <cg@exept.de>
parents: 1327
diff changeset
  1561
"/                (suff = 'tiff' or:[suff = 'tif']) ifTrue: [
c949e9f7757c give a warning, if saving in the given file-format is not
Claus Gittinger <cg@exept.de>
parents: 1327
diff changeset
  1562
"/                    imageReaderClass := TIFFReader
c949e9f7757c give a warning, if saving in the given file-format is not
Claus Gittinger <cg@exept.de>
parents: 1327
diff changeset
  1563
"/                ] ifFalse:[
c949e9f7757c give a warning, if saving in the given file-format is not
Claus Gittinger <cg@exept.de>
parents: 1327
diff changeset
  1564
"/                    suff = 'xpm' ifTrue: [
c949e9f7757c give a warning, if saving in the given file-format is not
Claus Gittinger <cg@exept.de>
parents: 1327
diff changeset
  1565
"/                        imageReaderClass := XPMReader
c949e9f7757c give a warning, if saving in the given file-format is not
Claus Gittinger <cg@exept.de>
parents: 1327
diff changeset
  1566
"/                    ] ifFalse:[
c949e9f7757c give a warning, if saving in the given file-format is not
Claus Gittinger <cg@exept.de>
parents: 1327
diff changeset
  1567
"/                        suff = 'xbm' ifTrue: [
c949e9f7757c give a warning, if saving in the given file-format is not
Claus Gittinger <cg@exept.de>
parents: 1327
diff changeset
  1568
"/                            imageReaderClass := XBMReader
c949e9f7757c give a warning, if saving in the given file-format is not
Claus Gittinger <cg@exept.de>
parents: 1327
diff changeset
  1569
"/                        ] ifFalse:[
c949e9f7757c give a warning, if saving in the given file-format is not
Claus Gittinger <cg@exept.de>
parents: 1327
diff changeset
  1570
"/                            suff = 'gif' ifTrue: [
c949e9f7757c give a warning, if saving in the given file-format is not
Claus Gittinger <cg@exept.de>
parents: 1327
diff changeset
  1571
"/                                imageReaderClass := GIFReader
c949e9f7757c give a warning, if saving in the given file-format is not
Claus Gittinger <cg@exept.de>
parents: 1327
diff changeset
  1572
"/                            ] ifFalse:[
c949e9f7757c give a warning, if saving in the given file-format is not
Claus Gittinger <cg@exept.de>
parents: 1327
diff changeset
  1573
"/                                (suff = 'jpg' or:[suff = 'jpeg']) ifTrue: [
c949e9f7757c give a warning, if saving in the given file-format is not
Claus Gittinger <cg@exept.de>
parents: 1327
diff changeset
  1574
"/                                    imageReaderClass := JPEGReader
c949e9f7757c give a warning, if saving in the given file-format is not
Claus Gittinger <cg@exept.de>
parents: 1327
diff changeset
  1575
"/                                ].
c949e9f7757c give a warning, if saving in the given file-format is not
Claus Gittinger <cg@exept.de>
parents: 1327
diff changeset
  1576
"/                            ]
c949e9f7757c give a warning, if saving in the given file-format is not
Claus Gittinger <cg@exept.de>
parents: 1327
diff changeset
  1577
"/                        ]
c949e9f7757c give a warning, if saving in the given file-format is not
Claus Gittinger <cg@exept.de>
parents: 1327
diff changeset
  1578
"/                    ]
c949e9f7757c give a warning, if saving in the given file-format is not
Claus Gittinger <cg@exept.de>
parents: 1327
diff changeset
  1579
"/                ].
1380
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
  1580
1373
c949e9f7757c give a warning, if saving in the given file-format is not
Claus Gittinger <cg@exept.de>
parents: 1327
diff changeset
  1581
                imageReaderClass isNil ifTrue: [
c949e9f7757c give a warning, if saving in the given file-format is not
Claus Gittinger <cg@exept.de>
parents: 1327
diff changeset
  1582
                    imageReaderClass := XPMReader. 
1380
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
  1583
                    image fileName:(fileName := image fileName, '.xpm').
1373
c949e9f7757c give a warning, if saving in the given file-format is not
Claus Gittinger <cg@exept.de>
parents: 1327
diff changeset
  1584
                    Dialog warn:(('Dont know how to write ''.' , suff , '''-files\\Saving in xpm format as ''%1''.') 
c949e9f7757c give a warning, if saving in the given file-format is not
Claus Gittinger <cg@exept.de>
parents: 1327
diff changeset
  1585
                                withCRs bindWith:image fileName asText allBold).
c949e9f7757c give a warning, if saving in the given file-format is not
Claus Gittinger <cg@exept.de>
parents: 1327
diff changeset
  1586
                ].
c949e9f7757c give a warning, if saving in the given file-format is not
Claus Gittinger <cg@exept.de>
parents: 1327
diff changeset
  1587
                (imageReaderClass canRepresent:image) ifFalse:[
c949e9f7757c give a warning, if saving in the given file-format is not
Claus Gittinger <cg@exept.de>
parents: 1327
diff changeset
  1588
                    imageReaderClass := XPMReader. 
1380
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
  1589
                    image fileName:(fileName := image fileName, '.xpm').
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
  1590
                    Dialog warn:(('Saving in ''.' , suff , '''-format is not supported\\Saving in xpm format as ''%1''.') 
1373
c949e9f7757c give a warning, if saving in the given file-format is not
Claus Gittinger <cg@exept.de>
parents: 1327
diff changeset
  1591
                                withCRs bindWith:image fileName asText allBold).
c949e9f7757c give a warning, if saving in the given file-format is not
Claus Gittinger <cg@exept.de>
parents: 1327
diff changeset
  1592
                ].
1380
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
  1593
                Transcript showCR:('saving as:' , fileName asFilename pathName).
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
  1594
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
  1595
                what = #image ifTrue: [image saveOn:fileName using: imageReaderClass. modified := false].
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
  1596
                what = #mask ifTrue: [image mask saveOn:fileName using: imageReaderClass].
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
  1597
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
  1598
                fileName asFilename exists ifFalse:[
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
  1599
                    Dialog warn:'Oops image save failed.'
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
  1600
                ]
1158
9b413954d34d issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents: 1121
diff changeset
  1601
            ]   
9b413954d34d issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents: 1121
diff changeset
  1602
        ]
1027
5bffbe90b8e2 show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents: 1025
diff changeset
  1603
    ]
5bffbe90b8e2 show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents: 1025
diff changeset
  1604
1380
3b343d2e69ef fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
  1605
    "Modified: / 18.5.1999 / 19:46:54 / cg"
633
594edef86630 revised version
tz
parents: 632
diff changeset
  1606
!
594edef86630 revised version
tz
parents: 632
diff changeset
  1607
594edef86630 revised version
tz
parents: 632
diff changeset
  1608
saveMethod
594edef86630 revised version
tz
parents: 632
diff changeset
  1609
594edef86630 revised version
tz
parents: 632
diff changeset
  1610
    Object errorSignal handle:
594edef86630 revised version
tz
parents: 632
diff changeset
  1611
    [:ex|
1116
441ff42c1472 fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents: 1106
diff changeset
  1612
	self warn: ex errorString.
441ff42c1472 fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents: 1106
diff changeset
  1613
	^nil                                 
633
594edef86630 revised version
tz
parents: 632
diff changeset
  1614
    ] 
594edef86630 revised version
tz
parents: 632
diff changeset
  1615
    do:
594edef86630 revised version
tz
parents: 632
diff changeset
  1616
    [   
1116
441ff42c1472 fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents: 1106
diff changeset
  1617
	|category imageStoreStream cls sel mthd imageKey|
822
cace81f0a86b do not overwrite method categories + toggle between mouse button colors
tz
parents: 796
diff changeset
  1618
1116
441ff42c1472 fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents: 1106
diff changeset
  1619
	windowGroup withExecuteCursorDo:[
441ff42c1472 fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents: 1106
diff changeset
  1620
	    (self resourceSelector trimBlanks size = 0) | (cls := Smalltalk at: self resourceClass) isClass not 
441ff42c1472 fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents: 1106
diff changeset
  1621
		ifTrue: [^self saveMethodAs].
822
cace81f0a86b do not overwrite method categories + toggle between mouse button colors
tz
parents: 796
diff changeset
  1622
1116
441ff42c1472 fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents: 1106
diff changeset
  1623
	    self image storeOn: (imageStoreStream := WriteStream on: '').
441ff42c1472 fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents: 1106
diff changeset
  1624
	    sel := self resourceSelector.
1027
5bffbe90b8e2 show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents: 1025
diff changeset
  1625
1116
441ff42c1472 fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents: 1106
diff changeset
  1626
	    "/ if that method already exists, do not overwrite the category
441ff42c1472 fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents: 1106
diff changeset
  1627
	    category := 'image specs'.
441ff42c1472 fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents: 1106
diff changeset
  1628
	    (mthd := cls class compiledMethodAt:sel) notNil ifTrue:[
441ff42c1472 fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents: 1106
diff changeset
  1629
		category := mthd category.
441ff42c1472 fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents: 1106
diff changeset
  1630
	    ].
822
cace81f0a86b do not overwrite method categories + toggle between mouse button colors
tz
parents: 796
diff changeset
  1631
1116
441ff42c1472 fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents: 1106
diff changeset
  1632
	    imageKey :=  (cls name, ' ', sel) asSymbol.
441ff42c1472 fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents: 1106
diff changeset
  1633
	    Icon constantNamed: imageKey put:nil.
441ff42c1472 fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents: 1106
diff changeset
  1634
	    ByteCodeCompiler 
441ff42c1472 fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents: 1106
diff changeset
  1635
		compile: ((sel,
441ff42c1472 fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents: 1106
diff changeset
  1636
		    '\', (ResourceSpecEditor codeGenerationCommentForClass: ImageEditor),
441ff42c1472 fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents: 1106
diff changeset
  1637
		    '\\' , 
441ff42c1472 fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents: 1106
diff changeset
  1638
		    '    "\',
441ff42c1472 fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents: 1106
diff changeset
  1639
		    '     self ' , self resourceSelector , ' inspect\',
441ff42c1472 fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents: 1106
diff changeset
  1640
		    '     ImageEditor openOnClass:self andSelector:#', self resourceSelector, 
441ff42c1472 fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents: 1106
diff changeset
  1641
		    '\    "',
441ff42c1472 fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents: 1106
diff changeset
  1642
		    '\\',
441ff42c1472 fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents: 1106
diff changeset
  1643
		    '    <resource: #image>',
441ff42c1472 fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents: 1106
diff changeset
  1644
		    '\\',
441ff42c1472 fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents: 1106
diff changeset
  1645
		    '    ^Icon\') withCRs, 
441ff42c1472 fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents: 1106
diff changeset
  1646
		    '        constantNamed:#''', imageKey, '''\' withCRs,
441ff42c1472 fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents: 1106
diff changeset
  1647
		    '        ifAbsentPut:[', imageStoreStream contents, ']')
441ff42c1472 fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents: 1106
diff changeset
  1648
		forClass: cls class inCategory: category.
441ff42c1472 fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents: 1106
diff changeset
  1649
	    modified := false.
441ff42c1472 fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents: 1106
diff changeset
  1650
	]
633
594edef86630 revised version
tz
parents: 632
diff changeset
  1651
    ]
1027
5bffbe90b8e2 show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents: 1025
diff changeset
  1652
1047
95f10ea8653d use #withExecuteCursorDo:
Claus Gittinger <cg@exept.de>
parents: 1038
diff changeset
  1653
    "Modified: / 31.7.1998 / 20:12:54 / cg"
633
594edef86630 revised version
tz
parents: 632
diff changeset
  1654
!
594edef86630 revised version
tz
parents: 632
diff changeset
  1655
594edef86630 revised version
tz
parents: 632
diff changeset
  1656
saveMethodAs
594edef86630 revised version
tz
parents: 632
diff changeset
  1657
636
d53428252193 revised version
tz
parents: 633
diff changeset
  1658
    (self resourceMessage:
1116
441ff42c1472 fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents: 1106
diff changeset
  1659
	(ResourceSelectionBrowser
441ff42c1472 fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents: 1106
diff changeset
  1660
	    request: 'Save Image In Class'
441ff42c1472 fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents: 1106
diff changeset
  1661
	    onSuperclass: #Object
441ff42c1472 fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents: 1106
diff changeset
  1662
	    andClass: self resourceClass
441ff42c1472 fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents: 1106
diff changeset
  1663
	    andSelector: self resourceSelector
441ff42c1472 fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents: 1106
diff changeset
  1664
	    withResourceTypes: #(image fileImage))) notNil
633
594edef86630 revised version
tz
parents: 632
diff changeset
  1665
    ifTrue:
674
f24ca336b717 if none image found for loading clear image
tz
parents: 662
diff changeset
  1666
    [   
1116
441ff42c1472 fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents: 1106
diff changeset
  1667
	^self saveMethod
674
f24ca336b717 if none image found for loading clear image
tz
parents: 662
diff changeset
  1668
    ].  
633
594edef86630 revised version
tz
parents: 632
diff changeset
  1669
    ^nil
1
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
  1670
! !
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
  1671
161
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
  1672
!ImageEditView methodsFor:'queries'!
5
be72e6ba4822 *** empty log message ***
claus
parents: 1
diff changeset
  1673
161
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
  1674
heightOfContents
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
  1675
686
33833bcbb5cd some cleans
tz
parents: 678
diff changeset
  1676
    image isNil ifTrue:[^0].
33833bcbb5cd some cleans
tz
parents: 678
diff changeset
  1677
    ^(image height * magnification y) rounded
5
be72e6ba4822 *** empty log message ***
claus
parents: 1
diff changeset
  1678
!
be72e6ba4822 *** empty log message ***
claus
parents: 1
diff changeset
  1679
995
cd84d6f8c449 several undos
tz
parents: 994
diff changeset
  1680
imageContainsPastePoint: aPoint
cd84d6f8c449 several undos
tz
parents: 994
diff changeset
  1681
cd84d6f8c449 several undos
tz
parents: 994
diff changeset
  1682
    ^image notNil and: 
1116
441ff42c1472 fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents: 1106
diff changeset
  1683
	[Clipboard notNil and:
441ff42c1472 fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents: 1106
diff changeset
  1684
	[((0@0 corner:(image extent) "- 1" - Clipboard extent) containsPoint: (((aPoint - margin + 1) / magnification) floor))]]
995
cd84d6f8c449 several undos
tz
parents: 994
diff changeset
  1685
!
cd84d6f8c449 several undos
tz
parents: 994
diff changeset
  1686
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
  1687
imageContainsPoint: aPoint
632
be1ac8ea33a7 checkin from browser
tz
parents: 628
diff changeset
  1688
be1ac8ea33a7 checkin from browser
tz
parents: 628
diff changeset
  1689
    ^image notNil and:
1116
441ff42c1472 fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents: 1106
diff changeset
  1690
	[((0@0 corner:(image extent) - 1) containsPoint: (((aPoint - margin + 1) / magnification) floor))]
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
  1691
!
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
  1692
783
c81a097b84b8 revised version
tz
parents: 747
diff changeset
  1693
imageInfoString
c81a097b84b8 revised version
tz
parents: 747
diff changeset
  1694
c81a097b84b8 revised version
tz
parents: 747
diff changeset
  1695
    |imageInfoString usedColors|
1011
325d334e93c8 added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents: 1006
diff changeset
  1696
325d334e93c8 added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents: 1006
diff changeset
  1697
    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
  1698
    ifFalse: [
1116
441ff42c1472 fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents: 1106
diff changeset
  1699
	image colorMap isNil ifTrue: [usedColors := '?'] ifFalse: [usedColors := image usedColors size].
441ff42c1472 fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents: 1106
diff changeset
  1700
	imageInfoString := image width printString, 'x'
441ff42c1472 fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents: 1106
diff changeset
  1701
	    , image height printString, 'x'
441ff42c1472 fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents: 1106
diff changeset
  1702
	    , (2 raisedTo: image depth) printString
441ff42c1472 fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents: 1106
diff changeset
  1703
	    , (image mask notNil ifTrue: [' (mask + '] ifFalse: ['('])
441ff42c1472 fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents: 1106
diff changeset
  1704
	    , usedColors printString
441ff42c1472 fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents: 1106
diff changeset
  1705
	    , ' used colors)'].
783
c81a097b84b8 revised version
tz
parents: 747
diff changeset
  1706
c81a097b84b8 revised version
tz
parents: 747
diff changeset
  1707
    ^imageInfoString
c81a097b84b8 revised version
tz
parents: 747
diff changeset
  1708
!
c81a097b84b8 revised version
tz
parents: 747
diff changeset
  1709
161
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
  1710
widthOfContents
5
be72e6ba4822 *** empty log message ***
claus
parents: 1
diff changeset
  1711
686
33833bcbb5cd some cleans
tz
parents: 678
diff changeset
  1712
    image isNil ifTrue:[^0].
33833bcbb5cd some cleans
tz
parents: 678
diff changeset
  1713
    ^(image width * magnification x) rounded
5
be72e6ba4822 *** empty log message ***
claus
parents: 1
diff changeset
  1714
! !
be72e6ba4822 *** empty log message ***
claus
parents: 1
diff changeset
  1715
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
  1716
!ImageEditView methodsFor:'release'!
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
  1717
995
cd84d6f8c449 several undos
tz
parents: 994
diff changeset
  1718
releasePasteDrawing
cd84d6f8c449 several undos
tz
parents: 994
diff changeset
  1719
cd84d6f8c449 several undos
tz
parents: 994
diff changeset
  1720
    (lastPastePoint notNil and: [ClipboardMagnification notNil]) 
cd84d6f8c449 several undos
tz
parents: 994
diff changeset
  1721
    ifTrue: 
cd84d6f8c449 several undos
tz
parents: 994
diff changeset
  1722
    [ 
1449
e5852c20c18a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
  1723
        self redraw: (lastPastePoint extent: (ClipboardMagnification extent)). 
995
cd84d6f8c449 several undos
tz
parents: 994
diff changeset
  1724
    ].
cd84d6f8c449 several undos
tz
parents: 994
diff changeset
  1725
    lastPastePoint := ClipboardMagnification := nil
cd84d6f8c449 several undos
tz
parents: 994
diff changeset
  1726
!
cd84d6f8c449 several undos
tz
parents: 994
diff changeset
  1727
cd84d6f8c449 several undos
tz
parents: 994
diff changeset
  1728
releaseUndos
cd84d6f8c449 several undos
tz
parents: 994
diff changeset
  1729
cd84d6f8c449 several undos
tz
parents: 994
diff changeset
  1730
    undoImages removeAll.
1038
6c0bb03e88a1 no need to invalidate after assign of new image.
Claus Gittinger <cg@exept.de>
parents: 1037
diff changeset
  1731
    "/ cg: what a kludge - please change to use a valueHolder,
1374
44f511c341c0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1373
diff changeset
  1732
"/    masterApplication notNil ifTrue:[
44f511c341c0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1373
diff changeset
  1733
"/        masterApplication valueOfCanUndo value: false.
44f511c341c0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1373
diff changeset
  1734
"/    ].
1038
6c0bb03e88a1 no need to invalidate after assign of new image.
Claus Gittinger <cg@exept.de>
parents: 1037
diff changeset
  1735
6c0bb03e88a1 no need to invalidate after assign of new image.
Claus Gittinger <cg@exept.de>
parents: 1037
diff changeset
  1736
    "Modified: / 31.7.1998 / 02:47:21 / cg"
627
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
  1737
! !
e0bf28f61361 many many fixes/enhancements
tz
parents: 624
diff changeset
  1738
632
be1ac8ea33a7 checkin from browser
tz
parents: 628
diff changeset
  1739
!ImageEditView methodsFor:'testing'!
be1ac8ea33a7 checkin from browser
tz
parents: 628
diff changeset
  1740
be1ac8ea33a7 checkin from browser
tz
parents: 628
diff changeset
  1741
checkModified
be1ac8ea33a7 checkin from browser
tz
parents: 628
diff changeset
  1742
be1ac8ea33a7 checkin from browser
tz
parents: 628
diff changeset
  1743
    modified
be1ac8ea33a7 checkin from browser
tz
parents: 628
diff changeset
  1744
    ifTrue:
be1ac8ea33a7 checkin from browser
tz
parents: 628
diff changeset
  1745
    [
1116
441ff42c1472 fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents: 1106
diff changeset
  1746
	((YesNoBox title:(resources string:'Image was modified !!'))
441ff42c1472 fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents: 1106
diff changeset
  1747
	    noText:(resources string:'Cancel');
441ff42c1472 fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents: 1106
diff changeset
  1748
	    yesText:(resources string:'Forget it and proceed');
441ff42c1472 fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents: 1106
diff changeset
  1749
	    showAtPointer;
441ff42c1472 fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents: 1106
diff changeset
  1750
	    accepted) ifFalse: [^false].
441ff42c1472 fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents: 1106
diff changeset
  1751
	modified := false
632
be1ac8ea33a7 checkin from browser
tz
parents: 628
diff changeset
  1752
    ].
be1ac8ea33a7 checkin from browser
tz
parents: 628
diff changeset
  1753
    ^true
1031
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
  1754
a5ab5869b2ba cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
  1755
    "Modified: / 29.7.1998 / 18:55:24 / cg"
632
be1ac8ea33a7 checkin from browser
tz
parents: 628
diff changeset
  1756
! !
be1ac8ea33a7 checkin from browser
tz
parents: 628
diff changeset
  1757
255
1dfa8deddaef checkin from browser
Claus Gittinger <cg@exept.de>
parents: 251
diff changeset
  1758
!ImageEditView class methodsFor:'documentation'!
161
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
  1759
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
  1760
version
1764
3dd553f8d9f0 oops - leftover halts
Claus Gittinger <cg@exept.de>
parents: 1763
diff changeset
  1761
    ^ '$Header: /cvs/stx/stx/libwidg2/ImageEditView.st,v 1.126 2000-04-19 11:18:21 cg Exp $'
161
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
  1762
! !
1245
68581e6aaf23 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1228
diff changeset
  1763
ImageEditView initialize!