RoundButtonBorder.st
author Claus Gittinger <cg@exept.de>
Wed, 04 Nov 2009 15:32:11 +0100
changeset 5464 a76eb3ed2aff
parent 5439 ead311cdf33a
child 5468 1ec468c66fa4
permissions -rw-r--r--
added: #copyright
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5464
a76eb3ed2aff added: #copyright
Claus Gittinger <cg@exept.de>
parents: 5439
diff changeset
     1
"
a76eb3ed2aff added: #copyright
Claus Gittinger <cg@exept.de>
parents: 5439
diff changeset
     2
 COPYRIGHT (c) 2009 by eXept Software AG
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
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    14
AbstractBorder subclass:#RoundButtonBorder
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    15
	instanceVariableNames:'color'
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    16
	classVariableNames:''
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    17
	poolDictionaries:''
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    18
	category:'Graphics-Support'
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    19
!
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    20
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    21
!RoundButtonBorder class methodsFor:'documentation'!
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    22
5464
a76eb3ed2aff added: #copyright
Claus Gittinger <cg@exept.de>
parents: 5439
diff changeset
    23
copyright
a76eb3ed2aff added: #copyright
Claus Gittinger <cg@exept.de>
parents: 5439
diff changeset
    24
"
a76eb3ed2aff added: #copyright
Claus Gittinger <cg@exept.de>
parents: 5439
diff changeset
    25
 COPYRIGHT (c) 2009 by eXept Software AG
a76eb3ed2aff added: #copyright
Claus Gittinger <cg@exept.de>
parents: 5439
diff changeset
    26
              All Rights Reserved
a76eb3ed2aff added: #copyright
Claus Gittinger <cg@exept.de>
parents: 5439
diff changeset
    27
a76eb3ed2aff added: #copyright
Claus Gittinger <cg@exept.de>
parents: 5439
diff changeset
    28
 This software is furnished under a license and may be used
a76eb3ed2aff added: #copyright
Claus Gittinger <cg@exept.de>
parents: 5439
diff changeset
    29
 only in accordance with the terms of that license and with the
a76eb3ed2aff added: #copyright
Claus Gittinger <cg@exept.de>
parents: 5439
diff changeset
    30
 inclusion of the above copyright notice.   This software may not
a76eb3ed2aff added: #copyright
Claus Gittinger <cg@exept.de>
parents: 5439
diff changeset
    31
 be provided or otherwise made available to, or used by, any
a76eb3ed2aff added: #copyright
Claus Gittinger <cg@exept.de>
parents: 5439
diff changeset
    32
 other person.  No title to or ownership of the software is
a76eb3ed2aff added: #copyright
Claus Gittinger <cg@exept.de>
parents: 5439
diff changeset
    33
 hereby transferred.
a76eb3ed2aff added: #copyright
Claus Gittinger <cg@exept.de>
parents: 5439
diff changeset
    34
"
a76eb3ed2aff added: #copyright
Claus Gittinger <cg@exept.de>
parents: 5439
diff changeset
    35
!
a76eb3ed2aff added: #copyright
Claus Gittinger <cg@exept.de>
parents: 5439
diff changeset
    36
5433
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    37
documentation
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    38
"
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    39
    experimental
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    40
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    41
    [author:]
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    42
        Claus Gittinger
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    43
"
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    44
! !
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    45
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    46
!RoundButtonBorder methodsFor:'accessing'!
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    47
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    48
color
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    49
    "the color of the border"
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    50
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    51
    ^ color
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    52
!
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    53
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    54
color:aColor
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    55
    "set the color of the border"
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    56
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    57
    width ~~ 0 ifTrue:[
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    58
        self assert:aColor notNil.
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    59
    ].
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    60
    color := aColor
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
width
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    64
    ^ 2
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    65
! !
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    66
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    67
!RoundButtonBorder methodsFor:'displaying'!
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    68
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    69
displayOn:aGC forDisplayBox:aRectangle
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    70
    |oldPaint left top w h|
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    71
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    72
    color isNil ifTrue:[ ^ self].
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    73
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    74
    oldPaint := aGC paint.
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    75
    aGC paint:color.
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    76
    left := aRectangle left.
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    77
    top := aRectangle top.
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    78
    w := aRectangle width.
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    79
    h := aRectangle height.
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    80
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    81
    aGC displayRectangleX:left y:top width:w height:h.
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    82
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    83
    aGC paint:color slightlyLightened.
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    84
    aGC displayPointX:left+2 y:top.
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    85
    aGC displayPointX:left+1 y:top+1.
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    86
    aGC displayPointX:left y:top+2.
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    87
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    88
    aGC displayPointX:left+2 y:top+h-1.
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    89
    aGC displayPointX:left+1 y:top+h-2.
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    90
    aGC displayPointX:left y:top+h-3.
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    91
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    92
    aGC displayPointX:left+w-3 y:top.
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    93
    aGC displayPointX:left+w-2 y:top+1.
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    94
    aGC displayPointX:left+w-1 y:top+2.
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    95
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    96
    aGC displayPointX:left+w-3 y:top+h-1.
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    97
    aGC displayPointX:left+w-2 y:top+h-2.
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    98
    aGC displayPointX:left+w-1 y:top+h-3.
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 lightened.
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   101
    aGC displayPointX:left+1 y:top.
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   102
    aGC displayPointX:left y:top+1.
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   103
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   104
    aGC displayPointX:left+1 y:top+h-1.
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   105
    aGC displayPointX:left y:top+h-2.
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   106
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   107
    aGC displayPointX:left+w-2 y:top.
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   108
    aGC displayPointX:left+w-1 y:top+1.
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   109
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   110
    aGC displayPointX:left+w-2 y:top+h-1.
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   111
    aGC displayPointX:left+w-1 y:top+h-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 paint:(aGC container ? aGC) viewBackground.
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   114
    aGC displayPointX:left y:top.
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   115
    aGC displayPointX:left+w-1 y:top.
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 displayPointX:left y:top+h-1.
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   118
    aGC displayPointX:left+w-1 y:top+h-1.
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   119
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   120
    aGC paint:oldPaint.
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   121
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   122
    "
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   123
     |v b|
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   124
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   125
     v := View new openAndWait.
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   126
     b := RoundButtonBorder width:2 color:Color grey.
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   127
     b displayOn:v forDisplayBox:(0@0 corner:v extent).
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   128
    "
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   129
! !
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   130
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   131
!RoundButtonBorder class methodsFor:'documentation'!
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   132
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   133
version_CVS
5464
a76eb3ed2aff added: #copyright
Claus Gittinger <cg@exept.de>
parents: 5439
diff changeset
   134
    ^ '$Header: /cvs/stx/stx/libview/RoundButtonBorder.st,v 1.3 2009-11-04 14:32:11 cg Exp $'
5433
1cb1b16f7bd2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   135
! !