SimpleBorder.st
author Claus Gittinger <cg@exept.de>
Thu, 27 Jan 2011 18:30:41 +0100
changeset 5691 b2381760f050
parent 5437 75f2638be06f
child 6715 c02e6d42e2cb
permissions -rw-r--r--
changed: #initialize use class based queries
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5375
0fd570afede6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     1
"
0fd570afede6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     2
 COPYRIGHT (c) 1997 by eXept Software AG
0fd570afede6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     3
 COPYRIGHT (c) 2009 by eXept Software AG
5410
03d42dd62a01 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5393
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
0fd570afede6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    15
AbstractBorder subclass:#SimpleBorder
5410
03d42dd62a01 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5393
diff changeset
    16
	instanceVariableNames:'color'
5375
0fd570afede6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    17
	classVariableNames:''
0fd570afede6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    18
	poolDictionaries:''
5393
429ab467ebbd category
Claus Gittinger <cg@exept.de>
parents: 5375
diff changeset
    19
	category:'Graphics-Support'
5375
0fd570afede6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    20
!
0fd570afede6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    21
0fd570afede6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    22
!SimpleBorder class methodsFor:'documentation'!
0fd570afede6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    23
0fd570afede6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    24
copyright
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 (c) 1997 by eXept Software AG
0fd570afede6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    27
 COPYRIGHT (c) 2009 by eXept Software AG
5410
03d42dd62a01 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5393
diff changeset
    28
	      All Rights Reserved
5375
0fd570afede6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    29
0fd570afede6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    30
 This software is furnished under a license and may be used
0fd570afede6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    31
 only in accordance with the terms of that license and with the
0fd570afede6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    32
 inclusion of the above copyright notice.   This software may not
0fd570afede6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    33
 be provided or otherwise made available to, or used by, any
0fd570afede6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    34
 other person.  No title to or ownership of the software is
0fd570afede6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    35
 hereby transferred.
0fd570afede6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    36
"
0fd570afede6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    37
!
0fd570afede6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    38
0fd570afede6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    39
documentation
0fd570afede6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    40
"
5410
03d42dd62a01 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5393
diff changeset
    41
    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
    42
0fd570afede6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    43
    [author:]
0fd570afede6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    44
        Claus Gittinger
0fd570afede6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    45
"
0fd570afede6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    46
! !
0fd570afede6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    47
0fd570afede6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    48
!SimpleBorder methodsFor:'accessing'!
0fd570afede6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    49
5410
03d42dd62a01 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5393
diff changeset
    50
color
5432
983983b0c312 comment/format in: #color:
Claus Gittinger <cg@exept.de>
parents: 5417
diff changeset
    51
    "the color of the border"
983983b0c312 comment/format in: #color:
Claus Gittinger <cg@exept.de>
parents: 5417
diff changeset
    52
5375
0fd570afede6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    53
    ^ color
0fd570afede6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    54
!
0fd570afede6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    55
5410
03d42dd62a01 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5393
diff changeset
    56
color:aColor
5432
983983b0c312 comment/format in: #color:
Claus Gittinger <cg@exept.de>
parents: 5417
diff changeset
    57
    "set the color of the border"
5375
0fd570afede6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    58
5417
b4a2fe418cce *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5410
diff changeset
    59
    width ~~ 0 ifTrue:[
b4a2fe418cce *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5410
diff changeset
    60
        self assert:aColor notNil.
b4a2fe418cce *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5410
diff changeset
    61
    ].
5410
03d42dd62a01 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5393
diff changeset
    62
    color := aColor
5375
0fd570afede6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    63
! !
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
!SimpleBorder methodsFor:'displaying'!
03d42dd62a01 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5393
diff changeset
    66
03d42dd62a01 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5393
diff changeset
    67
displayOn:aGC forDisplayBox:aRectangle
5437
75f2638be06f changed: #displayOn:forDisplayBox:
Claus Gittinger <cg@exept.de>
parents: 5432
diff changeset
    68
    |oldPaint boxLeft boxTop boxWidth boxHeight|
5375
0fd570afede6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    69
5417
b4a2fe418cce *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5410
diff changeset
    70
    color isNil ifTrue:[ ^ self].
5410
03d42dd62a01 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5393
diff changeset
    71
03d42dd62a01 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5393
diff changeset
    72
    oldPaint := aGC paint.
03d42dd62a01 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5393
diff changeset
    73
    aGC paint:color.
5437
75f2638be06f changed: #displayOn:forDisplayBox:
Claus Gittinger <cg@exept.de>
parents: 5432
diff changeset
    74
    width == 1 ifTrue:[
75f2638be06f changed: #displayOn:forDisplayBox:
Claus Gittinger <cg@exept.de>
parents: 5432
diff changeset
    75
        aGC displayRectangle:aRectangle.
75f2638be06f changed: #displayOn:forDisplayBox:
Claus Gittinger <cg@exept.de>
parents: 5432
diff changeset
    76
    ] ifFalse:[
75f2638be06f changed: #displayOn:forDisplayBox:
Claus Gittinger <cg@exept.de>
parents: 5432
diff changeset
    77
        boxLeft := aRectangle left.
75f2638be06f changed: #displayOn:forDisplayBox:
Claus Gittinger <cg@exept.de>
parents: 5432
diff changeset
    78
        boxTop := aRectangle top.
75f2638be06f changed: #displayOn:forDisplayBox:
Claus Gittinger <cg@exept.de>
parents: 5432
diff changeset
    79
        boxWidth := aRectangle width.
75f2638be06f changed: #displayOn:forDisplayBox:
Claus Gittinger <cg@exept.de>
parents: 5432
diff changeset
    80
        boxHeight := aRectangle height.
75f2638be06f changed: #displayOn:forDisplayBox:
Claus Gittinger <cg@exept.de>
parents: 5432
diff changeset
    81
        aGC fillRectangleX:boxLeft y:boxTop width:boxWidth height:width.
75f2638be06f changed: #displayOn:forDisplayBox:
Claus Gittinger <cg@exept.de>
parents: 5432
diff changeset
    82
        aGC fillRectangleX:boxLeft y:boxTop+boxHeight-width width:boxWidth height:width.
75f2638be06f changed: #displayOn:forDisplayBox:
Claus Gittinger <cg@exept.de>
parents: 5432
diff changeset
    83
        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
    84
        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
    85
    ].
5410
03d42dd62a01 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5393
diff changeset
    86
    aGC paint:oldPaint.
5437
75f2638be06f changed: #displayOn:forDisplayBox:
Claus Gittinger <cg@exept.de>
parents: 5432
diff changeset
    87
75f2638be06f changed: #displayOn:forDisplayBox:
Claus Gittinger <cg@exept.de>
parents: 5432
diff changeset
    88
    "
75f2638be06f changed: #displayOn:forDisplayBox:
Claus Gittinger <cg@exept.de>
parents: 5432
diff changeset
    89
     View new
75f2638be06f changed: #displayOn:forDisplayBox:
Claus Gittinger <cg@exept.de>
parents: 5432
diff changeset
    90
        border:(SimpleBorder width:2 color:Color red);
75f2638be06f changed: #displayOn:forDisplayBox:
Claus Gittinger <cg@exept.de>
parents: 5432
diff changeset
    91
        open.
75f2638be06f changed: #displayOn:forDisplayBox:
Claus Gittinger <cg@exept.de>
parents: 5432
diff changeset
    92
    "
75f2638be06f changed: #displayOn:forDisplayBox:
Claus Gittinger <cg@exept.de>
parents: 5432
diff changeset
    93
    "
75f2638be06f changed: #displayOn:forDisplayBox:
Claus Gittinger <cg@exept.de>
parents: 5432
diff changeset
    94
     View new
75f2638be06f changed: #displayOn:forDisplayBox:
Claus Gittinger <cg@exept.de>
parents: 5432
diff changeset
    95
        border:(SimpleBorder width:4 color:Color red);
75f2638be06f changed: #displayOn:forDisplayBox:
Claus Gittinger <cg@exept.de>
parents: 5432
diff changeset
    96
        open.
75f2638be06f changed: #displayOn:forDisplayBox:
Claus Gittinger <cg@exept.de>
parents: 5432
diff changeset
    97
    "
75f2638be06f changed: #displayOn:forDisplayBox:
Claus Gittinger <cg@exept.de>
parents: 5432
diff changeset
    98
75f2638be06f changed: #displayOn:forDisplayBox:
Claus Gittinger <cg@exept.de>
parents: 5432
diff changeset
    99
    "
75f2638be06f changed: #displayOn:forDisplayBox:
Claus Gittinger <cg@exept.de>
parents: 5432
diff changeset
   100
     StandardSystemView new
75f2638be06f changed: #displayOn:forDisplayBox:
Claus Gittinger <cg@exept.de>
parents: 5432
diff changeset
   101
        extent:200@200;
75f2638be06f changed: #displayOn:forDisplayBox:
Claus Gittinger <cg@exept.de>
parents: 5432
diff changeset
   102
        add:(View new
75f2638be06f changed: #displayOn:forDisplayBox:
Claus Gittinger <cg@exept.de>
parents: 5432
diff changeset
   103
                origin:(10@10) corner:0.9@0.9;
75f2638be06f changed: #displayOn:forDisplayBox:
Claus Gittinger <cg@exept.de>
parents: 5432
diff changeset
   104
                border:(SimpleBorder width:4 color:Color red));
75f2638be06f changed: #displayOn:forDisplayBox:
Claus Gittinger <cg@exept.de>
parents: 5432
diff changeset
   105
        open.
75f2638be06f changed: #displayOn:forDisplayBox:
Claus Gittinger <cg@exept.de>
parents: 5432
diff changeset
   106
    "
5375
0fd570afede6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   107
! !
0fd570afede6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   108
0fd570afede6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   109
!SimpleBorder class methodsFor:'documentation'!
0fd570afede6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   110
0fd570afede6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   111
version_CVS
5437
75f2638be06f changed: #displayOn:forDisplayBox:
Claus Gittinger <cg@exept.de>
parents: 5432
diff changeset
   112
    ^ '$Header: /cvs/stx/stx/libview/SimpleBorder.st,v 1.6 2009-10-29 15:59:43 cg Exp $'
5375
0fd570afede6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   113
! !