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