GradientBackground.st
author Stefan Vogel <sv@exept.de>
Tue, 28 Apr 2020 15:28:14 +0200
changeset 9038 dd177fea6408
parent 8606 13735a803dc5
permissions -rw-r--r--
#REFACTORING by stefan class: Font changed: #setFamily:face:style:size:sizeUnit:encoding:device:
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
8606
13735a803dc5 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7935
diff changeset
     1
"{ Encoding: utf8 }"
13735a803dc5 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7935
diff changeset
     2
5461
2451688b8d25 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     3
"
7935
1d8d21aa47e7 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7934
diff changeset
     4
 COPYRIGHT (c) 2009 by Claus Gittinger / eXept Software AG
5461
2451688b8d25 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     5
              All Rights Reserved
2451688b8d25 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     6
2451688b8d25 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     7
 This software is furnished under a license and may be used
2451688b8d25 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     8
 only in accordance with the terms of that license and with the
2451688b8d25 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     9
 inclusion of the above copyright notice.   This software may not
2451688b8d25 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    10
 be provided or otherwise made available to, or used by, any
2451688b8d25 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    11
 other person.  No title to or ownership of the software is
2451688b8d25 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    12
 hereby transferred.
2451688b8d25 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    13
"
2451688b8d25 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    14
"{ Package: 'stx:libview' }"
2451688b8d25 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    15
6769
5421316e7200 class: GradientBackground
Claus Gittinger <cg@exept.de>
parents: 6202
diff changeset
    16
"{ NameSpace: Smalltalk }"
5421316e7200 class: GradientBackground
Claus Gittinger <cg@exept.de>
parents: 6202
diff changeset
    17
5461
2451688b8d25 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    18
AbstractBackground subclass:#GradientBackground
6966
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
    19
	instanceVariableNames:'colors direction cachedForm usedLength'
5461
2451688b8d25 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    20
	classVariableNames:''
2451688b8d25 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    21
	poolDictionaries:''
2451688b8d25 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    22
	category:'Graphics-Support'
2451688b8d25 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    23
!
2451688b8d25 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    24
2451688b8d25 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    25
!GradientBackground class methodsFor:'documentation'!
2451688b8d25 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    26
2451688b8d25 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    27
copyright
2451688b8d25 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    28
"
7935
1d8d21aa47e7 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7934
diff changeset
    29
 COPYRIGHT (c) 2009 by Claus Gittinger / eXept Software AG
5461
2451688b8d25 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    30
              All Rights Reserved
2451688b8d25 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    31
2451688b8d25 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    32
 This software is furnished under a license and may be used
2451688b8d25 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    33
 only in accordance with the terms of that license and with the
2451688b8d25 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    34
 inclusion of the above copyright notice.   This software may not
2451688b8d25 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    35
 be provided or otherwise made available to, or used by, any
2451688b8d25 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    36
 other person.  No title to or ownership of the software is
2451688b8d25 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    37
 hereby transferred.
2451688b8d25 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    38
"
5705
56318de85b68 comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents: 5692
diff changeset
    39
!
56318de85b68 comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents: 5692
diff changeset
    40
7935
1d8d21aa47e7 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7934
diff changeset
    41
documentation
1d8d21aa47e7 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7934
diff changeset
    42
"
1d8d21aa47e7 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7934
diff changeset
    43
    instances of me can be installed as a viewBackground, 
1d8d21aa47e7 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7934
diff changeset
    44
    and will draw a gradient background.
1d8d21aa47e7 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7934
diff changeset
    45
    I can be used as background of color-sliders (HUE, Light, saturation),
1d8d21aa47e7 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7934
diff changeset
    46
    or for nice looking splashscreens (which was the original motivation for that).
1d8d21aa47e7 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7934
diff changeset
    47
    
1d8d21aa47e7 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7934
diff changeset
    48
    More than 2 colors can be specified, all given colors will be visited
1d8d21aa47e7 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7934
diff changeset
    49
    with a gradient in between each.
1d8d21aa47e7 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7934
diff changeset
    50
1d8d21aa47e7 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7934
diff changeset
    51
    When a view's size changes, I can be configured to either re-adjust my gradient,
1d8d21aa47e7 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7934
diff changeset
    52
    so that always all colors are visited (but which leads to flicker, because with every
1d8d21aa47e7 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7934
diff changeset
    53
    resize, the full background needs a redraw),
1d8d21aa47e7 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7934
diff changeset
    54
    or to always use the screens size as a reference.
1d8d21aa47e7 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7934
diff changeset
    55
    In the later case, onle new exposed areas need to be redrawn, but only a partial range o colors
1d8d21aa47e7 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7934
diff changeset
    56
    is drawn.
1d8d21aa47e7 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7934
diff changeset
    57
1d8d21aa47e7 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7934
diff changeset
    58
    See the example, which demonstrates the resizing behavior.
1d8d21aa47e7 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7934
diff changeset
    59
1d8d21aa47e7 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7934
diff changeset
    60
    [author:]
1d8d21aa47e7 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7934
diff changeset
    61
        Claus Gittinger
1d8d21aa47e7 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7934
diff changeset
    62
"
1d8d21aa47e7 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7934
diff changeset
    63
!
1d8d21aa47e7 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7934
diff changeset
    64
5705
56318de85b68 comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents: 5692
diff changeset
    65
examples
56318de85b68 comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents: 5692
diff changeset
    66
"
7078
8496a1fff589 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 6966
diff changeset
    67
  demonstrates the various options, which control gradient the effect:
6953
eac8b255a9e1 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6769
diff changeset
    68
                                                                    [exBegin]
6966
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
    69
    |bg t c1 c2 c3 v1 v2 v3 v4 v5 v6 v7 v8 l1 l2 l3 l4 l5 l6 l7 l8|
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
    70
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
    71
    c1 := Color yellow.
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
    72
    c2 := Color red.
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
    73
    c3 := Color blue.
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
    74
    
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
    75
    t := TopView new.
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
    76
    t width:800.
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
    77
    t maxExtent:800@Display height.
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
    78
    t minExtent:800@50.
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
    79
    
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
    80
    l1 := Label origin:0@0   extent:100@30 in:t.
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
    81
    l2 := Label origin:100@0 extent:100@30 in:t.
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
    82
    l3 := Label origin:200@0 extent:100@30 in:t.
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
    83
    l4 := Label origin:300@0 extent:100@30 in:t.
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
    84
    l5 := Label origin:400@0 extent:100@30 in:t.
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
    85
    l6 := Label origin:500@0 extent:100@30 in:t.
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
    86
    l7 := Label origin:600@0 extent:100@30 in:t.
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
    87
    l8 := Label origin:700@0 extent:100@30 in:t.
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
    88
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
    89
    v1 := View origin:0@30 extent:100@1.0 in:t.
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
    90
    v2 := View origin:100@30 extent:100@1.0 in:t.
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
    91
    v3 := View origin:200@30 extent:100@1.0 in:t.
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
    92
    v4 := View origin:300@30 extent:100@1.0 in:t.
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
    93
    v5 := View origin:400@30 extent:100@1.0 in:t.
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
    94
    v6 := View origin:500@30 extent:100@1.0 in:t.
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
    95
    v7 := View origin:600@30 extent:100@1.0 in:t.
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
    96
    v8 := View origin:700@30 extent:100@1.0 in:t.
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
    97
    
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
    98
    l1 label:'screen'; adjust:#center.
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
    99
    bg := GradientBackground new color1:c1 color2:c2.
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   100
    v1 viewBackground:bg.
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   101
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   102
    l2 label:'100'; adjust:#center.
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   103
    bg := GradientBackground new color1:c1 color2:c2.
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   104
    bg usedLength:100.
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   105
    v2 viewBackground:bg.
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   106
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   107
    l3 label:'300'; adjust:#center.
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   108
    bg := GradientBackground new color1:c1 color2:c2.
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   109
    bg usedLength:300.
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   110
    v3 viewBackground:bg.
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   111
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   112
    l4 label:'view'; adjust:#center.
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   113
    bg := GradientBackground new color1:c1 color2:c2.
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   114
    bg usedLength:#view.
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   115
    v4 viewBackground:bg.
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   116
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   117
    l5 label:'screen'; adjust:#center.
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   118
    bg := GradientBackground new color1:c1 color2:c2 color3:c3.
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   119
    v5 viewBackground:bg.
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   120
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   121
    l6 label:'100'; adjust:#center.
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   122
    bg := GradientBackground new color1:c1 color2:c2 color3:c3.
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   123
    bg usedLength:100.
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   124
    v6 viewBackground:bg.
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   125
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   126
    l7 label:'300'; adjust:#center.
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   127
    bg := GradientBackground new color1:c1 color2:c2 color3:c3.
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   128
    bg usedLength:300.
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   129
    v7 viewBackground:bg.
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   130
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   131
    l8 label:'view'; adjust:#center.
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   132
    bg := GradientBackground new color1:c1 color2:c2 color3:c3.
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   133
    bg usedLength:#view.
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   134
    v8 viewBackground:bg.
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   135
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   136
    t open.
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   137
                                                                    [exEnd]
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   138
                                                                    
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   139
                                                                    [exBegin]
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   140
    |bg v|
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   141
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   142
    bg := GradientBackground new colors:{ Color red . Color green . Color blue . Color red }.
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   143
    v := View new extent:300@300.
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   144
    v viewBackground:bg.
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   145
    v open.
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   146
                                                                    [exEnd]
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   147
                                                                    [exBegin]
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   148
    |bg v|
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   149
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   150
    bg := GradientBackground new colors:{ Color red . Color green . Color blue . Color red }.
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   151
    bg usedLength:#view.
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   152
    v := View new extent:300@300.
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   153
    v viewBackground:bg.
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   154
    v open.
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   155
                                                                    [exEnd]
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   156
                                                                    [exBegin]
5705
56318de85b68 comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents: 5692
diff changeset
   157
    |bg v|
56318de85b68 comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents: 5692
diff changeset
   158
56318de85b68 comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents: 5692
diff changeset
   159
    bg := GradientBackground new color1:Color red color2:Color yellow.
56318de85b68 comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents: 5692
diff changeset
   160
    v := View new extent:300@300.
56318de85b68 comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents: 5692
diff changeset
   161
    v viewBackground:bg.
56318de85b68 comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents: 5692
diff changeset
   162
    v open.
6953
eac8b255a9e1 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6769
diff changeset
   163
                                                                    [exEnd]
eac8b255a9e1 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6769
diff changeset
   164
eac8b255a9e1 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6769
diff changeset
   165
                                                                    [exBegin]
eac8b255a9e1 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6769
diff changeset
   166
    |bg v|
eac8b255a9e1 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6769
diff changeset
   167
eac8b255a9e1 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6769
diff changeset
   168
    bg := GradientBackground new color1:Color red color2:Color yellow.
eac8b255a9e1 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6769
diff changeset
   169
    bg usedLength:100.
eac8b255a9e1 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6769
diff changeset
   170
    v := View new extent:300@300.
eac8b255a9e1 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6769
diff changeset
   171
    v viewBackground:bg.
eac8b255a9e1 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6769
diff changeset
   172
    v open.
eac8b255a9e1 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6769
diff changeset
   173
                                                                    [exEnd]
eac8b255a9e1 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6769
diff changeset
   174
eac8b255a9e1 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6769
diff changeset
   175
                                                                    [exBegin]
eac8b255a9e1 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6769
diff changeset
   176
    |bg v|
eac8b255a9e1 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6769
diff changeset
   177
eac8b255a9e1 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6769
diff changeset
   178
    bg := GradientBackground new color1:Color red color2:Color yellow.
6966
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   179
    bg usedLength:#view.
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   180
    v := View new extent:300@300.
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   181
    v viewBackground:bg.
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   182
    v open.
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   183
                                                                    [exEnd]
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   184
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   185
                                                                    [exBegin]
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   186
    |bg v|
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   187
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   188
    bg := GradientBackground new color1:Color red color2:Color yellow.
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   189
    bg color3:Color green.
6953
eac8b255a9e1 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6769
diff changeset
   190
    v := View new extent:300@300.
eac8b255a9e1 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6769
diff changeset
   191
    v viewBackground:bg.
eac8b255a9e1 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6769
diff changeset
   192
    v open.
eac8b255a9e1 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6769
diff changeset
   193
                                                                    [exEnd]
6966
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   194
                                                                    [exBegin]
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   195
    |bg v|
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   196
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   197
    bg := GradientBackground new color1:Color red color2:Color yellow.
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   198
    bg color3:Color green.
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   199
    bg usedLength:100.
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   200
    v := View new extent:300@300.
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   201
    v viewBackground:bg.
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   202
    v open.
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   203
                                                                    [exEnd]
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   204
                                                                    [exBegin]
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   205
    |bg v|
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   206
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   207
    bg := GradientBackground new color1:Color red color2:Color yellow.
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   208
    bg color3:Color green.
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   209
    bg usedLength:#view.
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   210
    v := View new extent:300@300.
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   211
    v viewBackground:bg.
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   212
    v open.
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   213
                                                                    [exEnd]
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   214
5705
56318de85b68 comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents: 5692
diff changeset
   215
"
5461
2451688b8d25 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   216
! !
2451688b8d25 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   217
6013
aee5be18d9a1 class: GradientBackground
Claus Gittinger <cg@exept.de>
parents: 5739
diff changeset
   218
!GradientBackground class methodsFor:'instance creation'!
aee5be18d9a1 class: GradientBackground
Claus Gittinger <cg@exept.de>
parents: 5739
diff changeset
   219
aee5be18d9a1 class: GradientBackground
Claus Gittinger <cg@exept.de>
parents: 5739
diff changeset
   220
horizontal:color1 to:color2
aee5be18d9a1 class: GradientBackground
Claus Gittinger <cg@exept.de>
parents: 5739
diff changeset
   221
    ^ self new 
aee5be18d9a1 class: GradientBackground
Claus Gittinger <cg@exept.de>
parents: 5739
diff changeset
   222
        direction:#eastWest;
aee5be18d9a1 class: GradientBackground
Claus Gittinger <cg@exept.de>
parents: 5739
diff changeset
   223
        color1:color1 color2:color2
aee5be18d9a1 class: GradientBackground
Claus Gittinger <cg@exept.de>
parents: 5739
diff changeset
   224
aee5be18d9a1 class: GradientBackground
Claus Gittinger <cg@exept.de>
parents: 5739
diff changeset
   225
    "
aee5be18d9a1 class: GradientBackground
Claus Gittinger <cg@exept.de>
parents: 5739
diff changeset
   226
     |bg v|
aee5be18d9a1 class: GradientBackground
Claus Gittinger <cg@exept.de>
parents: 5739
diff changeset
   227
aee5be18d9a1 class: GradientBackground
Claus Gittinger <cg@exept.de>
parents: 5739
diff changeset
   228
     bg := GradientBackground horizontal:Color red to:Color yellow.
aee5be18d9a1 class: GradientBackground
Claus Gittinger <cg@exept.de>
parents: 5739
diff changeset
   229
     v := View new extent:300@300.
aee5be18d9a1 class: GradientBackground
Claus Gittinger <cg@exept.de>
parents: 5739
diff changeset
   230
     v viewBackground:bg.
aee5be18d9a1 class: GradientBackground
Claus Gittinger <cg@exept.de>
parents: 5739
diff changeset
   231
     v open.
aee5be18d9a1 class: GradientBackground
Claus Gittinger <cg@exept.de>
parents: 5739
diff changeset
   232
    "
6014
0da48fc12d6a class: GradientBackground
Claus Gittinger <cg@exept.de>
parents: 6013
diff changeset
   233
    "
0da48fc12d6a class: GradientBackground
Claus Gittinger <cg@exept.de>
parents: 6013
diff changeset
   234
     |bg v|
0da48fc12d6a class: GradientBackground
Claus Gittinger <cg@exept.de>
parents: 6013
diff changeset
   235
0da48fc12d6a class: GradientBackground
Claus Gittinger <cg@exept.de>
parents: 6013
diff changeset
   236
     bg := GradientBackground horizontal:Color red to:Color yellow.
0da48fc12d6a class: GradientBackground
Claus Gittinger <cg@exept.de>
parents: 6013
diff changeset
   237
     v := View new extent:300@300.
0da48fc12d6a class: GradientBackground
Claus Gittinger <cg@exept.de>
parents: 6013
diff changeset
   238
     v viewBackground:bg.
0da48fc12d6a class: GradientBackground
Claus Gittinger <cg@exept.de>
parents: 6013
diff changeset
   239
     v open.
0da48fc12d6a class: GradientBackground
Claus Gittinger <cg@exept.de>
parents: 6013
diff changeset
   240
    "
6013
aee5be18d9a1 class: GradientBackground
Claus Gittinger <cg@exept.de>
parents: 5739
diff changeset
   241
!
aee5be18d9a1 class: GradientBackground
Claus Gittinger <cg@exept.de>
parents: 5739
diff changeset
   242
aee5be18d9a1 class: GradientBackground
Claus Gittinger <cg@exept.de>
parents: 5739
diff changeset
   243
vertical:color1 to:color2
aee5be18d9a1 class: GradientBackground
Claus Gittinger <cg@exept.de>
parents: 5739
diff changeset
   244
    ^ self new 
aee5be18d9a1 class: GradientBackground
Claus Gittinger <cg@exept.de>
parents: 5739
diff changeset
   245
        direction:#northSouth;
aee5be18d9a1 class: GradientBackground
Claus Gittinger <cg@exept.de>
parents: 5739
diff changeset
   246
        color1:color1 color2:color2
aee5be18d9a1 class: GradientBackground
Claus Gittinger <cg@exept.de>
parents: 5739
diff changeset
   247
aee5be18d9a1 class: GradientBackground
Claus Gittinger <cg@exept.de>
parents: 5739
diff changeset
   248
    "
aee5be18d9a1 class: GradientBackground
Claus Gittinger <cg@exept.de>
parents: 5739
diff changeset
   249
     |bg v|
aee5be18d9a1 class: GradientBackground
Claus Gittinger <cg@exept.de>
parents: 5739
diff changeset
   250
aee5be18d9a1 class: GradientBackground
Claus Gittinger <cg@exept.de>
parents: 5739
diff changeset
   251
     bg := GradientBackground vertical:Color red to:Color yellow.
aee5be18d9a1 class: GradientBackground
Claus Gittinger <cg@exept.de>
parents: 5739
diff changeset
   252
     v := View new extent:300@300.
aee5be18d9a1 class: GradientBackground
Claus Gittinger <cg@exept.de>
parents: 5739
diff changeset
   253
     v viewBackground:bg.
aee5be18d9a1 class: GradientBackground
Claus Gittinger <cg@exept.de>
parents: 5739
diff changeset
   254
     v open.
aee5be18d9a1 class: GradientBackground
Claus Gittinger <cg@exept.de>
parents: 5739
diff changeset
   255
    "
aee5be18d9a1 class: GradientBackground
Claus Gittinger <cg@exept.de>
parents: 5739
diff changeset
   256
! !
aee5be18d9a1 class: GradientBackground
Claus Gittinger <cg@exept.de>
parents: 5739
diff changeset
   257
6769
5421316e7200 class: GradientBackground
Claus Gittinger <cg@exept.de>
parents: 6202
diff changeset
   258
!GradientBackground class methodsFor:'queries'!
5421316e7200 class: GradientBackground
Claus Gittinger <cg@exept.de>
parents: 6202
diff changeset
   259
5421316e7200 class: GradientBackground
Claus Gittinger <cg@exept.de>
parents: 6202
diff changeset
   260
possibleDirections 
5421316e7200 class: GradientBackground
Claus Gittinger <cg@exept.de>
parents: 6202
diff changeset
   261
    ^ #(#'northSouth' #'eastWest' )
5421316e7200 class: GradientBackground
Claus Gittinger <cg@exept.de>
parents: 6202
diff changeset
   262
! !
5421316e7200 class: GradientBackground
Claus Gittinger <cg@exept.de>
parents: 6202
diff changeset
   263
5684
c6029a2cf7c0 added:8 methods
Claus Gittinger <cg@exept.de>
parents: 5461
diff changeset
   264
!GradientBackground methodsFor:'accessing'!
c6029a2cf7c0 added:8 methods
Claus Gittinger <cg@exept.de>
parents: 5461
diff changeset
   265
8606
13735a803dc5 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7935
diff changeset
   266
averageColorIn:aRectangle
13735a803dc5 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7935
diff changeset
   267
    "return the images average color in an area.
13735a803dc5 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7935
diff changeset
   268
     The implementation below is slow - so you may want to
13735a803dc5 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7935
diff changeset
   269
     create tuned versions for DepthXImage if you plan to do
13735a803dc5 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7935
diff changeset
   270
     heavy image processing ...
13735a803dc5 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7935
diff changeset
   271
     (also, creating tuned versions of the enumeration messages helps a lot)"
13735a803dc5 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7935
diff changeset
   272
13735a803dc5 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7935
diff changeset
   273
    |clr1 clr2|
13735a803dc5 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7935
diff changeset
   274
13735a803dc5 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7935
diff changeset
   275
    clr1 := self color1.
13735a803dc5 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7935
diff changeset
   276
    clr2 := self color2.
13735a803dc5 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7935
diff changeset
   277
     ^ Color 
13735a803dc5 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7935
diff changeset
   278
        redByte:(clr1 redByte + clr2 redByte) // 2
13735a803dc5 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7935
diff changeset
   279
        greenByte:(clr1 greenByte + clr2 greenByte) // 2
13735a803dc5 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7935
diff changeset
   280
        blueByte:(clr1 blueByte + clr2 blueByte) // 2
13735a803dc5 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7935
diff changeset
   281
13735a803dc5 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7935
diff changeset
   282
    "
13735a803dc5 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7935
diff changeset
   283
     self new color1:(Color red) color2:(Color white)
13735a803dc5 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7935
diff changeset
   284
     (self new color1:(Color red) color2:(Color white)) averageColorIn:nil
13735a803dc5 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7935
diff changeset
   285
    "
13735a803dc5 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7935
diff changeset
   286
13735a803dc5 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7935
diff changeset
   287
    "Created: / 23-12-2018 / 01:07:37 / Claus Gittinger"
13735a803dc5 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7935
diff changeset
   288
!
13735a803dc5 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7935
diff changeset
   289
5684
c6029a2cf7c0 added:8 methods
Claus Gittinger <cg@exept.de>
parents: 5461
diff changeset
   290
color1
6966
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   291
    ^ colors at:1
5684
c6029a2cf7c0 added:8 methods
Claus Gittinger <cg@exept.de>
parents: 5461
diff changeset
   292
c6029a2cf7c0 added:8 methods
Claus Gittinger <cg@exept.de>
parents: 5461
diff changeset
   293
    "Created: / 23-01-2011 / 02:01:29 / cg"
c6029a2cf7c0 added:8 methods
Claus Gittinger <cg@exept.de>
parents: 5461
diff changeset
   294
!
c6029a2cf7c0 added:8 methods
Claus Gittinger <cg@exept.de>
parents: 5461
diff changeset
   295
c6029a2cf7c0 added:8 methods
Claus Gittinger <cg@exept.de>
parents: 5461
diff changeset
   296
color1:aColor
6966
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   297
    colors isNil ifTrue:[
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   298
        colors := Array new:2.
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   299
    ].    
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   300
    colors at:1 put:aColor.
5705
56318de85b68 comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents: 5692
diff changeset
   301
    cachedForm := nil.
5684
c6029a2cf7c0 added:8 methods
Claus Gittinger <cg@exept.de>
parents: 5461
diff changeset
   302
c6029a2cf7c0 added:8 methods
Claus Gittinger <cg@exept.de>
parents: 5461
diff changeset
   303
    "Created: / 23-01-2011 / 02:01:50 / cg"
5705
56318de85b68 comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents: 5692
diff changeset
   304
    "Modified: / 03-02-2011 / 19:49:18 / cg"
56318de85b68 comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents: 5692
diff changeset
   305
!
56318de85b68 comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents: 5692
diff changeset
   306
56318de85b68 comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents: 5692
diff changeset
   307
color1:aColor1 color2:aColor2
6966
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   308
    colors isNil ifTrue:[
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   309
        colors := Array new:2
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   310
    ].    
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   311
    colors at:1 put:aColor1.
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   312
    colors at:2 put:aColor2.
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   313
    cachedForm := nil.
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   314
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   315
    "Created: / 03-02-2011 / 19:52:59 / cg"
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   316
!
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   317
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   318
color1:aColor1 color2:aColor2 color3:aColor3
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   319
    colors isNil ifTrue:[
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   320
        colors := Array new:3
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   321
    ].    
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   322
    colors at:1 put:aColor1.
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   323
    colors at:2 put:aColor2.
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   324
    colors at:3 put:aColor3.
5705
56318de85b68 comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents: 5692
diff changeset
   325
    cachedForm := nil.
56318de85b68 comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents: 5692
diff changeset
   326
56318de85b68 comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents: 5692
diff changeset
   327
    "Created: / 03-02-2011 / 19:52:59 / cg"
5684
c6029a2cf7c0 added:8 methods
Claus Gittinger <cg@exept.de>
parents: 5461
diff changeset
   328
!
c6029a2cf7c0 added:8 methods
Claus Gittinger <cg@exept.de>
parents: 5461
diff changeset
   329
c6029a2cf7c0 added:8 methods
Claus Gittinger <cg@exept.de>
parents: 5461
diff changeset
   330
color2
6966
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   331
    ^ colors at:2
5684
c6029a2cf7c0 added:8 methods
Claus Gittinger <cg@exept.de>
parents: 5461
diff changeset
   332
c6029a2cf7c0 added:8 methods
Claus Gittinger <cg@exept.de>
parents: 5461
diff changeset
   333
    "Created: / 23-01-2011 / 02:01:32 / cg"
c6029a2cf7c0 added:8 methods
Claus Gittinger <cg@exept.de>
parents: 5461
diff changeset
   334
!
c6029a2cf7c0 added:8 methods
Claus Gittinger <cg@exept.de>
parents: 5461
diff changeset
   335
c6029a2cf7c0 added:8 methods
Claus Gittinger <cg@exept.de>
parents: 5461
diff changeset
   336
color2:aColor
6966
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   337
    colors isNil ifTrue:[
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   338
        colors := Array new:2.
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   339
    ].    
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   340
    colors at:2 put:aColor.
5705
56318de85b68 comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents: 5692
diff changeset
   341
    cachedForm := nil.
5684
c6029a2cf7c0 added:8 methods
Claus Gittinger <cg@exept.de>
parents: 5461
diff changeset
   342
6966
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   343
    "Created: / 23-01-2011 / 02:01:50 / cg"
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   344
    "Modified: / 03-02-2011 / 19:49:18 / cg"
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   345
!
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   346
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   347
color3
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   348
    ^ colors at:3 ifAbsent:[nil]
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   349
!
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   350
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   351
color3:aColor
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   352
    colors isNil ifTrue:[
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   353
        colors := Array new:3.
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   354
    ] ifFalse:[
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   355
        colors size < 3 ifTrue:[
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   356
            colors := (Array new:3) replaceFrom:1 with:colors; yourself
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   357
        ].    
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   358
    ].    
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   359
    colors at:3 put:aColor.
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   360
    cachedForm := nil.
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   361
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   362
    "Created: / 23-01-2011 / 02:01:50 / cg"
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   363
    "Modified: / 03-02-2011 / 19:49:18 / cg"
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   364
!
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   365
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   366
colors:aColorVector
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   367
    colors := aColorVector.
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   368
    cachedForm := nil.
5688
Claus Gittinger <cg@exept.de>
parents: 5687
diff changeset
   369
!
Claus Gittinger <cg@exept.de>
parents: 5687
diff changeset
   370
Claus Gittinger <cg@exept.de>
parents: 5687
diff changeset
   371
direction
Claus Gittinger <cg@exept.de>
parents: 5687
diff changeset
   372
    "possible values:
Claus Gittinger <cg@exept.de>
parents: 5687
diff changeset
   373
        #northSouth
Claus Gittinger <cg@exept.de>
parents: 5687
diff changeset
   374
        #eastWest
Claus Gittinger <cg@exept.de>
parents: 5687
diff changeset
   375
Claus Gittinger <cg@exept.de>
parents: 5687
diff changeset
   376
     others are not yet supported
Claus Gittinger <cg@exept.de>
parents: 5687
diff changeset
   377
    "
Claus Gittinger <cg@exept.de>
parents: 5687
diff changeset
   378
6966
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   379
    (direction == #eastWest or:[direction == #horizontal]) ifTrue:[^ #eastWest].
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   380
    ^ #northSouth
5688
Claus Gittinger <cg@exept.de>
parents: 5687
diff changeset
   381
Claus Gittinger <cg@exept.de>
parents: 5687
diff changeset
   382
    "Modified: / 23-01-2011 / 14:36:36 / cg"
Claus Gittinger <cg@exept.de>
parents: 5687
diff changeset
   383
!
Claus Gittinger <cg@exept.de>
parents: 5687
diff changeset
   384
Claus Gittinger <cg@exept.de>
parents: 5687
diff changeset
   385
direction:something
Claus Gittinger <cg@exept.de>
parents: 5687
diff changeset
   386
    "possible values:
Claus Gittinger <cg@exept.de>
parents: 5687
diff changeset
   387
        #northSouth
Claus Gittinger <cg@exept.de>
parents: 5687
diff changeset
   388
        #eastWest
Claus Gittinger <cg@exept.de>
parents: 5687
diff changeset
   389
Claus Gittinger <cg@exept.de>
parents: 5687
diff changeset
   390
     others are not yet supported
Claus Gittinger <cg@exept.de>
parents: 5687
diff changeset
   391
    "
Claus Gittinger <cg@exept.de>
parents: 5687
diff changeset
   392
5705
56318de85b68 comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents: 5692
diff changeset
   393
    direction ~= something ifTrue:[
56318de85b68 comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents: 5692
diff changeset
   394
        direction := something.
56318de85b68 comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents: 5692
diff changeset
   395
        cachedForm := nil.
56318de85b68 comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents: 5692
diff changeset
   396
    ]
56318de85b68 comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents: 5692
diff changeset
   397
56318de85b68 comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents: 5692
diff changeset
   398
    "Modified: / 03-02-2011 / 19:49:41 / cg"
5738
Claus Gittinger <cg@exept.de>
parents: 5733
diff changeset
   399
!
Claus Gittinger <cg@exept.de>
parents: 5733
diff changeset
   400
Claus Gittinger <cg@exept.de>
parents: 5733
diff changeset
   401
usedLength
Claus Gittinger <cg@exept.de>
parents: 5733
diff changeset
   402
    ^ usedLength
Claus Gittinger <cg@exept.de>
parents: 5733
diff changeset
   403
!
Claus Gittinger <cg@exept.de>
parents: 5733
diff changeset
   404
6966
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   405
usedLength:nilOrSymbolOrNumber
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   406
    "specify:
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   407
        nil: use the screen height and interpolate gradient along that
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   408
        #view: use the view's height and interpolate gradient along that
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   409
        <integer>: interpolate from 0..n, with color2 above that.
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   410
        See examples on how each looks"
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   411
        
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   412
    nilOrSymbolOrNumber == #full ifTrue:[
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   413
        "/ backw. compat.
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   414
        usedLength := #view
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   415
    ] ifFalse:[    
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   416
        usedLength := nilOrSymbolOrNumber.
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   417
    ]
5705
56318de85b68 comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents: 5692
diff changeset
   418
! !
56318de85b68 comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents: 5692
diff changeset
   419
56318de85b68 comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents: 5692
diff changeset
   420
!GradientBackground methodsFor:'converting'!
56318de85b68 comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents: 5692
diff changeset
   421
56318de85b68 comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents: 5692
diff changeset
   422
asFormOn:aDevice
6014
0da48fc12d6a class: GradientBackground
Claus Gittinger <cg@exept.de>
parents: 6013
diff changeset
   423
    |h w len|
0da48fc12d6a class: GradientBackground
Claus Gittinger <cg@exept.de>
parents: 6013
diff changeset
   424
6966
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   425
"/    usedLength == #view ifTrue:[
6953
eac8b255a9e1 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6769
diff changeset
   426
"/        self halt:'unsupported'. 
eac8b255a9e1 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6769
diff changeset
   427
"/        ^ nil
eac8b255a9e1 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6769
diff changeset
   428
"/    ].
5688
Claus Gittinger <cg@exept.de>
parents: 5687
diff changeset
   429
5705
56318de85b68 comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents: 5692
diff changeset
   430
    cachedForm isNil ifTrue:[
6966
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   431
        (len := usedLength) == #view ifTrue:[
6014
0da48fc12d6a class: GradientBackground
Claus Gittinger <cg@exept.de>
parents: 6013
diff changeset
   432
            len := nil
0da48fc12d6a class: GradientBackground
Claus Gittinger <cg@exept.de>
parents: 6013
diff changeset
   433
        ].
6966
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   434
        (self direction == #northSouth) ifTrue:[
6202
020ebdb99a1e Replace references to Diplay with "Screen current" - where appropriate
Stefan Vogel <sv@exept.de>
parents: 6102
diff changeset
   435
            h := len ? (aDevice height). "/ aView height.
5705
56318de85b68 comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents: 5692
diff changeset
   436
            w := 8.
56318de85b68 comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents: 5692
diff changeset
   437
        ] ifFalse:[
56318de85b68 comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents: 5692
diff changeset
   438
            h := 8.
6202
020ebdb99a1e Replace references to Diplay with "Screen current" - where appropriate
Stefan Vogel <sv@exept.de>
parents: 6102
diff changeset
   439
            w := len ? (aDevice width).  "/ aView width.
5705
56318de85b68 comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents: 5692
diff changeset
   440
        ].
56318de85b68 comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents: 5692
diff changeset
   441
        cachedForm := Form width:w height:h depth:aDevice depth onDevice:aDevice.
7359
dfee1b97dc3b #QUALITY by sr
sr
parents: 7078
diff changeset
   442
        cachedForm isNil ifTrue:[^nil].
5705
56318de85b68 comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents: 5692
diff changeset
   443
        "/ cachedForm clear.
56318de85b68 comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents: 5692
diff changeset
   444
        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
   445
    ].
56318de85b68 comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents: 5692
diff changeset
   446
56318de85b68 comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents: 5692
diff changeset
   447
    ^ cachedForm
56318de85b68 comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents: 5692
diff changeset
   448
56318de85b68 comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents: 5692
diff changeset
   449
    "Created: / 03-02-2011 / 20:05:30 / cg"
56318de85b68 comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents: 5692
diff changeset
   450
!
56318de85b68 comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents: 5692
diff changeset
   451
56318de85b68 comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents: 5692
diff changeset
   452
onDevice:device
56318de85b68 comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents: 5692
diff changeset
   453
    ^ self asFormOn:device.
56318de85b68 comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents: 5692
diff changeset
   454
56318de85b68 comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents: 5692
diff changeset
   455
    "Created: / 03-02-2011 / 19:56:06 / cg"
5684
c6029a2cf7c0 added:8 methods
Claus Gittinger <cg@exept.de>
parents: 5461
diff changeset
   456
! !
c6029a2cf7c0 added:8 methods
Claus Gittinger <cg@exept.de>
parents: 5461
diff changeset
   457
c6029a2cf7c0 added:8 methods
Claus Gittinger <cg@exept.de>
parents: 5461
diff changeset
   458
!GradientBackground methodsFor:'drawing'!
c6029a2cf7c0 added:8 methods
Claus Gittinger <cg@exept.de>
parents: 5461
diff changeset
   459
6966
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   460
fillRectangleX:x y:y width:w height:h in:aGC
7934
5c7dd401bfa2 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7359
diff changeset
   461
    "fill a rectangular area in aGC with a color gradient through colors (yes, more than 2 are possible).
5c7dd401bfa2 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7359
diff changeset
   462
     This is a first (very inefficient) try;
5c7dd401bfa2 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7359
diff changeset
   463
     as it is (currently) only used for some splash-screens and in
5c7dd401bfa2 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7359
diff changeset
   464
     expecco's demo mode, we don't really care for much performance (yet)"
5684
c6029a2cf7c0 added:8 methods
Claus Gittinger <cg@exept.de>
parents: 5461
diff changeset
   465
6966
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   466
    |hHalf wHalf h1 h2 w1 w2 usedHeight usedWidth scaleStartX scaleStartY x2 y2
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   467
     usedHeight2 usedWidth2 scaleStartX2 scaleStartY2 direction numSegs 
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   468
     usedHeightRange usedWidthRange usedRange startPos endPos
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   469
     partRange segOffset segNr pos
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   470
     r1 r2 g1 g2 b1 b2 minR maxR minG maxG minB maxB color1 color2
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   471
     dR dG dB r g b lastR lastG lastB endPart posRect szRun restSize|
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   472
    
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   473
    direction := self direction.
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   474
    
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   475
    usedLength isNil ifTrue:[
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   476
        "/ use screen's height; so the gradient changes when the bounds are moved
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   477
        usedHeightRange := aGC device height. "/ aView height.
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   478
        usedWidthRange := aGC device width.  "/ aView width.
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   479
    ] ifFalse:[
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   480
        usedLength == #view ifTrue:[
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   481
            usedHeightRange := aGC height.
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   482
            usedWidthRange := aGC width.
6014
0da48fc12d6a class: GradientBackground
Claus Gittinger <cg@exept.de>
parents: 6013
diff changeset
   483
        ] ifFalse:[
6966
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   484
            usedHeightRange := usedLength.
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   485
            usedWidthRange := usedLength.
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   486
        ].
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   487
    ].
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   488
    direction == #northSouth ifTrue:[
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   489
        usedRange := usedHeightRange.
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   490
        startPos := y.
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   491
        endPos := y+h.
5739
c4fbd37a6164 changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents: 5738
diff changeset
   492
    ] ifFalse:[
6966
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   493
        usedRange := usedWidthRange.
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   494
        startPos := x.
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   495
        endPos := x+w.
5739
c4fbd37a6164 changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents: 5738
diff changeset
   496
    ].
6966
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   497
    
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   498
    "/ each part
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   499
    numSegs := colors size - 1.
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   500
    partRange := (usedRange / numSegs) asFloat.
5684
c6029a2cf7c0 added:8 methods
Claus Gittinger <cg@exept.de>
parents: 5461
diff changeset
   501
6966
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   502
    "/ where is the start?
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   503
    segOffset := startPos \\ partRange.
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   504
    segNr := startPos // partRange + 1.
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   505
    
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   506
    pos := startPos.
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   507
    [pos < endPos] whileTrue:[
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   508
        segNr > numSegs ifTrue:[
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   509
            restSize := endPos - pos.
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   510
            aGC paint:(colors last).
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   511
            
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   512
            direction == #northSouth ifTrue:[
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   513
                aGC fillRectangleX:x y:pos width:w height:restSize.
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   514
            ] ifFalse:[    
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   515
                aGC fillRectangleX:pos y:y width:restSize height:h.
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   516
            ].    
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   517
            ^ self
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   518
        ].
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   519
        
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   520
        "/ we have to interpolate between those two colors
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   521
        color1 := colors at:segNr.
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   522
        color2 := colors at:segNr+1.
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   523
        
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   524
        r1 := color1 redByte.   r2 := color2 redByte.
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   525
        g1 := color1 greenByte. g2 := color2 greenByte.
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   526
        b1 := color1 blueByte.  b2 := color2 blueByte.
5728
c3c7f362b4c3 changed: #fillRectangleX:y:width:height:in:
Stefan Vogel <sv@exept.de>
parents: 5705
diff changeset
   527
6966
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   528
        minR := r1 min:r2. maxR := r1 max:r2.
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   529
        minG := g1 min:g2. maxG := g1 max:g2.
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   530
        minB := b1 min:b2. maxB := b1 max:b2.
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   531
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   532
        dR := (r2 - r1) / partRange. dG := (g2 - g1) / partRange. dB := (b2 - b1) / partRange.
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   533
        r := r1 + (dR * segOffset). 
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   534
        g := g1 + (dG * segOffset). 
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   535
        b := b1 + (dB * segOffset).
5733
08e2b386abef changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents: 5732
diff changeset
   536
5732
fba4327a852b changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents: 5731
diff changeset
   537
        r := (r max:minR) min:maxR. 
fba4327a852b changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents: 5731
diff changeset
   538
        g := (g max:minG) min:maxG.
fba4327a852b changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents: 5731
diff changeset
   539
        b := (b max:minB) min:maxB.
5684
c6029a2cf7c0 added:8 methods
Claus Gittinger <cg@exept.de>
parents: 5461
diff changeset
   540
5733
08e2b386abef changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents: 5732
diff changeset
   541
        lastR := r asInteger. lastG := g asInteger. lastB := b asInteger.
6966
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   542
        
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   543
        "/ now draw
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   544
        endPart := (startPos + partRange) truncated min:endPos.
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   545
        posRect := pos.
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   546
        szRun := 0.
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   547
        pos to:endPart-1 do:[:p |
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   548
            |rC gC bC|
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   549
            
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   550
            rC := r asInteger. gC := g asInteger. bC := b asInteger.
5684
c6029a2cf7c0 added:8 methods
Claus Gittinger <cg@exept.de>
parents: 5461
diff changeset
   551
            (rC ~~ lastR or:[gC ~~ lastG or:[bC ~~ lastB]]) ifTrue:[
6966
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   552
                aGC paint:(Color redByte:lastR greenByte:lastG blueByte:lastB).
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   553
                direction == #northSouth ifTrue:[
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   554
                    aGC fillRectangleX:x y:posRect width:w height:szRun.
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   555
                ] ifFalse:[    
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   556
                    aGC fillRectangleX:posRect y:y width:szRun height:h.
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   557
                ].    
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   558
                posRect := p. szRun := 0.
5684
c6029a2cf7c0 added:8 methods
Claus Gittinger <cg@exept.de>
parents: 5461
diff changeset
   559
                lastR := rC. lastG := gC. lastB := bC.
c6029a2cf7c0 added:8 methods
Claus Gittinger <cg@exept.de>
parents: 5461
diff changeset
   560
            ].
6966
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   561
            szRun := szRun + 1.
5731
e638acae4e19 changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents: 5730
diff changeset
   562
            r := ((r + dR) max:minR) min:maxR. 
e638acae4e19 changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents: 5730
diff changeset
   563
            g := ((g + dG) max:minG) min:maxG.
e638acae4e19 changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents: 5730
diff changeset
   564
            b := ((b + dB) max:minB) min:maxB.
5684
c6029a2cf7c0 added:8 methods
Claus Gittinger <cg@exept.de>
parents: 5461
diff changeset
   565
        ].
6966
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   566
        szRun ~~ 0 ifTrue:[
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   567
            aGC paint:(Color redByte:lastR greenByte:lastG blueByte:lastB).
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   568
            direction == #northSouth ifTrue:[
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   569
                aGC fillRectangleX:x y:posRect width:w height:szRun.
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   570
            ] ifFalse:[    
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   571
                aGC fillRectangleX:posRect y:y width:szRun height:h.
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   572
            ].    
5733
08e2b386abef changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents: 5732
diff changeset
   573
        ].
6966
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   574
        "/ self halt.
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   575
        "/ drawn one segment's gradient
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   576
        segOffset := 0.
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   577
        pos := startPos := endPart.
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   578
        segNr := segNr + 1.
5688
Claus Gittinger <cg@exept.de>
parents: 5687
diff changeset
   579
    ].
7934
5c7dd401bfa2 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7359
diff changeset
   580
5c7dd401bfa2 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7359
diff changeset
   581
    "Modified (comment): / 22-02-2017 / 21:09:03 / cg"
5684
c6029a2cf7c0 added:8 methods
Claus Gittinger <cg@exept.de>
parents: 5461
diff changeset
   582
! !
c6029a2cf7c0 added:8 methods
Claus Gittinger <cg@exept.de>
parents: 5461
diff changeset
   583
6953
eac8b255a9e1 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6769
diff changeset
   584
!GradientBackground methodsFor:'queries'!
eac8b255a9e1 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6769
diff changeset
   585
eac8b255a9e1 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6769
diff changeset
   586
needsFullRedrawOnChangeOfHeight
6966
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   587
    ^ usedLength == #view and:[self direction == #northSouth]
6953
eac8b255a9e1 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6769
diff changeset
   588
!
eac8b255a9e1 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6769
diff changeset
   589
eac8b255a9e1 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6769
diff changeset
   590
needsFullRedrawOnChangeOfWidth
6966
37711d94a0c0 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 6953
diff changeset
   591
    ^ usedLength == #view and:[direction == #eastWest]
6953
eac8b255a9e1 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6769
diff changeset
   592
! !
eac8b255a9e1 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6769
diff changeset
   593
5461
2451688b8d25 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   594
!GradientBackground class methodsFor:'documentation'!
2451688b8d25 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   595
6014
0da48fc12d6a class: GradientBackground
Claus Gittinger <cg@exept.de>
parents: 6013
diff changeset
   596
version
6953
eac8b255a9e1 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6769
diff changeset
   597
    ^ '$Header$'
6014
0da48fc12d6a class: GradientBackground
Claus Gittinger <cg@exept.de>
parents: 6013
diff changeset
   598
!
0da48fc12d6a class: GradientBackground
Claus Gittinger <cg@exept.de>
parents: 6013
diff changeset
   599
5461
2451688b8d25 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   600
version_CVS
6953
eac8b255a9e1 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6769
diff changeset
   601
    ^ '$Header$'
5461
2451688b8d25 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   602
! !
6013
aee5be18d9a1 class: GradientBackground
Claus Gittinger <cg@exept.de>
parents: 5739
diff changeset
   603