GradientBackground.st
author Claus Gittinger <cg@exept.de>
Wed, 06 Apr 2011 21:11:14 +0200
changeset 5738 b69308a38fb6
parent 5733 08e2b386abef
child 5739 c4fbd37a6164
permissions -rw-r--r--
added: #usedLength #usedLength:
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5461
2451688b8d25 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     1
"
2451688b8d25 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     2
 COPYRIGHT (c) 2009 by eXept Software AG
2451688b8d25 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     3
              All Rights Reserved
2451688b8d25 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     4
2451688b8d25 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     5
 This software is furnished under a license and may be used
2451688b8d25 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     6
 only in accordance with the terms of that license and with the
2451688b8d25 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
2451688b8d25 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     8
 be provided or otherwise made available to, or used by, any
2451688b8d25 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     9
 other person.  No title to or ownership of the software is
2451688b8d25 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    10
 hereby transferred.
2451688b8d25 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    11
"
2451688b8d25 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    12
"{ Package: 'stx:libview' }"
2451688b8d25 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    13
2451688b8d25 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    14
AbstractBackground subclass:#GradientBackground
5705
56318de85b68 comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents: 5692
diff changeset
    15
	instanceVariableNames:'color1 color2 direction cachedForm usedLength'
5461
2451688b8d25 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    16
	classVariableNames:''
2451688b8d25 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    17
	poolDictionaries:''
2451688b8d25 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    18
	category:'Graphics-Support'
2451688b8d25 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    19
!
2451688b8d25 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    20
2451688b8d25 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    21
!GradientBackground class methodsFor:'documentation'!
2451688b8d25 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    22
2451688b8d25 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    23
copyright
2451688b8d25 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    24
"
2451688b8d25 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    25
 COPYRIGHT (c) 2009 by eXept Software AG
2451688b8d25 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    26
              All Rights Reserved
2451688b8d25 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    27
2451688b8d25 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    28
 This software is furnished under a license and may be used
2451688b8d25 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    29
 only in accordance with the terms of that license and with the
2451688b8d25 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    30
 inclusion of the above copyright notice.   This software may not
2451688b8d25 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    31
 be provided or otherwise made available to, or used by, any
2451688b8d25 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    32
 other person.  No title to or ownership of the software is
2451688b8d25 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    33
 hereby transferred.
2451688b8d25 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    34
"
5705
56318de85b68 comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents: 5692
diff changeset
    35
!
56318de85b68 comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents: 5692
diff changeset
    36
56318de85b68 comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents: 5692
diff changeset
    37
examples
56318de85b68 comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents: 5692
diff changeset
    38
"
56318de85b68 comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents: 5692
diff changeset
    39
    |bg v|
56318de85b68 comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents: 5692
diff changeset
    40
56318de85b68 comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents: 5692
diff changeset
    41
    bg := GradientBackground new color1:Color red color2:Color yellow.
56318de85b68 comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents: 5692
diff changeset
    42
    v := View new extent:300@300.
56318de85b68 comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents: 5692
diff changeset
    43
    v viewBackground:bg.
56318de85b68 comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents: 5692
diff changeset
    44
    v open.
56318de85b68 comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents: 5692
diff changeset
    45
"
5461
2451688b8d25 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    46
! !
2451688b8d25 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    47
5684
c6029a2cf7c0 added:8 methods
Claus Gittinger <cg@exept.de>
parents: 5461
diff changeset
    48
!GradientBackground methodsFor:'accessing'!
c6029a2cf7c0 added:8 methods
Claus Gittinger <cg@exept.de>
parents: 5461
diff changeset
    49
c6029a2cf7c0 added:8 methods
Claus Gittinger <cg@exept.de>
parents: 5461
diff changeset
    50
color1
c6029a2cf7c0 added:8 methods
Claus Gittinger <cg@exept.de>
parents: 5461
diff changeset
    51
    ^ color1
c6029a2cf7c0 added:8 methods
Claus Gittinger <cg@exept.de>
parents: 5461
diff changeset
    52
c6029a2cf7c0 added:8 methods
Claus Gittinger <cg@exept.de>
parents: 5461
diff changeset
    53
    "Created: / 23-01-2011 / 02:01:29 / cg"
c6029a2cf7c0 added:8 methods
Claus Gittinger <cg@exept.de>
parents: 5461
diff changeset
    54
!
c6029a2cf7c0 added:8 methods
Claus Gittinger <cg@exept.de>
parents: 5461
diff changeset
    55
c6029a2cf7c0 added:8 methods
Claus Gittinger <cg@exept.de>
parents: 5461
diff changeset
    56
color1:aColor
c6029a2cf7c0 added:8 methods
Claus Gittinger <cg@exept.de>
parents: 5461
diff changeset
    57
    color1 := aColor.
5705
56318de85b68 comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents: 5692
diff changeset
    58
    cachedForm := nil.
5684
c6029a2cf7c0 added:8 methods
Claus Gittinger <cg@exept.de>
parents: 5461
diff changeset
    59
c6029a2cf7c0 added:8 methods
Claus Gittinger <cg@exept.de>
parents: 5461
diff changeset
    60
    "Created: / 23-01-2011 / 02:01:50 / cg"
5705
56318de85b68 comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents: 5692
diff changeset
    61
    "Modified: / 03-02-2011 / 19:49:18 / cg"
56318de85b68 comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents: 5692
diff changeset
    62
!
56318de85b68 comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents: 5692
diff changeset
    63
56318de85b68 comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents: 5692
diff changeset
    64
color1:aColor1 color2:aColor2
56318de85b68 comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents: 5692
diff changeset
    65
    color1 := aColor1.
56318de85b68 comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents: 5692
diff changeset
    66
    color2 := aColor2.
56318de85b68 comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents: 5692
diff changeset
    67
    cachedForm := nil.
56318de85b68 comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents: 5692
diff changeset
    68
56318de85b68 comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents: 5692
diff changeset
    69
    "Created: / 03-02-2011 / 19:52:59 / cg"
5684
c6029a2cf7c0 added:8 methods
Claus Gittinger <cg@exept.de>
parents: 5461
diff changeset
    70
!
c6029a2cf7c0 added:8 methods
Claus Gittinger <cg@exept.de>
parents: 5461
diff changeset
    71
c6029a2cf7c0 added:8 methods
Claus Gittinger <cg@exept.de>
parents: 5461
diff changeset
    72
color2
c6029a2cf7c0 added:8 methods
Claus Gittinger <cg@exept.de>
parents: 5461
diff changeset
    73
    ^ color2
c6029a2cf7c0 added:8 methods
Claus Gittinger <cg@exept.de>
parents: 5461
diff changeset
    74
c6029a2cf7c0 added:8 methods
Claus Gittinger <cg@exept.de>
parents: 5461
diff changeset
    75
    "Created: / 23-01-2011 / 02:01:32 / cg"
c6029a2cf7c0 added:8 methods
Claus Gittinger <cg@exept.de>
parents: 5461
diff changeset
    76
!
c6029a2cf7c0 added:8 methods
Claus Gittinger <cg@exept.de>
parents: 5461
diff changeset
    77
c6029a2cf7c0 added:8 methods
Claus Gittinger <cg@exept.de>
parents: 5461
diff changeset
    78
color2:aColor
c6029a2cf7c0 added:8 methods
Claus Gittinger <cg@exept.de>
parents: 5461
diff changeset
    79
    color2 := aColor.
5705
56318de85b68 comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents: 5692
diff changeset
    80
    cachedForm := nil.
5684
c6029a2cf7c0 added:8 methods
Claus Gittinger <cg@exept.de>
parents: 5461
diff changeset
    81
c6029a2cf7c0 added:8 methods
Claus Gittinger <cg@exept.de>
parents: 5461
diff changeset
    82
    "Created: / 23-01-2011 / 02:01:55 / cg"
5705
56318de85b68 comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents: 5692
diff changeset
    83
    "Modified: / 03-02-2011 / 19:49:23 / cg"
5688
Claus Gittinger <cg@exept.de>
parents: 5687
diff changeset
    84
!
Claus Gittinger <cg@exept.de>
parents: 5687
diff changeset
    85
Claus Gittinger <cg@exept.de>
parents: 5687
diff changeset
    86
direction
Claus Gittinger <cg@exept.de>
parents: 5687
diff changeset
    87
    "possible values:
Claus Gittinger <cg@exept.de>
parents: 5687
diff changeset
    88
        #northSouth
Claus Gittinger <cg@exept.de>
parents: 5687
diff changeset
    89
        #eastWest
Claus Gittinger <cg@exept.de>
parents: 5687
diff changeset
    90
Claus Gittinger <cg@exept.de>
parents: 5687
diff changeset
    91
     others are not yet supported
Claus Gittinger <cg@exept.de>
parents: 5687
diff changeset
    92
    "
Claus Gittinger <cg@exept.de>
parents: 5687
diff changeset
    93
Claus Gittinger <cg@exept.de>
parents: 5687
diff changeset
    94
    ^ direction
Claus Gittinger <cg@exept.de>
parents: 5687
diff changeset
    95
Claus Gittinger <cg@exept.de>
parents: 5687
diff changeset
    96
    "Modified: / 23-01-2011 / 14:36:36 / cg"
Claus Gittinger <cg@exept.de>
parents: 5687
diff changeset
    97
!
Claus Gittinger <cg@exept.de>
parents: 5687
diff changeset
    98
Claus Gittinger <cg@exept.de>
parents: 5687
diff changeset
    99
direction:something
Claus Gittinger <cg@exept.de>
parents: 5687
diff changeset
   100
    "possible values:
Claus Gittinger <cg@exept.de>
parents: 5687
diff changeset
   101
        #northSouth
Claus Gittinger <cg@exept.de>
parents: 5687
diff changeset
   102
        #eastWest
Claus Gittinger <cg@exept.de>
parents: 5687
diff changeset
   103
Claus Gittinger <cg@exept.de>
parents: 5687
diff changeset
   104
     others are not yet supported
Claus Gittinger <cg@exept.de>
parents: 5687
diff changeset
   105
    "
Claus Gittinger <cg@exept.de>
parents: 5687
diff changeset
   106
5705
56318de85b68 comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents: 5692
diff changeset
   107
    direction ~= something ifTrue:[
56318de85b68 comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents: 5692
diff changeset
   108
        direction := something.
56318de85b68 comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents: 5692
diff changeset
   109
        cachedForm := nil.
56318de85b68 comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents: 5692
diff changeset
   110
    ]
56318de85b68 comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents: 5692
diff changeset
   111
56318de85b68 comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents: 5692
diff changeset
   112
    "Modified: / 03-02-2011 / 19:49:41 / cg"
5738
Claus Gittinger <cg@exept.de>
parents: 5733
diff changeset
   113
!
Claus Gittinger <cg@exept.de>
parents: 5733
diff changeset
   114
Claus Gittinger <cg@exept.de>
parents: 5733
diff changeset
   115
usedLength
Claus Gittinger <cg@exept.de>
parents: 5733
diff changeset
   116
    ^ usedLength
Claus Gittinger <cg@exept.de>
parents: 5733
diff changeset
   117
!
Claus Gittinger <cg@exept.de>
parents: 5733
diff changeset
   118
Claus Gittinger <cg@exept.de>
parents: 5733
diff changeset
   119
usedLength:something
Claus Gittinger <cg@exept.de>
parents: 5733
diff changeset
   120
    usedLength := something.
5705
56318de85b68 comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents: 5692
diff changeset
   121
! !
56318de85b68 comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents: 5692
diff changeset
   122
56318de85b68 comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents: 5692
diff changeset
   123
!GradientBackground methodsFor:'converting'!
56318de85b68 comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents: 5692
diff changeset
   124
56318de85b68 comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents: 5692
diff changeset
   125
asFormOn:aDevice
56318de85b68 comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents: 5692
diff changeset
   126
    |h w|
5688
Claus Gittinger <cg@exept.de>
parents: 5687
diff changeset
   127
5705
56318de85b68 comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents: 5692
diff changeset
   128
    cachedForm isNil ifTrue:[
56318de85b68 comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents: 5692
diff changeset
   129
        (direction == #northSouth or:[direction == nil]) ifTrue:[
56318de85b68 comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents: 5692
diff changeset
   130
            h := usedLength ? (Display height). "/ aView height.
56318de85b68 comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents: 5692
diff changeset
   131
            w := 8.
56318de85b68 comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents: 5692
diff changeset
   132
        ] ifFalse:[
56318de85b68 comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents: 5692
diff changeset
   133
            h := 8.
56318de85b68 comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents: 5692
diff changeset
   134
            w := usedLength ? (Display width).  "/ aView width.
56318de85b68 comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents: 5692
diff changeset
   135
        ].
56318de85b68 comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents: 5692
diff changeset
   136
        cachedForm := Form width:w height:h depth:aDevice depth onDevice:aDevice.
56318de85b68 comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents: 5692
diff changeset
   137
        "/ cachedForm clear.
56318de85b68 comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents: 5692
diff changeset
   138
        self fillRectangleX:0 y:0 width:w height:h in:cachedForm
56318de85b68 comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents: 5692
diff changeset
   139
    ].
56318de85b68 comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents: 5692
diff changeset
   140
56318de85b68 comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents: 5692
diff changeset
   141
    ^ cachedForm
56318de85b68 comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents: 5692
diff changeset
   142
56318de85b68 comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents: 5692
diff changeset
   143
    "Created: / 03-02-2011 / 20:05:30 / cg"
56318de85b68 comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents: 5692
diff changeset
   144
!
56318de85b68 comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents: 5692
diff changeset
   145
56318de85b68 comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents: 5692
diff changeset
   146
onDevice:device
56318de85b68 comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents: 5692
diff changeset
   147
    ^ self asFormOn:device.
56318de85b68 comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents: 5692
diff changeset
   148
56318de85b68 comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents: 5692
diff changeset
   149
    "Created: / 03-02-2011 / 19:56:06 / cg"
5684
c6029a2cf7c0 added:8 methods
Claus Gittinger <cg@exept.de>
parents: 5461
diff changeset
   150
! !
c6029a2cf7c0 added:8 methods
Claus Gittinger <cg@exept.de>
parents: 5461
diff changeset
   151
c6029a2cf7c0 added:8 methods
Claus Gittinger <cg@exept.de>
parents: 5461
diff changeset
   152
!GradientBackground methodsFor:'drawing'!
c6029a2cf7c0 added:8 methods
Claus Gittinger <cg@exept.de>
parents: 5461
diff changeset
   153
c6029a2cf7c0 added:8 methods
Claus Gittinger <cg@exept.de>
parents: 5461
diff changeset
   154
fillRectangleX:x y:y width:w height:h in:aView
c6029a2cf7c0 added:8 methods
Claus Gittinger <cg@exept.de>
parents: 5461
diff changeset
   155
    "this is a first (very inefficient) try"
c6029a2cf7c0 added:8 methods
Claus Gittinger <cg@exept.de>
parents: 5461
diff changeset
   156
5688
Claus Gittinger <cg@exept.de>
parents: 5687
diff changeset
   157
    |hAll wAll r1 r2 g1 g2 b1 b2 dR r dG g dB b 
5733
08e2b386abef changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents: 5732
diff changeset
   158
     yRect hRun xRect wRun 
08e2b386abef changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents: 5732
diff changeset
   159
     rC gC bC lastR lastG lastB 
5731
e638acae4e19 changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents: 5730
diff changeset
   160
     minR maxR minG maxG minB maxB|
5687
d4ab14b6cf0a changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents: 5684
diff changeset
   161
5688
Claus Gittinger <cg@exept.de>
parents: 5687
diff changeset
   162
    "/ always take the full-screen as reference
Claus Gittinger <cg@exept.de>
parents: 5687
diff changeset
   163
    "/ (so we do not have to care for changed gradient, when view changes size)
5705
56318de85b68 comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents: 5692
diff changeset
   164
    hAll := usedLength ? (Display height). "/ aView height.
56318de85b68 comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents: 5692
diff changeset
   165
    wAll := usedLength ? (Display width).  "/ aView width.
5684
c6029a2cf7c0 added:8 methods
Claus Gittinger <cg@exept.de>
parents: 5461
diff changeset
   166
c6029a2cf7c0 added:8 methods
Claus Gittinger <cg@exept.de>
parents: 5461
diff changeset
   167
    r1 := color1 redByte.
c6029a2cf7c0 added:8 methods
Claus Gittinger <cg@exept.de>
parents: 5461
diff changeset
   168
    r2 := color2 redByte.
c6029a2cf7c0 added:8 methods
Claus Gittinger <cg@exept.de>
parents: 5461
diff changeset
   169
    g1 := color1 greenByte.
c6029a2cf7c0 added:8 methods
Claus Gittinger <cg@exept.de>
parents: 5461
diff changeset
   170
    g2 := color2 greenByte.
c6029a2cf7c0 added:8 methods
Claus Gittinger <cg@exept.de>
parents: 5461
diff changeset
   171
    b1 := color1 blueByte.
c6029a2cf7c0 added:8 methods
Claus Gittinger <cg@exept.de>
parents: 5461
diff changeset
   172
    b2 := color2 blueByte.
c6029a2cf7c0 added:8 methods
Claus Gittinger <cg@exept.de>
parents: 5461
diff changeset
   173
5731
e638acae4e19 changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents: 5730
diff changeset
   174
    minR := r1 min:r2.
e638acae4e19 changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents: 5730
diff changeset
   175
    maxR := r1 max:r2.
e638acae4e19 changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents: 5730
diff changeset
   176
    minG := g1 min:g2.
e638acae4e19 changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents: 5730
diff changeset
   177
    maxG := g1 max:g2.
e638acae4e19 changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents: 5730
diff changeset
   178
    minB := b1 min:b2.
e638acae4e19 changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents: 5730
diff changeset
   179
    maxB := b1 max:b2.
e638acae4e19 changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents: 5730
diff changeset
   180
5728
c3c7f362b4c3 changed: #fillRectangleX:y:width:height:in:
Stefan Vogel <sv@exept.de>
parents: 5705
diff changeset
   181
    aView lineStyle:#solid.
c3c7f362b4c3 changed: #fillRectangleX:y:width:height:in:
Stefan Vogel <sv@exept.de>
parents: 5705
diff changeset
   182
5688
Claus Gittinger <cg@exept.de>
parents: 5687
diff changeset
   183
    "/ individual lines; from top to bottom
5705
56318de85b68 comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents: 5692
diff changeset
   184
    (direction == #northSouth or:[direction == #vertical or:[direction == nil]]) ifTrue:[
5687
d4ab14b6cf0a changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents: 5684
diff changeset
   185
        dR := (r2 - r1) / hAll.
5684
c6029a2cf7c0 added:8 methods
Claus Gittinger <cg@exept.de>
parents: 5461
diff changeset
   186
        r := r1 + (dR * y).
5687
d4ab14b6cf0a changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents: 5684
diff changeset
   187
        dG := (g2 - g1) / hAll.
5684
c6029a2cf7c0 added:8 methods
Claus Gittinger <cg@exept.de>
parents: 5461
diff changeset
   188
        g := g1 + (dG * y).
5687
d4ab14b6cf0a changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents: 5684
diff changeset
   189
        dB := (b2 - b1) / hAll.
5684
c6029a2cf7c0 added:8 methods
Claus Gittinger <cg@exept.de>
parents: 5461
diff changeset
   190
        b := b1 + (dB * y).
5733
08e2b386abef changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents: 5732
diff changeset
   191
5732
fba4327a852b changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents: 5731
diff changeset
   192
        r := (r max:minR) min:maxR. 
fba4327a852b changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents: 5731
diff changeset
   193
        g := (g max:minG) min:maxG.
fba4327a852b changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents: 5731
diff changeset
   194
        b := (b max:minB) min:maxB.
5684
c6029a2cf7c0 added:8 methods
Claus Gittinger <cg@exept.de>
parents: 5461
diff changeset
   195
5733
08e2b386abef changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents: 5732
diff changeset
   196
        lastR := r asInteger. lastG := g asInteger. lastB := b asInteger.
5732
fba4327a852b changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents: 5731
diff changeset
   197
5733
08e2b386abef changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents: 5732
diff changeset
   198
        yRect := y.
08e2b386abef changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents: 5732
diff changeset
   199
        hRun := 0.
5731
e638acae4e19 changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents: 5730
diff changeset
   200
        y to:y+h-1 do:[:yP |
5684
c6029a2cf7c0 added:8 methods
Claus Gittinger <cg@exept.de>
parents: 5461
diff changeset
   201
            rC := r asInteger.
c6029a2cf7c0 added:8 methods
Claus Gittinger <cg@exept.de>
parents: 5461
diff changeset
   202
            gC := g asInteger.
c6029a2cf7c0 added:8 methods
Claus Gittinger <cg@exept.de>
parents: 5461
diff changeset
   203
            bC := b asInteger.
c6029a2cf7c0 added:8 methods
Claus Gittinger <cg@exept.de>
parents: 5461
diff changeset
   204
            (rC ~~ lastR or:[gC ~~ lastG or:[bC ~~ lastB]]) ifTrue:[
5733
08e2b386abef changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents: 5732
diff changeset
   205
                aView paint:(Color redByte:lastR greenByte:lastG blueByte:lastB).
08e2b386abef changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents: 5732
diff changeset
   206
                aView fillRectangleX:x y:yRect width:w height:hRun.
08e2b386abef changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents: 5732
diff changeset
   207
                yRect := yP. hRun := 0.
5684
c6029a2cf7c0 added:8 methods
Claus Gittinger <cg@exept.de>
parents: 5461
diff changeset
   208
                lastR := rC. lastG := gC. lastB := bC.
c6029a2cf7c0 added:8 methods
Claus Gittinger <cg@exept.de>
parents: 5461
diff changeset
   209
            ].
5733
08e2b386abef changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents: 5732
diff changeset
   210
            hRun := hRun + 1.
5731
e638acae4e19 changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents: 5730
diff changeset
   211
            r := ((r + dR) max:minR) min:maxR. 
e638acae4e19 changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents: 5730
diff changeset
   212
            g := ((g + dG) max:minG) min:maxG.
e638acae4e19 changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents: 5730
diff changeset
   213
            b := ((b + dB) max:minB) min:maxB.
5684
c6029a2cf7c0 added:8 methods
Claus Gittinger <cg@exept.de>
parents: 5461
diff changeset
   214
        ].
5733
08e2b386abef changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents: 5732
diff changeset
   215
        hRun ~~ 0 ifTrue:[
08e2b386abef changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents: 5732
diff changeset
   216
            aView paint:(Color redByte:lastR greenByte:lastG blueByte:lastB).
08e2b386abef changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents: 5732
diff changeset
   217
            aView fillRectangleX:x y:yRect width:w height:hRun.
08e2b386abef changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents: 5732
diff changeset
   218
        ].
5688
Claus Gittinger <cg@exept.de>
parents: 5687
diff changeset
   219
        ^ self.
Claus Gittinger <cg@exept.de>
parents: 5687
diff changeset
   220
    ].
Claus Gittinger <cg@exept.de>
parents: 5687
diff changeset
   221
Claus Gittinger <cg@exept.de>
parents: 5687
diff changeset
   222
    "/ individual lines; from left to right
Claus Gittinger <cg@exept.de>
parents: 5687
diff changeset
   223
    (direction == #eastWest or:[direction == #horizontal]) ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 5687
diff changeset
   224
        dR := (r2 - r1) / wAll.
5732
fba4327a852b changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents: 5731
diff changeset
   225
        r := r1 + (dR * x).
5688
Claus Gittinger <cg@exept.de>
parents: 5687
diff changeset
   226
        dG := (g2 - g1) / wAll.
5732
fba4327a852b changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents: 5731
diff changeset
   227
        g := g1 + (dG * x).
5688
Claus Gittinger <cg@exept.de>
parents: 5687
diff changeset
   228
        dB := (b2 - b1) / wAll.
5732
fba4327a852b changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents: 5731
diff changeset
   229
        b := b1 + (dB * x).
5733
08e2b386abef changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents: 5732
diff changeset
   230
5732
fba4327a852b changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents: 5731
diff changeset
   231
        r := (r max:minR) min:maxR. 
fba4327a852b changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents: 5731
diff changeset
   232
        g := (g max:minG) min:maxG.
fba4327a852b changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents: 5731
diff changeset
   233
        b := (b max:minB) min:maxB.
5688
Claus Gittinger <cg@exept.de>
parents: 5687
diff changeset
   234
5733
08e2b386abef changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents: 5732
diff changeset
   235
        lastR := r asInteger. lastG := g asInteger. lastB := b asInteger.
08e2b386abef changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents: 5732
diff changeset
   236
08e2b386abef changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents: 5732
diff changeset
   237
        xRect := x.
08e2b386abef changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents: 5732
diff changeset
   238
        wRun := 0.
08e2b386abef changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents: 5732
diff changeset
   239
5731
e638acae4e19 changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents: 5730
diff changeset
   240
        x to:x+w-1 do:[:xP |
5688
Claus Gittinger <cg@exept.de>
parents: 5687
diff changeset
   241
            rC := r asInteger.
Claus Gittinger <cg@exept.de>
parents: 5687
diff changeset
   242
            gC := g asInteger.
Claus Gittinger <cg@exept.de>
parents: 5687
diff changeset
   243
            bC := b asInteger.
Claus Gittinger <cg@exept.de>
parents: 5687
diff changeset
   244
            (rC ~~ lastR or:[gC ~~ lastG or:[bC ~~ lastB]]) ifTrue:[
5733
08e2b386abef changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents: 5732
diff changeset
   245
                aView paint:(Color redByte:lastR greenByte:lastG blueByte:lastB).
08e2b386abef changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents: 5732
diff changeset
   246
                aView fillRectangleX:xRect y:y width:wRun height:h.
08e2b386abef changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents: 5732
diff changeset
   247
                xRect := xP. wRun := 0.
5688
Claus Gittinger <cg@exept.de>
parents: 5687
diff changeset
   248
                lastR := rC. lastG := gC. lastB := bC.
Claus Gittinger <cg@exept.de>
parents: 5687
diff changeset
   249
            ].
5733
08e2b386abef changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents: 5732
diff changeset
   250
            wRun := wRun + 1.
5731
e638acae4e19 changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents: 5730
diff changeset
   251
            r := ((r + dR) max:minR) min:maxR. 
e638acae4e19 changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents: 5730
diff changeset
   252
            g := ((g + dG) max:minG) min:maxG.
e638acae4e19 changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents: 5730
diff changeset
   253
            b := ((b + dB) max:minB) min:maxB.
5688
Claus Gittinger <cg@exept.de>
parents: 5687
diff changeset
   254
        ].
5733
08e2b386abef changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents: 5732
diff changeset
   255
        wRun ~~ 0 ifTrue:[
08e2b386abef changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents: 5732
diff changeset
   256
            aView paint:(Color redByte:lastR greenByte:lastG blueByte:lastB).
08e2b386abef changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents: 5732
diff changeset
   257
            aView fillRectangleX:xRect y:y width:wRun height:h.
08e2b386abef changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents: 5732
diff changeset
   258
        ].
5688
Claus Gittinger <cg@exept.de>
parents: 5687
diff changeset
   259
        ^ self.
5684
c6029a2cf7c0 added:8 methods
Claus Gittinger <cg@exept.de>
parents: 5461
diff changeset
   260
    ]
c6029a2cf7c0 added:8 methods
Claus Gittinger <cg@exept.de>
parents: 5461
diff changeset
   261
c6029a2cf7c0 added:8 methods
Claus Gittinger <cg@exept.de>
parents: 5461
diff changeset
   262
    "Created: / 23-01-2011 / 01:59:29 / cg"
5733
08e2b386abef changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents: 5732
diff changeset
   263
    "Modified: / 24-03-2011 / 09:59:20 / cg"
5684
c6029a2cf7c0 added:8 methods
Claus Gittinger <cg@exept.de>
parents: 5461
diff changeset
   264
! !
c6029a2cf7c0 added:8 methods
Claus Gittinger <cg@exept.de>
parents: 5461
diff changeset
   265
5461
2451688b8d25 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   266
!GradientBackground class methodsFor:'documentation'!
2451688b8d25 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   267
2451688b8d25 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   268
version_CVS
5738
Claus Gittinger <cg@exept.de>
parents: 5733
diff changeset
   269
    ^ '$Header: /cvs/stx/stx/libview/GradientBackground.st,v 1.12 2011-04-06 19:11:14 cg Exp $'
5461
2451688b8d25 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   270
! !