WinVistaButtonRenderer.st
author matilk
Wed, 13 Sep 2017 09:40:34 +0200
changeset 8174 2704c965b97b
parent 5470 3653f524bd84
permissions -rw-r--r--
#BUGFIX by Maren class: DeviceGraphicsContext changed: #displayDeviceOpaqueForm:x:y: nil check
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5470
3653f524bd84 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     1
"
3653f524bd84 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     2
 COPYRIGHT (c) 2009 by eXept Software AG
3653f524bd84 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     3
              All Rights Reserved
3653f524bd84 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     4
3653f524bd84 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     5
 This software is furnished under a license and may be used
3653f524bd84 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     6
 only in accordance with the terms of that license and with the
3653f524bd84 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
3653f524bd84 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     8
 be provided or otherwise made available to, or used by, any
3653f524bd84 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     9
 other person.  No title to or ownership of the software is
3653f524bd84 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    10
 hereby transferred.
3653f524bd84 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    11
"
3653f524bd84 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    12
"{ Package: 'stx:libview' }"
3653f524bd84 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    13
3653f524bd84 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    14
ButtonRenderer subclass:#WinVistaButtonRenderer
3653f524bd84 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    15
	instanceVariableNames:''
3653f524bd84 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    16
	classVariableNames:''
3653f524bd84 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    17
	poolDictionaries:''
3653f524bd84 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    18
	category:'Graphics-Rendering'
3653f524bd84 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    19
!
3653f524bd84 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    20
3653f524bd84 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    21
!WinVistaButtonRenderer class methodsFor:'documentation'!
3653f524bd84 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    22
3653f524bd84 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    23
copyright
3653f524bd84 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    24
"
3653f524bd84 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    25
 COPYRIGHT (c) 2009 by eXept Software AG
3653f524bd84 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    26
              All Rights Reserved
3653f524bd84 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    27
3653f524bd84 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    28
 This software is furnished under a license and may be used
3653f524bd84 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    29
 only in accordance with the terms of that license and with the
3653f524bd84 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    30
 inclusion of the above copyright notice.   This software may not
3653f524bd84 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    31
 be provided or otherwise made available to, or used by, any
3653f524bd84 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    32
 other person.  No title to or ownership of the software is
3653f524bd84 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    33
 hereby transferred.
3653f524bd84 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    34
"
3653f524bd84 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    35
!
3653f524bd84 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    36
3653f524bd84 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    37
documentation
3653f524bd84 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    38
"
3653f524bd84 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    39
    experimental work in progress - unfinished; do not use
3653f524bd84 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    40
3653f524bd84 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    41
    |v b r|
3653f524bd84 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    42
3653f524bd84 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    43
    v := View new extent:100@100; openAndWait.
3653f524bd84 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    44
    b := Button new.
3653f524bd84 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    45
    b extent:100@20.
3653f524bd84 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    46
3653f524bd84 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    47
    r := WinVistaButtonRenderer new.
3653f524bd84 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    48
    r render:b on:v forDisplayBox:((0@0 corner:b extent)).
3653f524bd84 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    49
"
3653f524bd84 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    50
! !
3653f524bd84 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    51
3653f524bd84 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    52
!WinVistaButtonRenderer methodsFor:'rendering'!
3653f524bd84 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    53
3653f524bd84 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    54
render:aWidget on:aGC forDisplayBox:aRectangle
3653f524bd84 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    55
    |sav border bdClr bgClr step1 step2 h1 h2 y|
3653f524bd84 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    56
3653f524bd84 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    57
    sav := aGC paint.
3653f524bd84 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    58
3653f524bd84 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    59
    aWidget controller active ifTrue:[
3653f524bd84 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    60
        bdClr := (Color rgbValue:16r2C628B)
3653f524bd84 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    61
    ] ifFalse:[
3653f524bd84 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    62
        aWidget controller entered ifTrue:[
3653f524bd84 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    63
            bdClr := (Color rgbValue:16r3C7FB1)
3653f524bd84 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    64
        ] ifFalse:[
3653f524bd84 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    65
            bdClr := (Color rgbValue:16r707070).
3653f524bd84 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    66
        ].
3653f524bd84 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    67
    ].
3653f524bd84 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    68
3653f524bd84 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    69
    border := RoundButtonBorder new.
3653f524bd84 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    70
    border width:1 color:bdClr.
3653f524bd84 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    71
3653f524bd84 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    72
    border displayOn:aGC forDisplayBox:aRectangle.
3653f524bd84 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    73
3653f524bd84 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    74
    "/ blend 1/10 to 1/5 with color white...
3653f524bd84 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    75
    h1 := ((aWidget height - 4) // 2).
3653f524bd84 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    76
    step1 := ((1/5) - (1/10)) / h1.
3653f524bd84 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    77
    y := 2.
3653f524bd84 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    78
    (1/10) to:(1/5) by:step1 do:[:m |
3653f524bd84 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    79
        bgClr := bdClr mixed:m with:Color white.
3653f524bd84 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    80
        aGC paint:bgClr.
3653f524bd84 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    81
        aGC displayLineFromX:2 y:y toX:aWidget width-2 y:y.
3653f524bd84 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    82
        y := y + 1.
3653f524bd84 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    83
    ].
3653f524bd84 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    84
3653f524bd84 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    85
    "/ blend 1/3 to 1/2 with color white...
3653f524bd84 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    86
    h2 := aWidget height - 4 - h1.
3653f524bd84 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    87
    step2 := ((1/2) - (1/3)) / h2.
3653f524bd84 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    88
    (1/3) to:(1/2) by:step1 do:[:m |
3653f524bd84 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    89
        bgClr := bdClr mixed:m with:Color white.
3653f524bd84 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    90
        aGC paint:bgClr.
3653f524bd84 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    91
        aGC displayLineFromX:2 y:y toX:aWidget width-2 y:y.
3653f524bd84 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    92
        y := y + 1.
3653f524bd84 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    93
    ].
3653f524bd84 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    94
3653f524bd84 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    95
    aGC paint:sav.
3653f524bd84 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    96
! !
3653f524bd84 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    97
3653f524bd84 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    98
!WinVistaButtonRenderer class methodsFor:'documentation'!
3653f524bd84 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    99
3653f524bd84 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   100
version_CVS
3653f524bd84 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   101
    ^ '$Header: /cvs/stx/stx/libview/WinVistaButtonRenderer.st,v 1.1 2009-11-05 14:01:24 cg Exp $'
3653f524bd84 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   102
! !