GraphicsContext.st
author Claus Gittinger <cg@exept.de>
Sun, 12 May 1996 19:42:55 +0200
changeset 671 1bca26786912
parent 657 1394e675b34d
child 678 a0e9b66778d6
permissions -rw-r--r--
checkin from browser
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
48194c26a46c Initial revision
claus
parents:
diff changeset
     1
"
6
7ee0cfde237d *** empty log message ***
claus
parents: 5
diff changeset
     2
 COPYRIGHT (c) 1992 by Claus Gittinger
71
6a42b2b115f8 *** empty log message ***
claus
parents: 54
diff changeset
     3
	      All Rights Reserved
0
48194c26a46c Initial revision
claus
parents:
diff changeset
     4
48194c26a46c Initial revision
claus
parents:
diff changeset
     5
 This software is furnished under a license and may be used
48194c26a46c Initial revision
claus
parents:
diff changeset
     6
 only in accordance with the terms of that license and with the
48194c26a46c Initial revision
claus
parents:
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
48194c26a46c Initial revision
claus
parents:
diff changeset
     8
 be provided or otherwise made available to, or used by, any
48194c26a46c Initial revision
claus
parents:
diff changeset
     9
 other person.  No title to or ownership of the software is
48194c26a46c Initial revision
claus
parents:
diff changeset
    10
 hereby transferred.
48194c26a46c Initial revision
claus
parents:
diff changeset
    11
"
48194c26a46c Initial revision
claus
parents:
diff changeset
    12
48194c26a46c Initial revision
claus
parents:
diff changeset
    13
Object subclass:#GraphicsContext
519
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
    14
	instanceVariableNames:'paint bgPaint function font lineStyle lineWidth joinStyle
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
    15
		capStyle mask maskOrigin transformation'
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
    16
	classVariableNames:'White Black DefaultFont'
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
    17
	poolDictionaries:''
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
    18
	category:'Graphics-Support'
0
48194c26a46c Initial revision
claus
parents:
diff changeset
    19
!
48194c26a46c Initial revision
claus
parents:
diff changeset
    20
46
7b331e9012fd *** empty log message ***
claus
parents: 35
diff changeset
    21
!GraphicsContext class methodsFor:'documentation'!
7b331e9012fd *** empty log message ***
claus
parents: 35
diff changeset
    22
7b331e9012fd *** empty log message ***
claus
parents: 35
diff changeset
    23
copyright
7b331e9012fd *** empty log message ***
claus
parents: 35
diff changeset
    24
"
7b331e9012fd *** empty log message ***
claus
parents: 35
diff changeset
    25
 COPYRIGHT (c) 1992 by Claus Gittinger
71
6a42b2b115f8 *** empty log message ***
claus
parents: 54
diff changeset
    26
	      All Rights Reserved
46
7b331e9012fd *** empty log message ***
claus
parents: 35
diff changeset
    27
7b331e9012fd *** empty log message ***
claus
parents: 35
diff changeset
    28
 This software is furnished under a license and may be used
7b331e9012fd *** empty log message ***
claus
parents: 35
diff changeset
    29
 only in accordance with the terms of that license and with the
7b331e9012fd *** empty log message ***
claus
parents: 35
diff changeset
    30
 inclusion of the above copyright notice.   This software may not
7b331e9012fd *** empty log message ***
claus
parents: 35
diff changeset
    31
 be provided or otherwise made available to, or used by, any
7b331e9012fd *** empty log message ***
claus
parents: 35
diff changeset
    32
 other person.  No title to or ownership of the software is
7b331e9012fd *** empty log message ***
claus
parents: 35
diff changeset
    33
 hereby transferred.
7b331e9012fd *** empty log message ***
claus
parents: 35
diff changeset
    34
"
7b331e9012fd *** empty log message ***
claus
parents: 35
diff changeset
    35
!
7b331e9012fd *** empty log message ***
claus
parents: 35
diff changeset
    36
7b331e9012fd *** empty log message ***
claus
parents: 35
diff changeset
    37
documentation
7b331e9012fd *** empty log message ***
claus
parents: 35
diff changeset
    38
"
7b331e9012fd *** empty log message ***
claus
parents: 35
diff changeset
    39
    this is an abstract superclass for all kinds of graphic drawables -
7b331e9012fd *** empty log message ***
claus
parents: 35
diff changeset
    40
    both windows and printed pages (i.e. printers) are inheriting from
7b331e9012fd *** empty log message ***
claus
parents: 35
diff changeset
    41
    this class (even drawables not at all associated with any device would do so).
7b331e9012fd *** empty log message ***
claus
parents: 35
diff changeset
    42
76
db983d8d7e53 scaling
claus
parents: 71
diff changeset
    43
    Drawing is done in paint/bgPaint colors, which can be true colors (i.e.
db983d8d7e53 scaling
claus
parents: 71
diff changeset
    44
    directly supported by the underlying hardware) or simulated colors
db983d8d7e53 scaling
claus
parents: 71
diff changeset
    45
    (i.e. dithered colors or images).
db983d8d7e53 scaling
claus
parents: 71
diff changeset
    46
    The paint/bgPaint instance variables are set to the logical colors,
db983d8d7e53 scaling
claus
parents: 71
diff changeset
    47
    device specific drawable may like to keep actual colors in addition.
71
6a42b2b115f8 *** empty log message ***
claus
parents: 54
diff changeset
    48
6a42b2b115f8 *** empty log message ***
claus
parents: 54
diff changeset
    49
    The transformation instance variable is typically nil, for a 1-to-1
6a42b2b115f8 *** empty log message ***
claus
parents: 54
diff changeset
    50
    coordinate mapping (i.e. x/y coordinates are pixels in the drawable).
6a42b2b115f8 *** empty log message ***
claus
parents: 54
diff changeset
    51
    If nonNil, the transformation must be an  instance of WindowingTransformation
6a42b2b115f8 *** empty log message ***
claus
parents: 54
diff changeset
    52
    and offers both a scale-factor and a translation.
6a42b2b115f8 *** empty log message ***
claus
parents: 54
diff changeset
    53
    Also, drawing in metric- or inch-units can be done using transformations.
6a42b2b115f8 *** empty log message ***
claus
parents: 54
diff changeset
    54
    (see instance creation methods of WindowingTransformation, and examples
6a42b2b115f8 *** empty log message ***
claus
parents: 54
diff changeset
    55
     in 'doc/coding').
46
7b331e9012fd *** empty log message ***
claus
parents: 35
diff changeset
    56
7b331e9012fd *** empty log message ***
claus
parents: 35
diff changeset
    57
    All drawing is defined upon a few basic drawing methods, which must be 
7b331e9012fd *** empty log message ***
claus
parents: 35
diff changeset
    58
    implemented by subclasses (some subclasses also redefine the others for
7b331e9012fd *** empty log message ***
claus
parents: 35
diff changeset
    59
    more performance)
7b331e9012fd *** empty log message ***
claus
parents: 35
diff changeset
    60
611
e0442439a3c6 documentation
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
    61
    [Instance variables:]
46
7b331e9012fd *** empty log message ***
claus
parents: 35
diff changeset
    62
611
e0442439a3c6 documentation
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
    63
        paint           <Color>         the paint used for drawing
e0442439a3c6 documentation
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
    64
        bgPaint         <Color>         the background used for drawing texts and bitmaps
e0442439a3c6 documentation
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
    65
        function        <Symbol>        the drawing function (i.e. #copy, #or, #xor ...)
e0442439a3c6 documentation
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
    66
                                        - not all Drawables support every function
e0442439a3c6 documentation
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
    67
                                        (i.e. paper only allows #copy)
e0442439a3c6 documentation
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
    68
        font            <Font>          the current font to be used for drawing
e0442439a3c6 documentation
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
    69
        lineStyle       <Symbol>        the lineStyle (i.e. #solid, #dashed, #doubleDashed)
e0442439a3c6 documentation
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
    70
        lineWidth       <SmallInteger>  the lineWidth (device dependent, usually pixels)
e0442439a3c6 documentation
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
    71
        joinStyle       <Symbol>        the style in which lines (in polygons)
e0442439a3c6 documentation
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
    72
                                        are joined (i.e. #miter, #bevel, #round)
e0442439a3c6 documentation
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
    73
        capStyle        <Symbol>        the style in which the last point of a line is drawn
e0442439a3c6 documentation
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
    74
                                        (i.e. #notLast, #butt, #round, #projecting)
e0442439a3c6 documentation
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
    75
        mask            <Form>          a mask used for drawing
e0442439a3c6 documentation
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
    76
                                        - not all Drawables support it
e0442439a3c6 documentation
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
    77
        maskOrigin      <Point>         the origin of the mask relative to
e0442439a3c6 documentation
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
    78
                                        the drawables origin
46
7b331e9012fd *** empty log message ***
claus
parents: 35
diff changeset
    79
611
e0442439a3c6 documentation
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
    80
    [Class variables:[
e0442439a3c6 documentation
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
    81
e0442439a3c6 documentation
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
    82
        White           <Color>         cached white color - its needed so often
e0442439a3c6 documentation
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
    83
        Black           <Color>         cached black color - its needed so often
46
7b331e9012fd *** empty log message ***
claus
parents: 35
diff changeset
    84
611
e0442439a3c6 documentation
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
    85
        DefaultFont     <Font>          default font to use
46
7b331e9012fd *** empty log message ***
claus
parents: 35
diff changeset
    86
611
e0442439a3c6 documentation
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
    87
    [author:]
e0442439a3c6 documentation
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
    88
        Claus Gittinger
657
Claus Gittinger <cg@exept.de>
parents: 653
diff changeset
    89
Claus Gittinger <cg@exept.de>
parents: 653
diff changeset
    90
    [see also:]
Claus Gittinger <cg@exept.de>
parents: 653
diff changeset
    91
        Color Font Form Image
Claus Gittinger <cg@exept.de>
parents: 653
diff changeset
    92
        Geometric
Claus Gittinger <cg@exept.de>
parents: 653
diff changeset
    93
        DeviceWorkstation
46
7b331e9012fd *** empty log message ***
claus
parents: 35
diff changeset
    94
"
563
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
    95
!
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
    96
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
    97
examples
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
    98
"
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
    99
    drawing uses a paint color (which may be a dithered one) which is
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   100
    used like a `pen'. 
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   101
    A few drawing operations (opaqueForm and opaqueString drawing)
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   102
    use two colors, the paint and a backgroundPaint. For example,
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   103
    normal string drawing (#displayString:...) only draws the fonts
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   104
    on-pixels in the current paint, leaving off-pixels unchanged.
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   105
    In contrast, #drawOpaqueString:.. also changes these to the bgPaint color.
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   106
    The bgPaint can be changed with #backgroundPaint: or #paint:on: (which modifies both).
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   107
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   108
    lets try it in a view:
619
a46cb2ef56bf examples
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   109
                                                                        [exBegin]
563
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   110
        |v|
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   111
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   112
        v := View new.
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   113
        v openAndWait.
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   114
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   115
        v paint:(Color red).
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   116
        v displayString:'hello' x:10 y:50
619
a46cb2ef56bf examples
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   117
                                                                        [exEnd]
563
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   118
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   119
    the same using opaque drawing:
619
a46cb2ef56bf examples
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   120
                                                                        [exBegin]
563
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   121
        |v|
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   122
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   123
        v := View new.
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   124
        v openAndWait.
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   125
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   126
        v paint:(Color red) on:(Color yellow).
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   127
        v displayOpaqueString:'hello' x:10 y:50
619
a46cb2ef56bf examples
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   128
                                                                        [exEnd]
563
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   129
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   130
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   131
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   132
    Lines are drawn using the paint color (if solid) or both paint and bgPaint
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   133
    (dashed lines). The look of the line is controlled by joinStyle, capStyle,
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   134
    lineWidth and lineStyle.
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   135
    `lineStyle' can be one of #solid, #dashed, #doubleDashed
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   136
    where: #solid        - is for solid lines, drawn with the current paint color 
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   137
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   138
           #dashed       - for dashed lines, where only the on-dashes are drawn
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   139
                           with the current paint color
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   140
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   141
           #doubleDashed - dashed lines, draws on-dashes with paint color,
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   142
                           off-dashes with bgPaint
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   143
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   144
    for example:
619
a46cb2ef56bf examples
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   145
                                                                        [exBegin]
563
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   146
        |v|
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   147
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   148
        v := View new.
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   149
        v openAndWait.
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   150
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   151
        v paint:(Color red) on:(Color blue).
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   152
        v displayLineFrom:(10@10) to:(90@90).
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   153
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   154
        v lineStyle:#dashed.
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   155
        v displayLineFrom:(90@10) to:(10@90).
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   156
        
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   157
        v lineStyle:#doubleDashed.
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   158
        v displayRectangle:((5@5) corner:(95@95)).
619
a46cb2ef56bf examples
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   159
                                                                        [exEnd]
563
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   160
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   161
    changing the line-width:
619
a46cb2ef56bf examples
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   162
                                                                        [exBegin]
563
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   163
        |v|
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   164
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   165
        v := View new.
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   166
        v openAndWait.
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   167
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   168
        v paint:(Color red).
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   169
        v displayLineFrom:(20@20) to:(80@80).
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   170
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   171
        v lineWidth:5.
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   172
        v displayLineFrom:(80@20) to:(20@80).
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   173
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   174
        v lineWidth:8.
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   175
        v displayRectangle:((5@5) corner:(95@95)).
619
a46cb2ef56bf examples
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   176
                                                                        [exEnd]
563
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   177
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   178
    with wide lines, the corners (of polygons or rectangles) can be
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   179
    one of the joinStyles: #miter, #bevel, #round. The default is #miter.
619
a46cb2ef56bf examples
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   180
                                                                        [exBegin]
563
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   181
        |v|
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   182
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   183
        v := View new extent:200@200.
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   184
        v openAndWait.
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   185
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   186
        v lineWidth:15.
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   187
        v paint:(Color red).
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   188
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   189
        v displayRectangle:((65@65) corner:(135@135)).
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   190
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   191
        v joinStyle:#bevel.
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   192
        v displayRectangle:((45@45) corner:(155@155)).
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   193
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   194
        v joinStyle:#round.
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   195
        v displayRectangle:((25@25) corner:(175@175)).
619
a46cb2ef56bf examples
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   196
                                                                        [exEnd]
563
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   197
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   198
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   199
    the endPoints look is controlled with capStyle;
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   200
    possible values are: #notLast, #butt, #round, #projecting.
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   201
    The default is #butt. 
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   202
    #notLast is mostly useful when exoring (inverting): it will not draw the
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   203
    endPoint, to allow another line to join the previous line without inverting
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   204
    this point twice. (See the X manual for more info).
619
a46cb2ef56bf examples
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   205
                                                                        [exBegin]
563
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   206
        |v|
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   207
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   208
        v := View new extent:200@200.
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   209
        v openAndWait.
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   210
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   211
        v lineWidth:15.
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   212
        v paint:(Color red).
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   213
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   214
        v displayLineFrom:(25@25) to:(175@25).
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   215
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   216
        v capStyle:#round.
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   217
        v displayLineFrom:(25@55) to:(175@55).
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   218
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   219
        v capStyle:#projecting.
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   220
        v displayLineFrom:(25@85) to:(175@85).
619
a46cb2ef56bf examples
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   221
                                                                        [exEnd]
563
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   222
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   223
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   224
    You can use a bitmap as a point color:
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   225
    (this may be slow on some graphics devices, though)
619
a46cb2ef56bf examples
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   226
                                                                        [exBegin]
563
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   227
        |v|
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   228
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   229
        v := View new extent:200@200.
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   230
        v openAndWait.
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   231
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   232
        v lineWidth:15.
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   233
        v paint:(Image fromFile:'granite_small.tiff').
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   234
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   235
        v displayLineFrom:(25@25) to:(175@25).
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   236
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   237
        v capStyle:#round.
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   238
        v displayLineFrom:(25@55) to:(175@55).
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   239
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   240
        v capStyle:#projecting.
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   241
        v displayLineFrom:(25@85) to:(175@85).
619
a46cb2ef56bf examples
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   242
                                                                        [exEnd]
563
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   243
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   244
    all views support a translation and scale, so you can draw in another
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   245
    coordinate system:
619
a46cb2ef56bf examples
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   246
                                                                        [exBegin]
563
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   247
        |v|
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   248
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   249
        v := View new extent:200@200.
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   250
        v openAndWait.
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   251
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   252
        v displayForm:(Image fromFile:'SBrowser.xbm') x:10 y:10.
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   253
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   254
        v scale:(2@2); translation:50.
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   255
        v displayForm:(Image fromFile:'SBrowser.xbm') x:10 y:10.
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   256
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   257
        v scale:(0.5@0.5); translation:0.
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   258
        v displayForm:(Image fromFile:'SBrowser.xbm') x:10 y:10.
619
a46cb2ef56bf examples
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   259
                                                                        [exEnd]
563
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   260
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   261
    if scaling is on, it is often useful to be able to draw individual
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   262
    things unscaled - this still translates the position, but
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   263
    uses the unscaled font (for example, to draw strings in a graphic):
619
a46cb2ef56bf examples
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   264
                                                                        [exBegin]
563
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   265
        |v|
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   266
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   267
        v := View new extent:200@200.
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   268
        v openAndWait.
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   269
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   270
        v displayForm:(Image fromFile:'SBrowser.xbm') x:10 y:10.
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   271
        v displayString:'hello' x:50 y:40.
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   272
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   273
        v scale:(2@4).
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   274
        v displayForm:(Image fromFile:'SBrowser.xbm') x:10 y:10.
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   275
        v displayUnscaledString:'hello' x:50 y:40.
619
a46cb2ef56bf examples
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   276
                                                                        [exEnd]
563
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   277
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   278
    Filled objects are drawin using the #fillXXX methods; for example,
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   279
    displayRectangleXXX draws the outline, while fillRectangleXXX draws a
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   280
    filled one:
619
a46cb2ef56bf examples
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   281
                                                                        [exBegin]
563
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   282
        |v|
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   283
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   284
        v := View new extent:200@200.
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   285
        v openAndWait.
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   286
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   287
        v displayArcIn:(20@20 corner:50@50) from:0 angle:180.
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   288
        v paint:Color yellow.
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   289
        v fillArcIn:(120@120 corner:150@150) from:0 angle:180.
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   290
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   291
        v paint:Color red.
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   292
        v displayCircle:150@50 radius:30.
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   293
        v paint:Color blue.
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   294
        v fillCircle:50@150 radius:30.
619
a46cb2ef56bf examples
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   295
                                                                        [exEnd]
a46cb2ef56bf examples
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   296
a46cb2ef56bf examples
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   297
    polygons:
a46cb2ef56bf examples
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   298
                                                                        [exBegin]
a46cb2ef56bf examples
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   299
        |v poly1 poly2|
a46cb2ef56bf examples
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   300
a46cb2ef56bf examples
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   301
        poly1 := OrderedCollection new.
a46cb2ef56bf examples
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   302
        poly1 add:(10 @ 10).
a46cb2ef56bf examples
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   303
        poly1 add:(100 @ 50).
a46cb2ef56bf examples
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   304
        poly1 add:(50 @ 50).
a46cb2ef56bf examples
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   305
        poly1 add:(20 @ 100).
a46cb2ef56bf examples
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   306
        poly1 add:(10 @ 100).
a46cb2ef56bf examples
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   307
a46cb2ef56bf examples
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   308
        poly2 := poly1 copy.
a46cb2ef56bf examples
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   309
        poly2 add:(poly2 first).
a46cb2ef56bf examples
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   310
a46cb2ef56bf examples
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   311
        v := View new extent:200@200.
a46cb2ef56bf examples
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   312
        v openAndWait.
a46cb2ef56bf examples
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   313
a46cb2ef56bf examples
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   314
        v scale:2.
a46cb2ef56bf examples
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   315
        v paint:Color red.
a46cb2ef56bf examples
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   316
        v fillPolygon:poly1.
a46cb2ef56bf examples
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   317
a46cb2ef56bf examples
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   318
        v scale:1.
a46cb2ef56bf examples
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   319
        v paint:Color blue.
a46cb2ef56bf examples
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   320
        v displayPolygon:poly2.
a46cb2ef56bf examples
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   321
a46cb2ef56bf examples
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   322
        v scale:0.5.
a46cb2ef56bf examples
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   323
        v paint:Color yellow.
a46cb2ef56bf examples
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   324
        v fillPolygon:poly1.
a46cb2ef56bf examples
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   325
a46cb2ef56bf examples
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   326
                                                                        [exEnd]
563
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   327
"
46
7b331e9012fd *** empty log message ***
claus
parents: 35
diff changeset
   328
! !
7b331e9012fd *** empty log message ***
claus
parents: 35
diff changeset
   329
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   330
!GraphicsContext class methodsFor:'initialization'!
48194c26a46c Initial revision
claus
parents:
diff changeset
   331
48194c26a46c Initial revision
claus
parents:
diff changeset
   332
initialize
48194c26a46c Initial revision
claus
parents:
diff changeset
   333
    "setup some defaults - these are usually redefined
48194c26a46c Initial revision
claus
parents:
diff changeset
   334
     during startup."
48194c26a46c Initial revision
claus
parents:
diff changeset
   335
134
claus
parents: 109
diff changeset
   336
    White isNil ifTrue:[
386
f9a80cac659e only init once
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   337
	Color isNil ifTrue:[^ self].
f9a80cac659e only init once
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   338
	Display isNil ifTrue:[^ self].
f9a80cac659e only init once
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   339
134
claus
parents: 109
diff changeset
   340
	Color initialize.
46
7b331e9012fd *** empty log message ***
claus
parents: 35
diff changeset
   341
134
claus
parents: 109
diff changeset
   342
	White := Color white on:Display.
claus
parents: 109
diff changeset
   343
	Black := Color black on:Display.
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   344
134
claus
parents: 109
diff changeset
   345
	Font initialize.
claus
parents: 109
diff changeset
   346
	DefaultFont := Font family:'courier' face:'medium' style:'roman' size:12
claus
parents: 109
diff changeset
   347
    ]
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   348
! !
48194c26a46c Initial revision
claus
parents:
diff changeset
   349
519
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   350
!GraphicsContext class methodsFor:'instance creation'!
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   351
519
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   352
new
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   353
    "return a new instance of myself. Redefined to initialize
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   354
     the new thingy"
12
9f0995fac1fa *** empty log message ***
claus
parents: 6
diff changeset
   355
519
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   356
    ^ self basicNew initialize
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   357
! !
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   358
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   359
!GraphicsContext class methodsFor:'accessing defaults'!
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   360
48194c26a46c Initial revision
claus
parents:
diff changeset
   361
defaultFont
12
9f0995fac1fa *** empty log message ***
claus
parents: 6
diff changeset
   362
    "get the default font used for drawing"
9f0995fac1fa *** empty log message ***
claus
parents: 6
diff changeset
   363
71
6a42b2b115f8 *** empty log message ***
claus
parents: 54
diff changeset
   364
    DefaultFont isNil ifTrue:[
6a42b2b115f8 *** empty log message ***
claus
parents: 54
diff changeset
   365
	DefaultFont := Font family:'courier' face:'medium' style:'roman' size:12
6a42b2b115f8 *** empty log message ***
claus
parents: 54
diff changeset
   366
    ].
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   367
    ^ DefaultFont
519
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   368
!
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   369
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   370
defaultFont:aFont
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   371
    "set the default font used for drawing"
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   372
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   373
    DefaultFont := aFont
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   374
! !
48194c26a46c Initial revision
claus
parents:
diff changeset
   375
48194c26a46c Initial revision
claus
parents:
diff changeset
   376
!GraphicsContext class methodsFor:'constants'!
48194c26a46c Initial revision
claus
parents:
diff changeset
   377
519
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   378
capButt
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   379
    "return a constant to specify butt cap"
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   380
519
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   381
    ^ #butt
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   382
!
48194c26a46c Initial revision
claus
parents:
diff changeset
   383
48194c26a46c Initial revision
claus
parents:
diff changeset
   384
capNotLast
48194c26a46c Initial revision
claus
parents:
diff changeset
   385
    "return a constant to specify not-last cap"
48194c26a46c Initial revision
claus
parents:
diff changeset
   386
48194c26a46c Initial revision
claus
parents:
diff changeset
   387
    ^ #notLast
48194c26a46c Initial revision
claus
parents:
diff changeset
   388
!
48194c26a46c Initial revision
claus
parents:
diff changeset
   389
48194c26a46c Initial revision
claus
parents:
diff changeset
   390
capProjecting
48194c26a46c Initial revision
claus
parents:
diff changeset
   391
    "return a constant to specify projecting cap"
48194c26a46c Initial revision
claus
parents:
diff changeset
   392
48194c26a46c Initial revision
claus
parents:
diff changeset
   393
    ^ #projecting
48194c26a46c Initial revision
claus
parents:
diff changeset
   394
!
48194c26a46c Initial revision
claus
parents:
diff changeset
   395
48194c26a46c Initial revision
claus
parents:
diff changeset
   396
capRound
48194c26a46c Initial revision
claus
parents:
diff changeset
   397
    "return a constant to specify round cap"
48194c26a46c Initial revision
claus
parents:
diff changeset
   398
48194c26a46c Initial revision
claus
parents:
diff changeset
   399
    ^ #round
48194c26a46c Initial revision
claus
parents:
diff changeset
   400
!
48194c26a46c Initial revision
claus
parents:
diff changeset
   401
519
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   402
joinBevel
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   403
    "return a constant to specify bevel join"
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   404
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   405
    ^ #bevel
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   406
!
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   407
519
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   408
joinMiter
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   409
    "return a constant to specify miter join"
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   410
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   411
    ^ #miter
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   412
!
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   413
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   414
joinRound
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   415
    "return a constant to specify round join"
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   416
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   417
    ^ #round
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   418
! !
48194c26a46c Initial revision
claus
parents:
diff changeset
   419
519
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   420
!GraphicsContext methodsFor:'ST-80 compatibility'!
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   421
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   422
findFont:aFontDescription
585
426d2018cdc8 commentary
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   423
    "given a fontDescription, return a device font for it
426d2018cdc8 commentary
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   424
     on my device."
426d2018cdc8 commentary
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   425
519
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   426
    ^ aFontDescription on:self device
585
426d2018cdc8 commentary
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   427
426d2018cdc8 commentary
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   428
    "Modified: 22.4.1996 / 19:45:41 / cg"
519
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   429
!
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   430
519
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   431
widthOfString:aString
585
426d2018cdc8 commentary
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   432
    "given a string, return its width in pixels if
426d2018cdc8 commentary
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   433
     drawn on the receivers device."
426d2018cdc8 commentary
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   434
519
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   435
    ^ (font on:self device) widthOf:aString
585
426d2018cdc8 commentary
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   436
426d2018cdc8 commentary
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   437
    "Modified: 22.4.1996 / 19:46:10 / cg"
519
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   438
!
109
ba47d9d6bda8 *** empty log message ***
claus
parents: 81
diff changeset
   439
519
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   440
widthOfString:aString from:start to:stop
585
426d2018cdc8 commentary
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   441
    "given a string, return the width in pixels if
426d2018cdc8 commentary
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   442
     a substring is drawn on the receivers device."
426d2018cdc8 commentary
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   443
519
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   444
    ^ (font on:self device) widthOf:aString from:start to:stop
585
426d2018cdc8 commentary
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   445
426d2018cdc8 commentary
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   446
    "Modified: 22.4.1996 / 19:46:25 / cg"
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   447
! !
48194c26a46c Initial revision
claus
parents:
diff changeset
   448
519
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   449
!GraphicsContext methodsFor:'ST-80 displaying'!
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   450
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   451
displayArc:origin radius:radius from:startAngle angle:angle
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   452
    "draw an arc around a point"
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   453
653
0ad3de022f8b fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents: 619
diff changeset
   454
    self 
0ad3de022f8b fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents: 619
diff changeset
   455
        displayArcX:(origin x - radius)
0ad3de022f8b fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents: 619
diff changeset
   456
                  y:(origin y - radius)
0ad3de022f8b fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents: 619
diff changeset
   457
              width:(radius * 2) 
0ad3de022f8b fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents: 619
diff changeset
   458
             height:(radius * 2)
0ad3de022f8b fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents: 619
diff changeset
   459
               from:startAngle 
0ad3de022f8b fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents: 619
diff changeset
   460
              angle:angle
0ad3de022f8b fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents: 619
diff changeset
   461
0ad3de022f8b fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents: 619
diff changeset
   462
    "Modified: 8.5.1996 / 08:34:43 / cg"
519
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   463
!
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   464
519
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   465
displayArcBoundedBy:boundingBox startAngle:startAngle sweepAngle:sweepAngle at:origin
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   466
   "draw an arc/circle/ellipse - ST-80 compatibility"                                
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   467
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   468
   ^ self displayArcX:(boundingBox left + origin x)
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   469
		    y:(boundingBox top + origin y)
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   470
		width:(boundingBox width)
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   471
	       height:(boundingBox height)
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   472
		 from:startAngle
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   473
		angle:sweepAngle
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   474
!
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   475
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   476
displayLineFrom:startPoint to:endPoint translateBy:anOffset
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   477
    "draw a line - ST-80 compatibility"
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   478
519
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   479
    self displayLineFrom:(startPoint + anOffset)
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   480
		      to:(endPoint + anOffset)
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   481
!
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   482
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   483
displayPolyline:aPolygon
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   484
    "draw a polygon - ST-80 compatibility"
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   485
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   486
    ^ self displayPolygon:aPolygon 
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   487
!
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   488
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   489
displayRectangularBorder:aRectangle at:aPoint
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   490
    "draw a rectangle - ST-80 compatibility"
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   491
519
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   492
    self displayRectangle:(aRectangle translateBy:aPoint)
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   493
!
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   494
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   495
displayWedgeBoundedBy:boundingBox startAngle:startAngle sweepAngle:sweepAngle at:origin
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   496
   "fill an arc/circle/ellipse - ST-80 compatibility"
2
b35336ab0de3 *** empty log message ***
claus
parents: 0
diff changeset
   497
519
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   498
   ^ self fillArcX:(boundingBox left + origin x)
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   499
		 y:(boundingBox top + origin y)
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   500
	     width:(boundingBox width)
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   501
	    height:(boundingBox height)
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   502
	      from:startAngle
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   503
	     angle:sweepAngle
2
b35336ab0de3 *** empty log message ***
claus
parents: 0
diff changeset
   504
! !
b35336ab0de3 *** empty log message ***
claus
parents: 0
diff changeset
   505
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   506
!GraphicsContext methodsFor:'accessing'!
48194c26a46c Initial revision
claus
parents:
diff changeset
   507
48194c26a46c Initial revision
claus
parents:
diff changeset
   508
backgroundPaint
48194c26a46c Initial revision
claus
parents:
diff changeset
   509
    "return the background paint color.
48194c26a46c Initial revision
claus
parents:
diff changeset
   510
     (used for opaqueForms and opaqueStrings)"
48194c26a46c Initial revision
claus
parents:
diff changeset
   511
48194c26a46c Initial revision
claus
parents:
diff changeset
   512
    ^ bgPaint
48194c26a46c Initial revision
claus
parents:
diff changeset
   513
!
48194c26a46c Initial revision
claus
parents:
diff changeset
   514
48194c26a46c Initial revision
claus
parents:
diff changeset
   515
backgroundPaint:aColor
48194c26a46c Initial revision
claus
parents:
diff changeset
   516
    "set the background painting color (which is used for
48194c26a46c Initial revision
claus
parents:
diff changeset
   517
     opaqueForms and opaqueStrings). aColor can be a dithered one."
48194c26a46c Initial revision
claus
parents:
diff changeset
   518
48194c26a46c Initial revision
claus
parents:
diff changeset
   519
    ^ self subclassResponsibility
48194c26a46c Initial revision
claus
parents:
diff changeset
   520
!
48194c26a46c Initial revision
claus
parents:
diff changeset
   521
48194c26a46c Initial revision
claus
parents:
diff changeset
   522
capStyle
48194c26a46c Initial revision
claus
parents:
diff changeset
   523
    "return the current cap-style for line-drawing"
48194c26a46c Initial revision
claus
parents:
diff changeset
   524
48194c26a46c Initial revision
claus
parents:
diff changeset
   525
    ^ capStyle
48194c26a46c Initial revision
claus
parents:
diff changeset
   526
!
48194c26a46c Initial revision
claus
parents:
diff changeset
   527
48194c26a46c Initial revision
claus
parents:
diff changeset
   528
capStyle:aStyleSymbol
48194c26a46c Initial revision
claus
parents:
diff changeset
   529
    "set the cap-style for line-drawing;
48194c26a46c Initial revision
claus
parents:
diff changeset
   530
     possible styles are: #notLast, #butt, #round, #projecting"
48194c26a46c Initial revision
claus
parents:
diff changeset
   531
48194c26a46c Initial revision
claus
parents:
diff changeset
   532
    ^ self subclassResponsibility
48194c26a46c Initial revision
claus
parents:
diff changeset
   533
!
48194c26a46c Initial revision
claus
parents:
diff changeset
   534
76
db983d8d7e53 scaling
claus
parents: 71
diff changeset
   535
clipRect
db983d8d7e53 scaling
claus
parents: 71
diff changeset
   536
    "return the drawing clip-rectangle"
db983d8d7e53 scaling
claus
parents: 71
diff changeset
   537
db983d8d7e53 scaling
claus
parents: 71
diff changeset
   538
    ^ self subclassResponsibility
db983d8d7e53 scaling
claus
parents: 71
diff changeset
   539
!
db983d8d7e53 scaling
claus
parents: 71
diff changeset
   540
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   541
clipRect:aRectangle
48194c26a46c Initial revision
claus
parents:
diff changeset
   542
    "set the drawing clip-rectangle"
48194c26a46c Initial revision
claus
parents:
diff changeset
   543
48194c26a46c Initial revision
claus
parents:
diff changeset
   544
    ^ self subclassResponsibility
48194c26a46c Initial revision
claus
parents:
diff changeset
   545
!
48194c26a46c Initial revision
claus
parents:
diff changeset
   546
76
db983d8d7e53 scaling
claus
parents: 71
diff changeset
   547
clippingBounds
563
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   548
    "return the drawing clip-rectangle - name alias ST-80 compatibility"
76
db983d8d7e53 scaling
claus
parents: 71
diff changeset
   549
db983d8d7e53 scaling
claus
parents: 71
diff changeset
   550
    ^ self clipRect
563
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   551
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   552
    "Modified: 13.4.1996 / 20:13:04 / cg"
76
db983d8d7e53 scaling
claus
parents: 71
diff changeset
   553
!
db983d8d7e53 scaling
claus
parents: 71
diff changeset
   554
561
3c1ec7798f77 added #clippingRectangleOrNil for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 519
diff changeset
   555
clippingRectangleOrNil
563
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   556
    "return the drawing clip-rectangle, or nil if there is none"
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   557
561
3c1ec7798f77 added #clippingRectangleOrNil for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 519
diff changeset
   558
    ^ self subclassResponsibility
3c1ec7798f77 added #clippingRectangleOrNil for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 519
diff changeset
   559
3c1ec7798f77 added #clippingRectangleOrNil for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 519
diff changeset
   560
    "Created: 10.4.1996 / 14:31:19 / cg"
563
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   561
    "Modified: 13.4.1996 / 20:12:43 / cg"
561
3c1ec7798f77 added #clippingRectangleOrNil for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 519
diff changeset
   562
!
3c1ec7798f77 added #clippingRectangleOrNil for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 519
diff changeset
   563
519
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   564
font
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   565
    "return the current drawing font"
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   566
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   567
    ^ font
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   568
!
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   569
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   570
font:aFont
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   571
    "set the drawing font"
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   572
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   573
    ^ self subclassResponsibility
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   574
!
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   575
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   576
function
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   577
    "return the current drawing function"
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   578
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   579
    ^ function
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   580
!
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   581
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   582
function:aFunctionSymbol
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   583
    "set the drawing function"
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   584
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   585
    ^ self subclassResponsibility
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   586
!
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   587
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   588
graphicsContext
48194c26a46c Initial revision
claus
parents:
diff changeset
   589
    "for ST-80 compatibility"
48194c26a46c Initial revision
claus
parents:
diff changeset
   590
48194c26a46c Initial revision
claus
parents:
diff changeset
   591
    ^ self
2
b35336ab0de3 *** empty log message ***
claus
parents: 0
diff changeset
   592
!
b35336ab0de3 *** empty log message ***
claus
parents: 0
diff changeset
   593
519
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   594
joinStyle
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   595
    "return the current join-style for polygon-drawing"
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   596
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   597
    ^ joinStyle
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   598
!
12
9f0995fac1fa *** empty log message ***
claus
parents: 6
diff changeset
   599
519
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   600
joinStyle:aStyleSymbol
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   601
    "set the join-style of lines in polygon-drawing;
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   602
     possible styles are: #miter, #bevel, #round"
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   603
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   604
    ^ self subclassResponsibility
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   605
!
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   606
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   607
lineStyle
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   608
    "return the current line-drawing-style"
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   609
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   610
    ^ lineStyle
2
b35336ab0de3 *** empty log message ***
claus
parents: 0
diff changeset
   611
!
b35336ab0de3 *** empty log message ***
claus
parents: 0
diff changeset
   612
519
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   613
lineStyle:aStyleSymbol
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   614
    "set the line-drawing-style;
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   615
     possible styles are: #solid, #dashed, #doubleDashed"
151
claus
parents: 134
diff changeset
   616
519
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   617
    lineStyle := aStyleSymbol
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   618
!
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   619
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   620
lineWidth
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   621
    "return the current drawing linewidth"
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   622
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   623
    ^ lineWidth
151
claus
parents: 134
diff changeset
   624
!
claus
parents: 134
diff changeset
   625
519
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   626
lineWidth:aNumber
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   627
    "set the line drawing width in pixels"
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   628
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   629
    lineWidth := aNumber
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   630
!
151
claus
parents: 134
diff changeset
   631
519
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   632
mask
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   633
    "return the current drawing mask"
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   634
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   635
    ^ mask
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   636
!
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   637
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   638
mask:aForm
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   639
    "set the drawing mask"
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   640
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   641
    ^ self subclassResponsibility
151
claus
parents: 134
diff changeset
   642
!
claus
parents: 134
diff changeset
   643
claus
parents: 134
diff changeset
   644
maskOrigin
claus
parents: 134
diff changeset
   645
    "return the origin within the mask (used to draw with patterns).
claus
parents: 134
diff changeset
   646
     Should be redefined in classes which support it.
claus
parents: 134
diff changeset
   647
     This is an alias for ST-80's #phase"
claus
parents: 134
diff changeset
   648
claus
parents: 134
diff changeset
   649
    ^ maskOrigin
claus
parents: 134
diff changeset
   650
!
claus
parents: 134
diff changeset
   651
claus
parents: 134
diff changeset
   652
maskOrigin:aPoint
claus
parents: 134
diff changeset
   653
    "set the origin within the mask (used to draw with patterns).
claus
parents: 134
diff changeset
   654
     Should be redefined in classes which support it.
claus
parents: 134
diff changeset
   655
     This is an alias for ST-80's #phase:"
claus
parents: 134
diff changeset
   656
claus
parents: 134
diff changeset
   657
    ^ self maskOriginX:aPoint x y:aPoint y
claus
parents: 134
diff changeset
   658
!
claus
parents: 134
diff changeset
   659
claus
parents: 134
diff changeset
   660
maskOriginX:x y:y 
claus
parents: 134
diff changeset
   661
    "set the origin within the mask (used to draw with patterns).
claus
parents: 134
diff changeset
   662
     Should be redefined in classes which support it.
claus
parents: 134
diff changeset
   663
     This is an alias for ST-80's #phase:"
109
ba47d9d6bda8 *** empty log message ***
claus
parents: 81
diff changeset
   664
12
9f0995fac1fa *** empty log message ***
claus
parents: 6
diff changeset
   665
    ^ self
9f0995fac1fa *** empty log message ***
claus
parents: 6
diff changeset
   666
!
9f0995fac1fa *** empty log message ***
claus
parents: 6
diff changeset
   667
519
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   668
paint
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   669
    "return the current paint drawing color"
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   670
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   671
    ^ paint
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   672
!
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   673
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   674
paint:aColor
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   675
    "set the drawing painting color, aColor can be a dithered one"
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   676
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   677
    paint := aColor
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   678
!
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   679
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   680
paint:fgColor on:bgColor
563
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   681
    "set the paint and backgroundPaint, used for text and bitmaps.
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   682
     Both colors may be dithered colors"
519
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   683
671
1bca26786912 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 657
diff changeset
   684
    fgColor ~~ paint ifTrue:[
1bca26786912 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 657
diff changeset
   685
        self paint:fgColor.
1bca26786912 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 657
diff changeset
   686
    ].
519
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   687
    bgPaint := bgColor
563
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   688
671
1bca26786912 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 657
diff changeset
   689
    "Modified: 12.5.1996 / 19:40:43 / cg"
519
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   690
!
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   691
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   692
phase
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   693
    "return the origin within the mask (used to draw with patterns).
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   694
     This is an alias for ST/X's #maskOrigin"
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   695
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   696
    ^ self maskOrigin
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   697
!
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   698
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   699
phase:aPoint
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   700
    "set the origin within the mask (used to draw with patterns).
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   701
     This is an alias for ST/X's #maskOrigin:"
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   702
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   703
    ^ self maskOrigin:aPoint
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   704
!
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   705
151
claus
parents: 134
diff changeset
   706
setMaskOrigin:aPoint
claus
parents: 134
diff changeset
   707
    "set the origin within the mask (used to draw with patterns).
claus
parents: 134
diff changeset
   708
     OBSOLETE: use #maskOrigin: or #phase:"
claus
parents: 134
diff changeset
   709
claus
parents: 134
diff changeset
   710
    ^ self maskOrigin:aPoint
claus
parents: 134
diff changeset
   711
!
claus
parents: 134
diff changeset
   712
2
b35336ab0de3 *** empty log message ***
claus
parents: 0
diff changeset
   713
setMaskOriginX:x y:y
109
ba47d9d6bda8 *** empty log message ***
claus
parents: 81
diff changeset
   714
    "set the origin within the mask (used to draw with patterns).
151
claus
parents: 134
diff changeset
   715
     OBSOLETE: use #maskOriginX:y: or #phase:"
109
ba47d9d6bda8 *** empty log message ***
claus
parents: 81
diff changeset
   716
151
claus
parents: 134
diff changeset
   717
    ^ self maskOriginX:x y:y 
2
b35336ab0de3 *** empty log message ***
claus
parents: 0
diff changeset
   718
!
b35336ab0de3 *** empty log message ***
claus
parents: 0
diff changeset
   719
519
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   720
viewOrigin
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   721
    "return the drawables visible origin (for scrolling)"
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   722
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   723
    ^ 0@0
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   724
!
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   725
2
b35336ab0de3 *** empty log message ***
claus
parents: 0
diff changeset
   726
withPattern:aForm do:aBlock
109
ba47d9d6bda8 *** empty log message ***
claus
parents: 81
diff changeset
   727
    "draw with a pattern.
ba47d9d6bda8 *** empty log message ***
claus
parents: 81
diff changeset
   728
     Should be redefined in classes which support it"
ba47d9d6bda8 *** empty log message ***
claus
parents: 81
diff changeset
   729
519
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   730
    'GC: pattern drawing not implemented' infoPrintNL.
71
6a42b2b115f8 *** empty log message ***
claus
parents: 54
diff changeset
   731
2
b35336ab0de3 *** empty log message ***
claus
parents: 0
diff changeset
   732
    aBlock value
519
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   733
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   734
    "Modified: 7.3.1996 / 19:17:05 / cg"
418
0e10e256d5b2 scale access methods moved from SimpleView
Claus Gittinger <cg@exept.de>
parents: 386
diff changeset
   735
! !
0e10e256d5b2 scale access methods moved from SimpleView
Claus Gittinger <cg@exept.de>
parents: 386
diff changeset
   736
0e10e256d5b2 scale access methods moved from SimpleView
Claus Gittinger <cg@exept.de>
parents: 386
diff changeset
   737
!GraphicsContext methodsFor:'accessing-transformation'!
0e10e256d5b2 scale access methods moved from SimpleView
Claus Gittinger <cg@exept.de>
parents: 386
diff changeset
   738
0e10e256d5b2 scale access methods moved from SimpleView
Claus Gittinger <cg@exept.de>
parents: 386
diff changeset
   739
scale
0e10e256d5b2 scale access methods moved from SimpleView
Claus Gittinger <cg@exept.de>
parents: 386
diff changeset
   740
    "return the scale factor (as point) of the transformation"
0e10e256d5b2 scale access methods moved from SimpleView
Claus Gittinger <cg@exept.de>
parents: 386
diff changeset
   741
0e10e256d5b2 scale access methods moved from SimpleView
Claus Gittinger <cg@exept.de>
parents: 386
diff changeset
   742
    transformation isNil ifTrue:[^ 1].
0e10e256d5b2 scale access methods moved from SimpleView
Claus Gittinger <cg@exept.de>
parents: 386
diff changeset
   743
    ^ transformation scale
0e10e256d5b2 scale access methods moved from SimpleView
Claus Gittinger <cg@exept.de>
parents: 386
diff changeset
   744
!
0e10e256d5b2 scale access methods moved from SimpleView
Claus Gittinger <cg@exept.de>
parents: 386
diff changeset
   745
0e10e256d5b2 scale access methods moved from SimpleView
Claus Gittinger <cg@exept.de>
parents: 386
diff changeset
   746
scale:aPoint
0e10e256d5b2 scale access methods moved from SimpleView
Claus Gittinger <cg@exept.de>
parents: 386
diff changeset
   747
    "set the scale factor of the transformation"
0e10e256d5b2 scale access methods moved from SimpleView
Claus Gittinger <cg@exept.de>
parents: 386
diff changeset
   748
0e10e256d5b2 scale access methods moved from SimpleView
Claus Gittinger <cg@exept.de>
parents: 386
diff changeset
   749
    transformation isNil ifTrue:[
619
a46cb2ef56bf examples
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   750
        aPoint = 1 ifTrue:[^ self].
a46cb2ef56bf examples
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   751
        transformation := WindowingTransformation scale:aPoint translation:0
a46cb2ef56bf examples
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   752
    ] ifFalse:[
a46cb2ef56bf examples
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   753
        transformation scale:aPoint.
a46cb2ef56bf examples
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   754
    ]
418
0e10e256d5b2 scale access methods moved from SimpleView
Claus Gittinger <cg@exept.de>
parents: 386
diff changeset
   755
619
a46cb2ef56bf examples
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   756
    "Modified: 27.4.1996 / 18:47:38 / cg"
76
db983d8d7e53 scaling
claus
parents: 71
diff changeset
   757
!
db983d8d7e53 scaling
claus
parents: 71
diff changeset
   758
db983d8d7e53 scaling
claus
parents: 71
diff changeset
   759
transformation 
db983d8d7e53 scaling
claus
parents: 71
diff changeset
   760
    "return the transformation"
db983d8d7e53 scaling
claus
parents: 71
diff changeset
   761
db983d8d7e53 scaling
claus
parents: 71
diff changeset
   762
    ^ transformation
db983d8d7e53 scaling
claus
parents: 71
diff changeset
   763
!
db983d8d7e53 scaling
claus
parents: 71
diff changeset
   764
db983d8d7e53 scaling
claus
parents: 71
diff changeset
   765
transformation:aTransformation 
db983d8d7e53 scaling
claus
parents: 71
diff changeset
   766
    "set the transformation"
db983d8d7e53 scaling
claus
parents: 71
diff changeset
   767
db983d8d7e53 scaling
claus
parents: 71
diff changeset
   768
    transformation := aTransformation
619
a46cb2ef56bf examples
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   769
!
a46cb2ef56bf examples
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   770
a46cb2ef56bf examples
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   771
translation
a46cb2ef56bf examples
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   772
    "return the translation factor (as point) of the transformation"
a46cb2ef56bf examples
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   773
a46cb2ef56bf examples
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   774
    transformation isNil ifTrue:[^ 0@0].
a46cb2ef56bf examples
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   775
    ^ transformation translation
a46cb2ef56bf examples
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   776
a46cb2ef56bf examples
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   777
    "Created: 27.4.1996 / 18:46:41 / cg"
a46cb2ef56bf examples
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   778
!
a46cb2ef56bf examples
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   779
a46cb2ef56bf examples
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   780
translation:aPoint
a46cb2ef56bf examples
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   781
    "set the translation offset of the transformation"
a46cb2ef56bf examples
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   782
a46cb2ef56bf examples
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   783
    transformation isNil ifTrue:[
a46cb2ef56bf examples
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   784
        aPoint = 0 ifTrue:[^ self].
a46cb2ef56bf examples
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   785
        transformation := WindowingTransformation scale:1 translation:aPoint
a46cb2ef56bf examples
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   786
    ] ifFalse:[
a46cb2ef56bf examples
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   787
        transformation translation:aPoint.
a46cb2ef56bf examples
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   788
    ]
a46cb2ef56bf examples
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   789
a46cb2ef56bf examples
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   790
    "Created: 27.4.1996 / 18:47:28 / cg"
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   791
! !
48194c26a46c Initial revision
claus
parents:
diff changeset
   792
71
6a42b2b115f8 *** empty log message ***
claus
parents: 54
diff changeset
   793
!GraphicsContext methodsFor:'basic displaying'!
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   794
653
0ad3de022f8b fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents: 619
diff changeset
   795
displayArcX:x y:y w:w h:h from:startAngle angle:angle
0ad3de022f8b fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents: 619
diff changeset
   796
    "draw an arc; apply transformation if nonNil"
0ad3de022f8b fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents: 619
diff changeset
   797
0ad3de022f8b fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents: 619
diff changeset
   798
    self obsoleteMethodWarning:'use #displayArcX:y:width:height:from:angle:'.
0ad3de022f8b fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents: 619
diff changeset
   799
    self displayArcX:x y:y width:w height:h from:startAngle angle:angle
0ad3de022f8b fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents: 619
diff changeset
   800
0ad3de022f8b fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents: 619
diff changeset
   801
    "Modified: 8.5.1996 / 08:46:56 / cg"
0ad3de022f8b fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents: 619
diff changeset
   802
!
0ad3de022f8b fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents: 619
diff changeset
   803
0ad3de022f8b fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents: 619
diff changeset
   804
displayArcX:x y:y width:width height:height from:startAngle angle:angle
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   805
    "draw an arc in a box
48194c26a46c Initial revision
claus
parents:
diff changeset
   806
     - this could be recoded to draw using displayLine"
48194c26a46c Initial revision
claus
parents:
diff changeset
   807
48194c26a46c Initial revision
claus
parents:
diff changeset
   808
    ^ self subclassResponsibility
653
0ad3de022f8b fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents: 619
diff changeset
   809
0ad3de022f8b fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents: 619
diff changeset
   810
    "Created: 8.5.1996 / 08:47:06 / cg"
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   811
!
48194c26a46c Initial revision
claus
parents:
diff changeset
   812
26
ac9f66dc8f53 *** empty log message ***
claus
parents: 24
diff changeset
   813
displayForm:aForm x:x y:y
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   814
    "draw a form at x/y; if the form has depth 1, 1's in the form are
48194c26a46c Initial revision
claus
parents:
diff changeset
   815
     drawn in current fg, 0's are ignored.
24
e810b1be068b *** empty log message ***
claus
parents: 12
diff changeset
   816
     If the form has depth ~~ 1, the result is undefined"
e810b1be068b *** empty log message ***
claus
parents: 12
diff changeset
   817
71
6a42b2b115f8 *** empty log message ***
claus
parents: 54
diff changeset
   818
    |fg bg f noColor|
24
e810b1be068b *** empty log message ***
claus
parents: 12
diff changeset
   819
71
6a42b2b115f8 *** empty log message ***
claus
parents: 54
diff changeset
   820
    fg := paint.
6a42b2b115f8 *** empty log message ***
claus
parents: 54
diff changeset
   821
    bg := bgPaint.
24
e810b1be068b *** empty log message ***
claus
parents: 12
diff changeset
   822
    f := function.
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   823
71
6a42b2b115f8 *** empty log message ***
claus
parents: 54
diff changeset
   824
    f ~~ #copy ifTrue:[
6a42b2b115f8 *** empty log message ***
claus
parents: 54
diff changeset
   825
	self error:'function not supported'.
6a42b2b115f8 *** empty log message ***
claus
parents: 54
diff changeset
   826
	^ self
6a42b2b115f8 *** empty log message ***
claus
parents: 54
diff changeset
   827
    ].
6a42b2b115f8 *** empty log message ***
claus
parents: 54
diff changeset
   828
6a42b2b115f8 *** empty log message ***
claus
parents: 54
diff changeset
   829
    noColor := Color noColor.
6a42b2b115f8 *** empty log message ***
claus
parents: 54
diff changeset
   830
    "
6a42b2b115f8 *** empty log message ***
claus
parents: 54
diff changeset
   831
     stamp out fg-pixels
6a42b2b115f8 *** empty log message ***
claus
parents: 54
diff changeset
   832
    "
6a42b2b115f8 *** empty log message ***
claus
parents: 54
diff changeset
   833
    self paint:noColor on:Color allColor function:#and.
26
ac9f66dc8f53 *** empty log message ***
claus
parents: 24
diff changeset
   834
    self displayOpaqueForm:aForm x:x y:y.
71
6a42b2b115f8 *** empty log message ***
claus
parents: 54
diff changeset
   835
    "
6a42b2b115f8 *** empty log message ***
claus
parents: 54
diff changeset
   836
     or-in fg-pixels
6a42b2b115f8 *** empty log message ***
claus
parents: 54
diff changeset
   837
    "
6a42b2b115f8 *** empty log message ***
claus
parents: 54
diff changeset
   838
    self paint:fg on:Color noColor function:#or.
26
ac9f66dc8f53 *** empty log message ***
claus
parents: 24
diff changeset
   839
    self displayOpaqueForm:aForm x:x y:y.
71
6a42b2b115f8 *** empty log message ***
claus
parents: 54
diff changeset
   840
    self paint:fg on:fg function:f.
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   841
!
48194c26a46c Initial revision
claus
parents:
diff changeset
   842
26
ac9f66dc8f53 *** empty log message ***
claus
parents: 24
diff changeset
   843
displayOpaqueForm:aForm x:x y:y
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   844
    "draw a form at x/y; if the form has depth 1, 1's in the form are
48194c26a46c Initial revision
claus
parents:
diff changeset
   845
     drawn in current fg, 0's in current bg color.
48194c26a46c Initial revision
claus
parents:
diff changeset
   846
     If the form has depth ~~ 1, it is copied as is onto the receiver"
48194c26a46c Initial revision
claus
parents:
diff changeset
   847
48194c26a46c Initial revision
claus
parents:
diff changeset
   848
    ^ self subclassResponsibility
48194c26a46c Initial revision
claus
parents:
diff changeset
   849
!
48194c26a46c Initial revision
claus
parents:
diff changeset
   850
48194c26a46c Initial revision
claus
parents:
diff changeset
   851
displayOpaqueString:aString from:index1 to:index2 x:x y:y
48194c26a46c Initial revision
claus
parents:
diff changeset
   852
    "draw part of a string with both fg and bg at x/y in current font"
48194c26a46c Initial revision
claus
parents:
diff changeset
   853
48194c26a46c Initial revision
claus
parents:
diff changeset
   854
    ^ self subclassResponsibility
48194c26a46c Initial revision
claus
parents:
diff changeset
   855
!
48194c26a46c Initial revision
claus
parents:
diff changeset
   856
519
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   857
displayPolygon:aPolygon
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   858
    "draw a polygon
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   859
     - this could be recoded to draw using displayLine"
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   860
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   861
    ^ self subclassResponsibility
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   862
!
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   863
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   864
displayRectangleX:x y:y width:w height:h
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   865
    "draw a rectangle
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   866
     - this could be recoded to draw using displayLine"
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   867
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   868
    ^ self subclassResponsibility
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   869
!
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   870
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   871
displayString:aString from:index1 to:index2 x:x y:y
48194c26a46c Initial revision
claus
parents:
diff changeset
   872
    "draw part of a string with fg at x/y in current font"
48194c26a46c Initial revision
claus
parents:
diff changeset
   873
48194c26a46c Initial revision
claus
parents:
diff changeset
   874
    ^ self subclassResponsibility
48194c26a46c Initial revision
claus
parents:
diff changeset
   875
! !
48194c26a46c Initial revision
claus
parents:
diff changeset
   876
519
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   877
!GraphicsContext methodsFor:'basic filling'!
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   878
653
0ad3de022f8b fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents: 619
diff changeset
   879
fillArcX:x y:y w:w h:h from:startAngle angle:angle
0ad3de022f8b fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents: 619
diff changeset
   880
    "draw a filled arc; apply transformation if nonNil"
0ad3de022f8b fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents: 619
diff changeset
   881
0ad3de022f8b fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents: 619
diff changeset
   882
    self obsoleteMethodWarning:'use #fillArcX:y:width:height:from:angle:'.
0ad3de022f8b fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents: 619
diff changeset
   883
    self fillArcX:x y:y width:w height:h from:startAngle angle:angle
0ad3de022f8b fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents: 619
diff changeset
   884
0ad3de022f8b fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents: 619
diff changeset
   885
    "Modified: 8.5.1996 / 08:47:52 / cg"
0ad3de022f8b fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents: 619
diff changeset
   886
!
0ad3de022f8b fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents: 619
diff changeset
   887
0ad3de022f8b fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents: 619
diff changeset
   888
fillArcX:x y:y width:w height:h from:start angle:angle
519
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   889
    "fill an arc with current paint color"
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   890
519
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   891
    ^ self subclassResponsibility
653
0ad3de022f8b fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents: 619
diff changeset
   892
0ad3de022f8b fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents: 619
diff changeset
   893
    "Created: 8.5.1996 / 08:47:44 / cg"
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   894
!
48194c26a46c Initial revision
claus
parents:
diff changeset
   895
519
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   896
fillPolygon:points
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   897
    "fill a polygon with current paint color"
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   898
519
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   899
    ^ self subclassResponsibility
157
claus
parents: 151
diff changeset
   900
!
claus
parents: 151
diff changeset
   901
519
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   902
fillRectangleX:x y:y width:w height:h
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   903
    "fill a rectangle with current paint color"
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   904
519
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   905
    ^ self subclassResponsibility
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   906
! !
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   907
519
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   908
!GraphicsContext methodsFor:'bit blitting'!
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   909
519
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   910
copyFrom:aGC toX:dstX y:dstY
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   911
    "copy from a drawable - maybe self"
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   912
519
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   913
    self copyFrom:aGC x:0 y:0 toX:dstX y:dstY width:aGC width height:aGC height
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   914
!
48194c26a46c Initial revision
claus
parents:
diff changeset
   915
519
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   916
copyFrom:aGC x:srcX y:srcY toX:dstX y:dstY width:w height:h
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   917
    "copy from a drawable - maybe self"
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   918
519
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   919
    ^ self subclassResponsibility
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   920
!
48194c26a46c Initial revision
claus
parents:
diff changeset
   921
519
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   922
copyFrom:aGC x:dstX y:dstY width:w height:h
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   923
    "copy from a drawable - maybe self"
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   924
519
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   925
    self copyFrom:aGC x:0 y:0 toX:dstX y:dstY width:w height:h
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   926
! !
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   927
519
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   928
!GraphicsContext methodsFor:'drawing'!
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   929
12
9f0995fac1fa *** empty log message ***
claus
parents: 6
diff changeset
   930
displayArcIn:aRectangle from:startAngle angle:angle
9f0995fac1fa *** empty log message ***
claus
parents: 6
diff changeset
   931
    "draw an arc in a box"
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   932
653
0ad3de022f8b fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents: 619
diff changeset
   933
    self 
0ad3de022f8b fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents: 619
diff changeset
   934
        displayArcX:(aRectangle left)
0ad3de022f8b fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents: 619
diff changeset
   935
                  y:(aRectangle top)
0ad3de022f8b fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents: 619
diff changeset
   936
              width:(aRectangle width)
0ad3de022f8b fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents: 619
diff changeset
   937
             height:(aRectangle height)
0ad3de022f8b fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents: 619
diff changeset
   938
               from:startAngle
0ad3de022f8b fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents: 619
diff changeset
   939
              angle:angle
0ad3de022f8b fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents: 619
diff changeset
   940
0ad3de022f8b fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents: 619
diff changeset
   941
    "Modified: 8.5.1996 / 08:35:00 / cg"
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   942
!
48194c26a46c Initial revision
claus
parents:
diff changeset
   943
12
9f0995fac1fa *** empty log message ***
claus
parents: 6
diff changeset
   944
displayArcOrigin:origin corner:corner from:startAngle angle:angle
9f0995fac1fa *** empty log message ***
claus
parents: 6
diff changeset
   945
    "draw an arc in a box"
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   946
48194c26a46c Initial revision
claus
parents:
diff changeset
   947
    |left top right bot|
48194c26a46c Initial revision
claus
parents:
diff changeset
   948
48194c26a46c Initial revision
claus
parents:
diff changeset
   949
    left := origin x.
48194c26a46c Initial revision
claus
parents:
diff changeset
   950
    top := origin y.
48194c26a46c Initial revision
claus
parents:
diff changeset
   951
    right := corner x.
48194c26a46c Initial revision
claus
parents:
diff changeset
   952
    bot := corner y.
653
0ad3de022f8b fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents: 619
diff changeset
   953
    self 
0ad3de022f8b fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents: 619
diff changeset
   954
        displayArcX:left 
0ad3de022f8b fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents: 619
diff changeset
   955
                  y:top
0ad3de022f8b fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents: 619
diff changeset
   956
              width:(right - left + 1)
0ad3de022f8b fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents: 619
diff changeset
   957
             height:(bot - top + 1)
0ad3de022f8b fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents: 619
diff changeset
   958
               from:startAngle 
0ad3de022f8b fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents: 619
diff changeset
   959
              angle:angle
0ad3de022f8b fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents: 619
diff changeset
   960
0ad3de022f8b fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents: 619
diff changeset
   961
    "Modified: 8.5.1996 / 08:35:25 / cg"
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   962
!
48194c26a46c Initial revision
claus
parents:
diff changeset
   963
519
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   964
displayCircle:aPoint radius:r
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   965
    "draw a circle around a center point"
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   966
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   967
    self displayCircleX:(aPoint x) y:(aPoint y) radius:r
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   968
!
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   969
12
9f0995fac1fa *** empty log message ***
claus
parents: 6
diff changeset
   970
displayCircleIn:aRectangle
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   971
    "draw a circle in a box"
48194c26a46c Initial revision
claus
parents:
diff changeset
   972
48194c26a46c Initial revision
claus
parents:
diff changeset
   973
    self
653
0ad3de022f8b fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents: 619
diff changeset
   974
        displayArcX:(aRectangle left)
0ad3de022f8b fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents: 619
diff changeset
   975
                  y:(aRectangle top)
0ad3de022f8b fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents: 619
diff changeset
   976
              width:(aRectangle width)
0ad3de022f8b fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents: 619
diff changeset
   977
             height:(aRectangle height)
0ad3de022f8b fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents: 619
diff changeset
   978
               from:0 
0ad3de022f8b fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents: 619
diff changeset
   979
              angle:360
0ad3de022f8b fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents: 619
diff changeset
   980
0ad3de022f8b fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents: 619
diff changeset
   981
    "Modified: 8.5.1996 / 08:35:40 / cg"
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   982
!
48194c26a46c Initial revision
claus
parents:
diff changeset
   983
12
9f0995fac1fa *** empty log message ***
claus
parents: 6
diff changeset
   984
displayCircleX:x y:y radius:r
9f0995fac1fa *** empty log message ***
claus
parents: 6
diff changeset
   985
    "draw a circle around a center point"
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   986
48194c26a46c Initial revision
claus
parents:
diff changeset
   987
    |d|
48194c26a46c Initial revision
claus
parents:
diff changeset
   988
    d := 2 * r.
653
0ad3de022f8b fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents: 619
diff changeset
   989
    self 
0ad3de022f8b fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents: 619
diff changeset
   990
        displayArcX:(x - r) 
0ad3de022f8b fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents: 619
diff changeset
   991
                  y:(y - r)
0ad3de022f8b fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents: 619
diff changeset
   992
              width:d
0ad3de022f8b fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents: 619
diff changeset
   993
             height:d
0ad3de022f8b fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents: 619
diff changeset
   994
               from:0 
0ad3de022f8b fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents: 619
diff changeset
   995
              angle:360
0ad3de022f8b fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents: 619
diff changeset
   996
0ad3de022f8b fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents: 619
diff changeset
   997
    "Modified: 8.5.1996 / 08:36:03 / cg"
519
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   998
!
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   999
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1000
displayForm:aForm at:aPoint
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1001
    "draw a form"
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1002
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1003
    self displayForm:aForm x:(aPoint x) y:(aPoint y)
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1004
!
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1005
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1006
displayLineFrom:point1 to:point2
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1007
    "draw a line"
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1008
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1009
    self displayLineFromX:(point1 x) y:(point1 y)
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1010
		      toX:(point2 x) y:(point2 y)
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1011
!
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1012
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1013
displayOpaqueString:aString at:aPoint
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1014
    "draw a string with both fg and bg"
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1015
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1016
    self displayOpaqueString:aString x:(aPoint x) y:(aPoint y)
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1017
!
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1018
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1019
displayOpaqueString:aString from:start to:stop at:aPoint
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1020
    "draw part of a string - drawing both fg and bg"
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1021
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1022
    ^ self displayOpaqueString:aString from:start to:stop x:aPoint x y:aPoint y
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1023
!
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1024
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1025
displayOpaqueString:aString x:x y:y
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1026
    "draw a string with both fg and bg"
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1027
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1028
    self displayOpaqueString:aString from:1 to:(aString size) x:x y:y
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1029
!
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1030
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1031
displayPoint:aPoint
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1032
    "draw a pixel"
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1033
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1034
    self displayPointX:(aPoint x) y:(aPoint y)
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1035
!
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1036
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1037
displayPointX:x y:y
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1038
    "draw a point at x/y"
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1039
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1040
    self displayLineFromX:x y:y toX:x y:y
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1041
!
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1042
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1043
displayRectangle:aRectangle
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1044
    "draw a rectangle"
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1045
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1046
    self displayRectangleX:(aRectangle left)
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1047
			 y:(aRectangle top)
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1048
		     width:(aRectangle width)
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1049
		    height:(aRectangle height)
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1050
!
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1051
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1052
displayRectangleOrigin:origin corner:corner
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1053
    "draw a rectangle"
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1054
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1055
    |top left|
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1056
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1057
    left := origin x.
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1058
    top := origin y.
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1059
    self displayRectangleX:left y:top 
563
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
  1060
                     width:(corner x - left)
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
  1061
                    height:(corner y - top)
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
  1062
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
  1063
    "Modified: 13.4.1996 / 20:58:31 / cg"
519
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1064
!
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1065
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1066
displayString:aString at:aPoint
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1067
    "draw a string - drawing fg only"
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1068
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1069
    self displayString:aString x:aPoint x y:aPoint y
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1070
!
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1071
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1072
displayString:aString from:start to:stop at:aPoint
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1073
    "draw part of a string - drawing fg only"
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1074
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1075
    ^ self displayString:aString from:start to:stop x:aPoint x y:aPoint y
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1076
!
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1077
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1078
displayString:aString x:x y:y
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1079
    "draw a string - drawing fg only"
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1080
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1081
    self displayString:aString from:1 to:(aString size) x:x y:y
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1082
! !
519
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1083
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1084
!GraphicsContext methodsFor:'drawing in device coordinates'!
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1085
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1086
displayDeviceLineFromX:x1 y:y1 toX:x2 y:y2
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1087
    "draw a line in device coordinates"
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1088
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1089
    |sav|
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1090
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1091
    sav := transformation.
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1092
    transformation := nil.
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1093
    self displayLineFromX:x1 y:y1 toX:x2 y:y2.
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1094
    transformation := sav
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1095
!
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1096
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1097
fillDeviceRectangleX:x y:y width:w height:h
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1098
    "fill a rectangle with current paint color (device coordinates)"
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1099
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1100
    |sav|
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1101
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1102
    sav := transformation.
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1103
    transformation := nil.
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1104
    self fillRectangleX:x y:y width:w height:h.
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1105
    transformation := sav
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1106
!
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1107
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1108
fillDeviceRectangleX:x y:y width:w height:h with:aPattern
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1109
    "fill the rectangular area in the receiver with aPattern,
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1110
     which may be a Form or Color. Use device coordinates."
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1111
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1112
    self withPattern:aPattern do:[
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1113
	self fillDeviceRectangleX:x y:y width:w height:h
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1114
    ]
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1115
! !
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1116
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1117
!GraphicsContext methodsFor:'filling'!
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1118
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1119
fillArc:origin radius:r from:startAngle angle:angle
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1120
    "draw a filled arc around a point"
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1121
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1122
    |d|
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1123
    d := 2 * r.
653
0ad3de022f8b fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents: 619
diff changeset
  1124
    self 
0ad3de022f8b fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents: 619
diff changeset
  1125
        fillArcX:(origin x - r) 
0ad3de022f8b fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents: 619
diff changeset
  1126
               y:(origin y - r)
0ad3de022f8b fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents: 619
diff changeset
  1127
           width:d
0ad3de022f8b fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents: 619
diff changeset
  1128
          height:d
0ad3de022f8b fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents: 619
diff changeset
  1129
            from:startAngle
0ad3de022f8b fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents: 619
diff changeset
  1130
           angle:angle
0ad3de022f8b fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents: 619
diff changeset
  1131
0ad3de022f8b fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents: 619
diff changeset
  1132
    "Modified: 8.5.1996 / 08:41:54 / cg"
519
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1133
!
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1134
563
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
  1135
fillArcIn:aRectangle from:startAngle angle:angle
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
  1136
    "draw a filled arc in a box"
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
  1137
653
0ad3de022f8b fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents: 619
diff changeset
  1138
    self 
0ad3de022f8b fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents: 619
diff changeset
  1139
        fillArcX:(aRectangle left)
0ad3de022f8b fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents: 619
diff changeset
  1140
               y:(aRectangle top)
0ad3de022f8b fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents: 619
diff changeset
  1141
           width:(aRectangle width)
0ad3de022f8b fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents: 619
diff changeset
  1142
          height:(aRectangle height)
0ad3de022f8b fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents: 619
diff changeset
  1143
            from:startAngle
0ad3de022f8b fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents: 619
diff changeset
  1144
           angle:angle
563
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
  1145
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
  1146
    "Created: 13.4.1996 / 20:56:03 / cg"
653
0ad3de022f8b fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents: 619
diff changeset
  1147
    "Modified: 8.5.1996 / 08:42:13 / cg"
563
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
  1148
!
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
  1149
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
  1150
fillArcOrigin:origin corner:corner from:startAngle angle:angle
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
  1151
    "draw a filled arc in a box"
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
  1152
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
  1153
    |left top right bot|
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
  1154
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
  1155
    left := origin x.
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
  1156
    top := origin y.
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
  1157
    right := corner x.
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
  1158
    bot := corner y.
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
  1159
    self 
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
  1160
        fillArcX:left 
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
  1161
        y:top
653
0ad3de022f8b fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents: 619
diff changeset
  1162
        width:(right - left + 1) 
0ad3de022f8b fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents: 619
diff changeset
  1163
        height:(bot - top + 1)
563
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
  1164
        from:startAngle 
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
  1165
        angle:angle
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
  1166
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
  1167
    "Created: 13.4.1996 / 20:56:56 / cg"
653
0ad3de022f8b fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents: 619
diff changeset
  1168
    "Modified: 8.5.1996 / 08:42:23 / cg"
0ad3de022f8b fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents: 619
diff changeset
  1169
!
0ad3de022f8b fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents: 619
diff changeset
  1170
0ad3de022f8b fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents: 619
diff changeset
  1171
fillArcX:x y:y width:w height:h from:startAngle to:endAngle
0ad3de022f8b fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents: 619
diff changeset
  1172
    "draw a filled arc in a box, given startAngle and endAngle."
0ad3de022f8b fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents: 619
diff changeset
  1173
0ad3de022f8b fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents: 619
diff changeset
  1174
    self 
0ad3de022f8b fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents: 619
diff changeset
  1175
        fillArcX:x 
0ad3de022f8b fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents: 619
diff changeset
  1176
               y:y
0ad3de022f8b fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents: 619
diff changeset
  1177
           width:w
0ad3de022f8b fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents: 619
diff changeset
  1178
          height:h
0ad3de022f8b fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents: 619
diff changeset
  1179
            from:startAngle
0ad3de022f8b fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents: 619
diff changeset
  1180
           angle:(endAngle - startAngle)
0ad3de022f8b fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents: 619
diff changeset
  1181
0ad3de022f8b fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents: 619
diff changeset
  1182
    "Created: 8.5.1996 / 08:52:41 / cg"
563
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
  1183
!
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
  1184
519
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1185
fillCircle:aPoint radius:aNumber
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1186
    "draw a filled circle around aPoint"
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1187
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1188
    self fillCircleX:(aPoint x) y:(aPoint y) radius:aNumber
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1189
!
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1190
563
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
  1191
fillCircleIn:aRectangle
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
  1192
    "draw a filled circle in a box"
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
  1193
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
  1194
    self
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
  1195
        fillArcX:(aRectangle left)
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
  1196
               y:(aRectangle top)
653
0ad3de022f8b fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents: 619
diff changeset
  1197
           width:(aRectangle width)
0ad3de022f8b fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents: 619
diff changeset
  1198
          height:(aRectangle height)
563
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
  1199
            from:0 
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
  1200
           angle:360
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
  1201
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
  1202
    "Created: 13.4.1996 / 20:57:41 / cg"
653
0ad3de022f8b fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents: 619
diff changeset
  1203
    "Modified: 8.5.1996 / 08:42:38 / cg"
563
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
  1204
!
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
  1205
519
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1206
fillCircleX:x y:y radius:r
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1207
    "draw a filled circle around x@y"
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1208
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1209
    |d|
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1210
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1211
    d := 2 * r.
653
0ad3de022f8b fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents: 619
diff changeset
  1212
    self 
0ad3de022f8b fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents: 619
diff changeset
  1213
        fillArcX:(x - r)
0ad3de022f8b fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents: 619
diff changeset
  1214
        y:(y - r) 
0ad3de022f8b fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents: 619
diff changeset
  1215
        width:d
0ad3de022f8b fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents: 619
diff changeset
  1216
        height:d 
0ad3de022f8b fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents: 619
diff changeset
  1217
        from:0
0ad3de022f8b fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents: 619
diff changeset
  1218
        angle:360
0ad3de022f8b fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents: 619
diff changeset
  1219
0ad3de022f8b fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents: 619
diff changeset
  1220
    "Modified: 8.5.1996 / 08:43:02 / cg"
519
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1221
!
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1222
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1223
fillRectangle:aRectangle
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1224
    "fill a rectangle with current paint color"
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1225
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1226
    self fillRectangleX:(aRectangle left)
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1227
		      y:(aRectangle top)
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1228
		  width:(aRectangle width)
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1229
		 height:(aRectangle height)
563
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
  1230
!
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
  1231
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
  1232
fillRectangleOrigin:origin corner:corner
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
  1233
    "draw a filled rectangle"
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
  1234
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
  1235
    |top left|
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
  1236
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
  1237
    left := origin x.
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
  1238
    top := origin y.
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
  1239
    self fillRectangleX:left y:top 
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
  1240
                  width:(corner x - left)
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
  1241
                 height:(corner y - top)
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
  1242
d6c07537b4a4 commentary
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
  1243
    "Created: 13.4.1996 / 20:58:16 / cg"
519
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1244
! !
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1245
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1246
!GraphicsContext methodsFor:'initialization'!
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1247
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1248
initialize
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1249
    "set up some useful default values"
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1250
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1251
    paint := Black.
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1252
    bgPaint := White.
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1253
    function := #copy.
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1254
    lineWidth := 1.
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1255
    lineStyle := #solid.
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1256
    joinStyle := #miter.
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1257
    capStyle := #butt.
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1258
    font := DefaultFont.
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1259
! !
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1260
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1261
!GraphicsContext methodsFor:'misc'!
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1262
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1263
flush
585
426d2018cdc8 commentary
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
  1264
    "send all buffered drawing to the device."
519
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1265
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1266
    self device flush
585
426d2018cdc8 commentary
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
  1267
426d2018cdc8 commentary
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
  1268
    "Modified: 22.4.1996 / 19:47:19 / cg"
519
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1269
! !
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1270
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1271
!GraphicsContext class methodsFor:'documentation'!
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1272
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1273
version
671
1bca26786912 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 657
diff changeset
  1274
    ^ '$Header: /cvs/stx/stx/libview/GraphicsContext.st,v 1.31 1996-05-12 17:42:55 cg Exp $'
519
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1275
! !
ea7d88d346fe nicer message
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
  1276
GraphicsContext initialize!