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