ShadowView.st
author matilk
Wed, 13 Sep 2017 09:40:34 +0200
changeset 8174 2704c965b97b
parent 7792 36150f514d6a
child 7803 14d6df784ebb
child 8191 eba71ad14f69
permissions -rw-r--r--
#BUGFIX by Maren class: DeviceGraphicsContext changed: #displayDeviceOpaqueForm:x:y: nil check
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
48194c26a46c Initial revision
claus
parents:
diff changeset
     1
"
6
7ee0cfde237d *** empty log message ***
claus
parents: 5
diff changeset
     2
 COPYRIGHT (c) 1991 by Claus Gittinger
72
3e84121988c3 *** empty log message ***
claus
parents: 54
diff changeset
     3
	      All Rights Reserved
0
48194c26a46c Initial revision
claus
parents:
diff changeset
     4
48194c26a46c Initial revision
claus
parents:
diff changeset
     5
 This software is furnished under a license and may be used
48194c26a46c Initial revision
claus
parents:
diff changeset
     6
 only in accordance with the terms of that license and with the
48194c26a46c Initial revision
claus
parents:
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
48194c26a46c Initial revision
claus
parents:
diff changeset
     8
 be provided or otherwise made available to, or used by, any
48194c26a46c Initial revision
claus
parents:
diff changeset
     9
 other person.  No title to or ownership of the software is
48194c26a46c Initial revision
claus
parents:
diff changeset
    10
 hereby transferred.
48194c26a46c Initial revision
claus
parents:
diff changeset
    11
"
3292
f5cbe9b1dc2a comment
Claus Gittinger <cg@exept.de>
parents: 2916
diff changeset
    12
"{ Package: 'stx:libview' }"
f5cbe9b1dc2a comment
Claus Gittinger <cg@exept.de>
parents: 2916
diff changeset
    13
7267
15f4a39b25fd device access
Claus Gittinger <cg@exept.de>
parents: 6274
diff changeset
    14
"{ NameSpace: Smalltalk }"
15f4a39b25fd device access
Claus Gittinger <cg@exept.de>
parents: 6274
diff changeset
    15
135
claus
parents: 86
diff changeset
    16
SimpleView subclass:#ShadowView
616
56cf67c82664 documentation
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
    17
	instanceVariableNames:'myView shadowLength shadowClr imageUnderShadow'
56cf67c82664 documentation
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
    18
	classVariableNames:''
56cf67c82664 documentation
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
    19
	poolDictionaries:''
626
9f4a3aa6f8e2 class category changes
Claus Gittinger <cg@exept.de>
parents: 616
diff changeset
    20
	category:'Views-Special'
0
48194c26a46c Initial revision
claus
parents:
diff changeset
    21
!
48194c26a46c Initial revision
claus
parents:
diff changeset
    22
1292
130328a7fc1b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 950
diff changeset
    23
!ShadowView class methodsFor:'documentation'!
46
7b331e9012fd *** empty log message ***
claus
parents: 12
diff changeset
    24
7b331e9012fd *** empty log message ***
claus
parents: 12
diff changeset
    25
copyright
7b331e9012fd *** empty log message ***
claus
parents: 12
diff changeset
    26
"
7b331e9012fd *** empty log message ***
claus
parents: 12
diff changeset
    27
 COPYRIGHT (c) 1991 by Claus Gittinger
72
3e84121988c3 *** empty log message ***
claus
parents: 54
diff changeset
    28
	      All Rights Reserved
0
48194c26a46c Initial revision
claus
parents:
diff changeset
    29
46
7b331e9012fd *** empty log message ***
claus
parents: 12
diff changeset
    30
 This software is furnished under a license and may be used
7b331e9012fd *** empty log message ***
claus
parents: 12
diff changeset
    31
 only in accordance with the terms of that license and with the
7b331e9012fd *** empty log message ***
claus
parents: 12
diff changeset
    32
 inclusion of the above copyright notice.   This software may not
7b331e9012fd *** empty log message ***
claus
parents: 12
diff changeset
    33
 be provided or otherwise made available to, or used by, any
7b331e9012fd *** empty log message ***
claus
parents: 12
diff changeset
    34
 other person.  No title to or ownership of the software is
7b331e9012fd *** empty log message ***
claus
parents: 12
diff changeset
    35
 hereby transferred.
7b331e9012fd *** empty log message ***
claus
parents: 12
diff changeset
    36
"
7b331e9012fd *** empty log message ***
claus
parents: 12
diff changeset
    37
!
0
48194c26a46c Initial revision
claus
parents:
diff changeset
    38
46
7b331e9012fd *** empty log message ***
claus
parents: 12
diff changeset
    39
documentation
7b331e9012fd *** empty log message ***
claus
parents: 12
diff changeset
    40
"
676
c51fc273f1cb commentary
Claus Gittinger <cg@exept.de>
parents: 642
diff changeset
    41
    ShadowView exists just to give PopUps and ModalBoxes a shadow. 
c51fc273f1cb commentary
Claus Gittinger <cg@exept.de>
parents: 642
diff changeset
    42
72
3e84121988c3 *** empty log message ***
claus
parents: 54
diff changeset
    43
    If shadowClr is nil, the shadowView reads the screen-contents under 
3e84121988c3 *** empty log message ***
claus
parents: 54
diff changeset
    44
    itself before realization, and uses a greyed version of these pixels
3e84121988c3 *** empty log message ***
claus
parents: 54
diff changeset
    45
    for its background. If shadowClr is non-nil, that color is used
3e84121988c3 *** empty log message ***
claus
parents: 54
diff changeset
    46
    as shadow (can be used for solid-black shadows).
3e84121988c3 *** empty log message ***
claus
parents: 54
diff changeset
    47
3e84121988c3 *** empty log message ***
claus
parents: 54
diff changeset
    48
    The instance variable myView is the view, for which the shadow is for.
616
56cf67c82664 documentation
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
    49
56cf67c82664 documentation
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
    50
    [author:]
56cf67c82664 documentation
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
    51
        Claus Gittinger
46
7b331e9012fd *** empty log message ***
claus
parents: 12
diff changeset
    52
"
7b331e9012fd *** empty log message ***
claus
parents: 12
diff changeset
    53
! !
0
48194c26a46c Initial revision
claus
parents:
diff changeset
    54
269
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    55
!ShadowView methodsFor:'accessing'!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    56
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    57
for:aView
676
c51fc273f1cb commentary
Claus Gittinger <cg@exept.de>
parents: 642
diff changeset
    58
    "set the view I am a shadow for"
269
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    59
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    60
    myView := aView
676
c51fc273f1cb commentary
Claus Gittinger <cg@exept.de>
parents: 642
diff changeset
    61
c51fc273f1cb commentary
Claus Gittinger <cg@exept.de>
parents: 642
diff changeset
    62
    "Modified: 12.5.1996 / 21:59:17 / cg"
269
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    63
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    64
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    65
isPopUpView
676
c51fc273f1cb commentary
Claus Gittinger <cg@exept.de>
parents: 642
diff changeset
    66
    "return true, since I want to come up without decoration"
c51fc273f1cb commentary
Claus Gittinger <cg@exept.de>
parents: 642
diff changeset
    67
269
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    68
    ^ true
676
c51fc273f1cb commentary
Claus Gittinger <cg@exept.de>
parents: 642
diff changeset
    69
c51fc273f1cb commentary
Claus Gittinger <cg@exept.de>
parents: 642
diff changeset
    70
    "Modified: 12.5.1996 / 21:57:23 / cg"
269
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    71
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    72
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    73
shadowColor:aColor
676
c51fc273f1cb commentary
Claus Gittinger <cg@exept.de>
parents: 642
diff changeset
    74
    "set the shadow color"
269
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    75
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    76
    shadowClr := aColor
676
c51fc273f1cb commentary
Claus Gittinger <cg@exept.de>
parents: 642
diff changeset
    77
c51fc273f1cb commentary
Claus Gittinger <cg@exept.de>
parents: 642
diff changeset
    78
    "Modified: 12.5.1996 / 21:59:25 / cg"
269
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    79
! !
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    80
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    81
!ShadowView methodsFor:'event handling'!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    82
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    83
redraw
676
c51fc273f1cb commentary
Claus Gittinger <cg@exept.de>
parents: 642
diff changeset
    84
    "if I have a shadowColor, fill all of myself with it;
c51fc273f1cb commentary
Claus Gittinger <cg@exept.de>
parents: 642
diff changeset
    85
     otherwise, draw the saved image under myself."
269
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    86
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    87
    |ws hs|
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    88
274
30d54aac94a7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 269
diff changeset
    89
    ws := shadowLength x.
30d54aac94a7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 269
diff changeset
    90
    hs := shadowLength y.
269
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    91
    shadowClr isNil ifTrue:[
676
c51fc273f1cb commentary
Claus Gittinger <cg@exept.de>
parents: 642
diff changeset
    92
        imageUnderShadow isNil ifTrue:[^ self].
269
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    93
676
c51fc273f1cb commentary
Claus Gittinger <cg@exept.de>
parents: 642
diff changeset
    94
        self copyFrom:imageUnderShadow x:(width - ws) y:0 
c51fc273f1cb commentary
Claus Gittinger <cg@exept.de>
parents: 642
diff changeset
    95
                                     toX:(width - ws) y:0 
c51fc273f1cb commentary
Claus Gittinger <cg@exept.de>
parents: 642
diff changeset
    96
                                   width:ws height:height.
c51fc273f1cb commentary
Claus Gittinger <cg@exept.de>
parents: 642
diff changeset
    97
        self copyFrom:imageUnderShadow x:0 y:(height - hs) 
c51fc273f1cb commentary
Claus Gittinger <cg@exept.de>
parents: 642
diff changeset
    98
                                     toX:0 y:(height - hs) 
c51fc273f1cb commentary
Claus Gittinger <cg@exept.de>
parents: 642
diff changeset
    99
                                   width:width height:hs.
269
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   100
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   101
    ] ifFalse:[
7792
36150f514d6a #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 7585
diff changeset
   102
        gc paint:shadowClr.
36150f514d6a #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 7585
diff changeset
   103
        gc fillRectangleX:(width - ws) y:0 width:ws height:height
269
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   104
    ]
676
c51fc273f1cb commentary
Claus Gittinger <cg@exept.de>
parents: 642
diff changeset
   105
c51fc273f1cb commentary
Claus Gittinger <cg@exept.de>
parents: 642
diff changeset
   106
    "Modified: 12.5.1996 / 22:00:05 / cg"
269
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   107
! !
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   108
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   109
!ShadowView methodsFor:'initialization'!
48194c26a46c Initial revision
claus
parents:
diff changeset
   110
269
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   111
create
676
c51fc273f1cb commentary
Claus Gittinger <cg@exept.de>
parents: 642
diff changeset
   112
    "enable saveUnder of the covered view(s).
c51fc273f1cb commentary
Claus Gittinger <cg@exept.de>
parents: 642
diff changeset
   113
     This may not be supported by all devices - these have to redraw then"
c51fc273f1cb commentary
Claus Gittinger <cg@exept.de>
parents: 642
diff changeset
   114
269
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   115
    super create.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   116
    self backingStore:false.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   117
    self saveUnder:true
676
c51fc273f1cb commentary
Claus Gittinger <cg@exept.de>
parents: 642
diff changeset
   118
c51fc273f1cb commentary
Claus Gittinger <cg@exept.de>
parents: 642
diff changeset
   119
    "Modified: 12.5.1996 / 22:00:47 / cg"
269
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   120
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   121
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   122
initialize
48194c26a46c Initial revision
claus
parents:
diff changeset
   123
    super initialize.
5415
d6e243f99770 border handling
Claus Gittinger <cg@exept.de>
parents: 5389
diff changeset
   124
    self borderWidth:0.
72
3e84121988c3 *** empty log message ***
claus
parents: 54
diff changeset
   125
274
30d54aac94a7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 269
diff changeset
   126
    shadowClr := StyleSheet at:#popUpShadowColor.
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   127
48194c26a46c Initial revision
claus
parents:
diff changeset
   128
    "the length of the shadow from myView"
7267
15f4a39b25fd device access
Claus Gittinger <cg@exept.de>
parents: 6274
diff changeset
   129
    shadowLength := device pixelPerMillimeter.
6274
e37dc412eb6a class: ShadowView
Stefan Vogel <sv@exept.de>
parents: 5415
diff changeset
   130
    "/ shadowLength := (self graphicsDevice pixelPerMillimeter * 2.0) rounded.
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   131
!
48194c26a46c Initial revision
claus
parents:
diff changeset
   132
48194c26a46c Initial revision
claus
parents:
diff changeset
   133
realize
54
29a6b2f8e042 *** empty log message ***
claus
parents: 46
diff changeset
   134
    "realize the shadowView some distance away from myView,
29a6b2f8e042 *** empty log message ***
claus
parents: 46
diff changeset
   135
     get the pixels under the shadow from the screen"
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   136
3490
7a560c566b72 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3301
diff changeset
   137
    |root shW shH right bot kludge clr1 clr0 org blackIs0 img
6274
e37dc412eb6a class: ShadowView
Stefan Vogel <sv@exept.de>
parents: 5415
diff changeset
   138
     rS gS bS rM gM bM rSN gSN bSN pix r g b graphicsDevice|
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   139
48194c26a46c Initial revision
claus
parents:
diff changeset
   140
    myView notNil ifTrue:[
7267
15f4a39b25fd device access
Claus Gittinger <cg@exept.de>
parents: 6274
diff changeset
   141
        graphicsDevice := device.
2916
79eedd2e05ac checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2830
diff changeset
   142
743
64c9b71b3cc4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   143
        self origin:(myView origin + (myView borderWidth * 2) + shadowLength) 
64c9b71b3cc4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   144
             extent:(myView extent).
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   145
743
64c9b71b3cc4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   146
        shadowClr isNil ifTrue:[
64c9b71b3cc4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   147
            "
64c9b71b3cc4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   148
             get the pixels under the shadow 
64c9b71b3cc4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   149
             (copy from root-view into the 'imageUnderShadow'-form)
64c9b71b3cc4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   150
            "
6274
e37dc412eb6a class: ShadowView
Stefan Vogel <sv@exept.de>
parents: 5415
diff changeset
   151
            imageUnderShadow := Form width:width height:height depth:graphicsDevice depth onDevice:graphicsDevice.
1727
c2140507ab19 oops - X needs clippedByChildren:false.
Claus Gittinger <cg@exept.de>
parents: 1722
diff changeset
   152
            imageUnderShadow clippedByChildren:false.
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   153
743
64c9b71b3cc4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   154
            shW := shadowLength x.
64c9b71b3cc4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   155
            shH := shadowLength y.
64c9b71b3cc4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   156
            right := width - shW.
64c9b71b3cc4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   157
            bot := height - shH.
54
29a6b2f8e042 *** empty log message ***
claus
parents: 46
diff changeset
   158
6274
e37dc412eb6a class: ShadowView
Stefan Vogel <sv@exept.de>
parents: 5415
diff changeset
   159
            root := graphicsDevice rootView.
743
64c9b71b3cc4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   160
64c9b71b3cc4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   161
            clr0 := Color colorId:0.
64c9b71b3cc4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   162
            clr1 := Color colorId:1.
2
b35336ab0de3 *** empty log message ***
claus
parents: 0
diff changeset
   163
6274
e37dc412eb6a class: ShadowView
Stefan Vogel <sv@exept.de>
parents: 5415
diff changeset
   164
            kludge := graphicsDevice depth == 1.
e37dc412eb6a class: ShadowView
Stefan Vogel <sv@exept.de>
parents: 5415
diff changeset
   165
            blackIs0 := (graphicsDevice blackpixel == 0).
743
64c9b71b3cc4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   166
            (kludge and:[blackIs0]) ifTrue:[
1727
c2140507ab19 oops - X needs clippedByChildren:false.
Claus Gittinger <cg@exept.de>
parents: 1722
diff changeset
   167
                imageUnderShadow foreground:clr0 background:clr1.
743
64c9b71b3cc4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   168
            ].
2
b35336ab0de3 *** empty log message ***
claus
parents: 0
diff changeset
   169
743
64c9b71b3cc4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   170
            org := self origin.
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   171
743
64c9b71b3cc4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   172
            imageUnderShadow copyFrom:root x:(org x + right) y:org y 
64c9b71b3cc4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   173
                                         toX:right y:0 width:shW height:height.
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   174
743
64c9b71b3cc4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   175
            imageUnderShadow copyFrom:root x:org x y:(org y + bot) 
64c9b71b3cc4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   176
                                         toX:0 y:bot width:width height:shH.
72
3e84121988c3 *** empty log message ***
claus
parents: 54
diff changeset
   177
6274
e37dc412eb6a class: ShadowView
Stefan Vogel <sv@exept.de>
parents: 5415
diff changeset
   178
            false "graphicsDevice visualType == #TrueColor" ifTrue:[
2916
79eedd2e05ac checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2830
diff changeset
   179
                "
79eedd2e05ac checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2830
diff changeset
   180
                 grey out the image (by darkening the pixels)
7585
5c5e44bad956 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7428
diff changeset
   181
                 (that's expensive ...)
2916
79eedd2e05ac checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2830
diff changeset
   182
                "
3490
7a560c566b72 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3301
diff changeset
   183
                
2916
79eedd2e05ac checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2830
diff changeset
   184
                img := Image fromForm:imageUnderShadow.
3490
7a560c566b72 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3301
diff changeset
   185
7a560c566b72 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3301
diff changeset
   186
                rS := img redShiftForPixelValue.
7a560c566b72 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3301
diff changeset
   187
                gS := img greenShiftForPixelValue.
7a560c566b72 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3301
diff changeset
   188
                bS := img blueShiftForPixelValue.
7a560c566b72 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3301
diff changeset
   189
                rSN := rS negated.
7a560c566b72 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3301
diff changeset
   190
                gSN := gS negated.
7a560c566b72 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3301
diff changeset
   191
                bSN := bS negated.
7a560c566b72 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3301
diff changeset
   192
                rM := img redMaskForPixelValue.
7a560c566b72 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3301
diff changeset
   193
                gM := img greenMaskForPixelValue.
7a560c566b72 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3301
diff changeset
   194
                bM := img blueMaskForPixelValue.
7a560c566b72 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3301
diff changeset
   195
7a560c566b72 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3301
diff changeset
   196
                right to:right+shW-1 do:[:x |
7a560c566b72 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3301
diff changeset
   197
                    0 to:height-1-shH do:[:y |
2916
79eedd2e05ac checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2830
diff changeset
   198
                        pix := img pixelAtX:x y:y.
3490
7a560c566b72 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3301
diff changeset
   199
                        r := (pix bitShift:rS) bitAnd:rM.       "/ img redBitsOf:pix.
7a560c566b72 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3301
diff changeset
   200
                        g := (pix bitShift:gS) bitAnd:gM.       "/ img greenBitsOf:pix.
7a560c566b72 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3301
diff changeset
   201
                        b := (pix bitShift:bS) bitAnd:bM.       "/ img blueBitsOf:pix.
7a560c566b72 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3301
diff changeset
   202
                        r := (r * 0.7) rounded.
7a560c566b72 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3301
diff changeset
   203
                        g := (g * 0.7) rounded.
7a560c566b72 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3301
diff changeset
   204
                        b := (b * 0.7) rounded.
7a560c566b72 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3301
diff changeset
   205
                        pix := ((r bitShift:rSN)         "/ pix := img valueFromRedBits:r greenBits:g blueBits:b.
7a560c566b72 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3301
diff changeset
   206
                               bitOr:(g bitShift:gSN))
7a560c566b72 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3301
diff changeset
   207
                               bitOr:(b bitShift:bSN).
7a560c566b72 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3301
diff changeset
   208
2916
79eedd2e05ac checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2830
diff changeset
   209
                        img pixelAtX:x y:y put:pix.
79eedd2e05ac checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2830
diff changeset
   210
                    ].
79eedd2e05ac checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2830
diff changeset
   211
                ].
3490
7a560c566b72 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3301
diff changeset
   212
                bot to:bot+shH-1 do:[:y |
7a560c566b72 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3301
diff changeset
   213
                    0 to:width-1 do:[:x |
2916
79eedd2e05ac checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2830
diff changeset
   214
                        pix := img pixelAtX:x y:y.
3490
7a560c566b72 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3301
diff changeset
   215
                        r := (pix bitShift:rS) bitAnd:rM.       "/ img redBitsOf:pix.
7a560c566b72 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3301
diff changeset
   216
                        g := (pix bitShift:gS) bitAnd:gM.       "/ img greenBitsOf:pix.
7a560c566b72 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3301
diff changeset
   217
                        b := (pix bitShift:bS) bitAnd:bM.       "/ img blueBitsOf:pix.
7a560c566b72 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3301
diff changeset
   218
                        r := (r * 0.7) rounded.
7a560c566b72 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3301
diff changeset
   219
                        g := (g * 0.7) rounded.
7a560c566b72 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3301
diff changeset
   220
                        b := (b * 0.7) rounded.
7a560c566b72 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3301
diff changeset
   221
                        pix := ((r bitShift:rSN)         "/ pix := img valueFromRedBits:r greenBits:g blueBits:b.
7a560c566b72 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3301
diff changeset
   222
                               bitOr:(g bitShift:gSN))
7a560c566b72 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3301
diff changeset
   223
                               bitOr:(b bitShift:bSN).
2916
79eedd2e05ac checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2830
diff changeset
   224
                        img pixelAtX:x y:y put:pix.
79eedd2e05ac checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2830
diff changeset
   225
                    ].
79eedd2e05ac checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2830
diff changeset
   226
                ].
6274
e37dc412eb6a class: ShadowView
Stefan Vogel <sv@exept.de>
parents: 5415
diff changeset
   227
                imageUnderShadow := img asFormOn:graphicsDevice.
2916
79eedd2e05ac checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2830
diff changeset
   228
            ] ifFalse:[
79eedd2e05ac checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2830
diff changeset
   229
                "
79eedd2e05ac checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2830
diff changeset
   230
                 grey out the image (by oring-in a grey pattern)
79eedd2e05ac checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2830
diff changeset
   231
                 (sometimes we are lucky, and can do it with one raster-op)
79eedd2e05ac checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2830
diff changeset
   232
                "
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   233
2916
79eedd2e05ac checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2830
diff changeset
   234
                (kludge and:[blackIs0]) ifFalse:[
79eedd2e05ac checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2830
diff changeset
   235
                    imageUnderShadow foreground:clr0 background:(Color colorId:-1).
6274
e37dc412eb6a class: ShadowView
Stefan Vogel <sv@exept.de>
parents: 5415
diff changeset
   236
                    imageUnderShadow mask:(Form mediumGreyFormOn:graphicsDevice).
2916
79eedd2e05ac checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2830
diff changeset
   237
                    imageUnderShadow function:#and.
79eedd2e05ac checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2830
diff changeset
   238
                    imageUnderShadow fillRectangleX:right y:0 width:shW height:height.
79eedd2e05ac checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2830
diff changeset
   239
                    imageUnderShadow fillRectangleX:0 y:bot width:width height:shH.
79eedd2e05ac checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2830
diff changeset
   240
79eedd2e05ac checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2830
diff changeset
   241
                    blackIs0 ifFalse:[
7428
f065b77917fc #OTHER by stefan
Stefan Vogel <sv@exept.de>
parents: 7267
diff changeset
   242
                        imageUnderShadow foreground:self blackColor background:clr0.
2916
79eedd2e05ac checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2830
diff changeset
   243
                        imageUnderShadow function:#or.
79eedd2e05ac checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2830
diff changeset
   244
                        imageUnderShadow fillRectangleX:right y:0 width:shW height:height.
79eedd2e05ac checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2830
diff changeset
   245
                        imageUnderShadow fillRectangleX:0 y:bot width:width height:shH.
79eedd2e05ac checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2830
diff changeset
   246
                    ]
79eedd2e05ac checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2830
diff changeset
   247
                ] ifTrue:[
79eedd2e05ac checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2830
diff changeset
   248
                    imageUnderShadow foreground:clr1 background:clr0.
6274
e37dc412eb6a class: ShadowView
Stefan Vogel <sv@exept.de>
parents: 5415
diff changeset
   249
                    imageUnderShadow mask:(Form mediumGreyFormOn:graphicsDevice).
743
64c9b71b3cc4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   250
                    imageUnderShadow function:#or.
64c9b71b3cc4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   251
                    imageUnderShadow fillRectangleX:right y:0 width:shW height:height.
64c9b71b3cc4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   252
                    imageUnderShadow fillRectangleX:0 y:bot width:width height:shH.
2916
79eedd2e05ac checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2830
diff changeset
   253
                ].
743
64c9b71b3cc4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   254
            ].
64c9b71b3cc4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   255
        ].
64c9b71b3cc4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   256
        super realize.
64c9b71b3cc4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   257
        self raise
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   258
    ]
743
64c9b71b3cc4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   259
1727
c2140507ab19 oops - X needs clippedByChildren:false.
Claus Gittinger <cg@exept.de>
parents: 1722
diff changeset
   260
    "Modified: 12.5.1997 / 21:38:04 / cg"
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   261
!
48194c26a46c Initial revision
claus
parents:
diff changeset
   262
12
9f0995fac1fa *** empty log message ***
claus
parents: 6
diff changeset
   263
recreate
3301
1bcebb26ecbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3292
diff changeset
   264
    "sent after a snapin or a migration, reinit for new device"
3292
f5cbe9b1dc2a comment
Claus Gittinger <cg@exept.de>
parents: 2916
diff changeset
   265
72
3e84121988c3 *** empty log message ***
claus
parents: 54
diff changeset
   266
    shadowClr notNil ifTrue:[
7267
15f4a39b25fd device access
Claus Gittinger <cg@exept.de>
parents: 6274
diff changeset
   267
        shadowClr := shadowClr onDevice:device
72
3e84121988c3 *** empty log message ***
claus
parents: 54
diff changeset
   268
    ].
12
9f0995fac1fa *** empty log message ***
claus
parents: 6
diff changeset
   269
9f0995fac1fa *** empty log message ***
claus
parents: 6
diff changeset
   270
    "the length of the shadow from myView"
7267
15f4a39b25fd device access
Claus Gittinger <cg@exept.de>
parents: 6274
diff changeset
   271
    shadowLength := device pixelPerMillimeter.
12
9f0995fac1fa *** empty log message ***
claus
parents: 6
diff changeset
   272
9f0995fac1fa *** empty log message ***
claus
parents: 6
diff changeset
   273
    super recreate.
9f0995fac1fa *** empty log message ***
claus
parents: 6
diff changeset
   274
    self backingStore:false.
9f0995fac1fa *** empty log message ***
claus
parents: 6
diff changeset
   275
    self saveUnder:true
269
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   276
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   277
642
aa4108a9abe0 Rename unrealize-->unmap.
Stefan Vogel <sv@exept.de>
parents: 626
diff changeset
   278
unmap
2575
ee1eb6c85319 comment
Claus Gittinger <cg@exept.de>
parents: 2188
diff changeset
   279
    "unmap the view - the view stays created (but invisible), and can be remapped again later.
ee1eb6c85319 comment
Claus Gittinger <cg@exept.de>
parents: 2188
diff changeset
   280
     relase the saved image of the covered view"
676
c51fc273f1cb commentary
Claus Gittinger <cg@exept.de>
parents: 642
diff changeset
   281
269
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   282
    imageUnderShadow := nil.
642
aa4108a9abe0 Rename unrealize-->unmap.
Stefan Vogel <sv@exept.de>
parents: 626
diff changeset
   283
    super unmap.
aa4108a9abe0 Rename unrealize-->unmap.
Stefan Vogel <sv@exept.de>
parents: 626
diff changeset
   284
aa4108a9abe0 Rename unrealize-->unmap.
Stefan Vogel <sv@exept.de>
parents: 626
diff changeset
   285
    "Modified: 3.5.1996 / 23:45:23 / stefan"
676
c51fc273f1cb commentary
Claus Gittinger <cg@exept.de>
parents: 642
diff changeset
   286
    "Modified: 12.5.1996 / 22:01:17 / cg"
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   287
! !
48194c26a46c Initial revision
claus
parents:
diff changeset
   288
1292
130328a7fc1b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 950
diff changeset
   289
!ShadowView class methodsFor:'documentation'!
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   290
269
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   291
version
7267
15f4a39b25fd device access
Claus Gittinger <cg@exept.de>
parents: 6274
diff changeset
   292
    ^ '$Header$'
5389
6f57b1596bab no more direct accesses to borderWidth and borderColor
Claus Gittinger <cg@exept.de>
parents: 4782
diff changeset
   293
!
6f57b1596bab no more direct accesses to borderWidth and borderColor
Claus Gittinger <cg@exept.de>
parents: 4782
diff changeset
   294
6f57b1596bab no more direct accesses to borderWidth and borderColor
Claus Gittinger <cg@exept.de>
parents: 4782
diff changeset
   295
version_CVS
7267
15f4a39b25fd device access
Claus Gittinger <cg@exept.de>
parents: 6274
diff changeset
   296
    ^ '$Header$'
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   297
! !
6274
e37dc412eb6a class: ShadowView
Stefan Vogel <sv@exept.de>
parents: 5415
diff changeset
   298