GradientBackground.st
author Claus Gittinger <cg@exept.de>
Thu, 24 Mar 2011 09:51:49 +0100
changeset 5732 fba4327a852b
parent 5731 e638acae4e19
child 5733 08e2b386abef
permissions -rw-r--r--
changed: #fillRectangleX:y:width:height:in: draw fix
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"
56318de85b68 comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents: 5692
diff changeset
   113
! !
56318de85b68 comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents: 5692
diff changeset
   114
56318de85b68 comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents: 5692
diff changeset
   115
!GradientBackground methodsFor:'converting'!
56318de85b68 comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents: 5692
diff changeset
   116
56318de85b68 comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents: 5692
diff changeset
   117
asFormOn:aDevice
56318de85b68 comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents: 5692
diff changeset
   118
    |h w|
5688
Claus Gittinger <cg@exept.de>
parents: 5687
diff changeset
   119
5705
56318de85b68 comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents: 5692
diff changeset
   120
    cachedForm isNil ifTrue:[
56318de85b68 comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents: 5692
diff changeset
   121
        (direction == #northSouth or:[direction == nil]) ifTrue:[
56318de85b68 comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents: 5692
diff changeset
   122
            h := usedLength ? (Display height). "/ aView height.
56318de85b68 comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents: 5692
diff changeset
   123
            w := 8.
56318de85b68 comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents: 5692
diff changeset
   124
        ] ifFalse:[
56318de85b68 comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents: 5692
diff changeset
   125
            h := 8.
56318de85b68 comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents: 5692
diff changeset
   126
            w := usedLength ? (Display width).  "/ aView width.
56318de85b68 comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents: 5692
diff changeset
   127
        ].
56318de85b68 comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents: 5692
diff changeset
   128
        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
   129
        "/ cachedForm clear.
56318de85b68 comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents: 5692
diff changeset
   130
        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
   131
    ].
56318de85b68 comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents: 5692
diff changeset
   132
56318de85b68 comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents: 5692
diff changeset
   133
    ^ cachedForm
56318de85b68 comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents: 5692
diff changeset
   134
56318de85b68 comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents: 5692
diff changeset
   135
    "Created: / 03-02-2011 / 20:05:30 / cg"
56318de85b68 comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents: 5692
diff changeset
   136
!
56318de85b68 comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents: 5692
diff changeset
   137
56318de85b68 comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents: 5692
diff changeset
   138
onDevice:device
56318de85b68 comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents: 5692
diff changeset
   139
    ^ self asFormOn:device.
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
    "Created: / 03-02-2011 / 19:56:06 / cg"
5684
c6029a2cf7c0 added:8 methods
Claus Gittinger <cg@exept.de>
parents: 5461
diff changeset
   142
! !
c6029a2cf7c0 added:8 methods
Claus Gittinger <cg@exept.de>
parents: 5461
diff changeset
   143
c6029a2cf7c0 added:8 methods
Claus Gittinger <cg@exept.de>
parents: 5461
diff changeset
   144
!GradientBackground methodsFor:'drawing'!
c6029a2cf7c0 added:8 methods
Claus Gittinger <cg@exept.de>
parents: 5461
diff changeset
   145
c6029a2cf7c0 added:8 methods
Claus Gittinger <cg@exept.de>
parents: 5461
diff changeset
   146
fillRectangleX:x y:y width:w height:h in:aView
c6029a2cf7c0 added:8 methods
Claus Gittinger <cg@exept.de>
parents: 5461
diff changeset
   147
    "this is a first (very inefficient) try"
c6029a2cf7c0 added:8 methods
Claus Gittinger <cg@exept.de>
parents: 5461
diff changeset
   148
5688
Claus Gittinger <cg@exept.de>
parents: 5687
diff changeset
   149
    |hAll wAll r1 r2 g1 g2 b1 b2 dR r dG g dB b 
5731
e638acae4e19 changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents: 5730
diff changeset
   150
     xRight yBot rC gC bC lastR lastG lastB 
e638acae4e19 changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents: 5730
diff changeset
   151
     minR maxR minG maxG minB maxB|
5687
d4ab14b6cf0a changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents: 5684
diff changeset
   152
5688
Claus Gittinger <cg@exept.de>
parents: 5687
diff changeset
   153
    "/ always take the full-screen as reference
Claus Gittinger <cg@exept.de>
parents: 5687
diff changeset
   154
    "/ (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
   155
    hAll := usedLength ? (Display height). "/ aView height.
56318de85b68 comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents: 5692
diff changeset
   156
    wAll := usedLength ? (Display width).  "/ aView width.
5684
c6029a2cf7c0 added:8 methods
Claus Gittinger <cg@exept.de>
parents: 5461
diff changeset
   157
c6029a2cf7c0 added:8 methods
Claus Gittinger <cg@exept.de>
parents: 5461
diff changeset
   158
    r1 := color1 redByte.
c6029a2cf7c0 added:8 methods
Claus Gittinger <cg@exept.de>
parents: 5461
diff changeset
   159
    r2 := color2 redByte.
c6029a2cf7c0 added:8 methods
Claus Gittinger <cg@exept.de>
parents: 5461
diff changeset
   160
    g1 := color1 greenByte.
c6029a2cf7c0 added:8 methods
Claus Gittinger <cg@exept.de>
parents: 5461
diff changeset
   161
    g2 := color2 greenByte.
c6029a2cf7c0 added:8 methods
Claus Gittinger <cg@exept.de>
parents: 5461
diff changeset
   162
    b1 := color1 blueByte.
c6029a2cf7c0 added:8 methods
Claus Gittinger <cg@exept.de>
parents: 5461
diff changeset
   163
    b2 := color2 blueByte.
c6029a2cf7c0 added:8 methods
Claus Gittinger <cg@exept.de>
parents: 5461
diff changeset
   164
5731
e638acae4e19 changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents: 5730
diff changeset
   165
    minR := r1 min:r2.
e638acae4e19 changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents: 5730
diff changeset
   166
    maxR := r1 max:r2.
e638acae4e19 changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents: 5730
diff changeset
   167
    minG := g1 min:g2.
e638acae4e19 changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents: 5730
diff changeset
   168
    maxG := g1 max:g2.
e638acae4e19 changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents: 5730
diff changeset
   169
    minB := b1 min:b2.
e638acae4e19 changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents: 5730
diff changeset
   170
    maxB := b1 max:b2.
e638acae4e19 changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents: 5730
diff changeset
   171
5728
c3c7f362b4c3 changed: #fillRectangleX:y:width:height:in:
Stefan Vogel <sv@exept.de>
parents: 5705
diff changeset
   172
    aView lineStyle:#solid.
c3c7f362b4c3 changed: #fillRectangleX:y:width:height:in:
Stefan Vogel <sv@exept.de>
parents: 5705
diff changeset
   173
5688
Claus Gittinger <cg@exept.de>
parents: 5687
diff changeset
   174
    "/ individual lines; from top to bottom
5705
56318de85b68 comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents: 5692
diff changeset
   175
    (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
   176
        dR := (r2 - r1) / hAll.
5684
c6029a2cf7c0 added:8 methods
Claus Gittinger <cg@exept.de>
parents: 5461
diff changeset
   177
        r := r1 + (dR * y).
5687
d4ab14b6cf0a changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents: 5684
diff changeset
   178
        dG := (g2 - g1) / hAll.
5684
c6029a2cf7c0 added:8 methods
Claus Gittinger <cg@exept.de>
parents: 5461
diff changeset
   179
        g := g1 + (dG * y).
5687
d4ab14b6cf0a changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents: 5684
diff changeset
   180
        dB := (b2 - b1) / hAll.
5684
c6029a2cf7c0 added:8 methods
Claus Gittinger <cg@exept.de>
parents: 5461
diff changeset
   181
        b := b1 + (dB * y).
5732
fba4327a852b changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents: 5731
diff changeset
   182
        r := (r max:minR) min:maxR. 
fba4327a852b changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents: 5731
diff changeset
   183
        g := (g max:minG) min:maxG.
fba4327a852b changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents: 5731
diff changeset
   184
        b := (b max:minB) min:maxB.
5684
c6029a2cf7c0 added:8 methods
Claus Gittinger <cg@exept.de>
parents: 5461
diff changeset
   185
c6029a2cf7c0 added:8 methods
Claus Gittinger <cg@exept.de>
parents: 5461
diff changeset
   186
        xRight := x+w-1.
5732
fba4327a852b changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents: 5731
diff changeset
   187
        "xRight+1 since X11 does not show the last point of a line"
fba4327a852b changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents: 5731
diff changeset
   188
        xRight := xRight+1.
fba4327a852b changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents: 5731
diff changeset
   189
5731
e638acae4e19 changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents: 5730
diff changeset
   190
        y to:y+h-1 do:[:yP |
5684
c6029a2cf7c0 added:8 methods
Claus Gittinger <cg@exept.de>
parents: 5461
diff changeset
   191
            rC := r asInteger.
c6029a2cf7c0 added:8 methods
Claus Gittinger <cg@exept.de>
parents: 5461
diff changeset
   192
            gC := g asInteger.
c6029a2cf7c0 added:8 methods
Claus Gittinger <cg@exept.de>
parents: 5461
diff changeset
   193
            bC := b asInteger.
c6029a2cf7c0 added:8 methods
Claus Gittinger <cg@exept.de>
parents: 5461
diff changeset
   194
            (rC ~~ lastR or:[gC ~~ lastG or:[bC ~~ lastB]]) ifTrue:[
5732
fba4327a852b changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents: 5731
diff changeset
   195
                aView paint:(Color redByte:rC greenByte:gC blueByte:bC).
5684
c6029a2cf7c0 added:8 methods
Claus Gittinger <cg@exept.de>
parents: 5461
diff changeset
   196
                lastR := rC. lastG := gC. lastB := bC.
c6029a2cf7c0 added:8 methods
Claus Gittinger <cg@exept.de>
parents: 5461
diff changeset
   197
            ].
5732
fba4327a852b changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents: 5731
diff changeset
   198
            aView displayLineFromX:x y:yP toX:xRight y:yP.
5731
e638acae4e19 changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents: 5730
diff changeset
   199
            r := ((r + dR) max:minR) min:maxR. 
e638acae4e19 changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents: 5730
diff changeset
   200
            g := ((g + dG) max:minG) min:maxG.
e638acae4e19 changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents: 5730
diff changeset
   201
            b := ((b + dB) max:minB) min:maxB.
5684
c6029a2cf7c0 added:8 methods
Claus Gittinger <cg@exept.de>
parents: 5461
diff changeset
   202
        ].
5688
Claus Gittinger <cg@exept.de>
parents: 5687
diff changeset
   203
        ^ self.
Claus Gittinger <cg@exept.de>
parents: 5687
diff changeset
   204
    ].
Claus Gittinger <cg@exept.de>
parents: 5687
diff changeset
   205
Claus Gittinger <cg@exept.de>
parents: 5687
diff changeset
   206
    "/ individual lines; from left to right
Claus Gittinger <cg@exept.de>
parents: 5687
diff changeset
   207
    (direction == #eastWest or:[direction == #horizontal]) ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 5687
diff changeset
   208
        dR := (r2 - r1) / wAll.
5732
fba4327a852b changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents: 5731
diff changeset
   209
        r := r1 + (dR * x).
5688
Claus Gittinger <cg@exept.de>
parents: 5687
diff changeset
   210
        dG := (g2 - g1) / wAll.
5732
fba4327a852b changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents: 5731
diff changeset
   211
        g := g1 + (dG * x).
5688
Claus Gittinger <cg@exept.de>
parents: 5687
diff changeset
   212
        dB := (b2 - b1) / wAll.
5732
fba4327a852b changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents: 5731
diff changeset
   213
        b := b1 + (dB * x).
fba4327a852b changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents: 5731
diff changeset
   214
        r := (r max:minR) min:maxR. 
fba4327a852b changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents: 5731
diff changeset
   215
        g := (g max:minG) min:maxG.
fba4327a852b changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents: 5731
diff changeset
   216
        b := (b max:minB) min:maxB.
5688
Claus Gittinger <cg@exept.de>
parents: 5687
diff changeset
   217
Claus Gittinger <cg@exept.de>
parents: 5687
diff changeset
   218
        yBot := y+h-1.
5732
fba4327a852b changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents: 5731
diff changeset
   219
        "yBot+1 since X11 does not show the last point of a line"
fba4327a852b changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents: 5731
diff changeset
   220
        yBot := yBot+1.
5731
e638acae4e19 changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents: 5730
diff changeset
   221
        x to:x+w-1 do:[:xP |
5688
Claus Gittinger <cg@exept.de>
parents: 5687
diff changeset
   222
            rC := r asInteger.
Claus Gittinger <cg@exept.de>
parents: 5687
diff changeset
   223
            gC := g asInteger.
Claus Gittinger <cg@exept.de>
parents: 5687
diff changeset
   224
            bC := b asInteger.
Claus Gittinger <cg@exept.de>
parents: 5687
diff changeset
   225
            (rC ~~ lastR or:[gC ~~ lastG or:[bC ~~ lastB]]) ifTrue:[
5732
fba4327a852b changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents: 5731
diff changeset
   226
                aView paint:(Color redByte:rC greenByte:gC blueByte:bC).
5688
Claus Gittinger <cg@exept.de>
parents: 5687
diff changeset
   227
                lastR := rC. lastG := gC. lastB := bC.
Claus Gittinger <cg@exept.de>
parents: 5687
diff changeset
   228
            ].
5728
c3c7f362b4c3 changed: #fillRectangleX:y:width:height:in:
Stefan Vogel <sv@exept.de>
parents: 5705
diff changeset
   229
            "yBot+1 since X11 does not show the last point of a line"
5732
fba4327a852b changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents: 5731
diff changeset
   230
            aView displayLineFromX:xP y:y toX:xP y:yBot.
5731
e638acae4e19 changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents: 5730
diff changeset
   231
            r := ((r + dR) max:minR) min:maxR. 
e638acae4e19 changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents: 5730
diff changeset
   232
            g := ((g + dG) max:minG) min:maxG.
e638acae4e19 changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents: 5730
diff changeset
   233
            b := ((b + dB) max:minB) min:maxB.
5688
Claus Gittinger <cg@exept.de>
parents: 5687
diff changeset
   234
        ].
Claus Gittinger <cg@exept.de>
parents: 5687
diff changeset
   235
        ^ self.
5684
c6029a2cf7c0 added:8 methods
Claus Gittinger <cg@exept.de>
parents: 5461
diff changeset
   236
    ]
c6029a2cf7c0 added:8 methods
Claus Gittinger <cg@exept.de>
parents: 5461
diff changeset
   237
c6029a2cf7c0 added:8 methods
Claus Gittinger <cg@exept.de>
parents: 5461
diff changeset
   238
    "Created: / 23-01-2011 / 01:59:29 / cg"
5732
fba4327a852b changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents: 5731
diff changeset
   239
    "Modified: / 24-03-2011 / 09:51:31 / cg"
5684
c6029a2cf7c0 added:8 methods
Claus Gittinger <cg@exept.de>
parents: 5461
diff changeset
   240
! !
c6029a2cf7c0 added:8 methods
Claus Gittinger <cg@exept.de>
parents: 5461
diff changeset
   241
5461
2451688b8d25 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   242
!GradientBackground class methodsFor:'documentation'!
2451688b8d25 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   243
2451688b8d25 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   244
version_CVS
5732
fba4327a852b changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents: 5731
diff changeset
   245
    ^ '$Header: /cvs/stx/stx/libview/GradientBackground.st,v 1.10 2011-03-24 08:51:49 cg Exp $'
5461
2451688b8d25 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   246
! !