AbstractBorder.st
author Claus Gittinger <cg@exept.de>
Wed, 02 Feb 2011 01:42:50 +0100
changeset 5697 31054a18f308
parent 5407 767945d3ad71
child 6713 248ef6ff9725
permissions -rw-r--r--
automatically generated by browser
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5374
fa6ec7dc8508 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     1
"
fa6ec7dc8508 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     2
 COPYRIGHT (c) 1997 by eXept Software AG
fa6ec7dc8508 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     3
 COPYRIGHT (c) 2009 by eXept Software AG
5407
767945d3ad71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5392
diff changeset
     4
	      All Rights Reserved
5374
fa6ec7dc8508 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     5
fa6ec7dc8508 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     6
 This software is furnished under a license and may be used
fa6ec7dc8508 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     7
 only in accordance with the terms of that license and with the
fa6ec7dc8508 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     8
 inclusion of the above copyright notice.   This software may not
fa6ec7dc8508 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     9
 be provided or otherwise made available to, or used by, any
fa6ec7dc8508 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    10
 other person.  No title to or ownership of the software is
fa6ec7dc8508 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    11
 hereby transferred.
fa6ec7dc8508 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    12
"
fa6ec7dc8508 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    13
"{ Package: 'stx:libview' }"
fa6ec7dc8508 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    14
fa6ec7dc8508 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    15
Object subclass:#AbstractBorder
5407
767945d3ad71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5392
diff changeset
    16
	instanceVariableNames:'width'
5374
fa6ec7dc8508 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    17
	classVariableNames:''
fa6ec7dc8508 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    18
	poolDictionaries:''
5392
9cc77e8151a4 category
Claus Gittinger <cg@exept.de>
parents: 5374
diff changeset
    19
	category:'Graphics-Support'
5374
fa6ec7dc8508 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    20
!
fa6ec7dc8508 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    21
fa6ec7dc8508 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    22
!AbstractBorder class methodsFor:'documentation'!
fa6ec7dc8508 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    23
fa6ec7dc8508 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    24
copyright
fa6ec7dc8508 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    25
"
fa6ec7dc8508 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    26
 COPYRIGHT (c) 1997 by eXept Software AG
fa6ec7dc8508 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    27
 COPYRIGHT (c) 2009 by eXept Software AG
5407
767945d3ad71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5392
diff changeset
    28
	      All Rights Reserved
5374
fa6ec7dc8508 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    29
fa6ec7dc8508 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    30
 This software is furnished under a license and may be used
fa6ec7dc8508 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    31
 only in accordance with the terms of that license and with the
fa6ec7dc8508 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    32
 inclusion of the above copyright notice.   This software may not
fa6ec7dc8508 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    33
 be provided or otherwise made available to, or used by, any
fa6ec7dc8508 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    34
 other person.  No title to or ownership of the software is
fa6ec7dc8508 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    35
 hereby transferred.
fa6ec7dc8508 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    36
"
fa6ec7dc8508 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    37
!
fa6ec7dc8508 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    38
fa6ec7dc8508 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    39
documentation
fa6ec7dc8508 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    40
"
5392
9cc77e8151a4 category
Claus Gittinger <cg@exept.de>
parents: 5374
diff changeset
    41
    Extracted from Border.
9cc77e8151a4 category
Claus Gittinger <cg@exept.de>
parents: 5374
diff changeset
    42
    Common superclass for border-painters.
9cc77e8151a4 category
Claus Gittinger <cg@exept.de>
parents: 5374
diff changeset
    43
    This will replace the mixture of window-system supported borders and manually
9cc77e8151a4 category
Claus Gittinger <cg@exept.de>
parents: 5374
diff changeset
    44
    drawn 3D levels (which is ugly, but served me well for almost 20years now).
5374
fa6ec7dc8508 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    45
fa6ec7dc8508 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    46
    [author:]
5407
767945d3ad71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5392
diff changeset
    47
	Claus Gittinger
5374
fa6ec7dc8508 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    48
"
fa6ec7dc8508 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    49
! !
fa6ec7dc8508 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    50
fa6ec7dc8508 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    51
!AbstractBorder class methodsFor:'instance creation'!
fa6ec7dc8508 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    52
fa6ec7dc8508 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    53
width:borderWidth
5407
767945d3ad71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5392
diff changeset
    54
    "create a new instance of the receiver with a border of the given width
5374
fa6ec7dc8508 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    55
     (and default color)."
fa6ec7dc8508 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    56
fa6ec7dc8508 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    57
    ^ self new width:borderWidth color:(Color black)
fa6ec7dc8508 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    58
fa6ec7dc8508 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    59
    "Modified: 10.2.1997 / 15:19:57 / cg"
fa6ec7dc8508 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    60
!
fa6ec7dc8508 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    61
fa6ec7dc8508 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    62
width:borderWidth color:aColor
5407
767945d3ad71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5392
diff changeset
    63
    "create a new instance of the receiver with a border of the given width
5374
fa6ec7dc8508 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    64
     and color."
fa6ec7dc8508 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    65
5407
767945d3ad71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5392
diff changeset
    66
    ^ self new width:borderWidth color:aColor
5374
fa6ec7dc8508 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    67
fa6ec7dc8508 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    68
    "Modified: 10.2.1997 / 15:20:32 / cg"
fa6ec7dc8508 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    69
! !
fa6ec7dc8508 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    70
fa6ec7dc8508 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    71
!AbstractBorder methodsFor:'accessing'!
fa6ec7dc8508 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    72
5407
767945d3ad71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5392
diff changeset
    73
color:aColor
767945d3ad71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5392
diff changeset
    74
    "set the width"
767945d3ad71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5392
diff changeset
    75
767945d3ad71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5392
diff changeset
    76
    "/ self subclassResponsibility
767945d3ad71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5392
diff changeset
    77
!
767945d3ad71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5392
diff changeset
    78
767945d3ad71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5392
diff changeset
    79
level
767945d3ad71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5392
diff changeset
    80
    "get the 3D level"
767945d3ad71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5392
diff changeset
    81
767945d3ad71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5392
diff changeset
    82
    ^ 0
767945d3ad71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5392
diff changeset
    83
!
767945d3ad71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5392
diff changeset
    84
767945d3ad71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5392
diff changeset
    85
width
767945d3ad71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5392
diff changeset
    86
    "get the width"
767945d3ad71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5392
diff changeset
    87
767945d3ad71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5392
diff changeset
    88
    ^ width
767945d3ad71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5392
diff changeset
    89
!
767945d3ad71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5392
diff changeset
    90
767945d3ad71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5392
diff changeset
    91
width:aNumber
767945d3ad71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5392
diff changeset
    92
    "set the width"
767945d3ad71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5392
diff changeset
    93
767945d3ad71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5392
diff changeset
    94
    width := aNumber
767945d3ad71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5392
diff changeset
    95
!
767945d3ad71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5392
diff changeset
    96
767945d3ad71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5392
diff changeset
    97
width:aWidth color:aColor
767945d3ad71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5392
diff changeset
    98
     self width:aWidth.
767945d3ad71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5392
diff changeset
    99
     self color:aColor
5374
fa6ec7dc8508 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   100
fa6ec7dc8508 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   101
    "Created: 10.2.1997 / 15:21:27 / cg"
fa6ec7dc8508 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   102
! !
fa6ec7dc8508 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   103
fa6ec7dc8508 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   104
!AbstractBorder methodsFor:'displaying'!
fa6ec7dc8508 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   105
fa6ec7dc8508 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   106
displayOn:aGC forDisplayBox:aRectangle
fa6ec7dc8508 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   107
    "display the borders represented by the receiver in the specified rectangle.
fa6ec7dc8508 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   108
     The gc is restored after the draw."
fa6ec7dc8508 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   109
5407
767945d3ad71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5392
diff changeset
   110
    "/ self subclassResponsibility
5374
fa6ec7dc8508 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   111
! !
fa6ec7dc8508 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   112
5407
767945d3ad71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5392
diff changeset
   113
!AbstractBorder methodsFor:'queries'!
5374
fa6ec7dc8508 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   114
5407
767945d3ad71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5392
diff changeset
   115
allSidesEqual:aSmallInteger 
767945d3ad71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5392
diff changeset
   116
    "true if all four sides have the same border width;
767945d3ad71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5392
diff changeset
   117
     always true here - provided for compatibility"
5374
fa6ec7dc8508 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   118
5407
767945d3ad71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5392
diff changeset
   119
    ^ true
767945d3ad71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5392
diff changeset
   120
767945d3ad71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5392
diff changeset
   121
    "Created: 10.2.1997 / 14:53:13 / cg"
5374
fa6ec7dc8508 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   122
!
fa6ec7dc8508 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   123
5407
767945d3ad71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5392
diff changeset
   124
displayBoxFor:aRectangle
767945d3ad71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5392
diff changeset
   125
    "return a rectangle representing the overall display box of a component
767945d3ad71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5392
diff changeset
   126
     bordered by the receiver, which has bounds of aRectangle.
767945d3ad71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5392
diff changeset
   127
     That is, the argument outset by the receivers borders."
767945d3ad71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5392
diff changeset
   128
767945d3ad71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5392
diff changeset
   129
    |insetRectangle|
767945d3ad71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5392
diff changeset
   130
767945d3ad71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5392
diff changeset
   131
    insetRectangle := aRectangle copy.
767945d3ad71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5392
diff changeset
   132
    insetRectangle left:(insetRectangle left - width).
767945d3ad71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5392
diff changeset
   133
    insetRectangle right:(insetRectangle right + width).
767945d3ad71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5392
diff changeset
   134
    insetRectangle top:(insetRectangle top - width).
767945d3ad71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5392
diff changeset
   135
    insetRectangle bottom:(insetRectangle bottom + width).
767945d3ad71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5392
diff changeset
   136
    ^ insetRectangle
5374
fa6ec7dc8508 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   137
5407
767945d3ad71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5392
diff changeset
   138
    "Created: 10.2.1997 / 15:43:00 / cg"
767945d3ad71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5392
diff changeset
   139
!
767945d3ad71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5392
diff changeset
   140
767945d3ad71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5392
diff changeset
   141
insetDisplayBoxFor:aRectangle
767945d3ad71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5392
diff changeset
   142
    "return a rectangle representing the display box of a component
767945d3ad71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5392
diff changeset
   143
     bordered by the receiver in the outer bounds, aRectangle.
767945d3ad71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5392
diff changeset
   144
     That is, the argument inset by the receivers borders."
767945d3ad71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5392
diff changeset
   145
767945d3ad71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5392
diff changeset
   146
    |insetRectangle|
767945d3ad71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5392
diff changeset
   147
767945d3ad71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5392
diff changeset
   148
    insetRectangle := aRectangle copy.
767945d3ad71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5392
diff changeset
   149
    insetRectangle left:(insetRectangle left + width).
767945d3ad71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5392
diff changeset
   150
    insetRectangle right:(insetRectangle right - width).
767945d3ad71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5392
diff changeset
   151
    insetRectangle top:(insetRectangle top + width).
767945d3ad71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5392
diff changeset
   152
    insetRectangle bottom:(insetRectangle bottom - width).
767945d3ad71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5392
diff changeset
   153
    ^ insetRectangle
767945d3ad71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5392
diff changeset
   154
767945d3ad71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5392
diff changeset
   155
    "Created: 10.2.1997 / 15:42:06 / cg"
5374
fa6ec7dc8508 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   156
! !
fa6ec7dc8508 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   157
fa6ec7dc8508 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   158
!AbstractBorder class methodsFor:'documentation'!
fa6ec7dc8508 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   159
fa6ec7dc8508 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   160
version_CVS
5407
767945d3ad71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5392
diff changeset
   161
    ^ '$Header: /cvs/stx/stx/libview/AbstractBorder.st,v 1.3 2009-10-24 10:07:22 cg Exp $'
5374
fa6ec7dc8508 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   162
! !