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