Border.st
changeset 7013 1b1f3144927a
parent 6714 08b320104918
child 7947 ccd0e325ddf8
child 8595 7f9b84978a2e
equal deleted inserted replaced
7012:b39b300d4874 7013:1b1f3144927a
       
     1 "{ Encoding: utf8 }"
       
     2 
     1 "
     3 "
     2  COPYRIGHT (c) 1997 by eXept Software AG
     4  COPYRIGHT (c) 1997 by eXept Software AG
     3 	      All Rights Reserved
     5 	      All Rights Reserved
     4 
     6 
     5  This software is furnished under a license and may be used
     7  This software is furnished under a license and may be used
    12 "{ Package: 'stx:libview' }"
    14 "{ Package: 'stx:libview' }"
    13 
    15 
    14 "{ NameSpace: Smalltalk }"
    16 "{ NameSpace: Smalltalk }"
    15 
    17 
    16 AbstractBorder subclass:#Border
    18 AbstractBorder subclass:#Border
    17 	instanceVariableNames:'leftColor rightColor topColor bottomColor'
    19 	instanceVariableNames:'leftColor leftWidth rightColor rightWidth topColor topWidth
       
    20 		bottomColor bottomWidth'
    18 	classVariableNames:''
    21 	classVariableNames:''
    19 	poolDictionaries:''
    22 	poolDictionaries:''
    20 	category:'Graphics-Support'
    23 	category:'Graphics-Support'
    21 !
    24 !
    22 
    25 
    57      |v b|
    60      |v b|
    58 
    61 
    59      v := StandardSystemView extent:100@100.
    62      v := StandardSystemView extent:100@100.
    60      v openAndWait.
    63      v openAndWait.
    61 
    64 
       
    65      b := Border width:1 color:Color red.
       
    66      v border:b
       
    67                                                         [exEnd]
       
    68 
       
    69                                                         [exBegin]
       
    70      |v b|
       
    71 
       
    72      v := StandardSystemView extent:100@100.
       
    73      v openAndWait.
       
    74 
    62      b := Border width:10 color:Color red.
    75      b := Border width:10 color:Color red.
    63      b displayOn:v forDisplayBox:(0@0 corner:90@90).
    76      b displayOn:v forDisplayBox:(0@0 corner:90@90).
    64 
    77 
    65      Delay waitForSeconds:1.
    78      Delay waitForSeconds:1.
    66      b leftColor:Color blue.
    79      b leftColor:Color blue.
    78 
    91 
    79      v := StandardSystemView extent:100@100.
    92      v := StandardSystemView extent:100@100.
    80      v openAndWait.
    93      v openAndWait.
    81 
    94 
    82      b := Border width:10 color:Color red.
    95      b := Border width:10 color:Color red.
    83      v border:b
    96      b topColor:Color red.
       
    97      b leftColor:Color blue.
       
    98      b topColor:Color green.
       
    99      b rightColor:Color yellow.
       
   100      b leftWidth:10 rightWidth:20 topWidth:5 bottomWidth:15.
       
   101 
       
   102      b displayOn:v forDisplayBox:(0@0 corner:90@90).
    84                                                         [exEnd]
   103                                                         [exEnd]
    85 
   104 
    86                                                         [exBegin]
   105                                                         [exBegin]
    87      |v sub1 sub2 sub3|
   106      |v sub1 sub2 sub3|
    88 
   107 
   122     bottomColor := aColor
   141     bottomColor := aColor
   123 
   142 
   124     "Created: 10.2.1997 / 15:37:51 / cg"
   143     "Created: 10.2.1997 / 15:37:51 / cg"
   125 !
   144 !
   126 
   145 
       
   146 bottomWidth
       
   147     ^ bottomWidth
       
   148 !
       
   149 
       
   150 bottomWidth:something
       
   151     bottomWidth := something.
       
   152 !
       
   153 
   127 color:newColor
   154 color:newColor
   128     "set all four colors"
   155     "set all four colors"
   129 
   156 
   130      leftColor := rightColor := topColor := bottomColor := newColor
   157      leftColor := rightColor := topColor := bottomColor := newColor
   131 
   158 
   146     leftColor := aColor
   173     leftColor := aColor
   147 
   174 
   148     "Created: 10.2.1997 / 15:38:02 / cg"
   175     "Created: 10.2.1997 / 15:38:02 / cg"
   149 !
   176 !
   150 
   177 
       
   178 leftWidth
       
   179     ^ leftWidth
       
   180 !
       
   181 
       
   182 leftWidth:something
       
   183     leftWidth := something.
       
   184 !
       
   185 
       
   186 leftWidth:leftWidthArg rightWidth:rightWidthArg topWidth:topWidthArg bottomWidth:bottomWidthArg 
       
   187     leftWidth := leftWidthArg.
       
   188     rightWidth := rightWidthArg.
       
   189     topWidth := topWidthArg.
       
   190     bottomWidth := bottomWidthArg.
       
   191 !
       
   192 
   151 rightColor
   193 rightColor
   152     "return the value of the instance variable 'rightColor' (automatically generated)"
   194     "return the value of the instance variable 'rightColor' (automatically generated)"
   153 
   195 
   154     ^ rightColor
   196     ^ rightColor
   155 
   197 
   162     rightColor := aColor
   204     rightColor := aColor
   163 
   205 
   164     "Created: 10.2.1997 / 15:38:08 / cg"
   206     "Created: 10.2.1997 / 15:38:08 / cg"
   165 !
   207 !
   166 
   208 
       
   209 rightWidth
       
   210     ^ rightWidth
       
   211 !
       
   212 
       
   213 rightWidth:something
       
   214     rightWidth := something.
       
   215 !
       
   216 
   167 topColor
   217 topColor
   168     "return the value of the instance variable 'topColor' (automatically generated)"
   218     "return the value of the instance variable 'topColor' (automatically generated)"
   169 
   219 
   170     ^ topColor
   220     ^ topColor
   171 
   221 
   176     "set the topColor"
   226     "set the topColor"
   177 
   227 
   178     topColor := aColor
   228     topColor := aColor
   179 
   229 
   180     "Created: 10.2.1997 / 15:38:17 / cg"
   230     "Created: 10.2.1997 / 15:38:17 / cg"
       
   231 !
       
   232 
       
   233 topWidth
       
   234     ^ topWidth
       
   235 !
       
   236 
       
   237 topWidth:something
       
   238     topWidth := something.
       
   239 !
       
   240 
       
   241 width:w
       
   242     leftWidth := rightWidth := topWidth := bottomWidth := width := w.
   181 ! !
   243 ! !
   182 
   244 
   183 !Border methodsFor:'displaying'!
   245 !Border methodsFor:'displaying'!
   184 
   246 
   185 displayOn:aGC forDisplayBox:aRectangle
   247 displayOn:aGC forDisplayBox:aRectangle
   199     rH := aRectangle height.
   261     rH := aRectangle height.
   200     rW := aRectangle width.
   262     rW := aRectangle width.
   201 
   263 
   202     leftColor notNil ifTrue:[
   264     leftColor notNil ifTrue:[
   203         aGC paint:leftColor.
   265         aGC paint:leftColor.
   204         width == 1 ifTrue:[
   266         leftWidth == 1 ifTrue:[
   205             aGC displayLineFromX:rL y:rT toX:rL y:rB-1.
   267             aGC displayLineFromX:rL y:rT toX:rL y:rB-1.
   206         ] ifFalse:[
   268         ] ifFalse:[
   207             aGC fillRectangleX:rL y:rT width:width height:rH
   269             aGC fillRectangleX:rL y:rT width:leftWidth height:rH
   208         ].
   270         ].
   209     ].
   271     ].
   210 
   272 
   211     topColor notNil ifTrue:[
   273     topColor notNil ifTrue:[
   212         aGC paint:topColor.
   274         aGC paint:topColor.
   213         width == 1 ifTrue:[
   275         topWidth == 1 ifTrue:[
   214             aGC displayLineFromX:rL+1 y:rT toX:rR-1 y:rT.
   276             aGC displayLineFromX:rL+1 y:rT toX:rR-1 y:rT.
   215         ] ifFalse:[
   277         ] ifFalse:[
   216             aGC fillRectangleX:(rL + width) y:rT width:rW - width height:width
   278             aGC fillRectangleX:(rL + leftWidth) y:rT width:rW - leftWidth - rightWidth  height:topWidth
   217         ].
   279         ].
   218     ].
   280     ].
   219 
   281 
   220     rightColor notNil ifTrue:[
   282     rightColor notNil ifTrue:[
   221         aGC paint:rightColor.
   283         aGC paint:rightColor.
   222         width == 1 ifTrue:[
   284         rightWidth == 1 ifTrue:[
   223             aGC displayLineFromX:rR-1 y:rT toX:rR-1 y:rB-1.
   285             aGC displayLineFromX:rR-1 y:rT toX:rR-1 y:rB-1.
   224         ] ifFalse:[
   286         ] ifFalse:[
   225             aGC fillRectangleX:(rR - width) y:(rT + width) width:width height:rH-width
   287             aGC fillRectangleX:(rR - rightWidth) y:rT width:rightWidth height:rH
   226         ].
   288         ].
   227     ].
   289     ].
   228 
   290 
   229     bottomColor notNil ifTrue:[
   291     bottomColor notNil ifTrue:[
   230         aGC paint:bottomColor.
   292         aGC paint:bottomColor.
   231         width == 1 ifTrue:[
   293         bottomWidth == 1 ifTrue:[
   232             aGC displayLineFromX:rL y:rB-1 toX:rR-1 y:rB-1.
   294             aGC displayLineFromX:rL+1 y:rB-1 toX:rR-2 y:rB-1.
   233         ] ifFalse:[
   295         ] ifFalse:[
   234             aGC fillRectangleX:rL y:(rB-width) width:rW - width height:width
   296             aGC fillRectangleX:rL+leftWidth y:(rB-bottomWidth) width:rW - leftWidth - rightWidth height:bottomWidth
   235         ].
   297         ].
   236     ].
   298     ].
   237 
   299 
   238     aGC paint: oldPaint
   300     aGC paint: oldPaint
   239 
   301 
   240     "Modified: 10.2.1997 / 15:55:04 / cg"
   302     "Modified: 10.2.1997 / 15:55:04 / cg"
   241 ! !
   303 ! !
   242 
   304 
       
   305 !Border methodsFor:'initialization'!
       
   306 
       
   307 initialize
       
   308     width := 1.
       
   309     leftWidth := rightWidth := topWidth := bottomWidth := 1.
       
   310 ! !
       
   311 
       
   312 !Border methodsFor:'queries'!
       
   313 
       
   314 bottomMargin
       
   315     ^ bottomWidth
       
   316 !
       
   317 
       
   318 leftMargin
       
   319     ^ leftWidth
       
   320 !
       
   321 
       
   322 rightMargin
       
   323     ^ rightWidth
       
   324 !
       
   325 
       
   326 topMargin
       
   327     ^ topWidth
       
   328 ! !
       
   329 
   243 !Border class methodsFor:'documentation'!
   330 !Border class methodsFor:'documentation'!
   244 
   331 
   245 version
   332 version
   246     ^ '$Header: /cvs/stx/stx/libview/Border.st,v 1.10 2015-01-05 20:34:51 cg Exp $'
   333     ^ '$Header$'
   247 !
   334 !
   248 
   335 
   249 version_CVS
   336 version_CVS
   250     ^ '$Header: /cvs/stx/stx/libview/Border.st,v 1.10 2015-01-05 20:34:51 cg Exp $'
   337     ^ '$Header$'
   251 ! !
   338 ! !
   252 
   339