StrokingWrapper.st
author Claus Gittinger <cg@exept.de>
Sun, 29 Jan 2017 02:26:51 +0100
changeset 3853 5a78ffcf69de
parent 2634 487acf365da5
child 3855 1db7742d33ad
permissions -rw-r--r--
#FEATURE by cg class: TypeConverter changed: #timeOfClass:withFormat:orDefault:language:
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
245
8d7f9a8d2c78 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     1
"
8d7f9a8d2c78 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     2
 COPYRIGHT (c) 1996 by Claus Gittinger
8d7f9a8d2c78 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     3
              All Rights Reserved
8d7f9a8d2c78 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     4
8d7f9a8d2c78 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     5
 This software is furnished under a license and may be used
8d7f9a8d2c78 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     6
 only in accordance with the terms of that license and with the
8d7f9a8d2c78 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
8d7f9a8d2c78 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     8
 be provided or otherwise made available to, or used by, any
8d7f9a8d2c78 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     9
 other person.  No title to or ownership of the software is
8d7f9a8d2c78 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    10
 hereby transferred.
8d7f9a8d2c78 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    11
"
1789
f52f0a0d8448 category
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
    12
"{ Package: 'stx:libview2' }"
f52f0a0d8448 category
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
    13
2634
487acf365da5 refactored
Claus Gittinger <cg@exept.de>
parents: 1789
diff changeset
    14
StrokingOrFillingWrapper subclass:#StrokingWrapper
487acf365da5 refactored
Claus Gittinger <cg@exept.de>
parents: 1789
diff changeset
    15
	instanceVariableNames:''
245
8d7f9a8d2c78 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    16
	classVariableNames:''
8d7f9a8d2c78 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    17
	poolDictionaries:''
1789
f52f0a0d8448 category
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
    18
	category:'Compatibility-ST80-Graphics-Display Objects'
245
8d7f9a8d2c78 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    19
!
8d7f9a8d2c78 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    20
280
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
    21
!StrokingWrapper class methodsFor:'documentation'!
245
8d7f9a8d2c78 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    22
8d7f9a8d2c78 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    23
copyright
8d7f9a8d2c78 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    24
"
8d7f9a8d2c78 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    25
 COPYRIGHT (c) 1996 by Claus Gittinger
8d7f9a8d2c78 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    26
              All Rights Reserved
8d7f9a8d2c78 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    27
8d7f9a8d2c78 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    28
 This software is furnished under a license and may be used
8d7f9a8d2c78 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    29
 only in accordance with the terms of that license and with the
8d7f9a8d2c78 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    30
 inclusion of the above copyright notice.   This software may not
8d7f9a8d2c78 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    31
 be provided or otherwise made available to, or used by, any
8d7f9a8d2c78 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    32
 other person.  No title to or ownership of the software is
8d7f9a8d2c78 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    33
 hereby transferred.
8d7f9a8d2c78 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    34
"
8d7f9a8d2c78 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    35
8d7f9a8d2c78 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    36
!
8d7f9a8d2c78 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    37
8d7f9a8d2c78 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    38
documentation
8d7f9a8d2c78 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    39
"
280
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
    40
    a wrapper for a geometric object, which is to be drawn stroked.
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
    41
    This allows any geometric thingy to be used as a component in a view.
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
    42
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
    43
    (background info: geometrics are mathematical objects - they do not 
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
    44
     keep any color or lineStyle attributes. Wrappers add this information
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
    45
     and can also be used as components of a view)
254
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
    46
265
45c83acd7562 comments
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
    47
    Notice: 
45c83acd7562 comments
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
    48
        this class was implemented using protocol information
365
47e0d48fd769 commentary
Claus Gittinger <cg@exept.de>
parents: 295
diff changeset
    49
        from alpha testers, from reading PD programs and 
47e0d48fd769 commentary
Claus Gittinger <cg@exept.de>
parents: 295
diff changeset
    50
        from the Hopkins/Horan book.
265
45c83acd7562 comments
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
    51
        - it may not be complete or compatible to the corresponding ST-80 class. 
45c83acd7562 comments
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
    52
        If you encounter any incompatibilities, please forward a note 
45c83acd7562 comments
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
    53
        describing the incompatibility verbal (i.e. no code) to the ST/X team.
45c83acd7562 comments
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
    54
248
266a7ec53d9f more examples & comments
Claus Gittinger <cg@exept.de>
parents: 246
diff changeset
    55
    [see also:]
280
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
    56
        FillingWrapper Geometric GraphicsContext
248
266a7ec53d9f more examples & comments
Claus Gittinger <cg@exept.de>
parents: 246
diff changeset
    57
245
8d7f9a8d2c78 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    58
    [author:]
8d7f9a8d2c78 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    59
        Claus Gittinger
8d7f9a8d2c78 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    60
"
8d7f9a8d2c78 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    61
!
8d7f9a8d2c78 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    62
8d7f9a8d2c78 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    63
examples
8d7f9a8d2c78 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    64
"
280
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
    65
  wrap an ellipticArc and display it
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
    66
  (notice, that no automatic redraw is performed):
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
    67
                                                                        [exBegin]
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
    68
    |v e component|
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
    69
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
    70
    v := (StandardSystemView extent:250@250) openAndWait.
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
    71
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
    72
    e := EllipticalArc boundingBox:(10@10 corner:90@90)
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
    73
                        startAngle:0 
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
    74
                        sweepAngle:270.
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
    75
    component := StrokingWrapper on:e.
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
    76
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
    77
    component displayOn:v.
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
    78
                                                                        [exEnd]
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
    79
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
    80
  wrap a rectangle and an ellipticArc,
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
    81
  and add them as components to a View
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
    82
  (notice, that doing so makes the redraw automatic):
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
    83
                                                                        [exBegin]
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
    84
    |v e component|
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
    85
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
    86
    v := StandardSystemView extent:250@250.
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
    87
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
    88
    e := Rectangle origin:10@10 corner:90@90.
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
    89
    component := FillingWrapper on:e.
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
    90
    component foregroundColor:Color red.
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
    91
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
    92
    v addComponent:component.
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
    93
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
    94
    e := EllipticalArc boundingBox:(10@10 corner:90@90)
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
    95
                     startAngle:0 sweepAngle:360.
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
    96
    component := StrokingWrapper on:e.
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
    97
    component lineWidth:5.
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
    98
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
    99
    v addComponent:component.
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
   100
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
   101
    v addComponent:(Button label:'hello').
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
   102
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
   103
    v open
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
   104
                                                                        [exEnd]
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
   105
  with lineWidth & style:
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
   106
  (notice, that the redraw is automatic):
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
   107
                                                                        [exBegin]
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
   108
    |v e|
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
   109
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
   110
    v := StandardSystemView extent:250@250.
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
   111
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
   112
    e := EllipticalArc boundingBox:(10@10 corner:90@90)
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
   113
                        startAngle:0 
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
   114
                        sweepAngle:270.
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
   115
    v addComponent:((StrokingWrapper on:e)
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
   116
                        lineWidth:5;
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
   117
                        lineStyle:#dashed;
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
   118
                        foregroundColor:(Color red)).
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
   119
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
   120
    e := EllipticalArc boundingBox:(30@30 corner:70@70)
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
   121
                        startAngle:90 
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
   122
                        sweepAngle:270.
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
   123
    v addComponent:((StrokingWrapper on:e)
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
   124
                        lineWidth:5;
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
   125
                        lineStyle:#doubleDashed;
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
   126
                        foregroundColor:(Color red);
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
   127
                        backgroundColor:(Color green)).
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
   128
    v open.
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
   129
                                                                        [exEnd]
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
   130
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
   131
  scrolling:
273
f76fb9098814 fixed bounds computation
Claus Gittinger <cg@exept.de>
parents: 265
diff changeset
   132
                                                                        [exBegin]
f76fb9098814 fixed bounds computation
Claus Gittinger <cg@exept.de>
parents: 265
diff changeset
   133
    |t s v e component|
f76fb9098814 fixed bounds computation
Claus Gittinger <cg@exept.de>
parents: 265
diff changeset
   134
f76fb9098814 fixed bounds computation
Claus Gittinger <cg@exept.de>
parents: 265
diff changeset
   135
    t := StandardSystemView extent:250@200.
f76fb9098814 fixed bounds computation
Claus Gittinger <cg@exept.de>
parents: 265
diff changeset
   136
    s := HVScrollableView for:View miniScroller:true in:t.
f76fb9098814 fixed bounds computation
Claus Gittinger <cg@exept.de>
parents: 265
diff changeset
   137
    s origin:0.0@0.0 corner:1.0@1.0.
f76fb9098814 fixed bounds computation
Claus Gittinger <cg@exept.de>
parents: 265
diff changeset
   138
    v := s scrolledView.
f76fb9098814 fixed bounds computation
Claus Gittinger <cg@exept.de>
parents: 265
diff changeset
   139
f76fb9098814 fixed bounds computation
Claus Gittinger <cg@exept.de>
parents: 265
diff changeset
   140
    e := Rectangle origin:10@10 corner:90@90.
f76fb9098814 fixed bounds computation
Claus Gittinger <cg@exept.de>
parents: 265
diff changeset
   141
    component := FillingWrapper on:e.
f76fb9098814 fixed bounds computation
Claus Gittinger <cg@exept.de>
parents: 265
diff changeset
   142
    component foregroundColor:Color red.
f76fb9098814 fixed bounds computation
Claus Gittinger <cg@exept.de>
parents: 265
diff changeset
   143
    v addComponent:component.
f76fb9098814 fixed bounds computation
Claus Gittinger <cg@exept.de>
parents: 265
diff changeset
   144
f76fb9098814 fixed bounds computation
Claus Gittinger <cg@exept.de>
parents: 265
diff changeset
   145
    e := EllipticalArc boundingBox:(10@10 corner:90@90)
f76fb9098814 fixed bounds computation
Claus Gittinger <cg@exept.de>
parents: 265
diff changeset
   146
                     startAngle:0 sweepAngle:360.
f76fb9098814 fixed bounds computation
Claus Gittinger <cg@exept.de>
parents: 265
diff changeset
   147
    component := StrokingWrapper on:e.
f76fb9098814 fixed bounds computation
Claus Gittinger <cg@exept.de>
parents: 265
diff changeset
   148
    component lineWidth:5.
f76fb9098814 fixed bounds computation
Claus Gittinger <cg@exept.de>
parents: 265
diff changeset
   149
    v addComponent:component.
f76fb9098814 fixed bounds computation
Claus Gittinger <cg@exept.de>
parents: 265
diff changeset
   150
f76fb9098814 fixed bounds computation
Claus Gittinger <cg@exept.de>
parents: 265
diff changeset
   151
    e := Arrow from:100@100 to:150@250.
f76fb9098814 fixed bounds computation
Claus Gittinger <cg@exept.de>
parents: 265
diff changeset
   152
    component := StrokingWrapper on:e.
f76fb9098814 fixed bounds computation
Claus Gittinger <cg@exept.de>
parents: 265
diff changeset
   153
    component lineWidth:2.
f76fb9098814 fixed bounds computation
Claus Gittinger <cg@exept.de>
parents: 265
diff changeset
   154
    v addComponent:component.
f76fb9098814 fixed bounds computation
Claus Gittinger <cg@exept.de>
parents: 265
diff changeset
   155
280
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
   156
    v addComponent:(Button label:'hello').
273
f76fb9098814 fixed bounds computation
Claus Gittinger <cg@exept.de>
parents: 265
diff changeset
   157
f76fb9098814 fixed bounds computation
Claus Gittinger <cg@exept.de>
parents: 265
diff changeset
   158
    t open
f76fb9098814 fixed bounds computation
Claus Gittinger <cg@exept.de>
parents: 265
diff changeset
   159
                                                                        [exEnd]
f76fb9098814 fixed bounds computation
Claus Gittinger <cg@exept.de>
parents: 265
diff changeset
   160
245
8d7f9a8d2c78 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   161
"
8d7f9a8d2c78 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   162
! !
8d7f9a8d2c78 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   163
280
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
   164
!StrokingWrapper methodsFor:'displaying'!
245
8d7f9a8d2c78 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   165
8d7f9a8d2c78 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   166
displayOn:aGC
280
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
   167
    "display myself - here, display the geometric object asStroked"
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
   168
2634
487acf365da5 refactored
Claus Gittinger <cg@exept.de>
parents: 1789
diff changeset
   169
    self displayStrokedOn:aGC
245
8d7f9a8d2c78 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   170
! !
8d7f9a8d2c78 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   171
280
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
   172
!StrokingWrapper class methodsFor:'documentation'!
245
8d7f9a8d2c78 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   173
8d7f9a8d2c78 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   174
version
2634
487acf365da5 refactored
Claus Gittinger <cg@exept.de>
parents: 1789
diff changeset
   175
    ^ '$Header: /cvs/stx/stx/libview2/StrokingWrapper.st,v 1.16 2009-05-06 07:29:41 cg Exp $'
245
8d7f9a8d2c78 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   176
! !