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