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