GradientBackground.st
author Stefan Vogel <sv@exept.de>
Fri, 04 Mar 2011 17:09:07 +0100
changeset 5728 c3c7f362b4c3
parent 5705 56318de85b68
child 5730 74d4e149580b
permissions -rw-r--r--
changed: #fillRectangleX:y:width:height:in: Now works under Linux
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 
Claus Gittinger <cg@exept.de>
parents: 5687
diff changeset
   150
     xRight yBot rC gC bC lastR lastG lastB|
5687
d4ab14b6cf0a changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents: 5684
diff changeset
   151
5688
Claus Gittinger <cg@exept.de>
parents: 5687
diff changeset
   152
    "/ always take the full-screen as reference
Claus Gittinger <cg@exept.de>
parents: 5687
diff changeset
   153
    "/ (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
   154
    hAll := usedLength ? (Display height). "/ aView height.
56318de85b68 comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents: 5692
diff changeset
   155
    wAll := usedLength ? (Display width).  "/ aView width.
5684
c6029a2cf7c0 added:8 methods
Claus Gittinger <cg@exept.de>
parents: 5461
diff changeset
   156
c6029a2cf7c0 added:8 methods
Claus Gittinger <cg@exept.de>
parents: 5461
diff changeset
   157
    r1 := color1 redByte.
c6029a2cf7c0 added:8 methods
Claus Gittinger <cg@exept.de>
parents: 5461
diff changeset
   158
    r2 := color2 redByte.
c6029a2cf7c0 added:8 methods
Claus Gittinger <cg@exept.de>
parents: 5461
diff changeset
   159
    g1 := color1 greenByte.
c6029a2cf7c0 added:8 methods
Claus Gittinger <cg@exept.de>
parents: 5461
diff changeset
   160
    g2 := color2 greenByte.
c6029a2cf7c0 added:8 methods
Claus Gittinger <cg@exept.de>
parents: 5461
diff changeset
   161
    b1 := color1 blueByte.
c6029a2cf7c0 added:8 methods
Claus Gittinger <cg@exept.de>
parents: 5461
diff changeset
   162
    b2 := color2 blueByte.
c6029a2cf7c0 added:8 methods
Claus Gittinger <cg@exept.de>
parents: 5461
diff changeset
   163
5728
c3c7f362b4c3 changed: #fillRectangleX:y:width:height:in:
Stefan Vogel <sv@exept.de>
parents: 5705
diff changeset
   164
    aView lineStyle:#solid.
c3c7f362b4c3 changed: #fillRectangleX:y:width:height:in:
Stefan Vogel <sv@exept.de>
parents: 5705
diff changeset
   165
5688
Claus Gittinger <cg@exept.de>
parents: 5687
diff changeset
   166
    "/ individual lines; from top to bottom
5705
56318de85b68 comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents: 5692
diff changeset
   167
    (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
   168
        dR := (r2 - r1) / hAll.
5684
c6029a2cf7c0 added:8 methods
Claus Gittinger <cg@exept.de>
parents: 5461
diff changeset
   169
        r := r1 + (dR * y).
5687
d4ab14b6cf0a changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents: 5684
diff changeset
   170
        dG := (g2 - g1) / hAll.
5684
c6029a2cf7c0 added:8 methods
Claus Gittinger <cg@exept.de>
parents: 5461
diff changeset
   171
        g := g1 + (dG * y).
5687
d4ab14b6cf0a changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents: 5684
diff changeset
   172
        dB := (b2 - b1) / hAll.
5684
c6029a2cf7c0 added:8 methods
Claus Gittinger <cg@exept.de>
parents: 5461
diff changeset
   173
        b := b1 + (dB * y).
c6029a2cf7c0 added:8 methods
Claus Gittinger <cg@exept.de>
parents: 5461
diff changeset
   174
c6029a2cf7c0 added:8 methods
Claus Gittinger <cg@exept.de>
parents: 5461
diff changeset
   175
        xRight := x+w-1.
5705
56318de85b68 comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents: 5692
diff changeset
   176
        0 to:hAll-1 do:[:yP |
5684
c6029a2cf7c0 added:8 methods
Claus Gittinger <cg@exept.de>
parents: 5461
diff changeset
   177
            rC := r asInteger.
c6029a2cf7c0 added:8 methods
Claus Gittinger <cg@exept.de>
parents: 5461
diff changeset
   178
            gC := g asInteger.
c6029a2cf7c0 added:8 methods
Claus Gittinger <cg@exept.de>
parents: 5461
diff changeset
   179
            bC := b asInteger.
c6029a2cf7c0 added:8 methods
Claus Gittinger <cg@exept.de>
parents: 5461
diff changeset
   180
            (rC ~~ lastR or:[gC ~~ lastG or:[bC ~~ lastB]]) ifTrue:[
c6029a2cf7c0 added:8 methods
Claus Gittinger <cg@exept.de>
parents: 5461
diff changeset
   181
                aView foreground:(Color redByte:rC greenByte:gC blueByte:bC).
c6029a2cf7c0 added:8 methods
Claus Gittinger <cg@exept.de>
parents: 5461
diff changeset
   182
                lastR := rC. lastG := gC. lastB := bC.
c6029a2cf7c0 added:8 methods
Claus Gittinger <cg@exept.de>
parents: 5461
diff changeset
   183
            ].
5728
c3c7f362b4c3 changed: #fillRectangleX:y:width:height:in:
Stefan Vogel <sv@exept.de>
parents: 5705
diff changeset
   184
            "xRight+1 since X11 does not show the last point of a line"
c3c7f362b4c3 changed: #fillRectangleX:y:width:height:in:
Stefan Vogel <sv@exept.de>
parents: 5705
diff changeset
   185
            aView displayLineFromX:x y:y+yP toX:xRight+1 y:y+yP.
c3c7f362b4c3 changed: #fillRectangleX:y:width:height:in:
Stefan Vogel <sv@exept.de>
parents: 5705
diff changeset
   186
            r := r + dR "used to do min:r2 here, but this does not work if r2 < r1 and dR is negative".
c3c7f362b4c3 changed: #fillRectangleX:y:width:height:in:
Stefan Vogel <sv@exept.de>
parents: 5705
diff changeset
   187
            g := g + dG .
c3c7f362b4c3 changed: #fillRectangleX:y:width:height:in:
Stefan Vogel <sv@exept.de>
parents: 5705
diff changeset
   188
            b := b + dB.
5684
c6029a2cf7c0 added:8 methods
Claus Gittinger <cg@exept.de>
parents: 5461
diff changeset
   189
        ].
5728
c3c7f362b4c3 changed: #fillRectangleX:y:width:height:in:
Stefan Vogel <sv@exept.de>
parents: 5705
diff changeset
   190
        aView fillRectangleX:x y:hAll-1 width:w height:(h-hAll+1).
5688
Claus Gittinger <cg@exept.de>
parents: 5687
diff changeset
   191
        ^ self.
Claus Gittinger <cg@exept.de>
parents: 5687
diff changeset
   192
    ].
Claus Gittinger <cg@exept.de>
parents: 5687
diff changeset
   193
Claus Gittinger <cg@exept.de>
parents: 5687
diff changeset
   194
    "/ individual lines; from left to right
Claus Gittinger <cg@exept.de>
parents: 5687
diff changeset
   195
    (direction == #eastWest or:[direction == #horizontal]) ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 5687
diff changeset
   196
        dR := (r2 - r1) / wAll.
Claus Gittinger <cg@exept.de>
parents: 5687
diff changeset
   197
        r := r1 + (dR * y).
Claus Gittinger <cg@exept.de>
parents: 5687
diff changeset
   198
        dG := (g2 - g1) / wAll.
Claus Gittinger <cg@exept.de>
parents: 5687
diff changeset
   199
        g := g1 + (dG * y).
Claus Gittinger <cg@exept.de>
parents: 5687
diff changeset
   200
        dB := (b2 - b1) / wAll.
Claus Gittinger <cg@exept.de>
parents: 5687
diff changeset
   201
        b := b1 + (dB * y).
Claus Gittinger <cg@exept.de>
parents: 5687
diff changeset
   202
Claus Gittinger <cg@exept.de>
parents: 5687
diff changeset
   203
        yBot := y+h-1.
5705
56318de85b68 comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents: 5692
diff changeset
   204
        0 to:wAll-1 do:[:xP |
5688
Claus Gittinger <cg@exept.de>
parents: 5687
diff changeset
   205
            rC := r asInteger.
Claus Gittinger <cg@exept.de>
parents: 5687
diff changeset
   206
            gC := g asInteger.
Claus Gittinger <cg@exept.de>
parents: 5687
diff changeset
   207
            bC := b asInteger.
Claus Gittinger <cg@exept.de>
parents: 5687
diff changeset
   208
            (rC ~~ lastR or:[gC ~~ lastG or:[bC ~~ lastB]]) ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 5687
diff changeset
   209
                aView foreground:(Color redByte:rC greenByte:gC blueByte:bC).
Claus Gittinger <cg@exept.de>
parents: 5687
diff changeset
   210
                lastR := rC. lastG := gC. lastB := bC.
Claus Gittinger <cg@exept.de>
parents: 5687
diff changeset
   211
            ].
5728
c3c7f362b4c3 changed: #fillRectangleX:y:width:height:in:
Stefan Vogel <sv@exept.de>
parents: 5705
diff changeset
   212
            "yBot+1 since X11 does not show the last point of a line"
c3c7f362b4c3 changed: #fillRectangleX:y:width:height:in:
Stefan Vogel <sv@exept.de>
parents: 5705
diff changeset
   213
            aView displayLineFromX:x+xP y:y toX:x+xP y:yBot+1.
c3c7f362b4c3 changed: #fillRectangleX:y:width:height:in:
Stefan Vogel <sv@exept.de>
parents: 5705
diff changeset
   214
            r := r + dR.
c3c7f362b4c3 changed: #fillRectangleX:y:width:height:in:
Stefan Vogel <sv@exept.de>
parents: 5705
diff changeset
   215
            g := g + dG.
c3c7f362b4c3 changed: #fillRectangleX:y:width:height:in:
Stefan Vogel <sv@exept.de>
parents: 5705
diff changeset
   216
            b := b + dB.
5688
Claus Gittinger <cg@exept.de>
parents: 5687
diff changeset
   217
        ].
5728
c3c7f362b4c3 changed: #fillRectangleX:y:width:height:in:
Stefan Vogel <sv@exept.de>
parents: 5705
diff changeset
   218
        aView fillRectangleX:wAll y:y width:(w-wAll+1) height:h.
5688
Claus Gittinger <cg@exept.de>
parents: 5687
diff changeset
   219
        ^ self.
5684
c6029a2cf7c0 added:8 methods
Claus Gittinger <cg@exept.de>
parents: 5461
diff changeset
   220
    ]
c6029a2cf7c0 added:8 methods
Claus Gittinger <cg@exept.de>
parents: 5461
diff changeset
   221
c6029a2cf7c0 added:8 methods
Claus Gittinger <cg@exept.de>
parents: 5461
diff changeset
   222
    "Created: / 23-01-2011 / 01:59:29 / cg"
5705
56318de85b68 comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents: 5692
diff changeset
   223
    "Modified: / 03-02-2011 / 20:26:55 / cg"
5684
c6029a2cf7c0 added:8 methods
Claus Gittinger <cg@exept.de>
parents: 5461
diff changeset
   224
! !
c6029a2cf7c0 added:8 methods
Claus Gittinger <cg@exept.de>
parents: 5461
diff changeset
   225
5461
2451688b8d25 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   226
!GradientBackground class methodsFor:'documentation'!
2451688b8d25 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   227
2451688b8d25 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   228
version_CVS
5728
c3c7f362b4c3 changed: #fillRectangleX:y:width:height:in:
Stefan Vogel <sv@exept.de>
parents: 5705
diff changeset
   229
    ^ '$Header: /cvs/stx/stx/libview/GradientBackground.st,v 1.7 2011-03-04 16:09:07 stefan Exp $'
5461
2451688b8d25 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   230
! !