SimpleBorder.st
author matilk
Wed, 13 Sep 2017 09:40:34 +0200
changeset 8174 2704c965b97b
parent 7940 8a46a8c0dd58
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:
5375
0fd570afede6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     1
"
7940
8a46a8c0dd58 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 6715
diff changeset
     2
 COPYRIGHT (c) 1997 by Claus Gittinger
5375
0fd570afede6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     3
 COPYRIGHT (c) 2009 by eXept Software AG
7940
8a46a8c0dd58 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 6715
diff changeset
     4
              All Rights Reserved
5375
0fd570afede6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     5
0fd570afede6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     6
 This software is furnished under a license and may be used
0fd570afede6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     7
 only in accordance with the terms of that license and with the
0fd570afede6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     8
 inclusion of the above copyright notice.   This software may not
0fd570afede6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     9
 be provided or otherwise made available to, or used by, any
0fd570afede6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    10
 other person.  No title to or ownership of the software is
0fd570afede6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    11
 hereby transferred.
0fd570afede6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    12
"
0fd570afede6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    13
"{ Package: 'stx:libview' }"
0fd570afede6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    14
6715
c02e6d42e2cb class: SimpleBorder
Claus Gittinger <cg@exept.de>
parents: 5437
diff changeset
    15
"{ NameSpace: Smalltalk }"
c02e6d42e2cb class: SimpleBorder
Claus Gittinger <cg@exept.de>
parents: 5437
diff changeset
    16
5375
0fd570afede6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    17
AbstractBorder subclass:#SimpleBorder
5410
03d42dd62a01 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5393
diff changeset
    18
	instanceVariableNames:'color'
5375
0fd570afede6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    19
	classVariableNames:''
0fd570afede6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    20
	poolDictionaries:''
5393
429ab467ebbd category
Claus Gittinger <cg@exept.de>
parents: 5375
diff changeset
    21
	category:'Graphics-Support'
5375
0fd570afede6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    22
!
0fd570afede6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    23
0fd570afede6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    24
!SimpleBorder class methodsFor:'documentation'!
0fd570afede6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    25
0fd570afede6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    26
copyright
0fd570afede6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    27
"
7940
8a46a8c0dd58 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 6715
diff changeset
    28
 COPYRIGHT (c) 1997 by Claus Gittinger
5375
0fd570afede6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    29
 COPYRIGHT (c) 2009 by eXept Software AG
7940
8a46a8c0dd58 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 6715
diff changeset
    30
              All Rights Reserved
5375
0fd570afede6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    31
0fd570afede6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    32
 This software is furnished under a license and may be used
0fd570afede6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    33
 only in accordance with the terms of that license and with the
0fd570afede6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    34
 inclusion of the above copyright notice.   This software may not
0fd570afede6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    35
 be provided or otherwise made available to, or used by, any
0fd570afede6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    36
 other person.  No title to or ownership of the software is
0fd570afede6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    37
 hereby transferred.
0fd570afede6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    38
"
0fd570afede6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    39
!
0fd570afede6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    40
0fd570afede6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    41
documentation
0fd570afede6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    42
"
5410
03d42dd62a01 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5393
diff changeset
    43
    a simple border, where all four sides are drawn in the same solid color
5375
0fd570afede6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    44
0fd570afede6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    45
    [author:]
0fd570afede6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    46
        Claus Gittinger
0fd570afede6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    47
"
6715
c02e6d42e2cb class: SimpleBorder
Claus Gittinger <cg@exept.de>
parents: 5437
diff changeset
    48
!
c02e6d42e2cb class: SimpleBorder
Claus Gittinger <cg@exept.de>
parents: 5437
diff changeset
    49
c02e6d42e2cb class: SimpleBorder
Claus Gittinger <cg@exept.de>
parents: 5437
diff changeset
    50
examples
c02e6d42e2cb class: SimpleBorder
Claus Gittinger <cg@exept.de>
parents: 5437
diff changeset
    51
"
c02e6d42e2cb class: SimpleBorder
Claus Gittinger <cg@exept.de>
parents: 5437
diff changeset
    52
                                                    [exBegin]
c02e6d42e2cb class: SimpleBorder
Claus Gittinger <cg@exept.de>
parents: 5437
diff changeset
    53
    |v1 v2 b|
c02e6d42e2cb class: SimpleBorder
Claus Gittinger <cg@exept.de>
parents: 5437
diff changeset
    54
c02e6d42e2cb class: SimpleBorder
Claus Gittinger <cg@exept.de>
parents: 5437
diff changeset
    55
    v1 := View new extent:100@100.
c02e6d42e2cb class: SimpleBorder
Claus Gittinger <cg@exept.de>
parents: 5437
diff changeset
    56
    v2 := View origin:10@10 corner:90@20 in:v2.
c02e6d42e2cb class: SimpleBorder
Claus Gittinger <cg@exept.de>
parents: 5437
diff changeset
    57
    v2 border:(SimpleBorder new color:Color red).
c02e6d42e2cb class: SimpleBorder
Claus Gittinger <cg@exept.de>
parents: 5437
diff changeset
    58
    v1 openAndWait.
c02e6d42e2cb class: SimpleBorder
Claus Gittinger <cg@exept.de>
parents: 5437
diff changeset
    59
                                                    [exEnd]
c02e6d42e2cb class: SimpleBorder
Claus Gittinger <cg@exept.de>
parents: 5437
diff changeset
    60
"
5375
0fd570afede6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    61
! !
0fd570afede6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    62
0fd570afede6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    63
!SimpleBorder methodsFor:'accessing'!
0fd570afede6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    64
5410
03d42dd62a01 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5393
diff changeset
    65
color
5432
983983b0c312 comment/format in: #color:
Claus Gittinger <cg@exept.de>
parents: 5417
diff changeset
    66
    "the color of the border"
983983b0c312 comment/format in: #color:
Claus Gittinger <cg@exept.de>
parents: 5417
diff changeset
    67
5375
0fd570afede6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    68
    ^ color
0fd570afede6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    69
!
0fd570afede6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    70
5410
03d42dd62a01 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5393
diff changeset
    71
color:aColor
5432
983983b0c312 comment/format in: #color:
Claus Gittinger <cg@exept.de>
parents: 5417
diff changeset
    72
    "set the color of the border"
5375
0fd570afede6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    73
5417
b4a2fe418cce *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5410
diff changeset
    74
    width ~~ 0 ifTrue:[
b4a2fe418cce *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5410
diff changeset
    75
        self assert:aColor notNil.
b4a2fe418cce *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5410
diff changeset
    76
    ].
5410
03d42dd62a01 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5393
diff changeset
    77
    color := aColor
5375
0fd570afede6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    78
! !
0fd570afede6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    79
5410
03d42dd62a01 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5393
diff changeset
    80
!SimpleBorder methodsFor:'displaying'!
03d42dd62a01 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5393
diff changeset
    81
03d42dd62a01 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5393
diff changeset
    82
displayOn:aGC forDisplayBox:aRectangle
5437
75f2638be06f changed: #displayOn:forDisplayBox:
Claus Gittinger <cg@exept.de>
parents: 5432
diff changeset
    83
    |oldPaint boxLeft boxTop boxWidth boxHeight|
5375
0fd570afede6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    84
5417
b4a2fe418cce *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5410
diff changeset
    85
    color isNil ifTrue:[ ^ self].
5410
03d42dd62a01 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5393
diff changeset
    86
03d42dd62a01 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5393
diff changeset
    87
    oldPaint := aGC paint.
03d42dd62a01 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5393
diff changeset
    88
    aGC paint:color.
5437
75f2638be06f changed: #displayOn:forDisplayBox:
Claus Gittinger <cg@exept.de>
parents: 5432
diff changeset
    89
    width == 1 ifTrue:[
75f2638be06f changed: #displayOn:forDisplayBox:
Claus Gittinger <cg@exept.de>
parents: 5432
diff changeset
    90
        aGC displayRectangle:aRectangle.
75f2638be06f changed: #displayOn:forDisplayBox:
Claus Gittinger <cg@exept.de>
parents: 5432
diff changeset
    91
    ] ifFalse:[
75f2638be06f changed: #displayOn:forDisplayBox:
Claus Gittinger <cg@exept.de>
parents: 5432
diff changeset
    92
        boxLeft := aRectangle left.
75f2638be06f changed: #displayOn:forDisplayBox:
Claus Gittinger <cg@exept.de>
parents: 5432
diff changeset
    93
        boxTop := aRectangle top.
75f2638be06f changed: #displayOn:forDisplayBox:
Claus Gittinger <cg@exept.de>
parents: 5432
diff changeset
    94
        boxWidth := aRectangle width.
75f2638be06f changed: #displayOn:forDisplayBox:
Claus Gittinger <cg@exept.de>
parents: 5432
diff changeset
    95
        boxHeight := aRectangle height.
75f2638be06f changed: #displayOn:forDisplayBox:
Claus Gittinger <cg@exept.de>
parents: 5432
diff changeset
    96
        aGC fillRectangleX:boxLeft y:boxTop width:boxWidth height:width.
75f2638be06f changed: #displayOn:forDisplayBox:
Claus Gittinger <cg@exept.de>
parents: 5432
diff changeset
    97
        aGC fillRectangleX:boxLeft y:boxTop+boxHeight-width width:boxWidth height:width.
75f2638be06f changed: #displayOn:forDisplayBox:
Claus Gittinger <cg@exept.de>
parents: 5432
diff changeset
    98
        aGC fillRectangleX:boxLeft y:boxTop+width width:width height:boxHeight-width-width.
75f2638be06f changed: #displayOn:forDisplayBox:
Claus Gittinger <cg@exept.de>
parents: 5432
diff changeset
    99
        aGC fillRectangleX:boxLeft+boxWidth-width y:boxTop+width width:width height:boxHeight-width-width.
75f2638be06f changed: #displayOn:forDisplayBox:
Claus Gittinger <cg@exept.de>
parents: 5432
diff changeset
   100
    ].
5410
03d42dd62a01 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5393
diff changeset
   101
    aGC paint:oldPaint.
5437
75f2638be06f changed: #displayOn:forDisplayBox:
Claus Gittinger <cg@exept.de>
parents: 5432
diff changeset
   102
75f2638be06f changed: #displayOn:forDisplayBox:
Claus Gittinger <cg@exept.de>
parents: 5432
diff changeset
   103
    "
75f2638be06f changed: #displayOn:forDisplayBox:
Claus Gittinger <cg@exept.de>
parents: 5432
diff changeset
   104
     View new
75f2638be06f changed: #displayOn:forDisplayBox:
Claus Gittinger <cg@exept.de>
parents: 5432
diff changeset
   105
        border:(SimpleBorder width:2 color:Color red);
75f2638be06f changed: #displayOn:forDisplayBox:
Claus Gittinger <cg@exept.de>
parents: 5432
diff changeset
   106
        open.
75f2638be06f changed: #displayOn:forDisplayBox:
Claus Gittinger <cg@exept.de>
parents: 5432
diff changeset
   107
    "
75f2638be06f changed: #displayOn:forDisplayBox:
Claus Gittinger <cg@exept.de>
parents: 5432
diff changeset
   108
    "
75f2638be06f changed: #displayOn:forDisplayBox:
Claus Gittinger <cg@exept.de>
parents: 5432
diff changeset
   109
     View new
75f2638be06f changed: #displayOn:forDisplayBox:
Claus Gittinger <cg@exept.de>
parents: 5432
diff changeset
   110
        border:(SimpleBorder width:4 color:Color red);
75f2638be06f changed: #displayOn:forDisplayBox:
Claus Gittinger <cg@exept.de>
parents: 5432
diff changeset
   111
        open.
75f2638be06f changed: #displayOn:forDisplayBox:
Claus Gittinger <cg@exept.de>
parents: 5432
diff changeset
   112
    "
75f2638be06f changed: #displayOn:forDisplayBox:
Claus Gittinger <cg@exept.de>
parents: 5432
diff changeset
   113
75f2638be06f changed: #displayOn:forDisplayBox:
Claus Gittinger <cg@exept.de>
parents: 5432
diff changeset
   114
    "
75f2638be06f changed: #displayOn:forDisplayBox:
Claus Gittinger <cg@exept.de>
parents: 5432
diff changeset
   115
     StandardSystemView new
75f2638be06f changed: #displayOn:forDisplayBox:
Claus Gittinger <cg@exept.de>
parents: 5432
diff changeset
   116
        extent:200@200;
75f2638be06f changed: #displayOn:forDisplayBox:
Claus Gittinger <cg@exept.de>
parents: 5432
diff changeset
   117
        add:(View new
75f2638be06f changed: #displayOn:forDisplayBox:
Claus Gittinger <cg@exept.de>
parents: 5432
diff changeset
   118
                origin:(10@10) corner:0.9@0.9;
75f2638be06f changed: #displayOn:forDisplayBox:
Claus Gittinger <cg@exept.de>
parents: 5432
diff changeset
   119
                border:(SimpleBorder width:4 color:Color red));
75f2638be06f changed: #displayOn:forDisplayBox:
Claus Gittinger <cg@exept.de>
parents: 5432
diff changeset
   120
        open.
75f2638be06f changed: #displayOn:forDisplayBox:
Claus Gittinger <cg@exept.de>
parents: 5432
diff changeset
   121
    "
5375
0fd570afede6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   122
! !
0fd570afede6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   123
0fd570afede6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   124
!SimpleBorder class methodsFor:'documentation'!
0fd570afede6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   125
0fd570afede6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   126
version_CVS
7940
8a46a8c0dd58 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 6715
diff changeset
   127
    ^ '$Header$'
5375
0fd570afede6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   128
! !
6715
c02e6d42e2cb class: SimpleBorder
Claus Gittinger <cg@exept.de>
parents: 5437
diff changeset
   129