FillingWrapper.st
author Jan Vrany <jan.vrany@labware.com>
Tue, 04 Apr 2023 14:22:18 +0200
branchjv
changeset 4473 3675eb1de41b
parent 3855 1db7742d33ad
permissions -rw-r--r--
Cherry-picked `WindowBuilder >> #isWebPageBuilder`
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: 2635
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: 2635
diff changeset
    15
2635
dd576df334a4 refactored
Claus Gittinger <cg@exept.de>
parents: 1789
diff changeset
    16
StrokingOrFillingWrapper subclass:#FillingWrapper
245
8d7f9a8d2c78 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    17
	instanceVariableNames:''
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
8d7f9a8d2c78 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    23
!FillingWrapper class methodsFor:'documentation'!
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
8d7f9a8d2c78 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    41
documentation
8d7f9a8d2c78 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    42
"
8d7f9a8d2c78 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    43
    a wrapper for a geometric object, which is to be drawn filled.
8d7f9a8d2c78 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    44
    This allows any geometric thingy to be used as a filled component in a view.
8d7f9a8d2c78 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    45
254
Claus Gittinger <cg@exept.de>
parents: 252
diff changeset
    46
    (background info: geometrics are mathematical objects - they do not 
Claus Gittinger <cg@exept.de>
parents: 252
diff changeset
    47
     keep any color or lineStyle attributes. Wrappers add this information
Claus Gittinger <cg@exept.de>
parents: 252
diff changeset
    48
     and can also be used as components of a view)
Claus Gittinger <cg@exept.de>
parents: 252
diff changeset
    49
265
45c83acd7562 comments
Claus Gittinger <cg@exept.de>
parents: 254
diff changeset
    50
    Notice: 
45c83acd7562 comments
Claus Gittinger <cg@exept.de>
parents: 254
diff changeset
    51
        this class was implemented using protocol information
365
47e0d48fd769 commentary
Claus Gittinger <cg@exept.de>
parents: 282
diff changeset
    52
        from alpha testers, from reading PD programs and 
47e0d48fd769 commentary
Claus Gittinger <cg@exept.de>
parents: 282
diff changeset
    53
        from the Hopkins/Horan book.
265
45c83acd7562 comments
Claus Gittinger <cg@exept.de>
parents: 254
diff changeset
    54
        - it may not be complete or compatible to the corresponding ST-80 class. 
45c83acd7562 comments
Claus Gittinger <cg@exept.de>
parents: 254
diff changeset
    55
        If you encounter any incompatibilities, please forward a note 
45c83acd7562 comments
Claus Gittinger <cg@exept.de>
parents: 254
diff changeset
    56
        describing the incompatibility verbal (i.e. no code) to the ST/X team.
45c83acd7562 comments
Claus Gittinger <cg@exept.de>
parents: 254
diff changeset
    57
248
266a7ec53d9f more examples & comments
Claus Gittinger <cg@exept.de>
parents: 246
diff changeset
    58
    [see also:]
266a7ec53d9f more examples & comments
Claus Gittinger <cg@exept.de>
parents: 246
diff changeset
    59
        StrokingWrapper Geometric GraphicsContext
266a7ec53d9f more examples & comments
Claus Gittinger <cg@exept.de>
parents: 246
diff changeset
    60
245
8d7f9a8d2c78 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    61
    [author:]
8d7f9a8d2c78 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    62
        Claus Gittinger
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
8d7f9a8d2c78 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    66
!
8d7f9a8d2c78 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    67
8d7f9a8d2c78 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    68
examples
8d7f9a8d2c78 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    69
"
254
Claus Gittinger <cg@exept.de>
parents: 252
diff changeset
    70
  wrap an ellipticArc and display it
Claus Gittinger <cg@exept.de>
parents: 252
diff changeset
    71
  (notice, that no automatic redraw is performed):
245
8d7f9a8d2c78 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    72
                                                                        [exBegin]
254
Claus Gittinger <cg@exept.de>
parents: 252
diff changeset
    73
    |v e component|
Claus Gittinger <cg@exept.de>
parents: 252
diff changeset
    74
Claus Gittinger <cg@exept.de>
parents: 252
diff changeset
    75
    v := (View extent:250@250) openAndWait.
Claus Gittinger <cg@exept.de>
parents: 252
diff changeset
    76
Claus Gittinger <cg@exept.de>
parents: 252
diff changeset
    77
    e := EllipticalArc boundingBox:(10@10 corner:90@90)
Claus Gittinger <cg@exept.de>
parents: 252
diff changeset
    78
                        startAngle:0 
Claus Gittinger <cg@exept.de>
parents: 252
diff changeset
    79
                        sweepAngle:270.
Claus Gittinger <cg@exept.de>
parents: 252
diff changeset
    80
    component := FillingWrapper on:e.
245
8d7f9a8d2c78 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    81
254
Claus Gittinger <cg@exept.de>
parents: 252
diff changeset
    82
    component displayOn:v.
Claus Gittinger <cg@exept.de>
parents: 252
diff changeset
    83
                                                                        [exEnd]
Claus Gittinger <cg@exept.de>
parents: 252
diff changeset
    84
  wrap an spline and display it
Claus Gittinger <cg@exept.de>
parents: 252
diff changeset
    85
  (notice, that no automatic redraw is performed):
Claus Gittinger <cg@exept.de>
parents: 252
diff changeset
    86
                                                                        [exBegin]
Claus Gittinger <cg@exept.de>
parents: 252
diff changeset
    87
    |v s component|
Claus Gittinger <cg@exept.de>
parents: 252
diff changeset
    88
Claus Gittinger <cg@exept.de>
parents: 252
diff changeset
    89
    v := (View extent:250@250) openAndWait.
245
8d7f9a8d2c78 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    90
254
Claus Gittinger <cg@exept.de>
parents: 252
diff changeset
    91
    s := Spline controlPoints:
Claus Gittinger <cg@exept.de>
parents: 252
diff changeset
    92
               (Array with:(20@20)
Claus Gittinger <cg@exept.de>
parents: 252
diff changeset
    93
                      with:(80@80)
Claus Gittinger <cg@exept.de>
parents: 252
diff changeset
    94
                      with:(20@80)
Claus Gittinger <cg@exept.de>
parents: 252
diff changeset
    95
                      with:(20@20)).
Claus Gittinger <cg@exept.de>
parents: 252
diff changeset
    96
    component := FillingWrapper on:s.
Claus Gittinger <cg@exept.de>
parents: 252
diff changeset
    97
    component foregroundColor:(Color green darkened).
Claus Gittinger <cg@exept.de>
parents: 252
diff changeset
    98
    component displayOn:v.
Claus Gittinger <cg@exept.de>
parents: 252
diff changeset
    99
                                                                        [exEnd]
Claus Gittinger <cg@exept.de>
parents: 252
diff changeset
   100
  wrap ellipticArcs
Claus Gittinger <cg@exept.de>
parents: 252
diff changeset
   101
  and add them as components to a View
Claus Gittinger <cg@exept.de>
parents: 252
diff changeset
   102
  (notice, that doing so makes the redraw automatic):
Claus Gittinger <cg@exept.de>
parents: 252
diff changeset
   103
                                                                        [exBegin]
Claus Gittinger <cg@exept.de>
parents: 252
diff changeset
   104
    |v e component|
245
8d7f9a8d2c78 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   105
254
Claus Gittinger <cg@exept.de>
parents: 252
diff changeset
   106
    v := View extent:250@250.
Claus Gittinger <cg@exept.de>
parents: 252
diff changeset
   107
Claus Gittinger <cg@exept.de>
parents: 252
diff changeset
   108
    e := EllipticalArc boundingBox:(10@10 corner:90@90)
Claus Gittinger <cg@exept.de>
parents: 252
diff changeset
   109
                        startAngle:0 
Claus Gittinger <cg@exept.de>
parents: 252
diff changeset
   110
                        sweepAngle:270.
Claus Gittinger <cg@exept.de>
parents: 252
diff changeset
   111
    v addComponent:(StrokingWrapper on:e).
Claus Gittinger <cg@exept.de>
parents: 252
diff changeset
   112
Claus Gittinger <cg@exept.de>
parents: 252
diff changeset
   113
    e := EllipticalArc boundingBox:(110@110 corner:190@190)
Claus Gittinger <cg@exept.de>
parents: 252
diff changeset
   114
                        startAngle:0 
Claus Gittinger <cg@exept.de>
parents: 252
diff changeset
   115
                        sweepAngle:270.
Claus Gittinger <cg@exept.de>
parents: 252
diff changeset
   116
    v addComponent:(FillingWrapper on:e).
Claus Gittinger <cg@exept.de>
parents: 252
diff changeset
   117
    v open
245
8d7f9a8d2c78 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   118
                                                                        [exEnd]
8d7f9a8d2c78 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   119
8d7f9a8d2c78 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   120
254
Claus Gittinger <cg@exept.de>
parents: 252
diff changeset
   121
  wrap a rectangle and an ellipticArc,
Claus Gittinger <cg@exept.de>
parents: 252
diff changeset
   122
  and add them as components to a View
Claus Gittinger <cg@exept.de>
parents: 252
diff changeset
   123
  (notice, that doing so makes the redraw automatic):
245
8d7f9a8d2c78 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   124
                                                                        [exBegin]
254
Claus Gittinger <cg@exept.de>
parents: 252
diff changeset
   125
    |v e component|
245
8d7f9a8d2c78 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   126
254
Claus Gittinger <cg@exept.de>
parents: 252
diff changeset
   127
    v := View new.
Claus Gittinger <cg@exept.de>
parents: 252
diff changeset
   128
    v extent:250@250.
245
8d7f9a8d2c78 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   129
254
Claus Gittinger <cg@exept.de>
parents: 252
diff changeset
   130
    e := Rectangle origin:10@10 corner:90@90.
Claus Gittinger <cg@exept.de>
parents: 252
diff changeset
   131
    component := FillingWrapper on:e.
Claus Gittinger <cg@exept.de>
parents: 252
diff changeset
   132
    component foregroundColor:Color red.
245
8d7f9a8d2c78 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   133
254
Claus Gittinger <cg@exept.de>
parents: 252
diff changeset
   134
    v addComponent:component.
245
8d7f9a8d2c78 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   135
254
Claus Gittinger <cg@exept.de>
parents: 252
diff changeset
   136
    e := EllipticalArc boundingBox:(10@10 corner:90@90)
Claus Gittinger <cg@exept.de>
parents: 252
diff changeset
   137
                     startAngle:0 sweepAngle:270.
Claus Gittinger <cg@exept.de>
parents: 252
diff changeset
   138
    component := StrokingWrapper on:e.
Claus Gittinger <cg@exept.de>
parents: 252
diff changeset
   139
    component lineWidth:5.
245
8d7f9a8d2c78 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   140
254
Claus Gittinger <cg@exept.de>
parents: 252
diff changeset
   141
    v addComponent:component.
245
8d7f9a8d2c78 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   142
254
Claus Gittinger <cg@exept.de>
parents: 252
diff changeset
   143
    v addComponent:(Button label:'hello').
245
8d7f9a8d2c78 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   144
254
Claus Gittinger <cg@exept.de>
parents: 252
diff changeset
   145
    v open
245
8d7f9a8d2c78 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   146
                                                                        [exEnd]
266
e9d35cd74f64 wrappers usable as label in Label/Button etc.
Claus Gittinger <cg@exept.de>
parents: 265
diff changeset
   147
e9d35cd74f64 wrappers usable as label in Label/Button etc.
Claus Gittinger <cg@exept.de>
parents: 265
diff changeset
   148
 spline as a Buttons-label (hugh ?):
e9d35cd74f64 wrappers usable as label in Label/Button etc.
Claus Gittinger <cg@exept.de>
parents: 265
diff changeset
   149
                                                                        [exBegin]
e9d35cd74f64 wrappers usable as label in Label/Button etc.
Claus Gittinger <cg@exept.de>
parents: 265
diff changeset
   150
    |a b|
e9d35cd74f64 wrappers usable as label in Label/Button etc.
Claus Gittinger <cg@exept.de>
parents: 265
diff changeset
   151
e9d35cd74f64 wrappers usable as label in Label/Button etc.
Claus Gittinger <cg@exept.de>
parents: 265
diff changeset
   152
    a := ArrowedSpline controlPoints:
e9d35cd74f64 wrappers usable as label in Label/Button etc.
Claus Gittinger <cg@exept.de>
parents: 265
diff changeset
   153
               (Array with:(00@00)
e9d35cd74f64 wrappers usable as label in Label/Button etc.
Claus Gittinger <cg@exept.de>
parents: 265
diff changeset
   154
                      with:(60@60)
e9d35cd74f64 wrappers usable as label in Label/Button etc.
Claus Gittinger <cg@exept.de>
parents: 265
diff changeset
   155
                      with:(00@60)).
e9d35cd74f64 wrappers usable as label in Label/Button etc.
Claus Gittinger <cg@exept.de>
parents: 265
diff changeset
   156
e9d35cd74f64 wrappers usable as label in Label/Button etc.
Claus Gittinger <cg@exept.de>
parents: 265
diff changeset
   157
    b := Button label:(((StrokingWrapper on:a) 
e9d35cd74f64 wrappers usable as label in Label/Button etc.
Claus Gittinger <cg@exept.de>
parents: 265
diff changeset
   158
                        foregroundColor:Color red;
e9d35cd74f64 wrappers usable as label in Label/Button etc.
Claus Gittinger <cg@exept.de>
parents: 265
diff changeset
   159
                        lineWidth:3;
e9d35cd74f64 wrappers usable as label in Label/Button etc.
Claus Gittinger <cg@exept.de>
parents: 265
diff changeset
   160
                        lineStyle:#dashed)).
e9d35cd74f64 wrappers usable as label in Label/Button etc.
Claus Gittinger <cg@exept.de>
parents: 265
diff changeset
   161
    b open.
e9d35cd74f64 wrappers usable as label in Label/Button etc.
Claus Gittinger <cg@exept.de>
parents: 265
diff changeset
   162
                                                                        [exEnd]
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
8d7f9a8d2c78 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   166
!FillingWrapper methodsFor:'displaying'!
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
246
9f80dbcbcd34 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 245
diff changeset
   169
    "display myself - here, display the geometric object asFilled"
9f80dbcbcd34 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 245
diff changeset
   170
2635
dd576df334a4 refactored
Claus Gittinger <cg@exept.de>
parents: 1789
diff changeset
   171
    self displayFilledOn: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
8d7f9a8d2c78 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   174
!FillingWrapper class methodsFor:'documentation'!
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
2635
dd576df334a4 refactored
Claus Gittinger <cg@exept.de>
parents: 1789
diff changeset
   177
    ^ '$Header: /cvs/stx/stx/libview2/FillingWrapper.st,v 1.12 2009-05-06 07:29:44 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: 2635
diff changeset
   179