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