RoundButtonBorder.st
author matilk
Wed, 13 Sep 2017 09:40:34 +0200
changeset 8174 2704c965b97b
parent 7944 12278ec87e7e
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:
5464
a76eb3ed2aff added: #copyright
Claus Gittinger <cg@exept.de>
parents: 5439
diff changeset
     1
"
7944
12278ec87e7e #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 5468
diff changeset
     2
 COPYRIGHT (c) 2009 by Claus Gittinger / eXept Software AG
5464
a76eb3ed2aff added: #copyright
Claus Gittinger <cg@exept.de>
parents: 5439
diff changeset
     3
              All Rights Reserved
a76eb3ed2aff added: #copyright
Claus Gittinger <cg@exept.de>
parents: 5439
diff changeset
     4
a76eb3ed2aff added: #copyright
Claus Gittinger <cg@exept.de>
parents: 5439
diff changeset
     5
 This software is furnished under a license and may be used
a76eb3ed2aff added: #copyright
Claus Gittinger <cg@exept.de>
parents: 5439
diff changeset
     6
 only in accordance with the terms of that license and with the
a76eb3ed2aff added: #copyright
Claus Gittinger <cg@exept.de>
parents: 5439
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
a76eb3ed2aff added: #copyright
Claus Gittinger <cg@exept.de>
parents: 5439
diff changeset
     8
 be provided or otherwise made available to, or used by, any
a76eb3ed2aff added: #copyright
Claus Gittinger <cg@exept.de>
parents: 5439
diff changeset
     9
 other person.  No title to or ownership of the software is
a76eb3ed2aff added: #copyright
Claus Gittinger <cg@exept.de>
parents: 5439
diff changeset
    10
 hereby transferred.
a76eb3ed2aff added: #copyright
Claus Gittinger <cg@exept.de>
parents: 5439
diff changeset
    11
"
5433
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    12
"{ Package: 'stx:libview' }"
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    13
7944
12278ec87e7e #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 5468
diff changeset
    14
"{ NameSpace: Smalltalk }"
12278ec87e7e #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 5468
diff changeset
    15
5433
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    16
AbstractBorder subclass:#RoundButtonBorder
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    17
	instanceVariableNames:'color'
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    18
	classVariableNames:''
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    19
	poolDictionaries:''
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    20
	category:'Graphics-Support'
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    21
!
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    22
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    23
!RoundButtonBorder class methodsFor:'documentation'!
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    24
5464
a76eb3ed2aff added: #copyright
Claus Gittinger <cg@exept.de>
parents: 5439
diff changeset
    25
copyright
a76eb3ed2aff added: #copyright
Claus Gittinger <cg@exept.de>
parents: 5439
diff changeset
    26
"
7944
12278ec87e7e #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 5468
diff changeset
    27
 COPYRIGHT (c) 2009 by Claus Gittinger / eXept Software AG
5464
a76eb3ed2aff added: #copyright
Claus Gittinger <cg@exept.de>
parents: 5439
diff changeset
    28
              All Rights Reserved
a76eb3ed2aff added: #copyright
Claus Gittinger <cg@exept.de>
parents: 5439
diff changeset
    29
a76eb3ed2aff added: #copyright
Claus Gittinger <cg@exept.de>
parents: 5439
diff changeset
    30
 This software is furnished under a license and may be used
a76eb3ed2aff added: #copyright
Claus Gittinger <cg@exept.de>
parents: 5439
diff changeset
    31
 only in accordance with the terms of that license and with the
a76eb3ed2aff added: #copyright
Claus Gittinger <cg@exept.de>
parents: 5439
diff changeset
    32
 inclusion of the above copyright notice.   This software may not
a76eb3ed2aff added: #copyright
Claus Gittinger <cg@exept.de>
parents: 5439
diff changeset
    33
 be provided or otherwise made available to, or used by, any
a76eb3ed2aff added: #copyright
Claus Gittinger <cg@exept.de>
parents: 5439
diff changeset
    34
 other person.  No title to or ownership of the software is
a76eb3ed2aff added: #copyright
Claus Gittinger <cg@exept.de>
parents: 5439
diff changeset
    35
 hereby transferred.
a76eb3ed2aff added: #copyright
Claus Gittinger <cg@exept.de>
parents: 5439
diff changeset
    36
"
a76eb3ed2aff added: #copyright
Claus Gittinger <cg@exept.de>
parents: 5439
diff changeset
    37
!
a76eb3ed2aff added: #copyright
Claus Gittinger <cg@exept.de>
parents: 5439
diff changeset
    38
5433
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    39
documentation
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    40
"
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    41
    experimental
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    42
5468
1ec468c66fa4 changed: #documentation
Claus Gittinger <cg@exept.de>
parents: 5464
diff changeset
    43
    |v b|
1ec468c66fa4 changed: #documentation
Claus Gittinger <cg@exept.de>
parents: 5464
diff changeset
    44
1ec468c66fa4 changed: #documentation
Claus Gittinger <cg@exept.de>
parents: 5464
diff changeset
    45
    v := View new extent:100@100; openAndWait.
1ec468c66fa4 changed: #documentation
Claus Gittinger <cg@exept.de>
parents: 5464
diff changeset
    46
    b := RoundButtonBorder new.
1ec468c66fa4 changed: #documentation
Claus Gittinger <cg@exept.de>
parents: 5464
diff changeset
    47
    b width:1 color:(Color rgbValue:16r707070).
1ec468c66fa4 changed: #documentation
Claus Gittinger <cg@exept.de>
parents: 5464
diff changeset
    48
    b displayOn:v forDisplayBox:((0@0 corner:v extent) insetBy:10).
1ec468c66fa4 changed: #documentation
Claus Gittinger <cg@exept.de>
parents: 5464
diff changeset
    49
    Delay waitForSeconds:3.
1ec468c66fa4 changed: #documentation
Claus Gittinger <cg@exept.de>
parents: 5464
diff changeset
    50
1ec468c66fa4 changed: #documentation
Claus Gittinger <cg@exept.de>
parents: 5464
diff changeset
    51
    b width:1 color:(Color rgbValue:16r2C628B).
1ec468c66fa4 changed: #documentation
Claus Gittinger <cg@exept.de>
parents: 5464
diff changeset
    52
    b displayOn:v forDisplayBox:((0@0 corner:v extent) insetBy:10).
1ec468c66fa4 changed: #documentation
Claus Gittinger <cg@exept.de>
parents: 5464
diff changeset
    53
    Delay waitForSeconds:3.
1ec468c66fa4 changed: #documentation
Claus Gittinger <cg@exept.de>
parents: 5464
diff changeset
    54
1ec468c66fa4 changed: #documentation
Claus Gittinger <cg@exept.de>
parents: 5464
diff changeset
    55
    b width:1 color:(Color rgbValue:16r3C7FB1).
1ec468c66fa4 changed: #documentation
Claus Gittinger <cg@exept.de>
parents: 5464
diff changeset
    56
    b displayOn:v forDisplayBox:((0@0 corner:v extent) insetBy:10).
1ec468c66fa4 changed: #documentation
Claus Gittinger <cg@exept.de>
parents: 5464
diff changeset
    57
5433
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    58
    [author:]
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    59
        Claus Gittinger
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    60
"
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    61
! !
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    62
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    63
!RoundButtonBorder methodsFor:'accessing'!
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    64
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    65
color
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    66
    "the color of the border"
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    67
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    68
    ^ color
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    69
!
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    70
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    71
color:aColor
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    72
    "set the color of the border"
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    73
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    74
    width ~~ 0 ifTrue:[
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    75
        self assert:aColor notNil.
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    76
    ].
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    77
    color := aColor
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    78
!
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    79
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    80
width
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    81
    ^ 2
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    82
! !
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    83
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    84
!RoundButtonBorder methodsFor:'displaying'!
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    85
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    86
displayOn:aGC forDisplayBox:aRectangle
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    87
    |oldPaint left top w h|
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    88
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    89
    color isNil ifTrue:[ ^ self].
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    90
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    91
    oldPaint := aGC paint.
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    92
    aGC paint:color.
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    93
    left := aRectangle left.
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    94
    top := aRectangle top.
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    95
    w := aRectangle width.
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    96
    h := aRectangle height.
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    97
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    98
    aGC displayRectangleX:left y:top width:w height:h.
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    99
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   100
    aGC paint:color slightlyLightened.
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   101
    aGC displayPointX:left+2 y:top.
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   102
    aGC displayPointX:left+1 y:top+1.
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   103
    aGC displayPointX:left y:top+2.
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   104
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   105
    aGC displayPointX:left+2 y:top+h-1.
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   106
    aGC displayPointX:left+1 y:top+h-2.
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   107
    aGC displayPointX:left y:top+h-3.
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   108
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   109
    aGC displayPointX:left+w-3 y:top.
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   110
    aGC displayPointX:left+w-2 y:top+1.
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   111
    aGC displayPointX:left+w-1 y:top+2.
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   112
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   113
    aGC displayPointX:left+w-3 y:top+h-1.
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   114
    aGC displayPointX:left+w-2 y:top+h-2.
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   115
    aGC displayPointX:left+w-1 y:top+h-3.
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   116
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   117
    aGC paint:color lightened.
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   118
    aGC displayPointX:left+1 y:top.
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   119
    aGC displayPointX:left y:top+1.
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   120
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   121
    aGC displayPointX:left+1 y:top+h-1.
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   122
    aGC displayPointX:left y:top+h-2.
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   123
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   124
    aGC displayPointX:left+w-2 y:top.
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   125
    aGC displayPointX:left+w-1 y:top+1.
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   126
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   127
    aGC displayPointX:left+w-2 y:top+h-1.
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   128
    aGC displayPointX:left+w-1 y:top+h-2.
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   129
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   130
    aGC paint:(aGC container ? aGC) viewBackground.
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   131
    aGC displayPointX:left y:top.
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   132
    aGC displayPointX:left+w-1 y:top.
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   133
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   134
    aGC displayPointX:left y:top+h-1.
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   135
    aGC displayPointX:left+w-1 y:top+h-1.
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   136
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   137
    aGC paint:oldPaint.
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   138
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   139
    "
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   140
     |v b|
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   141
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   142
     v := View new openAndWait.
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   143
     b := RoundButtonBorder width:2 color:Color grey.
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   144
     b displayOn:v forDisplayBox:(0@0 corner:v extent).
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   145
    "
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   146
! !
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   147
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   148
!RoundButtonBorder class methodsFor:'documentation'!
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   149
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   150
version_CVS
7944
12278ec87e7e #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 5468
diff changeset
   151
    ^ '$Header$'
5433
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   152
! !
7944
12278ec87e7e #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 5468
diff changeset
   153