DeviceGraphicsContext.st
author Claus Gittinger <cg@exept.de>
Fri, 21 Jun 1996 13:32:40 +0200
changeset 895 0d49372cded9
parent 868 65c93e5f6f8b
child 902 7f5d81d377de
permissions -rw-r--r--
if a deep image has a mask, care for it (stamp out & or-in)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     1
"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     2
 COPYRIGHT (c) 1992 by Claus Gittinger
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     3
	      All Rights Reserved
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     4
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     5
 This software is furnished under a license and may be used
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     6
 only in accordance with the terms of that license and with the
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     8
 be provided or otherwise made available to, or used by, any
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     9
 other person.  No title to or ownership of the software is
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    10
 hereby transferred.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    11
"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    12
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    13
GraphicsContext subclass:#DeviceGraphicsContext
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    14
	instanceVariableNames:'drawableId gcId deviceFont foreground background'
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    15
	classVariableNames:'CachedScaledForms CachedScales Lobby'
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    16
	poolDictionaries:''
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    17
	category:'Graphics-Support'
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    18
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    19
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    20
!DeviceGraphicsContext class methodsFor:'documentation'!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    21
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    22
copyright
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    23
"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    24
 COPYRIGHT (c) 1992 by Claus Gittinger
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    25
	      All Rights Reserved
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    26
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    27
 This software is furnished under a license and may be used
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    28
 only in accordance with the terms of that license and with the
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    29
 inclusion of the above copyright notice.   This software may not
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    30
 be provided or otherwise made available to, or used by, any
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    31
 other person.  No title to or ownership of the software is
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    32
 hereby transferred.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    33
"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    34
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    35
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    36
documentation
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    37
"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    38
    I provide the common protocol for a graphicsContext which is associated with a particular
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    39
    device (i.e. Bitmaps, Pixmaps, RootWindow and Windows in Xs world, but also postscript 
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    40
    printer pages or fax pages).
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    41
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    42
    My instance variables are mainly caching device-related stuff (such as font- and color-Ids)
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    43
    to avoid needless message traffic. This class is abstract, no direct instances of it
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    44
    exist in the system.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    45
    All real work is done by my device, which is accessed via the device instance variable.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    46
    Most drawing requests are simply forwarded to it, others are simulated by using more basic 
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    47
    drawing functions (see GraphicsContext drawing vs. basic drawing category).
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    48
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    49
    The added variables foreground/background are the drawing colors actually 
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    50
    used; these are the real (i.e. non dithered) colors supported by the device.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    51
    Direct access to fg/bg is discouraged, since in the future, these may be 
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    52
    totally replaced by paint/bgPaint 
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    53
    (there are some operations and special cases, for which a direct access to 
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    54
     fg/bg makes sense)
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    55
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    56
    [Instance variables:]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    57
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    58
        drawableId      <SmallInteger>  my drawableId on the device (a device handle)
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    59
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    60
        gcId            <SmallInteger>  my gc's ID on the device (a device handle)
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    61
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    62
        deviceFont      <Font>          the actual font, currently set in the device
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    63
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    64
        foreground      <Color>         the device foreground color used for drawing
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    65
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    66
        background      <Color>         the device background color used for drawing
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    67
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    68
    [see also:]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    69
        DeviceWorkstation
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    70
        Color Font Cursor
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    71
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    72
    [author:]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    73
        Claus Gittinger
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    74
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    75
"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    76
! !
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    77
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    78
!DeviceGraphicsContext class methodsFor:'initialization'!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    79
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    80
initialize
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    81
    Lobby isNil ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    82
	Lobby := Registry new.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    83
    ]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    84
! !
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    85
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    86
!DeviceGraphicsContext class methodsFor:'instance creation'!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    87
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    88
new
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    89
    "create a new drawable - take the current display as
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    90
     its device (for now, this may be changed until the view is
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    91
     physically created)"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    92
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    93
"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    94
    'Warning: DeviceGraphicsContext (' print. self name print. ') should not be created with new' printNL.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    95
"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    96
    ^ self onDevice:Screen current "Display"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    97
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    98
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    99
on:aDevice
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   100
    "create a new drawable on aDevice"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   101
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   102
    ^ self onDevice:aDevice
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   103
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   104
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   105
onDevice:aDevice
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   106
    "create a new drawable on aDevice"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   107
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   108
    |newDrawable|
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   109
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   110
    newDrawable := self basicNew.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   111
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   112
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   113
     set display before its initialized 
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   114
     - so it can do something useful (i.e. get font sizes etc.) in its
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   115
     intitialize method(s)
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   116
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   117
    newDrawable device:aDevice.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   118
    newDrawable initialize.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   119
    Lobby register:newDrawable.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   120
    ^ newDrawable
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   121
! !
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   122
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   123
!DeviceGraphicsContext class methodsFor:'cleanup'!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   124
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   125
lowSpaceCleanup
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   126
    CachedScaledForms := CachedScales := nil
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   127
! !
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   128
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   129
!DeviceGraphicsContext methodsFor:'accessing'!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   130
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   131
at:aPoint
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   132
    "return the pixel at the coordinate given by aPoint"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   133
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   134
    ^ device
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   135
	getPixelX:(aPoint x)
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   136
		y:(aPoint y)
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   137
	     from:drawableId
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   138
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   139
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   140
at:aPoint put:aPixel
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   141
    "set a pixel"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   142
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   143
    |oldFg|
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   144
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   145
    oldFg := foreground.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   146
    self foreground:aPixel.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   147
    self displayPointX:(aPoint x) y:(aPoint y).
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   148
    self foreground:oldFg
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   149
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   150
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   151
atX:x y:y
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   152
    "return the pixel at the coordinate given by x/y"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   153
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   154
    ^ device getPixelX:x y:y from:drawableId
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   155
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   156
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   157
atX:x y:y put:aPixel
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   158
    "set a pixel"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   159
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   160
    |oldFg|
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   161
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   162
    oldFg := foreground.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   163
    self foreground:aPixel.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   164
    self displayPointX:x y:y.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   165
    self foreground:oldFg
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   166
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   167
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   168
backgroundPaint:aColor
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   169
    "set the background-paint color; this is used in opaque-draw
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   170
     operations"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   171
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   172
    (aColor ~~ bgPaint) ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   173
	aColor notNil ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   174
	    bgPaint := aColor.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   175
	    gcId notNil ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   176
		bgPaint isColor ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   177
		    bgPaint := aColor on:device.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   178
		    bgPaint colorId notNil ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   179
			background := bgPaint.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   180
			device setBackground:(bgPaint colorId) in:drawableId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   181
			^ self
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   182
		    ]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   183
		].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   184
		self paint:paint on:aColor
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   185
	    ]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   186
	]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   187
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   188
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   189
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   190
basicFont
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   191
    "return set the font for drawing"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   192
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   193
    ^ font
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   194
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   195
    "Created: 12.5.1996 / 11:17:59 / cg"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   196
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   197
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   198
basicFont:aFont
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   199
    "set the font for drawing if it has changed.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   200
     This is a low level entry, which is not to be redefined
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   201
     (i.e. it must not imply a redraw operation)"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   202
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   203
    |id|
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   204
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   205
    (aFont ~~ font) ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   206
        aFont notNil ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   207
            font := aFont.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   208
            gcId notNil ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   209
                font := font on:device.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   210
                id := font fontId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   211
                id notNil ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   212
                    device setFont:id in:gcId
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   213
                ]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   214
            ]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   215
        ]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   216
    ]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   217
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   218
    "Modified: 23.2.1996 / 17:01:06 / cg"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   219
    "Created: 23.2.1996 / 17:16:51 / cg"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   220
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   221
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   222
capStyle:aSymbol
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   223
    "set the style in which the endpoints of lines
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   224
     are drawn - aSymbol may be #notLast, #butt, #round, #projecting"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   225
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   226
    |s|
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   227
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   228
    (s := aSymbol) isNil ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   229
        s := #butt.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   230
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   231
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   232
    (s ~~ capStyle) ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   233
        capStyle := s.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   234
        gcId notNil ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   235
            device setLineWidth:lineWidth 
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   236
                          style:lineStyle
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   237
                            cap:s
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   238
                           join:joinStyle
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   239
                             in:gcId
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   240
        ]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   241
    ]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   242
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   243
    "Modified: 12.5.1996 / 22:23:03 / cg"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   244
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   245
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   246
clipRect
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   247
    "return the clipping rectangle for drawing. If there is currently no clipRect,
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   248
     a dummy is created."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   249
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   250
    |rect|
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   251
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   252
    clipRect isNil ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   253
        rect := 0@0 extent:(self extent).
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   254
        transformation notNil ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   255
            rect := transformation applyInverseTo:rect.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   256
        ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   257
        ^ rect
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   258
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   259
    ^ clipRect
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   260
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   261
    "Modified: 10.4.1996 / 14:32:22 / cg"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   262
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   263
735
44ad59ece2db checkin from browser
Claus Gittinger <cg@exept.de>
parents: 732
diff changeset
   264
clippingRectangle:aRectangleOrNil
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   265
    "set the clipping rectangle for drawing (in logical coordinates);
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   266
     a nil argument turn off clipping (i.e. whole view is drawable)"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   267
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   268
    |x y w h|
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   269
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   270
    aRectangleOrNil isNil ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   271
        clipRect isNil ifTrue:[^ self].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   272
        gcId notNil ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   273
            device noClipIn:gcId
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   274
        ]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   275
    ] ifFalse:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   276
        clipRect notNil ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   277
            (clipRect = aRectangleOrNil) ifTrue:[^ self]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   278
        ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   279
        gcId notNil ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   280
            x := aRectangleOrNil left.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   281
            y := aRectangleOrNil top.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   282
            w := aRectangleOrNil width.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   283
            h := aRectangleOrNil height.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   284
            transformation notNil ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   285
                x := transformation applyToX:x.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   286
                y := transformation applyToY:y.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   287
                w := transformation applyScaleX:w.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   288
                h := transformation applyScaleY:h.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   289
            ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   290
            (x class == SmallInteger) ifFalse:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   291
                w := w + (x - x truncated).
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   292
                x := x truncated
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   293
            ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   294
            (y class == SmallInteger) ifFalse:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   295
                h := h + (y - y truncated).
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   296
                y := y truncated
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   297
            ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   298
            (w class == SmallInteger) ifFalse:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   299
                w := w truncated + 1
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   300
            ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   301
            (h class == SmallInteger) ifFalse:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   302
                h := h truncated + 1
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   303
            ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   304
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   305
            device setClipX:x y:y width:w height:h in:gcId
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   306
        ]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   307
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   308
    clipRect := aRectangleOrNil
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   309
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   310
    "Modified: 22.5.1996 / 13:12:07 / cg"
735
44ad59ece2db checkin from browser
Claus Gittinger <cg@exept.de>
parents: 732
diff changeset
   311
    "Created: 28.5.1996 / 19:40:20 / cg"
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   312
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   313
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   314
clippingRectangleOrNil
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   315
    "return the clipping rectangle for drawing, nil if there is none."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   316
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   317
    ^ clipRect
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   318
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   319
    "Created: 10.4.1996 / 14:32:02 / cg"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   320
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   321
786
af5fecf93126 added dashStyle: ...
Claus Gittinger <cg@exept.de>
parents: 784
diff changeset
   322
dashStyle:aDashList offset:dashOffset
af5fecf93126 added dashStyle: ...
Claus Gittinger <cg@exept.de>
parents: 784
diff changeset
   323
    "define dashes. Each element of the dashList specifies the length
af5fecf93126 added dashStyle: ...
Claus Gittinger <cg@exept.de>
parents: 784
diff changeset
   324
     of a corresponding dash. For example, setting it to [4 4]
af5fecf93126 added dashStyle: ...
Claus Gittinger <cg@exept.de>
parents: 784
diff changeset
   325
     defines 4on-4off dashing; 
af5fecf93126 added dashStyle: ...
Claus Gittinger <cg@exept.de>
parents: 784
diff changeset
   326
     Setting it to [1 2 4 2] defines 1on-2off-4on-2off dashes.
af5fecf93126 added dashStyle: ...
Claus Gittinger <cg@exept.de>
parents: 784
diff changeset
   327
     The dashOffset specifies where in the dashList the dashing starts.
af5fecf93126 added dashStyle: ...
Claus Gittinger <cg@exept.de>
parents: 784
diff changeset
   328
     This may not be supported by all graphics devices."
af5fecf93126 added dashStyle: ...
Claus Gittinger <cg@exept.de>
parents: 784
diff changeset
   329
af5fecf93126 added dashStyle: ...
Claus Gittinger <cg@exept.de>
parents: 784
diff changeset
   330
    gcId notNil ifTrue:[
af5fecf93126 added dashStyle: ...
Claus Gittinger <cg@exept.de>
parents: 784
diff changeset
   331
        device setDashes:(ByteArray withAll:aDashList)
af5fecf93126 added dashStyle: ...
Claus Gittinger <cg@exept.de>
parents: 784
diff changeset
   332
              dashOffset:dashOffset
af5fecf93126 added dashStyle: ...
Claus Gittinger <cg@exept.de>
parents: 784
diff changeset
   333
                      in:gcId
af5fecf93126 added dashStyle: ...
Claus Gittinger <cg@exept.de>
parents: 784
diff changeset
   334
    ]
af5fecf93126 added dashStyle: ...
Claus Gittinger <cg@exept.de>
parents: 784
diff changeset
   335
af5fecf93126 added dashStyle: ...
Claus Gittinger <cg@exept.de>
parents: 784
diff changeset
   336
    "Modified: 4.6.1996 / 19:03:06 / cg"
af5fecf93126 added dashStyle: ...
Claus Gittinger <cg@exept.de>
parents: 784
diff changeset
   337
!
af5fecf93126 added dashStyle: ...
Claus Gittinger <cg@exept.de>
parents: 784
diff changeset
   338
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   339
device
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   340
    "return the device, the receiver is associated with"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   341
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   342
    ^ device
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   343
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   344
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   345
device:aDevice
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   346
    "set the device"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   347
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   348
    device := aDevice
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   349
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   350
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   351
font:aFont
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   352
    "set the font for drawing if it has changed.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   353
     This should be redefined in some widget to perform an automatic
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   354
     redraw. See also: #basicFont:"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   355
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   356
    (aFont ~~ font) ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   357
        self basicFont:aFont
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   358
    ]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   359
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   360
    "Modified: 6.3.1996 / 18:17:40 / cg"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   361
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   362
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   363
function:aSymbol
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   364
    "set the drawing function if it has changed"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   365
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   366
    (aSymbol ~~ function) ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   367
	function := aSymbol.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   368
	gcId notNil ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   369
	    device setFunction:aSymbol in:gcId
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   370
	]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   371
    ]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   372
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   373
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   374
gcId
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   375
    "return the receivers graphic context id on the device"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   376
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   377
    ^ gcId
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   378
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   379
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   380
graphicsDevice
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   381
    "return the device, the receiver is associated with.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   382
     Same as #device, for ST-80 compatibility."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   383
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   384
    ^ device
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   385
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   386
    "Created: 9.5.1996 / 01:37:58 / cg"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   387
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   388
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   389
id
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   390
    "return the id of the dravable on the device"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   391
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   392
    ^ drawableId
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   393
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   394
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   395
joinStyle:aSymbol
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   396
    "set the style in which 2 lines are connected in polygons -
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   397
     aSymbol may be #miter, #bevel, #round"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   398
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   399
    |s|
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   400
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   401
    (s := aSymbol) isNil ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   402
        s := #miter
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   403
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   404
    (s ~~ joinStyle) ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   405
        joinStyle := s.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   406
        
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   407
        gcId notNil ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   408
            device setLineWidth:lineWidth 
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   409
                          style:lineStyle
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   410
                            cap:capStyle
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   411
                           join:s
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   412
                             in:gcId
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   413
        ]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   414
    ]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   415
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   416
    "Modified: 12.5.1996 / 22:20:43 / cg"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   417
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   418
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   419
lineStyle:aSymbol
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   420
    "set the style in which lines are drawn -
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   421
     aSymbol may be #solid, #dashed, #doubleDashed"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   422
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   423
    |s|
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   424
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   425
    (s := aSymbol) isNil ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   426
        s := #solid
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   427
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   428
    (s ~~ lineStyle) ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   429
        lineStyle := s.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   430
        gcId notNil ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   431
            device setLineWidth:lineWidth 
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   432
                          style:s
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   433
                            cap:capStyle
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   434
                           join:joinStyle
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   435
                             in:gcId
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   436
        ]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   437
    ]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   438
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   439
    "Modified: 12.5.1996 / 22:21:25 / cg"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   440
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   441
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   442
lineWidth:aNumber
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   443
    "set the line width for drawing if it has changed"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   444
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   445
    |n|
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   446
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   447
    (aNumber ~~ lineWidth) ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   448
	lineWidth := aNumber.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   449
	transformation isNil ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   450
	    n := aNumber.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   451
	] ifFalse:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   452
	    n := transformation applyScaleX:aNumber.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   453
	    n := n rounded
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   454
	].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   455
	gcId notNil ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   456
	    device setLineWidth:n 
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   457
			  style:lineStyle
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   458
			    cap:capStyle
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   459
			   join:joinStyle
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   460
			     in:gcId
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   461
	]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   462
    ]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   463
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   464
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   465
mask:aForm
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   466
    "set the mask form for drawing"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   467
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   468
    |id|
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   469
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   470
    (aForm ~~ mask) ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   471
	mask := aForm.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   472
	gcId notNil ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   473
	    (mask == nil) ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   474
		device setBitmapMask:nil in:gcId
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   475
	    ] ifFalse:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   476
		mask := mask on:device.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   477
		id := mask id.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   478
		(mask depth == 1) ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   479
		    device setBitmapMask:id in:gcId
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   480
		] ifFalse:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   481
		    device setPixmapMask:id in:gcId
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   482
		]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   483
	    ]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   484
	]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   485
    ]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   486
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   487
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   488
paint:aColor
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   489
    "set the drawing color, which may be a real color, a dithered one
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   490
     or even an image."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   491
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   492
    (aColor ~~ paint) ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   493
        aColor notNil ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   494
            paint := aColor.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   495
            self setGCForPaint.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   496
        ]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   497
    ]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   498
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   499
    "Modified: 16.5.1996 / 15:35:57 / cg"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   500
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   501
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   502
paint:fgColor on:bgColor
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   503
    "set the paint and background-paint color. 
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   504
     The bg-paint is used in opaque-draw operations"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   505
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   506
    |fgId bgId|
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   507
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   508
    ((fgColor ~~ paint) or:[bgColor ~~ bgPaint]) ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   509
        fgColor notNil ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   510
            paint := fgColor
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   511
        ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   512
        bgColor notNil ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   513
            bgPaint := bgColor
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   514
        ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   515
        gcId notNil ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   516
            paint := paint on:device.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   517
            paint isColor ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   518
                fgId := paint colorId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   519
                fgId notNil ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   520
                    mask notNil ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   521
                        mask := nil.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   522
                        device setBitmapMask:nil in:gcId
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   523
                    ]. 
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   524
                    bgPaint := bgPaint on:device.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   525
                    bgPaint isColor ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   526
                        bgId := bgPaint colorId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   527
                        bgId notNil ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   528
                            "the common case, both are real colors"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   529
                            (paint ~~ foreground) ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   530
                                foreground := paint.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   531
                                (bgPaint ~~ background) ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   532
                                    background := bgPaint.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   533
                                    device setForeground:fgId background:bgId in:gcId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   534
                                    ^ self
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   535
                                ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   536
                                device setForeground:fgId in:gcId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   537
                                ^ self
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   538
                            ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   539
                            (bgPaint ~~ background) ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   540
                                background := bgPaint.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   541
                                device setBackground:bgId in:gcId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   542
                            ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   543
                            ^ self
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   544
                        ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   545
                        "bgPaint is dithered, setup paint here, leave bgPaint
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   546
                         till next opaque draw comes around."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   547
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   548
                        (paint ~~ foreground) ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   549
                            foreground := paint.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   550
                            device setForeground:fgId in:gcId
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   551
                        ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   552
                        ^ self
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   553
                    ]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   554
                ]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   555
            ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   556
            "either paint or bgPaint (or both) are dithered colors,
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   557
             setup for paint, leave bg-problem till next opaque draw
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   558
             comes around.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   559
            "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   560
            self setGCForPaint.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   561
        ]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   562
    ]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   563
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   564
    "Modified: 16.5.1996 / 15:37:05 / cg"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   565
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   566
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   567
paint:fgColor on:bgColor function:f
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   568
    "set paint, background-paint and function"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   569
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   570
    self paint:fgColor on:bgColor.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   571
    self function:f
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   572
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   573
    "Modified: 16.5.1996 / 15:36:35 / cg"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   574
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   575
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   576
setGraphicsExposures:aBoolean
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   577
    "want to if aBoolean is true - or dont want to be notified
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   578
     of graphics exposures"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   579
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   580
    gcId notNil ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   581
	device setGraphicsExposures:aBoolean in:gcId
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   582
    ]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   583
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   584
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   585
setMaskOrigin:aPoint
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   586
    "set the origin of the fill pattern"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   587
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   588
    (maskOrigin isNil or:[maskOrigin ~= aPoint]) ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   589
	transformation isNil ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   590
	    maskOrigin := aPoint.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   591
	] ifFalse:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   592
	    maskOrigin := transformation applyTo:aPoint
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   593
	].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   594
	gcId notNil ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   595
	    device setMaskOriginX:maskOrigin x rounded 
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   596
				y:maskOrigin y rounded 
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   597
			       in:gcId
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   598
	]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   599
    ]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   600
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   601
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   602
setMaskOriginX:orgX y:orgY
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   603
    "set the origin of the pattern"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   604
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   605
    |x y|
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   606
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   607
    transformation notNil ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   608
	x := transformation applyToX:orgX.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   609
	y := transformation applyToY:orgY.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   610
    ] ifFalse:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   611
	x := orgX.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   612
	y := orgY
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   613
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   614
    x := x rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   615
    y := y rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   616
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   617
    (maskOrigin isNil or:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   618
     ((x ~~ maskOrigin x) or:[y ~~ maskOrigin y]) ]) ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   619
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   620
	maskOrigin := x @ y.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   621
	gcId notNil ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   622
	    device setMaskOriginX:x y:y in:gcId
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   623
	]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   624
    ]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   625
! !
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   626
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   627
!DeviceGraphicsContext methodsFor:'accessing - internals'!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   628
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   629
background
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   630
    "return the current background drawing color.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   631
     OBSOLETE: use #paint: / #backgroundPaint: / #paint:on:"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   632
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   633
    ^ background
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   634
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   635
    "Modified: 12.5.1996 / 22:28:09 / cg"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   636
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   637
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   638
background:aColor
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   639
    "set the internal background color for drawing - aColor must be a real color.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   640
     OBSOLETE: this method will vanish; use #paint: / #backgroundPaint: / #paint:on:"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   641
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   642
    |bgId|
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   643
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   644
    (aColor ~~ background) ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   645
        aColor notNil ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   646
            background := aColor.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   647
            gcId notNil ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   648
                background := background on:device.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   649
                bgId := background colorId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   650
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   651
                "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   652
                 mhmh the following is a kludge ....
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   653
                "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   654
                bgId isNil ifTrue:[
745
d4465098f2c0 gray vs. grey
Claus Gittinger <cg@exept.de>
parents: 735
diff changeset
   655
                    (background grayIntensity >= 50) ifTrue:[
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   656
                        bgId := device whitepixel
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   657
                    ] ifFalse:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   658
                        bgId := device blackpixel
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   659
                    ]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   660
                ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   661
                device setBackground:bgId in:gcId
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   662
            ]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   663
        ]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   664
    ]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   665
745
d4465098f2c0 gray vs. grey
Claus Gittinger <cg@exept.de>
parents: 735
diff changeset
   666
    "Modified: 28.5.1996 / 20:44:55 / cg"
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   667
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   668
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   669
foreground
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   670
    "return the current foreground drawing color.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   671
     OBSOLETE: use #paint: / #paint:on:"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   672
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   673
    ^ foreground
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   674
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   675
    "Modified: 12.5.1996 / 22:28:03 / cg"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   676
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   677
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   678
foreground:aColor
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   679
    "set the internal foreground color for drawing - aColor must be a real color.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   680
     OBSOLETE: this method will vanish; use #paint: / #paint:on:"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   681
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   682
    |fgId|
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   683
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   684
    (aColor ~~ foreground) ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   685
        aColor notNil ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   686
            foreground := aColor.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   687
            gcId notNil ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   688
                (foreground class == SmallInteger) ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   689
                    fgId := foreground
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   690
                ] ifFalse:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   691
                    foreground := foreground on:device.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   692
                    fgId := foreground colorId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   693
                ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   694
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   695
                "mhmh the following is a kludge ...."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   696
                fgId isNil ifTrue:[
745
d4465098f2c0 gray vs. grey
Claus Gittinger <cg@exept.de>
parents: 735
diff changeset
   697
                    (foreground grayIntensity >= 50) ifTrue:[
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   698
                        fgId := device whitepixel
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   699
                    ] ifFalse:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   700
                        fgId := device blackpixel
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   701
                    ]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   702
                ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   703
                device setForeground:fgId in:gcId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   704
                paint := foreground
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   705
            ]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   706
        ]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   707
    ]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   708
745
d4465098f2c0 gray vs. grey
Claus Gittinger <cg@exept.de>
parents: 735
diff changeset
   709
    "Modified: 28.5.1996 / 20:45:02 / cg"
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   710
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   711
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   712
foreground:fgColor background:bgColor
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   713
    "set both internal foreground and internal background colors 
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   714
     - these must be real colors.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   715
     OBSOLETE: this method will vanish; use #paint: / #paint:on:"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   716
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   717
    |fgPixel bgPixel|
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   718
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   719
    ((fgColor ~~ foreground) or:[bgColor ~~ background]) ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   720
        fgColor notNil ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   721
            foreground := fgColor
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   722
        ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   723
        bgColor notNil ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   724
            background := bgColor
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   725
        ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   726
        gcId notNil ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   727
            foreground := foreground on:device.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   728
            background := background on:device.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   729
            fgPixel := foreground colorId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   730
            bgPixel := background colorId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   731
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   732
            "mhmh the following is a kludge ...."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   733
            fgPixel isNil ifTrue:[
745
d4465098f2c0 gray vs. grey
Claus Gittinger <cg@exept.de>
parents: 735
diff changeset
   734
                (foreground grayIntensity >= 50) ifTrue:[
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   735
                    fgPixel := device whitepixel
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   736
                ] ifFalse:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   737
                    fgPixel := device blackpixel
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   738
                ]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   739
            ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   740
            bgPixel isNil ifTrue:[
745
d4465098f2c0 gray vs. grey
Claus Gittinger <cg@exept.de>
parents: 735
diff changeset
   741
                (background grayIntensity >= 50) ifTrue:[
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   742
                    bgPixel := device whitepixel
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   743
                ] ifFalse:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   744
                    bgPixel := device blackpixel
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   745
                ]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   746
            ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   747
            device setForeground:fgPixel background:bgPixel in:gcId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   748
            paint := foreground
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   749
        ]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   750
    ]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   751
745
d4465098f2c0 gray vs. grey
Claus Gittinger <cg@exept.de>
parents: 735
diff changeset
   752
    "Modified: 28.5.1996 / 20:45:27 / cg"
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   753
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   754
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   755
foreground:fgColor background:bgColor function:fun
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   756
    "set foreground, background colors and function.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   757
     OBSOLETE: this method will vanish; use #paint: / #paint:on:"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   758
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   759
    self foreground:fgColor background:bgColor.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   760
    self function:fun
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   761
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   762
    "Modified: 12.5.1996 / 22:28:34 / cg"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   763
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   764
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   765
foreground:aColor function:fun
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   766
    "set the foreground color and function for drawing.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   767
     OBSOLETE: this method will vanish; use #paint: / #paint:on:"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   768
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   769
    |fgPixel|
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   770
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   771
    ((aColor ~~ foreground) or:[fun ~~ function]) ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   772
        foreground := aColor.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   773
        function := fun.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   774
        gcId notNil ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   775
            foreground := foreground on:device.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   776
            fgPixel := foreground colorId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   777
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   778
            "mhmh the following is a kludge ...."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   779
            fgPixel isNil ifTrue:[
745
d4465098f2c0 gray vs. grey
Claus Gittinger <cg@exept.de>
parents: 735
diff changeset
   780
                (foreground grayIntensity >= 50) ifTrue:[
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   781
                    fgPixel := device whitepixel
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   782
                ] ifFalse:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   783
                    fgPixel := device blackpixel
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   784
                ]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   785
            ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   786
            device setForeground:fgPixel in:gcId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   787
            device setFunction:fun in:gcId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   788
            paint := foreground
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   789
        ]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   790
    ]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   791
745
d4465098f2c0 gray vs. grey
Claus Gittinger <cg@exept.de>
parents: 735
diff changeset
   792
    "Modified: 28.5.1996 / 20:45:09 / cg"
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   793
! !
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   794
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   795
!DeviceGraphicsContext methodsFor:'bit blitting'!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   796
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   797
copyBitsFrom:aByteArray bitsPerPixel:bpp depth:depth width:srcW height:srcH x:srcX y:srcY toX:dstX y:dstY
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   798
    "copy bits from a smalltalk byteArray.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   799
     The bits found there are supposed to be in the devices native format (i.e.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   800
     translated to allocated color indices on pseudoColor devices and padded as required.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   801
     The byteOrder is MSB and will be converted as appropriate by the underlying devices 
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   802
     method to whatever the device needs."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   803
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   804
    device
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   805
	drawBits:aByteArray bitsPerPixel:bpp depth:depth  
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   806
	   width:srcW height:srcH
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   807
	       x:srcX y:srcY
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   808
	    into:drawableId
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   809
	       x:dstX y:dstY 
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   810
	   width:(self width) height:(self height)
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   811
	    with:gcId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   812
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   813
    "Created: 21.10.1995 / 00:04:22 / cg"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   814
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   815
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   816
copyFrom:aDrawable x:srcX y:srcY toX:dstX y:dstY width:w height:h
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   817
    "copy from aDrawable into the receiver;
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   818
     the source may be the receiver as well - in this case its a scroll.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   819
     All coordinates are in device coordinates."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   820
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   821
    |id|
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   822
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   823
    id := aDrawable id.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   824
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   825
    "temporary ...
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   826
     this fixes a problem after restart on another display,
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   827
     when a file-bitmap wasnt found. In this case, the id of the
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   828
     bitmap will be nil. This will be fixed soon.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   829
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   830
    (id isNil 
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   831
    or:[aDrawable graphicsDevice ~~ device]) ifTrue:[
868
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
   832
        'DEVGC: invalid bitmap copy - ignored' errorPrintNL.
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
   833
        ^ self
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   834
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   835
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   836
    gcId isNil ifTrue:[
868
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
   837
        self initGC
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   838
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   839
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   840
    "this is a workaround for a bug (or a feature ?) in many X-servers;
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   841
     copy is only copy if fg==1 and bg==0"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   842
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   843
"/No: it was my fault - shame, shame
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   844
"/
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   845
"/    ((aDrawable == self) and:[function == #copy]) ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   846
"/        device setForeground:1 background:0 in:gcId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   847
"/        background := nil.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   848
"/        foreground := nil.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   849
"/        paint := nil
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   850
"/    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   851
"/
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   852
    ((aDrawable depth == 1) and:[device depth ~~ 1]) ifTrue:[
868
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
   853
        device
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
   854
            copyPlaneFromId:id
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
   855
                     x:srcX y:srcY
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
   856
                    to:drawableId
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
   857
                     x:dstX y:dstY
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
   858
                 width:w
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
   859
                height:h
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
   860
                  with:gcId
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   861
    ] ifFalse:[
868
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
   862
        device
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
   863
            copyFromId:id
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
   864
                     x:srcX y:srcY
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
   865
                    to:drawableId
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
   866
                     x:dstX y:dstY
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
   867
                 width:w
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
   868
                height:h
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
   869
                  with:gcId
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   870
    ]
868
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
   871
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
   872
    "Modified: 15.6.1996 / 15:36:38 / cg"
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   873
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   874
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   875
copyPlaneFrom:aDrawable x:srcX y:srcY toX:dstX y:dstY width:w height:h
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   876
    "copy one plane from aDrawable into the receiver. 0's are drawn in
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   877
     background, while 1's are drawn with foreground color.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   878
     The depth of aDrawable must (should) be 1.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   879
     The drawable must have been allocated on the same device.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   880
     All coordinates are in device coordinates."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   881
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   882
    |id|
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   883
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   884
    id := aDrawable id.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   885
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   886
    "temporary ...
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   887
     this fixes a problem after restart on another display,
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   888
     when a file-bitmap wasnt found. In this case, the id of the
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   889
     bitmap will be nil. This will be fixed soon.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   890
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   891
    (id isNil 
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   892
    or:[aDrawable graphicsDevice ~~ device]) ifTrue:[
868
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
   893
        'DEVGC: invalid copyPlane - ignored' errorPrintNL.
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
   894
        ^ self
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   895
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   896
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   897
    gcId isNil ifTrue:[
868
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
   898
        self initGC
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   899
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   900
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   901
    device
868
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
   902
        copyPlaneFromId:id
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
   903
                 x:srcX y:srcY
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
   904
                to:drawableId
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
   905
                 x:dstX y:dstY
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
   906
             width:w
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
   907
            height:h
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
   908
              with:gcId
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
   909
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
   910
    "Modified: 15.6.1996 / 15:36:42 / cg"
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   911
! !
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   912
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   913
!DeviceGraphicsContext methodsFor:'copying'!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   914
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   915
postCopy
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   916
    "this may not be enough to allow copying of views ..."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   917
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   918
    super postCopy.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   919
    device := drawableId := gcId := nil.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   920
    self recreate
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   921
! !
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   922
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   923
!DeviceGraphicsContext methodsFor:'drawing'!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   924
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   925
displayArcX:x y:y width:w height:h from:startAngle angle:angle
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   926
    "draw an arc; apply transformation if nonNil"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   927
784
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
   928
    |pX pY rpX rpY nW nH|
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   929
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   930
    gcId isNil ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   931
        self initGC
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   932
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   933
    transformation notNil ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   934
        pX := transformation applyToX:x.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   935
        pY := transformation applyToY:y.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   936
        nW := transformation applyScaleX:w.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   937
        nH := transformation applyScaleY:h.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   938
        nW < 0 ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   939
              nW := nW abs.  
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   940
              pX := pX - nW.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   941
        ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   942
        nH < 0 ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   943
              nH := nH abs.  
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   944
              pY := pY - nH.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   945
        ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   946
    ] ifFalse:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   947
        pX := x.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   948
        pY := y.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   949
        nW := w.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   950
        nH := h.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   951
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   952
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   953
    pX := pX rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   954
    pY := pY rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   955
    nW := nW rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   956
    nH := nH rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   957
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   958
    device
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   959
          displayArcX:pX 
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   960
                    y:pY 
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   961
                width:nW 
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   962
               height:nH 
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   963
                 from:startAngle 
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   964
                angle:angle
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   965
                   in:drawableId 
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   966
                 with:gcId
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   967
784
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
   968
"/    rpX := pX rounded.
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
   969
"/    rpY := pY rounded.
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
   970
"/    nW := (nW + (rpX - pX)) rounded.
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
   971
"/    nH := (nH + (rpY - pY)) rounded.
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
   972
"/
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
   973
"/    device
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
   974
"/          displayArcX:rpX 
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
   975
"/                    y:rpY 
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
   976
"/                width:nW 
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
   977
"/               height:nH 
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
   978
"/                 from:startAngle 
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
   979
"/                angle:angle
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
   980
"/                   in:drawableId 
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
   981
"/                 with:gcId
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
   982
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   983
    "Created: 8.5.1996 / 08:31:30 / cg"
784
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
   984
    "Modified: 4.6.1996 / 17:59:28 / cg"
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   985
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   986
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   987
displayForm:formToDraw x:x y:y
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   988
    "draw a form; if its a 1-plane bitmap, 1-bits are drawn in the
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   989
     current paint-color, leaving pixels with 0-bits unchanged
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   990
     (i.e. only 1-bits are drawn from the form).
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   991
     If its a deep form (i.e. a pixmap) the current paint
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   992
     settings are ignored and the form is drawn as-is. 
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   993
     Care must be taken, that the paint color is correctly allocated 
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   994
     (by sending #on: to the color) before doing so.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   995
     Using functions other than #copy only makes sense if you are
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   996
     certain, that the colors are real colors (actually, only for
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   997
     noColor or allColor)."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   998
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   999
    |realForm pX pY w h nW nH|
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1000
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1001
    realForm := formToDraw.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1002
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1003
    transformation notNil ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1004
        pX := transformation applyToX:x.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1005
        pY := transformation applyToY:y.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1006
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1007
        transformation noScale ifFalse:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1008
            w := formToDraw width.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1009
            h := formToDraw height.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1010
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1011
            nW := (transformation applyScaleX:w) rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1012
            nH := (transformation applyScaleY:h) rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1013
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1014
            ((nW ~= w) or:[nH ~= h]) ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1015
                "/
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1016
                "/ hard case - someone is drawing forms with scaling in effect
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1017
                "/ look if we have a scaled version in our pocket ...
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1018
                "/
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1019
                realForm := nil.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1020
                CachedScaledForms notNil ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1021
                    (CachedScales at:formToDraw ifAbsent:nil) = transformation scale ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1022
                        realForm := CachedScaledForms at:formToDraw ifAbsent:nil.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1023
                    ]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1024
                ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1025
                realForm isNil ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1026
                    "/
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1027
                    "/ nope - must do the work ...
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1028
                    "/
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1029
                    realForm := formToDraw magnifiedBy:(nW / w) @ (nH / h).
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1030
                    CachedScaledForms isNil ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1031
                        CachedScaledForms := WeakIdentityDictionary new.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1032
                        CachedScales := WeakIdentityDictionary new.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1033
                    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1034
                    CachedScaledForms at:formToDraw put:realForm.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1035
                    CachedScales at:formToDraw put:transformation scale.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1036
                ]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1037
            ]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1038
        ]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1039
    ] ifFalse:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1040
        pX := x.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1041
        pY := y.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1042
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1043
    pX := pX rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1044
    pY := pY rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1045
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1046
    self displayDeviceForm:realForm x:pX y:pY
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1047
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1048
    "Modified: 21.5.1996 / 21:15:44 / cg"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1049
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1050
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1051
displayLineFromX:x0 y:y0 toX:x1 y:y1
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1052
    "draw a line (with current paint-color); apply transformation if nonNil"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1053
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1054
    |pX0 pY0 pX1 pY1 easy fgId bgId|
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1055
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1056
    gcId isNil ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1057
        self initGC
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1058
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1059
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1060
    lineStyle == #doubleDashed ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1061
        "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1062
         if bgPaint or paint is not a real color, we have to do it the hard way ...
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1063
        "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1064
        easy := true.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1065
        paint isColor ifFalse:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1066
            easy := false
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1067
        ] ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1068
            fgId := paint colorId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1069
            fgId isNil ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1070
                easy := false
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1071
            ]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1072
        ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1073
        bgPaint isColor ifFalse:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1074
            easy := false
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1075
        ] ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1076
            bgId := bgPaint colorId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1077
            bgId isNil ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1078
                easy := false
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1079
            ]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1080
        ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1081
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1082
        easy ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1083
            ((foreground ~~ paint) or:[background ~~ bgPaint]) ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1084
                device setForeground:fgId background:bgId in:gcId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1085
                foreground := paint.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1086
                background := bgPaint.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1087
            ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1088
        ] ifFalse:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1089
            'DEVDRAW: cannot draw dashes with dithered colors' errorPrintNL
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1090
        ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1091
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1092
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1093
    transformation notNil ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1094
        pX0 := transformation applyToX:x0.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1095
        pY0 := transformation applyToY:y0.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1096
        pX1 := transformation applyToX:x1.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1097
        pY1 := transformation applyToY:y1.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1098
    ] ifFalse:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1099
        pX0 := x0.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1100
        pY0 := y0.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1101
        pX1 := x1.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1102
        pY1 := y1
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1103
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1104
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1105
    pX0 := pX0 rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1106
    pY0 := pY0 rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1107
    pX1 := pX1 rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1108
    pY1 := pY1 rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1109
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1110
    device displayLineFromX:pX0 y:pY0 toX:pX1 y:pY1 in:drawableId with:gcId
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1111
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1112
    "Modified: 13.4.1996 / 20:31:19 / cg"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1113
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1114
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1115
displayOpaqueForm:formToDraw x:x y:y
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1116
    "draw a form; if its a 1-plane bitmap, 1-bits are drawn in the
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1117
     current paint-color and 0-bits in the bgPaint color.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1118
     If its a deep form (i.e. a pixmap) the current paint/bgPaint
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1119
     settings are ignored and the form drawn as-is. 
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1120
     In the 1-plane case, special care must be taken if paint and/or bgPaint 
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1121
     dithered colors or patterns, since are that the colors are correctly allocated 
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1122
     (by sending #on: to the colors) before doing so.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1123
     If there is a transformation, the image is scaled as appropiate."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1124
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1125
    |w h realForm pX pY nW nH|
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1126
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1127
    bgPaint isNil ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1128
        "/
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1129
        "/ actually not an opaque draw
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1130
        "/
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1131
        self displayForm:formToDraw x:x y:y.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1132
        ^ self
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1133
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1134
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1135
    realForm := formToDraw.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1136
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1137
    transformation notNil ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1138
        pX := transformation applyToX:x.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1139
        pY := transformation applyToY:y.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1140
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1141
        transformation noScale ifFalse:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1142
            w := formToDraw width.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1143
            h := formToDraw height.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1144
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1145
            nW := (transformation applyScaleX:w) rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1146
            nH := (transformation applyScaleY:h) rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1147
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1148
            ((nW ~= w) or:[nH ~= h]) ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1149
                "/
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1150
                "/ hard case - someone is drawing forms with scaling in effect
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1151
                "/ look if we have a scaled version in our pocket ...
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1152
                "/
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1153
                realForm := nil.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1154
                CachedScaledForms notNil ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1155
                    (CachedScales at:formToDraw ifAbsent:nil) = transformation scale ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1156
                        realForm := CachedScaledForms at:formToDraw ifAbsent:nil.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1157
                    ]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1158
                ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1159
                realForm isNil ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1160
                    "/
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1161
                    "/ nope - must do the work ...
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1162
                    "/
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1163
                    realForm := formToDraw magnifiedBy:(nW / w) @ (nH / h).
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1164
                    CachedScaledForms isNil ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1165
                        CachedScaledForms := WeakIdentityDictionary new.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1166
                        CachedScales := WeakIdentityDictionary new.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1167
                    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1168
                    CachedScaledForms at:formToDraw put:realForm.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1169
                    CachedScales at:formToDraw put:transformation scale.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1170
                ]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1171
            ]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1172
        ]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1173
    ] ifFalse:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1174
        pX := x.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1175
        pY := y.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1176
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1177
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1178
    pX := pX rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1179
    pY := pY rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1180
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1181
    self displayDeviceOpaqueForm:realForm x:pX y:pY
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1182
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1183
    "Modified: 21.5.1996 / 21:15:54 / cg"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1184
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1185
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1186
displayOpaqueString:aString from:index1 to:index2 x:x y:y
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1187
    "draw a substring at the coordinate x/y - draw foreground pixels in
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1188
     paint-color and background pixels in bgPaint-color.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1189
     If the transformation involves scaling, 
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1190
     the fonts point-size is scaled as appropriate.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1191
     Assuming that device can only draw in device colors, we have to handle
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1192
     the case where paint and/or bgPaint are dithered colors"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1193
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1194
    |easy w h savedPaint fgId bgId
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1195
     id pX pY fontUsed sz s|
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1196
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1197
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1198
     if backgroundPaint color is nil, we assume
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1199
     this is a non-opaque draw
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1200
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1201
    bgPaint isNil ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1202
        self displayString:aString from:index1 to:index2 x:x y:y.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1203
        ^ self
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1204
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1205
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1206
    (aString isString not
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1207
    or:[aString isText]) ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1208
        "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1209
         hook for non-strings (i.e. attributed text)
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1210
         that 'thing' should know how to display itself ...
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1211
        "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1212
        aString displayOpaqueOn:self x:x y:y from:index1 to:index2.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1213
        ^ self
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1214
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1215
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1216
    gcId isNil ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1217
        self initGC
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1218
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1219
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1220
    fontUsed := font.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1221
    transformation notNil ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1222
        pX := transformation applyToX:x.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1223
        pY := transformation applyToY:y.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1224
        transformation noScale ifFalse:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1225
            sz := font size.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1226
            sz isNil ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1227
                "/ oops - not a real font; use original font
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1228
                fontUsed := font
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1229
            ] ifFalse:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1230
                fontUsed := font size:(transformation applyScaleY:sz) rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1231
            ]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1232
        ]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1233
    ] ifFalse:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1234
        pX := x.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1235
        pY := y.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1236
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1237
    pX := pX rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1238
    pY := pY rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1239
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1240
    fontUsed := fontUsed on:device.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1241
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1242
    id := fontUsed fontId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1243
    id isNil ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1244
        "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1245
         hook for alien fonts
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1246
         that 'font' should know how to display the string ...
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1247
        "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1248
        fontUsed displayOpaqueString:aString from:index1 to:index2 x:x y:y in:self.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1249
        ^ self
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1250
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1251
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1252
    s := aString.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1253
    s encoding ~~ font encoding ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1254
        s := s encodeInto:(font encoding).
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1255
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1256
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1257
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1258
     if bgPaint or paint is not a real Color, we have to do it the hard way ...
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1259
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1260
    easy := true.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1261
    paint isColor ifFalse:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1262
        easy := false
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1263
    ] ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1264
        fgId := paint colorId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1265
        fgId isNil ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1266
            easy := false
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1267
        ]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1268
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1269
    bgPaint isColor ifFalse:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1270
        easy := false
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1271
    ] ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1272
        bgId := bgPaint colorId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1273
        bgId isNil ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1274
            easy := false
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1275
        ]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1276
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1277
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1278
    easy ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1279
        deviceFont ~~ fontUsed ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1280
            device setFont:id in:gcId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1281
            deviceFont := fontUsed
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1282
        ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1283
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1284
        device setForeground:fgId background:bgId in:gcId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1285
        foreground := paint.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1286
        background := bgPaint.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1287
        device displayOpaqueString:s 
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1288
                              from:index1 to:index2
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1289
                                 x:pX y:pY 
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1290
                                in:drawableId with:gcId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1291
        ^ self
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1292
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1293
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1294
    w := fontUsed widthOf:s from:index1 to:index2.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1295
    h := fontUsed height.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1296
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1297
    (fgId notNil and:[function == #copy]) ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1298
        deviceFont ~~ fontUsed ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1299
            device setFont:id in:gcId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1300
            deviceFont := fontUsed
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1301
        ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1302
        "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1303
         only bg is dithered; fill with bg first ...
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1304
        "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1305
        savedPaint := paint.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1306
        self paint:bgPaint.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1307
        self fillDeviceRectangleX:pX y:(pY - fontUsed ascent) width:w height:h.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1308
        self paint:savedPaint.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1309
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1310
        "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1311
         then draw using fgPaint (which is a real color)
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1312
        "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1313
        device displayString:s 
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1314
                        from:index1 to:index2
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1315
                           x:pX y:pY 
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1316
                          in:drawableId with:gcId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1317
        ^ self
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1318
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1319
832
064890dcfabd fixed opaque string draw with deep-dither
Claus Gittinger <cg@exept.de>
parents: 786
diff changeset
  1320
    "/ the very hard case (fg-dither)
064890dcfabd fixed opaque string draw with deep-dither
Claus Gittinger <cg@exept.de>
parents: 786
diff changeset
  1321
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1322
    self displayDeviceOpaqueString:s from:index1 to:index2 in:fontUsed x:pX y:pY.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1323
832
064890dcfabd fixed opaque string draw with deep-dither
Claus Gittinger <cg@exept.de>
parents: 786
diff changeset
  1324
    "Modified: 12.6.1996 / 12:36:33 / cg"
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1325
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1326
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1327
displayOpaqueString:aString x:x y:y
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1328
    "draw a string at the coordinate x/y - draw foreground pixels in paint-color,
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1329
     background pixels in bgPaint color. If the transformation involves scaling, 
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1330
     the fonts point-size is scaled as appropriate.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1331
     Assuming that device can only draw in device colors, we have to handle
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1332
     the case where paint and/or bgPaint are dithered colors or images."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1333
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1334
    |id easy fgId bgId pX pY fontUsed sz s|
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1335
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1336
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1337
     if backgroundPaint color is nil, we assume
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1338
     this is a non-opaque draw
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1339
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1340
    bgPaint isNil ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1341
        self displayString:aString x:x y:y.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1342
        ^ self
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1343
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1344
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1345
    (aString isString not
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1346
    or:[aString isText]) ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1347
        "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1348
         hook for non-strings (i.e. attributed text)
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1349
         that 'thing' should know how to display itself ...
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1350
        "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1351
        aString displayOpaqueOn:self x:x y:y.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1352
        ^ self
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1353
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1354
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1355
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1356
     if bgPaint or paint is not a real Color, we have to do it the hard way ...
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1357
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1358
    easy := true.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1359
    paint isColor ifFalse:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1360
        easy := false
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1361
    ] ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1362
        fgId := paint colorId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1363
        fgId isNil ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1364
            easy := false
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1365
        ]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1366
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1367
    bgPaint isColor ifFalse:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1368
        easy := false
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1369
    ] ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1370
        bgId := bgPaint colorId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1371
        bgId isNil ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1372
            easy := false
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1373
        ]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1374
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1375
    easy ifFalse:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1376
        "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1377
         for the hard case, use the general drawing method
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1378
         (no need for optimizations - its slow anyway)
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1379
        "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1380
        self displayOpaqueString:aString 
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1381
                            from:1 to:(aString size)
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1382
                               x:x y:y. 
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1383
        ^ self
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1384
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1385
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1386
    gcId isNil ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1387
        self initGC
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1388
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1389
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1390
    fontUsed := font.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1391
    transformation notNil ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1392
        pX := transformation applyToX:x.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1393
        pY := transformation applyToY:y.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1394
        transformation noScale ifFalse:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1395
            sz := font size.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1396
            sz isNil ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1397
                "/ oops - not a real font; use original font
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1398
                fontUsed := font
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1399
            ] ifFalse:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1400
                fontUsed := font size:(transformation applyScaleY:sz) rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1401
            ]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1402
        ]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1403
    ] ifFalse:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1404
        pX := x.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1405
        pY := y.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1406
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1407
    pX := pX rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1408
    pY := pY rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1409
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1410
    fontUsed := fontUsed on:device.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1411
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1412
    id := fontUsed fontId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1413
    id isNil ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1414
        "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1415
         hook for alien fonts
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1416
         that 'font' should know how to display the string ...
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1417
        "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1418
        fontUsed displayOpaqueString:aString from:1 to:(aString size) x:x y:y in:self.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1419
        ^ self
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1420
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1421
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1422
    s := aString.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1423
    s encoding ~~ font encoding ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1424
        s := s encodeInto:(font encoding).
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1425
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1426
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1427
    deviceFont ~~ fontUsed ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1428
        device setFont:id in:gcId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1429
        deviceFont := fontUsed
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1430
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1431
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1432
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1433
    device setForeground:fgId background:bgId in:gcId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1434
    foreground := paint.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1435
    background := bgPaint.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1436
    device displayOpaqueString:s 
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1437
                             x:pX y:pY 
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1438
                            in:drawableId with:gcId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1439
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1440
    "Modified: 21.5.1996 / 21:16:17 / cg"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1441
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1442
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1443
displayPointX:x y:y
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1444
    "draw a point (with current paint-color); apply transformation if nonNil"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1445
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1446
    |pX pY|
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1447
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1448
    gcId isNil ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1449
	self initGC
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1450
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1451
    transformation notNil ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1452
	pX := transformation applyToX:x.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1453
	pY := transformation applyToY:y.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1454
    ] ifFalse:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1455
	pX := x.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1456
	pY := y
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1457
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1458
    pX := pX rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1459
    pY := pY rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1460
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1461
    device displayPointX:pX y:pY in:drawableId with:gcId
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1462
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1463
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1464
displayPolygon:aPolygon
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1465
    "draw (the outline of) a polygon (with current paint-color).
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1466
     Apply transformation if nonNil"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1467
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1468
    |newPolygon|
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1469
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1470
    gcId isNil ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1471
	self initGC
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1472
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1473
    transformation notNil ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1474
	newPolygon := aPolygon collect:[:point | transformation applyTo:point].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1475
    ] ifFalse:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1476
	newPolygon := aPolygon
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1477
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1478
    (newPolygon findFirst:[:p | 
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1479
	(p isPoint not 
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1480
	or:[(p x class ~~ SmallInteger)
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1481
	or:[(p y class ~~ SmallInteger)]])
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1482
     ]) ~~ 0 ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1483
	newPolygon := newPolygon collect:[:p | p asPoint rounded]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1484
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1485
        
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1486
    device displayPolygon:newPolygon in:drawableId with:gcId
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1487
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1488
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1489
displayRectangleX:x y:y width:w height:h
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1490
    "draw a rectangle (with current paint-color).
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1491
     If transformation is nonNil, drawing is in logical coordinates."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1492
784
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
  1493
    |pX pY rpX rpY nW nH easy fgId bgId|
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1494
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1495
    gcId isNil ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1496
        self initGC
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1497
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1498
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1499
    lineStyle == #doubleDashed ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1500
        "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1501
         if bgPaint or paint is not a real color, we have to do it the hard way ...
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1502
        "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1503
        easy := true.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1504
        paint isColor ifFalse:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1505
            easy := false
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1506
        ] ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1507
            fgId := paint colorId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1508
            fgId isNil ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1509
                easy := false
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1510
            ]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1511
        ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1512
        bgPaint isColor ifFalse:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1513
            easy := false
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1514
        ] ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1515
            bgId := bgPaint colorId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1516
            bgId isNil ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1517
                easy := false
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1518
            ]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1519
        ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1520
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1521
        easy ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1522
            ((foreground ~~ paint) or:[background ~~ bgPaint]) ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1523
                device setForeground:fgId background:bgId in:gcId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1524
                foreground := paint.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1525
                background := bgPaint.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1526
            ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1527
        ] ifFalse:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1528
            'DEVDRAW: cannot draw dashes with dithered colors' errorPrintNL
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1529
        ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1530
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1531
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1532
    transformation notNil ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1533
        pX := transformation applyToX:x.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1534
        pY := transformation applyToY:y.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1535
        nW := transformation applyScaleX:w.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1536
        nH := transformation applyScaleY:h.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1537
        nW < 0 ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1538
              nW := nW abs.  
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1539
              pX := pX - nW.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1540
        ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1541
        nH < 0 ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1542
              nH := nH abs.  
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1543
              pY := pY - nH.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1544
        ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1545
    ] ifFalse:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1546
        pX := x.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1547
        pY := y.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1548
        nW := w.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1549
        nH := h
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1550
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1551
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1552
    pX := pX rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1553
    pY := pY rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1554
    nW := nW rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1555
    nH := nH rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1556
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1557
    "I asked myself many times if we should draw w/h or (w-1)/(h-1) bits -
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1558
     this one seems mathematically incorrect but allows to draw and fill
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1559
     a rectangle using the same extents.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1560
     I'm not certain if is the right thing to do ...
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1561
    "
784
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
  1562
    device displayRectangleX:pX 
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
  1563
                           y:pY 
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
  1564
                       width:(nW - 1) 
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
  1565
                      height:(nH - 1)
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
  1566
                          in:drawableId with:gcId
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
  1567
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
  1568
"/    rpX := pX rounded.
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
  1569
"/    rpY := pY rounded.
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
  1570
"/    nW := (nW + (rpX - pX)) rounded.
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
  1571
"/    nH := (nH + (rpY - pY)) rounded.
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
  1572
"/
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
  1573
"/    "I asked myself many times if we should draw w/h or (w-1)/(h-1) bits -
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
  1574
"/     this one seems mathematically incorrect but allows to draw and fill
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
  1575
"/     a rectangle using the same extents.
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
  1576
"/     I'm not certain if is the right thing to do ...
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
  1577
"/    "
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
  1578
"/    device displayRectangleX:rpX 
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
  1579
"/                           y:rpY 
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
  1580
"/                       width:(nW - 1) 
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
  1581
"/                      height:(nH - 1)
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
  1582
"/                          in:drawableId with:gcId
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
  1583
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
  1584
    "Modified: 4.6.1996 / 18:00:03 / cg"
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1585
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1586
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1587
displayString:aString from:index1 to:index2 x:x y:y
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1588
    "draw a substring at the coordinate x/y -  
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1589
     draw foreground-pixels only (in current paint-color), 
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1590
     leaving background as-is. If the transformation involves scaling,
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1591
     the fonts point-size is scaled as appropriate."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1592
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1593
    |id pX pY fontUsed sz s|
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1594
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1595
    "hook for non-strings (i.e. attributed text)"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1596
    aString isString ifFalse:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1597
        ^ aString displayOn:self x:x y:y from:index1 to:index2
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1598
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1599
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1600
    gcId isNil ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1601
        self initGC
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1602
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1603
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1604
    fontUsed := font.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1605
    transformation notNil ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1606
        pX := transformation applyToX:x.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1607
        pY := transformation applyToY:y.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1608
        transformation noScale ifFalse:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1609
            sz := font size.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1610
            sz isNil ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1611
                "/ oops - not a real font; use original font
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1612
                fontUsed := font
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1613
            ] ifFalse:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1614
                fontUsed := font size:(transformation applyScaleY:sz) rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1615
            ]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1616
        ]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1617
    ] ifFalse:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1618
        pX := x.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1619
        pY := y.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1620
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1621
    pX := pX rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1622
    pY := pY rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1623
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1624
    fontUsed := fontUsed on:device.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1625
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1626
    id := fontUsed fontId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1627
    id isNil ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1628
        "hook for alien fonts"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1629
        font displayString:aString from:index1 to:index2 x:x y:y in:self.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1630
        ^ self
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1631
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1632
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1633
    s := aString.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1634
    s encoding ~~ font encoding ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1635
        s := s encodeInto:(font encoding).
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1636
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1637
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1638
    deviceFont ~~ fontUsed ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1639
        device setFont:id in:gcId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1640
        deviceFont := fontUsed
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1641
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1642
    device displayString:s from:index1 to:index2
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1643
                       x:pX y:pY in:drawableId with:gcId
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1644
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1645
    "Modified: 21.5.1996 / 21:16:24 / cg"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1646
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1647
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1648
displayString:aString x:x y:y
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1649
    "draw a string at the coordinate x/y - 
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1650
     draw foreground-pixels only (in current paint-color), 
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1651
     leaving background as-is. If the transformation involves scaling, 
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1652
     the fonts point-size is scaled as appropriate."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1653
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1654
    |id pX pY fontUsed sz s|
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1655
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1656
    "hook for non-strings (i.e. attributed text)"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1657
    (aString isString not
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1658
    or:[aString isText]) ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1659
        ^ aString displayOn:self x:x y:y
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1660
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1661
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1662
    gcId isNil ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1663
        self initGC
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1664
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1665
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1666
    fontUsed := font.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1667
    transformation notNil ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1668
        pX := transformation applyToX:x.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1669
        pY := transformation applyToY:y.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1670
        transformation noScale ifFalse:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1671
            sz := font size.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1672
            sz isNil ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1673
                "/ oops - not a real font; use original font
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1674
                fontUsed := font
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1675
            ] ifFalse:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1676
                fontUsed := font size:(transformation applyScaleY:sz) rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1677
            ]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1678
        ]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1679
    ] ifFalse:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1680
        pX := x.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1681
        pY := y.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1682
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1683
    pX := pX rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1684
    pY := pY rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1685
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1686
    fontUsed := fontUsed on:device.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1687
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1688
    id := fontUsed fontId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1689
    id isNil ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1690
        "hook for alien fonts"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1691
        fontUsed displayString:aString x:x y:y in:self
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1692
    ] ifFalse:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1693
        s := aString.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1694
        s encoding ~~ fontUsed encoding ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1695
            s := s encodeInto:(fontUsed encoding).
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1696
        ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1697
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1698
        deviceFont ~~ fontUsed ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1699
            device setFont:id in:gcId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1700
            deviceFont := fontUsed
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1701
        ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1702
        device displayString:s x:pX y:pY in:drawableId with:gcId
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1703
    ]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1704
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1705
    "Modified: 21.5.1996 / 21:16:30 / cg"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1706
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1707
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1708
displayUnscaledForm:formToDraw x:x y:y
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1709
    "draw a form; if its a 1-plane bitmap, 1-bits are drawn in the
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1710
     current paint-color, leaving pixels with 0-bits unchanged
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1711
     (i.e. only 1-bits are drawn from the form).
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1712
     If its a deep form (i.e. a pixmap) the current paint
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1713
     settings are ignored and the form is drawn as-is. 
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1714
     Care must be taken, that the paint color is correctly allocated 
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1715
     (by sending #on: to the color) before doing so.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1716
     Using functions other than #copy only makes sense if you are
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1717
     certain, that the colors are real colors (actually, only for
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1718
     noColor or allColor).
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1719
     The origins coordinate is transformed, but the image itself is unscaled."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1720
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1721
    |pX pY|
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1722
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1723
    transformation notNil ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1724
	pX := transformation applyToX:x.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1725
	pY := transformation applyToY:y.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1726
    ] ifFalse:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1727
	pX := x.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1728
	pY := y.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1729
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1730
    pX := pX rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1731
    pY := pY rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1733
    self displayDeviceForm:formToDraw x:pX y:pY
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1734
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1735
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1736
displayUnscaledOpaqueForm:formToDraw x:x y:y
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1737
    "draw a form; if its a 1-plane bitmap, 1-bits are drawn in the
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1738
     current paint-color, 0 bits in background color.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1739
     If its a deep form (i.e. a pixmap) the current paint
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1740
     settings are ignored and the form is drawn as-is (opaque). 
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1741
     The origins coordinate is transformed, but the image itself is unscaled."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1742
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1743
    |pX pY|
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1744
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1745
    transformation notNil ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1746
	pX := transformation applyToX:x.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1747
	pY := transformation applyToY:y.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1748
    ] ifFalse:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1749
	pX := x.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1750
	pY := y.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1751
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1752
    pX := pX rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1753
    pY := pY rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1754
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1755
    self displayDeviceOpaqueForm:formToDraw x:pX y:pY
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1756
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1757
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1758
displayUnscaledOpaqueString:aString from:index1 to:index2 x:x y:y
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1759
    "draw a substring at the transformed coordinate x/y but do not scale the font.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1760
     Draw foreground pixels in paint-color, background pixels in bgPaint color."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1761
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1762
    |pX pY|
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1763
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1764
    transformation notNil ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1765
	pX := transformation applyToX:x.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1766
	pY := transformation applyToY:y.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1767
    ] ifFalse:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1768
	pX := x.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1769
	pY := y.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1770
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1771
    self displayDeviceOpaqueString:aString from:index1 to:index2 in:font x:pX y:pY
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1772
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1773
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1774
displayUnscaledOpaqueString:aString x:x y:y
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1775
    "draw a string at the transformed coordinate x/y but do not scale the font.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1776
     Draw foreground pixels in paint-color, background pixels in bgPaint color."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1777
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1778
    |pX pY|
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1779
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1780
    transformation notNil ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1781
	pX := transformation applyToX:x.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1782
	pY := transformation applyToY:y.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1783
    ] ifFalse:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1784
	pX := x.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1785
	pY := y.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1786
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1787
    self displayDeviceOpaqueString:aString from:1 to:(aString size) in:font x:pX y:pY
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1788
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1789
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1790
displayUnscaledString:aString from:index1 to:index2 x:x y:y
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1791
    "draw a substring at the transformed coordinate x/y but do not scale the font.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1792
     draw foreground-pixels only (in current paint-color), leaving background as-is."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1793
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1794
    |pX pY|
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1795
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1796
    transformation notNil ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1797
	pX := transformation applyToX:x.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1798
	pY := transformation applyToY:y.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1799
    ] ifFalse:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1800
	pX := x.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1801
	pY := y.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1802
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1803
    self displayDeviceString:aString from:index1 to:index2 in:font x:pX y:pY
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1804
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1805
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1806
displayUnscaledString:aString x:x y:y
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1807
    "draw a string at the transformed coordinate x/y but do not scale the font.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1808
     draw foreground-pixels only (in current paint-color), leaving background as-is."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1809
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1810
    |pX pY|
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1811
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1812
    transformation notNil ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1813
	pX := transformation applyToX:x.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1814
	pY := transformation applyToY:y.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1815
    ] ifFalse:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1816
	pX := x.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1817
	pY := y.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1818
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1819
    self displayDeviceString:aString from:1 to:(aString size) in:font x:pX y:pY
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1820
! !
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1821
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1822
!DeviceGraphicsContext methodsFor:'drawing in device coordinates'!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1823
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1824
displayDeviceForm:aForm x:x y:y
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1825
    "draw a form; if its a 1-plane bitmap, 1-bits are drawn in the
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1826
     current paint-color, leaving pixels with 0-bits unchanged
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1827
     (i.e. only 1-bits are drawn from the form).
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1828
     The form must have been allocated on the same device.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1829
     No transformation or scaling is done.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1830
     If its a deep form (i.e. a pixmap) the current paint
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1831
     settings are ignored and the form is drawn as-is. 
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1832
     Care must be taken, that the paint color is correctly allocated 
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1833
     (by sending #on: to the color) before doing so.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1834
     Using functions other than #copy only makes sense if you are
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1835
     certain, that the colors are real colors (actually, only for
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1836
     noColor or allColor)."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1837
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1838
    |id w h easy paintDither tmpForm 
895
0d49372cded9 if a deep image has a mask, care for it (stamp out & or-in)
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
  1839
     fgId noColor allColor allBits pX pY
0d49372cded9 if a deep image has a mask, care for it (stamp out & or-in)
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
  1840
     mask maskId|
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1841
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1842
    w := aForm width.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1843
    h := aForm height.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1844
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1845
    pX := x rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1846
    pY := y rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1847
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1848
    id := aForm id.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1849
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1850
    "temporary ..."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1851
    (id isNil 
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1852
    or:[aForm graphicsDevice ~~ device]) ifTrue:[
768
77e4f9d30a22 fixes for b&w screens
Claus Gittinger <cg@exept.de>
parents: 745
diff changeset
  1853
        id := (aForm on:device) id.
77e4f9d30a22 fixes for b&w screens
Claus Gittinger <cg@exept.de>
parents: 745
diff changeset
  1854
        id isNil ifTrue:[
868
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
  1855
            'DEVGC: invalid form draw - ignored' errorPrintNL.
768
77e4f9d30a22 fixes for b&w screens
Claus Gittinger <cg@exept.de>
parents: 745
diff changeset
  1856
            ^ self
77e4f9d30a22 fixes for b&w screens
Claus Gittinger <cg@exept.de>
parents: 745
diff changeset
  1857
        ].
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1858
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1859
    gcId isNil ifTrue:[
768
77e4f9d30a22 fixes for b&w screens
Claus Gittinger <cg@exept.de>
parents: 745
diff changeset
  1860
        self initGC
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1861
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1862
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1863
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1864
     a deep form ignores paint/bgPaint settings
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1865
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1866
    (aForm depth ~~ 1) ifTrue:[
895
0d49372cded9 if a deep image has a mask, care for it (stamp out & or-in)
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
  1867
        (mask := aForm mask) notNil ifTrue:[
0d49372cded9 if a deep image has a mask, care for it (stamp out & or-in)
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
  1868
            mask depth == 1 ifFalse:[
0d49372cded9 if a deep image has a mask, care for it (stamp out & or-in)
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
  1869
                'DEVGC: alpha channel not yet supported' errorPrintCR.
0d49372cded9 if a deep image has a mask, care for it (stamp out & or-in)
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
  1870
            ] ifTrue:[
0d49372cded9 if a deep image has a mask, care for it (stamp out & or-in)
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
  1871
                maskId := (mask on:device) id.
0d49372cded9 if a deep image has a mask, care for it (stamp out & or-in)
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
  1872
                maskId notNil ifTrue:[
0d49372cded9 if a deep image has a mask, care for it (stamp out & or-in)
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
  1873
                    "
0d49372cded9 if a deep image has a mask, care for it (stamp out & or-in)
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
  1874
                     create temp-form;
0d49372cded9 if a deep image has a mask, care for it (stamp out & or-in)
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
  1875
                    "
0d49372cded9 if a deep image has a mask, care for it (stamp out & or-in)
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
  1876
                    tmpForm := Form width:w height:h depth:device depth on:device.
0d49372cded9 if a deep image has a mask, care for it (stamp out & or-in)
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
  1877
                    tmpForm initGC.
0d49372cded9 if a deep image has a mask, care for it (stamp out & or-in)
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
  1878
0d49372cded9 if a deep image has a mask, care for it (stamp out & or-in)
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
  1879
                    "
0d49372cded9 if a deep image has a mask, care for it (stamp out & or-in)
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
  1880
                     fill tempform with image
0d49372cded9 if a deep image has a mask, care for it (stamp out & or-in)
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
  1881
                    "
0d49372cded9 if a deep image has a mask, care for it (stamp out & or-in)
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
  1882
                    device
0d49372cded9 if a deep image has a mask, care for it (stamp out & or-in)
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
  1883
                        copyFromId:id
0d49372cded9 if a deep image has a mask, care for it (stamp out & or-in)
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
  1884
                                 x:0 y:0
0d49372cded9 if a deep image has a mask, care for it (stamp out & or-in)
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
  1885
                                to:tmpForm id
0d49372cded9 if a deep image has a mask, care for it (stamp out & or-in)
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
  1886
                                 x:0 y:0 
0d49372cded9 if a deep image has a mask, care for it (stamp out & or-in)
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
  1887
                             width:w 
0d49372cded9 if a deep image has a mask, care for it (stamp out & or-in)
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
  1888
                            height:h 
0d49372cded9 if a deep image has a mask, care for it (stamp out & or-in)
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
  1889
                              with:tmpForm gcId.
0d49372cded9 if a deep image has a mask, care for it (stamp out & or-in)
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
  1890
0d49372cded9 if a deep image has a mask, care for it (stamp out & or-in)
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
  1891
                    allColor := Color allColor.
0d49372cded9 if a deep image has a mask, care for it (stamp out & or-in)
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
  1892
                    allBits := allColor colorId.
0d49372cded9 if a deep image has a mask, care for it (stamp out & or-in)
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
  1893
0d49372cded9 if a deep image has a mask, care for it (stamp out & or-in)
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
  1894
                    "
0d49372cded9 if a deep image has a mask, care for it (stamp out & or-in)
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
  1895
                     stamp out mask in temp form
0d49372cded9 if a deep image has a mask, care for it (stamp out & or-in)
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
  1896
                    "
0d49372cded9 if a deep image has a mask, care for it (stamp out & or-in)
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
  1897
                    device setForeground:allBits background:0 in:tmpForm gcId.
0d49372cded9 if a deep image has a mask, care for it (stamp out & or-in)
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
  1898
                    device setFunction:#and in:tmpForm gcId.
0d49372cded9 if a deep image has a mask, care for it (stamp out & or-in)
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
  1899
                    device
0d49372cded9 if a deep image has a mask, care for it (stamp out & or-in)
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
  1900
                        copyPlaneFromId:maskId
0d49372cded9 if a deep image has a mask, care for it (stamp out & or-in)
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
  1901
                                      x:0 y:0
0d49372cded9 if a deep image has a mask, care for it (stamp out & or-in)
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
  1902
                                     to:tmpForm id
0d49372cded9 if a deep image has a mask, care for it (stamp out & or-in)
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
  1903
                                      x:0 y:0
0d49372cded9 if a deep image has a mask, care for it (stamp out & or-in)
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
  1904
                                  width:w 
0d49372cded9 if a deep image has a mask, care for it (stamp out & or-in)
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
  1905
                                 height:h 
0d49372cded9 if a deep image has a mask, care for it (stamp out & or-in)
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
  1906
                                   with:tmpForm gcId.
0d49372cded9 if a deep image has a mask, care for it (stamp out & or-in)
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
  1907
0d49372cded9 if a deep image has a mask, care for it (stamp out & or-in)
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
  1908
0d49372cded9 if a deep image has a mask, care for it (stamp out & or-in)
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
  1909
                    "
0d49372cded9 if a deep image has a mask, care for it (stamp out & or-in)
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
  1910
                     stamp out mask in destination
0d49372cded9 if a deep image has a mask, care for it (stamp out & or-in)
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
  1911
                    "
0d49372cded9 if a deep image has a mask, care for it (stamp out & or-in)
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
  1912
                    device setForeground:0 background:allBits in:gcId.
0d49372cded9 if a deep image has a mask, care for it (stamp out & or-in)
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
  1913
                    device setFunction:#and in:gcId.
0d49372cded9 if a deep image has a mask, care for it (stamp out & or-in)
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
  1914
                    device
0d49372cded9 if a deep image has a mask, care for it (stamp out & or-in)
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
  1915
                        copyPlaneFromId:maskId
0d49372cded9 if a deep image has a mask, care for it (stamp out & or-in)
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
  1916
                                      x:0 y:0
0d49372cded9 if a deep image has a mask, care for it (stamp out & or-in)
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
  1917
                                     to:drawableId
0d49372cded9 if a deep image has a mask, care for it (stamp out & or-in)
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
  1918
                                      x:pX y:pY
0d49372cded9 if a deep image has a mask, care for it (stamp out & or-in)
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
  1919
                                  width:w 
0d49372cded9 if a deep image has a mask, care for it (stamp out & or-in)
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
  1920
                                 height:h 
0d49372cded9 if a deep image has a mask, care for it (stamp out & or-in)
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
  1921
                                   with:gcId.
0d49372cded9 if a deep image has a mask, care for it (stamp out & or-in)
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
  1922
    "/ Delay waitForSeconds:3.
0d49372cded9 if a deep image has a mask, care for it (stamp out & or-in)
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
  1923
                    "
0d49372cded9 if a deep image has a mask, care for it (stamp out & or-in)
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
  1924
                     or-in tempform-bits ...
0d49372cded9 if a deep image has a mask, care for it (stamp out & or-in)
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
  1925
                    "
0d49372cded9 if a deep image has a mask, care for it (stamp out & or-in)
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
  1926
                    device setFunction:#or in:gcId.
0d49372cded9 if a deep image has a mask, care for it (stamp out & or-in)
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
  1927
                    device
0d49372cded9 if a deep image has a mask, care for it (stamp out & or-in)
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
  1928
                        copyFromId:tmpForm id
0d49372cded9 if a deep image has a mask, care for it (stamp out & or-in)
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
  1929
                                 x:0 y:0
0d49372cded9 if a deep image has a mask, care for it (stamp out & or-in)
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
  1930
                                to:drawableId
0d49372cded9 if a deep image has a mask, care for it (stamp out & or-in)
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
  1931
                                 x:pX y:pY 
0d49372cded9 if a deep image has a mask, care for it (stamp out & or-in)
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
  1932
                             width:w 
0d49372cded9 if a deep image has a mask, care for it (stamp out & or-in)
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
  1933
                            height:h 
0d49372cded9 if a deep image has a mask, care for it (stamp out & or-in)
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
  1934
                              with:gcId.
0d49372cded9 if a deep image has a mask, care for it (stamp out & or-in)
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
  1935
0d49372cded9 if a deep image has a mask, care for it (stamp out & or-in)
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
  1936
                    foreground notNil ifTrue:[
0d49372cded9 if a deep image has a mask, care for it (stamp out & or-in)
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
  1937
                        self device setForeground:foreground colorId in:gcId.
0d49372cded9 if a deep image has a mask, care for it (stamp out & or-in)
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
  1938
                    ].
0d49372cded9 if a deep image has a mask, care for it (stamp out & or-in)
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
  1939
                    background notNil ifTrue:[
0d49372cded9 if a deep image has a mask, care for it (stamp out & or-in)
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
  1940
                        self device setBackground:background colorId in:gcId.
0d49372cded9 if a deep image has a mask, care for it (stamp out & or-in)
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
  1941
                    ].
0d49372cded9 if a deep image has a mask, care for it (stamp out & or-in)
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
  1942
                    device setFunction:function in:gcId.
0d49372cded9 if a deep image has a mask, care for it (stamp out & or-in)
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
  1943
                    ^ self
0d49372cded9 if a deep image has a mask, care for it (stamp out & or-in)
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
  1944
                ]
0d49372cded9 if a deep image has a mask, care for it (stamp out & or-in)
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
  1945
            ]
0d49372cded9 if a deep image has a mask, care for it (stamp out & or-in)
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
  1946
        ].
0d49372cded9 if a deep image has a mask, care for it (stamp out & or-in)
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
  1947
768
77e4f9d30a22 fixes for b&w screens
Claus Gittinger <cg@exept.de>
parents: 745
diff changeset
  1948
        device
77e4f9d30a22 fixes for b&w screens
Claus Gittinger <cg@exept.de>
parents: 745
diff changeset
  1949
            copyFromId:id
77e4f9d30a22 fixes for b&w screens
Claus Gittinger <cg@exept.de>
parents: 745
diff changeset
  1950
                     x:0 y:0
77e4f9d30a22 fixes for b&w screens
Claus Gittinger <cg@exept.de>
parents: 745
diff changeset
  1951
                    to:drawableId
77e4f9d30a22 fixes for b&w screens
Claus Gittinger <cg@exept.de>
parents: 745
diff changeset
  1952
                     x:pX y:pY 
77e4f9d30a22 fixes for b&w screens
Claus Gittinger <cg@exept.de>
parents: 745
diff changeset
  1953
                 width:w 
77e4f9d30a22 fixes for b&w screens
Claus Gittinger <cg@exept.de>
parents: 745
diff changeset
  1954
                height:h 
77e4f9d30a22 fixes for b&w screens
Claus Gittinger <cg@exept.de>
parents: 745
diff changeset
  1955
                  with:gcId.
77e4f9d30a22 fixes for b&w screens
Claus Gittinger <cg@exept.de>
parents: 745
diff changeset
  1956
        ^ self
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1957
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1958
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1959
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1960
     the following code is somewhat complicated, since it has to deal
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1961
     with dithered paint colors, which cannot be done directly on most
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1962
     devices (actually, a test for the devices capabilities has to be added here)
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1963
     (just assume drawing a bitmap with dithered paint color ... sigh)
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1964
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1965
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1966
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1967
     if paint is not a real color, we have to do it the hard way ...
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1968
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1969
    easy := (function == #copy).
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1970
    easy ifTrue:[
768
77e4f9d30a22 fixes for b&w screens
Claus Gittinger <cg@exept.de>
parents: 745
diff changeset
  1971
        paint isColor ifFalse:[
77e4f9d30a22 fixes for b&w screens
Claus Gittinger <cg@exept.de>
parents: 745
diff changeset
  1972
            paintDither := paint.
77e4f9d30a22 fixes for b&w screens
Claus Gittinger <cg@exept.de>
parents: 745
diff changeset
  1973
            easy := false
77e4f9d30a22 fixes for b&w screens
Claus Gittinger <cg@exept.de>
parents: 745
diff changeset
  1974
        ] ifTrue:[
77e4f9d30a22 fixes for b&w screens
Claus Gittinger <cg@exept.de>
parents: 745
diff changeset
  1975
            paintDither := paint ditherForm.
77e4f9d30a22 fixes for b&w screens
Claus Gittinger <cg@exept.de>
parents: 745
diff changeset
  1976
            paintDither notNil ifTrue:[
77e4f9d30a22 fixes for b&w screens
Claus Gittinger <cg@exept.de>
parents: 745
diff changeset
  1977
                easy := false.
77e4f9d30a22 fixes for b&w screens
Claus Gittinger <cg@exept.de>
parents: 745
diff changeset
  1978
            ]
77e4f9d30a22 fixes for b&w screens
Claus Gittinger <cg@exept.de>
parents: 745
diff changeset
  1979
        ].
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1980
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1981
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1982
    allColor := Color allColor.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1983
    allBits := allColor colorId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1984
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1985
    easy ifTrue:[
768
77e4f9d30a22 fixes for b&w screens
Claus Gittinger <cg@exept.de>
parents: 745
diff changeset
  1986
        "
77e4f9d30a22 fixes for b&w screens
Claus Gittinger <cg@exept.de>
parents: 745
diff changeset
  1987
         paint is a real color
77e4f9d30a22 fixes for b&w screens
Claus Gittinger <cg@exept.de>
parents: 745
diff changeset
  1988
        "
77e4f9d30a22 fixes for b&w screens
Claus Gittinger <cg@exept.de>
parents: 745
diff changeset
  1989
77e4f9d30a22 fixes for b&w screens
Claus Gittinger <cg@exept.de>
parents: 745
diff changeset
  1990
        "
77e4f9d30a22 fixes for b&w screens
Claus Gittinger <cg@exept.de>
parents: 745
diff changeset
  1991
         if paint color is all-0 or all-1's, we can do it in one
77e4f9d30a22 fixes for b&w screens
Claus Gittinger <cg@exept.de>
parents: 745
diff changeset
  1992
         operation ...
77e4f9d30a22 fixes for b&w screens
Claus Gittinger <cg@exept.de>
parents: 745
diff changeset
  1993
        "
77e4f9d30a22 fixes for b&w screens
Claus Gittinger <cg@exept.de>
parents: 745
diff changeset
  1994
        fgId := paint colorId.
77e4f9d30a22 fixes for b&w screens
Claus Gittinger <cg@exept.de>
parents: 745
diff changeset
  1995
77e4f9d30a22 fixes for b&w screens
Claus Gittinger <cg@exept.de>
parents: 745
diff changeset
  1996
        ((fgId ~~ ((1 bitShift:device depth)-1))
77e4f9d30a22 fixes for b&w screens
Claus Gittinger <cg@exept.de>
parents: 745
diff changeset
  1997
        and:[fgId ~~ allBits]) ifTrue:[
77e4f9d30a22 fixes for b&w screens
Claus Gittinger <cg@exept.de>
parents: 745
diff changeset
  1998
            "
77e4f9d30a22 fixes for b&w screens
Claus Gittinger <cg@exept.de>
parents: 745
diff changeset
  1999
             clear fg-bits ...
77e4f9d30a22 fixes for b&w screens
Claus Gittinger <cg@exept.de>
parents: 745
diff changeset
  2000
            "
77e4f9d30a22 fixes for b&w screens
Claus Gittinger <cg@exept.de>
parents: 745
diff changeset
  2001
            device setForeground:0 background:allBits in:gcId.
77e4f9d30a22 fixes for b&w screens
Claus Gittinger <cg@exept.de>
parents: 745
diff changeset
  2002
            device setFunction:#and in:gcId.
77e4f9d30a22 fixes for b&w screens
Claus Gittinger <cg@exept.de>
parents: 745
diff changeset
  2003
            device
77e4f9d30a22 fixes for b&w screens
Claus Gittinger <cg@exept.de>
parents: 745
diff changeset
  2004
                copyPlaneFromId:id
77e4f9d30a22 fixes for b&w screens
Claus Gittinger <cg@exept.de>
parents: 745
diff changeset
  2005
                              x:0 y:0
77e4f9d30a22 fixes for b&w screens
Claus Gittinger <cg@exept.de>
parents: 745
diff changeset
  2006
                             to:drawableId
77e4f9d30a22 fixes for b&w screens
Claus Gittinger <cg@exept.de>
parents: 745
diff changeset
  2007
                              x:pX y:pY
77e4f9d30a22 fixes for b&w screens
Claus Gittinger <cg@exept.de>
parents: 745
diff changeset
  2008
                          width:w 
77e4f9d30a22 fixes for b&w screens
Claus Gittinger <cg@exept.de>
parents: 745
diff changeset
  2009
                         height:h 
77e4f9d30a22 fixes for b&w screens
Claus Gittinger <cg@exept.de>
parents: 745
diff changeset
  2010
                           with:gcId.
77e4f9d30a22 fixes for b&w screens
Claus Gittinger <cg@exept.de>
parents: 745
diff changeset
  2011
        ].
77e4f9d30a22 fixes for b&w screens
Claus Gittinger <cg@exept.de>
parents: 745
diff changeset
  2012
77e4f9d30a22 fixes for b&w screens
Claus Gittinger <cg@exept.de>
parents: 745
diff changeset
  2013
        fgId ~~ 0 ifTrue:[
77e4f9d30a22 fixes for b&w screens
Claus Gittinger <cg@exept.de>
parents: 745
diff changeset
  2014
            "
77e4f9d30a22 fixes for b&w screens
Claus Gittinger <cg@exept.de>
parents: 745
diff changeset
  2015
             or-in fg-bits ...
77e4f9d30a22 fixes for b&w screens
Claus Gittinger <cg@exept.de>
parents: 745
diff changeset
  2016
            "
77e4f9d30a22 fixes for b&w screens
Claus Gittinger <cg@exept.de>
parents: 745
diff changeset
  2017
            device setForeground:fgId background:0 in:gcId.
77e4f9d30a22 fixes for b&w screens
Claus Gittinger <cg@exept.de>
parents: 745
diff changeset
  2018
            device setFunction:#or in:gcId.
77e4f9d30a22 fixes for b&w screens
Claus Gittinger <cg@exept.de>
parents: 745
diff changeset
  2019
            device
77e4f9d30a22 fixes for b&w screens
Claus Gittinger <cg@exept.de>
parents: 745
diff changeset
  2020
                copyPlaneFromId:id
77e4f9d30a22 fixes for b&w screens
Claus Gittinger <cg@exept.de>
parents: 745
diff changeset
  2021
                              x:0 y:0
77e4f9d30a22 fixes for b&w screens
Claus Gittinger <cg@exept.de>
parents: 745
diff changeset
  2022
                             to:drawableId
77e4f9d30a22 fixes for b&w screens
Claus Gittinger <cg@exept.de>
parents: 745
diff changeset
  2023
                              x:pX y:pY
77e4f9d30a22 fixes for b&w screens
Claus Gittinger <cg@exept.de>
parents: 745
diff changeset
  2024
                          width:w 
77e4f9d30a22 fixes for b&w screens
Claus Gittinger <cg@exept.de>
parents: 745
diff changeset
  2025
                         height:h 
77e4f9d30a22 fixes for b&w screens
Claus Gittinger <cg@exept.de>
parents: 745
diff changeset
  2026
                           with:gcId.
77e4f9d30a22 fixes for b&w screens
Claus Gittinger <cg@exept.de>
parents: 745
diff changeset
  2027
        ].
77e4f9d30a22 fixes for b&w screens
Claus Gittinger <cg@exept.de>
parents: 745
diff changeset
  2028
        "
77e4f9d30a22 fixes for b&w screens
Claus Gittinger <cg@exept.de>
parents: 745
diff changeset
  2029
         flush foreground/background cache
77e4f9d30a22 fixes for b&w screens
Claus Gittinger <cg@exept.de>
parents: 745
diff changeset
  2030
        "
77e4f9d30a22 fixes for b&w screens
Claus Gittinger <cg@exept.de>
parents: 745
diff changeset
  2031
        foreground := nil.
77e4f9d30a22 fixes for b&w screens
Claus Gittinger <cg@exept.de>
parents: 745
diff changeset
  2032
        background := nil.
77e4f9d30a22 fixes for b&w screens
Claus Gittinger <cg@exept.de>
parents: 745
diff changeset
  2033
        device setFunction:function in:gcId.
77e4f9d30a22 fixes for b&w screens
Claus Gittinger <cg@exept.de>
parents: 745
diff changeset
  2034
        ^ self
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2035
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2036
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2037
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2038
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2039
     hard case; paint is a dithered color
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2040
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2041
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2042
    noColor := Color noColor.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2043
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2044
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2045
     create temp-form;
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2046
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2047
    tmpForm := Form width:w height:h depth:device depth on:device.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2048
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2049
     fill tempform
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2050
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2051
    tmpForm paint:paint.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2052
    tmpForm fillRectangleX:0 y:0 width:w height:h.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2053
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2054
     stamp out background
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2055
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2056
    tmpForm paint:allColor on:noColor.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2057
    tmpForm function:#and.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2058
    tmpForm displayOpaqueForm:aForm x:0 y:0.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2059
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2060
     stamp out foreground from destination
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2061
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2062
    device setForeground:0 background:allBits in:gcId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2063
    device setFunction:#and in:gcId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2064
    device
768
77e4f9d30a22 fixes for b&w screens
Claus Gittinger <cg@exept.de>
parents: 745
diff changeset
  2065
        copyPlaneFromId:id
77e4f9d30a22 fixes for b&w screens
Claus Gittinger <cg@exept.de>
parents: 745
diff changeset
  2066
                      x:0 y:0
77e4f9d30a22 fixes for b&w screens
Claus Gittinger <cg@exept.de>
parents: 745
diff changeset
  2067
                     to:drawableId
77e4f9d30a22 fixes for b&w screens
Claus Gittinger <cg@exept.de>
parents: 745
diff changeset
  2068
                      x:pX y:pY
77e4f9d30a22 fixes for b&w screens
Claus Gittinger <cg@exept.de>
parents: 745
diff changeset
  2069
                  width:w 
77e4f9d30a22 fixes for b&w screens
Claus Gittinger <cg@exept.de>
parents: 745
diff changeset
  2070
                 height:h 
77e4f9d30a22 fixes for b&w screens
Claus Gittinger <cg@exept.de>
parents: 745
diff changeset
  2071
                   with:gcId.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2072
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2073
     or-in temp into destination
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2074
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2075
    device setForeground:allBits background:0 in:gcId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2076
    device setFunction:#or in:gcId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2077
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2078
    device
768
77e4f9d30a22 fixes for b&w screens
Claus Gittinger <cg@exept.de>
parents: 745
diff changeset
  2079
        copyFromId:tmpForm id
77e4f9d30a22 fixes for b&w screens
Claus Gittinger <cg@exept.de>
parents: 745
diff changeset
  2080
                 x:0 y:0
77e4f9d30a22 fixes for b&w screens
Claus Gittinger <cg@exept.de>
parents: 745
diff changeset
  2081
                to:drawableId
77e4f9d30a22 fixes for b&w screens
Claus Gittinger <cg@exept.de>
parents: 745
diff changeset
  2082
                 x:pX y:pY
77e4f9d30a22 fixes for b&w screens
Claus Gittinger <cg@exept.de>
parents: 745
diff changeset
  2083
             width:w 
77e4f9d30a22 fixes for b&w screens
Claus Gittinger <cg@exept.de>
parents: 745
diff changeset
  2084
            height:h 
77e4f9d30a22 fixes for b&w screens
Claus Gittinger <cg@exept.de>
parents: 745
diff changeset
  2085
              with:gcId.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2086
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2087
     flush foreground/background cache
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2088
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2089
    foreground := nil.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2090
    background := nil.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2091
    device setFunction:function in:gcId.
768
77e4f9d30a22 fixes for b&w screens
Claus Gittinger <cg@exept.de>
parents: 745
diff changeset
  2092
895
0d49372cded9 if a deep image has a mask, care for it (stamp out & or-in)
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
  2093
    "Modified: 21.6.1996 / 13:26:10 / cg"
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2094
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2095
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2096
displayDeviceLineFromX:x0 y:y0 toX:x1 y:y1
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2097
    "draw a line (with current paint-color) in device coordinate space.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2098
     This ignores any transformations. The coordinates must be integers."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2099
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2100
    gcId isNil ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2101
	self initGC
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2102
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2103
    device displayLineFromX:x0 y:y0 toX:x1 y:y1 in:drawableId with:gcId
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2104
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2105
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2106
displayDeviceOpaqueForm:aForm x:x y:y
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2107
    "draw a form; if its a 1-plane bitmap, 1-bits are drawn in the
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2108
     current paint-color and 0-bits in the bgPaint color.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2109
     If its a deep form (i.e. a pixmap) the current paint/bgPaint
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2110
     settings are ignored and the form drawn as-is. 
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2111
     In the 1-plane case, special care must be taken if paint and/or bgPaint 
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2112
     dithered colors or patterns, since are that the colors are correctly allocated (by sending #on:
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2113
     to the colors) before doing so.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2114
     The form must have been allocated on the same device.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2115
     Drawing is in device coordinates; no scaling is done."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2116
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2117
    |id w h easy savedPaint bgForm fgForm tmpForm 
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2118
     fgId bgId noColor allColor allBits dx dy
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2119
     pX pY deviceDepth|
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2120
895
0d49372cded9 if a deep image has a mask, care for it (stamp out & or-in)
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
  2121
    "
0d49372cded9 if a deep image has a mask, care for it (stamp out & or-in)
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
  2122
     a deep form ignores paint/bgPaint settings
0d49372cded9 if a deep image has a mask, care for it (stamp out & or-in)
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
  2123
     and is always drawn opaque.
0d49372cded9 if a deep image has a mask, care for it (stamp out & or-in)
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
  2124
    "
0d49372cded9 if a deep image has a mask, care for it (stamp out & or-in)
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
  2125
    (aForm depth ~~ 1) ifTrue:[
0d49372cded9 if a deep image has a mask, care for it (stamp out & or-in)
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
  2126
        device
0d49372cded9 if a deep image has a mask, care for it (stamp out & or-in)
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
  2127
            copyFromId:id
0d49372cded9 if a deep image has a mask, care for it (stamp out & or-in)
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
  2128
                     x:0 y:0
0d49372cded9 if a deep image has a mask, care for it (stamp out & or-in)
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
  2129
                    to:drawableId
0d49372cded9 if a deep image has a mask, care for it (stamp out & or-in)
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
  2130
                     x:pX y:pY 
0d49372cded9 if a deep image has a mask, care for it (stamp out & or-in)
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
  2131
                 width:w 
0d49372cded9 if a deep image has a mask, care for it (stamp out & or-in)
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
  2132
                height:h 
0d49372cded9 if a deep image has a mask, care for it (stamp out & or-in)
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
  2133
                  with:gcId.
0d49372cded9 if a deep image has a mask, care for it (stamp out & or-in)
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
  2134
        ^ self
0d49372cded9 if a deep image has a mask, care for it (stamp out & or-in)
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
  2135
    ].
0d49372cded9 if a deep image has a mask, care for it (stamp out & or-in)
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
  2136
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2137
    bgPaint isNil ifTrue:[
868
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
  2138
        self displayDeviceForm:aForm x:x y:y.
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
  2139
        ^ self
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2140
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2141
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2142
    w := aForm width.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2143
    h := aForm height.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2144
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2145
    pX := x rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2146
    pY := y rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2147
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2148
    id := aForm id.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2149
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2150
    "temporary ..."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2151
    (id isNil 
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2152
    or:[aForm graphicsDevice ~~ device]) ifTrue:[
868
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
  2153
        id := (aForm on:device) id.
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
  2154
        id isNil ifTrue:[
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
  2155
            'DEVGC: invalid form draw - ignored' errorPrintNL.
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
  2156
            ^ self
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
  2157
        ].
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2158
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2159
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2160
    gcId isNil ifTrue:[
868
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
  2161
        self initGC
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2162
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2163
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2164
    "the following code is somewhat complicated, since it has to deal
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2165
     with dithered fg/bg colors, which cannot be done directly on most
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2166
     devices (actually, a test for the devices capabilities has to be added here)
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2167
     (just assume drawing a bitmap with dithered fg/bg colors ... sigh)
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2168
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2169
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2170
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2171
     if bgPaint or paint is not a real color, we have to do it the hard way ...
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2172
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2173
    easy := true.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2174
    paint isColor ifFalse:[
868
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
  2175
        easy := false
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2176
    ] ifTrue:[
868
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
  2177
        fgId := paint colorId.
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
  2178
        fgId isNil ifTrue:[
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
  2179
            easy := false
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
  2180
        ]
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2181
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2182
    bgPaint isColor ifFalse:[
868
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
  2183
        easy := false
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2184
    ] ifTrue:[
868
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
  2185
        bgId := bgPaint colorId.
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
  2186
        bgId isNil ifTrue:[
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
  2187
            easy := false
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
  2188
        ]
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2189
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2190
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2191
    easy ifTrue:[
868
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
  2192
        "
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
  2193
         easy: both paint and bgPaint are real colors
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
  2194
        "
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
  2195
        ((foreground ~~ paint) or:[background ~~ bgPaint]) ifTrue:[
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
  2196
            device setForeground:fgId background:bgId in:gcId.
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
  2197
            foreground := paint.
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
  2198
            background := bgPaint.
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
  2199
        ].
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
  2200
        device
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
  2201
            copyPlaneFromId:id
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
  2202
                          x:0 y:0
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
  2203
                         to:drawableId
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
  2204
                          x:pX y:pY 
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
  2205
                      width:w 
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
  2206
                     height:h 
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
  2207
                       with:gcId.
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
  2208
        ^ self
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2209
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2210
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2211
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2212
     hard case: paint and/or bgPaint are dithered or patterns
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2213
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2214
    allColor := Color allColor.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2215
    allBits := allColor colorId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2216
    deviceDepth := device depth.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2217
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2218
    (fgId notNil and:[function == #copy]) ifTrue:[
868
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
  2219
        "
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
  2220
         only bg is dithered; fill with bg first ...
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
  2221
        "
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
  2222
        savedPaint := paint.
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
  2223
        self paint:bgPaint.
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
  2224
        self fillDeviceRectangleX:pX y:pY width:w height:h.
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
  2225
        self paint:savedPaint.
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
  2226
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
  2227
        "
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
  2228
         if paint color is all-0 or all-1's, we can do it in one
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
  2229
         operation ...
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
  2230
        "
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
  2231
        ((fgId ~~ ((1 bitShift:deviceDepth)-1))
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
  2232
        and:[fgId ~~ allBits]) ifTrue:[
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
  2233
            "
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
  2234
             clear fg-bits ...
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
  2235
            "
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
  2236
            device setForeground:0 background:allBits in:gcId.
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
  2237
            device setFunction:#and in:gcId.
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
  2238
            device
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
  2239
                copyPlaneFromId:id
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
  2240
                              x:0 y:0
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
  2241
                             to:drawableId
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
  2242
                              x:pX y:pY
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
  2243
                          width:w 
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
  2244
                         height:h 
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
  2245
                           with:gcId.
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
  2246
        ].
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
  2247
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
  2248
        fgId ~~ 0 ifTrue:[
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
  2249
            "
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
  2250
             or-in fg-bits ...
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
  2251
            "
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
  2252
            device setForeground:fgId background:0 in:gcId.
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
  2253
            device setFunction:#or in:gcId.
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
  2254
            device
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
  2255
                copyPlaneFromId:id
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
  2256
                              x:0 y:0
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
  2257
                             to:drawableId
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
  2258
                              x:pX y:pY
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
  2259
                          width:w 
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
  2260
                         height:h 
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
  2261
                           with:gcId.
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
  2262
        ].
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
  2263
        "
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
  2264
         flush foreground/background cache
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
  2265
        "
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
  2266
        foreground := nil.
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
  2267
        background := nil.
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
  2268
        device setFunction:function in:gcId.
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
  2269
        ^ self
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2270
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2271
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2272
    (bgId notNil and:[function == #copy]) ifTrue:[
868
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
  2273
        "
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
  2274
         only fg is dithered; fill with fg first ...
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
  2275
        "
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
  2276
        self fillDeviceRectangleX:pX y:pY width:w height:h.
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
  2277
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
  2278
        "
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
  2279
         if paint color is all-0 or all-1's, we can do it in one
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
  2280
         operation ...
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
  2281
        "
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
  2282
        ((bgId ~~ ((1 bitShift:deviceDepth)-1))
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
  2283
        and:[bgId ~~ allBits]) ifTrue:[
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
  2284
            "
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
  2285
             clear bg-bits ...
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
  2286
            "
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
  2287
            device setForeground:allBits background:0 in:gcId.
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
  2288
            device setFunction:#and in:gcId.
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
  2289
            device
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
  2290
                copyPlaneFromId:id
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
  2291
                              x:0 y:0
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
  2292
                             to:drawableId
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
  2293
                              x:pX y:pY
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
  2294
                          width:w 
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
  2295
                         height:h 
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
  2296
                           with:gcId.
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
  2297
        ].
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
  2298
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
  2299
        "
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
  2300
         or-in bg-bits ...
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
  2301
        "
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
  2302
        bgId ~~ 0 ifTrue:[
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
  2303
            device setForeground:0 background:bgId in:gcId.
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
  2304
            device setFunction:#or in:gcId.
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
  2305
            device
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
  2306
                copyPlaneFromId:id
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
  2307
                              x:0 y:0
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
  2308
                             to:drawableId
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
  2309
                              x:pX y:pY 
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
  2310
                          width:w 
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
  2311
                         height:h 
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
  2312
                           with:gcId.
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
  2313
        ].
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
  2314
        "
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
  2315
         flush foreground/background cache
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
  2316
        "
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
  2317
        foreground := nil.
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
  2318
        background := nil.
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
  2319
        device setFunction:function in:gcId.
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
  2320
        ^ self
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2321
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2322
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2323
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2324
     very hard case; both fg and bg are dithered colors
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2325
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2326
    noColor := Color noColor.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2327
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2328
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2329
     create temp-forms;
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2330
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2331
    bgForm := Form width:w height:h depth:deviceDepth on:device.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2332
    fgForm := Form width:w height:h depth:deviceDepth on:device.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2333
    tmpForm := Form width:w height:h depth:deviceDepth on:device.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2334
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2335
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2336
     fill
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2337
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2338
    dx := dy := 0.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2339
    maskOrigin notNil ifTrue:[
868
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
  2340
        dx := maskOrigin x.
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
  2341
        dy := maskOrigin y
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2342
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2343
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2344
    bgForm paint:bgPaint.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2345
    bgForm setMaskOriginX:(x negated + dx) y:(y negated + dy).
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2346
    bgForm fillRectangleX:0 y:0 width:w height:h.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2347
    fgForm paint:paint.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2348
    fgForm setMaskOriginX:(x negated + dx) y:(y negated + dy).
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2349
    fgForm fillRectangleX:0 y:0 width:w height:h.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2350
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2351
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2352
     stamp-out background
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2353
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2354
    bgForm paint:noColor on:allColor.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2355
    bgForm function:#and.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2356
    bgForm displayOpaqueForm:aForm x:0 y:0.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2357
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2358
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2359
     stamp-out foreground
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2360
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2361
    fgForm paint:allColor on:noColor.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2362
    fgForm function:#and.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2363
    fgForm displayOpaqueForm:aForm x:0 y:0.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2364
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2365
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2366
     clear tempform
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2367
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2368
    tmpForm paint:noColor.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2369
    tmpForm fillRectangleX:0 y:0 width:w height:h.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2370
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2371
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2372
     merge fg-temp and bg-temp into tmp
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2373
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2374
    tmpForm function:#or.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2375
    tmpForm paint:noColor on:allColor.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2376
    tmpForm copyFrom:fgForm x:0 y:0 toX:0 y:0 width:w height:h.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2377
    tmpForm copyFrom:bgForm x:0 y:0 toX:0 y:0 width:w height:h.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2378
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2379
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2380
     finally, draw it
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2381
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2382
    device setForeground:0 background:allBits in:gcId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2383
    device
868
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
  2384
        copyFromId:tmpForm id
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
  2385
                 x:0 y:0
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
  2386
                to:drawableId
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
  2387
                 x:pX y:pY 
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
  2388
             width:w 
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
  2389
            height:h 
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
  2390
              with:gcId.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2391
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2392
     flush foreground/background cache
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2393
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2394
    foreground := nil.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2395
    background := nil.
868
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
  2396
895
0d49372cded9 if a deep image has a mask, care for it (stamp out & or-in)
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
  2397
    "Modified: 21.6.1996 / 13:31:06 / cg"
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2398
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2399
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2400
displayDeviceOpaqueString:aString from:index1 to:index2 in:font x:x y:y
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2401
    "draw a substring at the coordinate x/y - draw foreground pixels in
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2402
     paint-color and background pixels in bgPaint-color.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2403
     Assuming that device can only draw in device colors, we have to handle
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2404
     the case where paint and/or bgPaint are dithered colors.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2405
     No translation or scaling is done."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2406
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2407
    |easy w h savedPaint fgId bgId allColor allBits noColor
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2408
     id bgForm fgForm tmpForm maskForm dx dy pX pY fontUsed s
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2409
     deviceDepth|
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2410
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2411
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2412
     if backgroundPaint color is nil, we assume
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2413
     this is a non-opaque draw
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2414
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2415
    bgPaint isNil ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2416
        self displayDeviceString:aString from:index1 to:index2 x:x y:y.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2417
        ^ self
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2418
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2419
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2420
    (aString isString not
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2421
    or:[aString isText]) ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2422
        "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2423
         hook for non-strings (i.e. attributed text)
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2424
         that 'thing' should know how to display itself ...
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2425
        "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2426
        aString displayOpaqueOn:self x:x y:y from:index1 to:index2.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2427
        ^ self
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2428
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2429
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2430
    gcId isNil ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2431
        self initGC
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2432
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2433
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2434
    pX := x rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2435
    pY := y rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2436
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2437
    fontUsed := font on:device.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2438
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2439
    id := fontUsed fontId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2440
    id isNil ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2441
        "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2442
         hook for alien fonts
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2443
         that 'font' should know how to display the string ...
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2444
        "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2445
        font displayOpaqueString:aString from:index1 to:index2 x:x y:y in:self.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2446
        ^ self
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2447
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2448
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2449
    s := aString.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2450
    s encoding ~~ font encoding ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2451
        s := s encodeInto:(font encoding).
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2452
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2453
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2454
    deviceFont ~~ fontUsed ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2455
        device setFont:id in:gcId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2456
        deviceFont := fontUsed
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2457
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2458
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2459
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2460
     if bgPaint or paint is not a real Color, we have to do it the hard way ...
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2461
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2462
    easy := true.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2463
    paint isColor ifFalse:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2464
        easy := false
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2465
    ] ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2466
        fgId := paint colorId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2467
        fgId isNil ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2468
            easy := false
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2469
        ]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2470
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2471
    bgPaint isColor ifFalse:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2472
        easy := false
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2473
    ] ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2474
        bgId := bgPaint colorId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2475
        bgId isNil ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2476
            easy := false
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2477
        ]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2478
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2479
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2480
    easy ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2481
        device setForeground:fgId background:bgId in:gcId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2482
        foreground := paint.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2483
        background := bgPaint.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2484
        device displayOpaqueString:s 
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2485
                              from:index1 to:index2
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2486
                                 x:pX y:pY 
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2487
                                in:drawableId with:gcId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2488
        ^ self
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2489
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2490
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2491
    w := fontUsed widthOf:s from:index1 to:index2.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2492
    h := fontUsed height.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2493
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2494
    (fgId notNil and:[function == #copy]) ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2495
        "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2496
         only bg is dithered; fill with bg first ...
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2497
        "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2498
        savedPaint := paint.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2499
        self paint:bgPaint.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2500
        self fillRectangleX:pX y:(pY - fontUsed ascent) width:w height:h.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2501
        self paint:savedPaint.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2502
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2503
        "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2504
         then draw using fgPaint (which is a real color)
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2505
        "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2506
        device displayString:s 
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2507
                        from:index1 to:index2
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2508
                           x:pX y:pY 
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2509
                          in:drawableId with:gcId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2510
        ^ self
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2511
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2512
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2513
    allColor := Color allColor.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2514
    allBits := allColor colorId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2515
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2516
    deviceDepth := device depth.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2517
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2518
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2519
     the code below is correct, but some (all?) implementations of the
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2520
     X Window system seem to not support ALU-functions when drawing opaque strings.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2521
     Therefore we use the slower code below.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2522
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2523
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2524
"/    (bgId notNil and:[function == #copy]) ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2525
"/      "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2526
"/       only fg is dithered; fill with fg first ...
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2527
"/      "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2528
"/      self fillRectangleX:pX y:(pY - fontUsed ascent) width:w height:h.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2529
"/
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2530
"/      "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2531
"/       if bgPaint color is all-0 or all-1's, we can do it in one
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2532
"/       operation ...
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2533
"/      "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2534
"/      ((bgId ~~ ((1 bitShift:deviceDepth)-1))
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2535
"/      and:[bgId ~~ allBits]) ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2536
"/          "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2537
"/           clear bg bits ...
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2538
"/          "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2539
"/          device setForeground:allBits background:0 in:gcId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2540
"/          device setFunction:#and in:gcId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2541
"/          device displayOpaqueString:s 
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2542
"/                                from:index1 to:index2
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2543
"/                                   x:pX y:pY 
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2544
"/                                  in:drawableId with:gcId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2545
"/      ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2546
"/
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2547
"/      "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2548
"/       or-in bg bits ...
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2549
"/      "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2550
"/      bgId ~~ 0 ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2551
"/          device setForeground:0 background:bgId in:gcId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2552
"/          device setFunction:#or in:gcId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2553
"/          device displayOpaqueString:s 
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2554
"/                                from:index1 to:index2
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2555
"/                                   x:pX y:pY 
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2556
"/                                  in:drawableId with:gcId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2557
"/      ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2558
"/      "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2559
"/       flush foreground/background cache
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2560
"/      "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2561
"/      foreground := nil.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2562
"/      background := nil.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2563
"/      device setFunction:function in:gcId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2564
"/      ^ self
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2565
"/  ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2566
768
77e4f9d30a22 fixes for b&w screens
Claus Gittinger <cg@exept.de>
parents: 745
diff changeset
  2567
    (bgId notNil and:[function == #copy]) ifTrue:[
77e4f9d30a22 fixes for b&w screens
Claus Gittinger <cg@exept.de>
parents: 745
diff changeset
  2568
        "
77e4f9d30a22 fixes for b&w screens
Claus Gittinger <cg@exept.de>
parents: 745
diff changeset
  2569
         only fg is dithered; fill with bg first ...
77e4f9d30a22 fixes for b&w screens
Claus Gittinger <cg@exept.de>
parents: 745
diff changeset
  2570
        "
77e4f9d30a22 fixes for b&w screens
Claus Gittinger <cg@exept.de>
parents: 745
diff changeset
  2571
        device setForeground:bgId in:gcId.
77e4f9d30a22 fixes for b&w screens
Claus Gittinger <cg@exept.de>
parents: 745
diff changeset
  2572
        device setFunction:#copy in:gcId.
832
064890dcfabd fixed opaque string draw with deep-dither
Claus Gittinger <cg@exept.de>
parents: 786
diff changeset
  2573
        device setBitmapMask:nil in:gcId.
768
77e4f9d30a22 fixes for b&w screens
Claus Gittinger <cg@exept.de>
parents: 745
diff changeset
  2574
        self fillRectangleX:pX y:(pY - fontUsed ascent) width:w height:h.
77e4f9d30a22 fixes for b&w screens
Claus Gittinger <cg@exept.de>
parents: 745
diff changeset
  2575
832
064890dcfabd fixed opaque string draw with deep-dither
Claus Gittinger <cg@exept.de>
parents: 786
diff changeset
  2576
        "/ draw fg dithered
768
77e4f9d30a22 fixes for b&w screens
Claus Gittinger <cg@exept.de>
parents: 745
diff changeset
  2577
        (mask depth == 1) ifTrue:[
832
064890dcfabd fixed opaque string draw with deep-dither
Claus Gittinger <cg@exept.de>
parents: 786
diff changeset
  2578
            device setBitmapMask:mask id in:gcId.
064890dcfabd fixed opaque string draw with deep-dither
Claus Gittinger <cg@exept.de>
parents: 786
diff changeset
  2579
            device setForeground:foreground colorId background:background colorId in:gcId.
768
77e4f9d30a22 fixes for b&w screens
Claus Gittinger <cg@exept.de>
parents: 745
diff changeset
  2580
        ] ifFalse:[
77e4f9d30a22 fixes for b&w screens
Claus Gittinger <cg@exept.de>
parents: 745
diff changeset
  2581
            device setPixmapMask:mask id in:gcId
77e4f9d30a22 fixes for b&w screens
Claus Gittinger <cg@exept.de>
parents: 745
diff changeset
  2582
        ].
77e4f9d30a22 fixes for b&w screens
Claus Gittinger <cg@exept.de>
parents: 745
diff changeset
  2583
77e4f9d30a22 fixes for b&w screens
Claus Gittinger <cg@exept.de>
parents: 745
diff changeset
  2584
        device displayString:s
77e4f9d30a22 fixes for b&w screens
Claus Gittinger <cg@exept.de>
parents: 745
diff changeset
  2585
                    from:index1 to:index2 
77e4f9d30a22 fixes for b&w screens
Claus Gittinger <cg@exept.de>
parents: 745
diff changeset
  2586
                       x:pX y:pY
77e4f9d30a22 fixes for b&w screens
Claus Gittinger <cg@exept.de>
parents: 745
diff changeset
  2587
                      in:drawableId with:gcId.
77e4f9d30a22 fixes for b&w screens
Claus Gittinger <cg@exept.de>
parents: 745
diff changeset
  2588
        ^ self.
77e4f9d30a22 fixes for b&w screens
Claus Gittinger <cg@exept.de>
parents: 745
diff changeset
  2589
"/
77e4f9d30a22 fixes for b&w screens
Claus Gittinger <cg@exept.de>
parents: 745
diff changeset
  2590
"/      "
77e4f9d30a22 fixes for b&w screens
Claus Gittinger <cg@exept.de>
parents: 745
diff changeset
  2591
"/       if bgPaint color is all-0 or all-1's, we can do it in one
77e4f9d30a22 fixes for b&w screens
Claus Gittinger <cg@exept.de>
parents: 745
diff changeset
  2592
"/       operation ...
77e4f9d30a22 fixes for b&w screens
Claus Gittinger <cg@exept.de>
parents: 745
diff changeset
  2593
"/      "
77e4f9d30a22 fixes for b&w screens
Claus Gittinger <cg@exept.de>
parents: 745
diff changeset
  2594
"/      ((bgId ~~ ((1 bitShift:deviceDepth)-1))
77e4f9d30a22 fixes for b&w screens
Claus Gittinger <cg@exept.de>
parents: 745
diff changeset
  2595
"/      and:[bgId ~~ allBits]) ifTrue:[
77e4f9d30a22 fixes for b&w screens
Claus Gittinger <cg@exept.de>
parents: 745
diff changeset
  2596
"/          "
77e4f9d30a22 fixes for b&w screens
Claus Gittinger <cg@exept.de>
parents: 745
diff changeset
  2597
"/           clear bg bits ...
77e4f9d30a22 fixes for b&w screens
Claus Gittinger <cg@exept.de>
parents: 745
diff changeset
  2598
"/          "
77e4f9d30a22 fixes for b&w screens
Claus Gittinger <cg@exept.de>
parents: 745
diff changeset
  2599
"/          device setForeground:allBits background:0 in:gcId.
77e4f9d30a22 fixes for b&w screens
Claus Gittinger <cg@exept.de>
parents: 745
diff changeset
  2600
"/          device setFunction:#and in:gcId.
77e4f9d30a22 fixes for b&w screens
Claus Gittinger <cg@exept.de>
parents: 745
diff changeset
  2601
"/          device displayOpaqueString:s 
77e4f9d30a22 fixes for b&w screens
Claus Gittinger <cg@exept.de>
parents: 745
diff changeset
  2602
"/                                from:index1 to:index2
77e4f9d30a22 fixes for b&w screens
Claus Gittinger <cg@exept.de>
parents: 745
diff changeset
  2603
"/                                   x:pX y:pY 
77e4f9d30a22 fixes for b&w screens
Claus Gittinger <cg@exept.de>
parents: 745
diff changeset
  2604
"/                                  in:drawableId with:gcId.
77e4f9d30a22 fixes for b&w screens
Claus Gittinger <cg@exept.de>
parents: 745
diff changeset
  2605
"/      ].
77e4f9d30a22 fixes for b&w screens
Claus Gittinger <cg@exept.de>
parents: 745
diff changeset
  2606
"/
77e4f9d30a22 fixes for b&w screens
Claus Gittinger <cg@exept.de>
parents: 745
diff changeset
  2607
"/      "
77e4f9d30a22 fixes for b&w screens
Claus Gittinger <cg@exept.de>
parents: 745
diff changeset
  2608
"/       or-in bg bits ...
77e4f9d30a22 fixes for b&w screens
Claus Gittinger <cg@exept.de>
parents: 745
diff changeset
  2609
"/      "
77e4f9d30a22 fixes for b&w screens
Claus Gittinger <cg@exept.de>
parents: 745
diff changeset
  2610
"/      bgId ~~ 0 ifTrue:[
77e4f9d30a22 fixes for b&w screens
Claus Gittinger <cg@exept.de>
parents: 745
diff changeset
  2611
"/          device setForeground:0 background:bgId in:gcId.
77e4f9d30a22 fixes for b&w screens
Claus Gittinger <cg@exept.de>
parents: 745
diff changeset
  2612
"/          device setFunction:#or in:gcId.
77e4f9d30a22 fixes for b&w screens
Claus Gittinger <cg@exept.de>
parents: 745
diff changeset
  2613
"/          device displayOpaqueString:s 
77e4f9d30a22 fixes for b&w screens
Claus Gittinger <cg@exept.de>
parents: 745
diff changeset
  2614
"/                                from:index1 to:index2
77e4f9d30a22 fixes for b&w screens
Claus Gittinger <cg@exept.de>
parents: 745
diff changeset
  2615
"/                                   x:pX y:pY 
77e4f9d30a22 fixes for b&w screens
Claus Gittinger <cg@exept.de>
parents: 745
diff changeset
  2616
"/                                  in:drawableId with:gcId.
77e4f9d30a22 fixes for b&w screens
Claus Gittinger <cg@exept.de>
parents: 745
diff changeset
  2617
"/      ].
77e4f9d30a22 fixes for b&w screens
Claus Gittinger <cg@exept.de>
parents: 745
diff changeset
  2618
"/      "
77e4f9d30a22 fixes for b&w screens
Claus Gittinger <cg@exept.de>
parents: 745
diff changeset
  2619
"/       flush foreground/background cache
77e4f9d30a22 fixes for b&w screens
Claus Gittinger <cg@exept.de>
parents: 745
diff changeset
  2620
"/      "
77e4f9d30a22 fixes for b&w screens
Claus Gittinger <cg@exept.de>
parents: 745
diff changeset
  2621
"/      foreground := nil.
77e4f9d30a22 fixes for b&w screens
Claus Gittinger <cg@exept.de>
parents: 745
diff changeset
  2622
"/      background := nil.
77e4f9d30a22 fixes for b&w screens
Claus Gittinger <cg@exept.de>
parents: 745
diff changeset
  2623
"/      device setFunction:function in:gcId.
77e4f9d30a22 fixes for b&w screens
Claus Gittinger <cg@exept.de>
parents: 745
diff changeset
  2624
"/      ^ self
832
064890dcfabd fixed opaque string draw with deep-dither
Claus Gittinger <cg@exept.de>
parents: 786
diff changeset
  2625
    ].
064890dcfabd fixed opaque string draw with deep-dither
Claus Gittinger <cg@exept.de>
parents: 786
diff changeset
  2626
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2627
    "
832
064890dcfabd fixed opaque string draw with deep-dither
Claus Gittinger <cg@exept.de>
parents: 786
diff changeset
  2628
     very hard case, both fg and bg are dithered colors/images
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2629
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2630
    noColor := Color noColor.
832
064890dcfabd fixed opaque string draw with deep-dither
Claus Gittinger <cg@exept.de>
parents: 786
diff changeset
  2631
"/ 'hard: ' print. aString print. ' ' print. paint print. ' ' print. bgPaint printCR.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2632
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2633
     create temp-forms;
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2634
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2635
    bgForm := Form width:w height:h depth:deviceDepth on:device.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2636
    fgForm := Form width:w height:h depth:deviceDepth on:device.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2637
    tmpForm := Form width:w height:h depth:deviceDepth on:device.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2638
    maskForm := Form width:w height:h depth:deviceDepth on:device.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2639
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2640
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2641
     fill
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2642
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2643
    dx := 0.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2644
    dy := fontUsed ascent.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2645
    maskOrigin notNil ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2646
        dx := maskOrigin x.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2647
        dy := dy + maskOrigin y
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2648
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2649
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2650
    bgForm paint:bgPaint.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2651
    bgForm setMaskOriginX:(pX negated + dx) y:(pY negated + dy).
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2652
    bgForm fillRectangleX:0 y:0 width:w height:h.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2653
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2654
    fgForm paint:paint.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2655
    fgForm setMaskOriginX:(pX negated + dx) y:(pY negated + dy).
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2656
    fgForm fillRectangleX:0 y:0 width:w height:h.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2657
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2658
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2659
     stamp-out background (have now bg-bits with fg=0 in bgForm)
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2660
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2661
    bgForm font:fontUsed.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2662
    bgForm paint:noColor on:allColor.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2663
    bgForm function:#and.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2664
    bgForm displayString:s 
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2665
                    from:index1 to:index2 
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2666
                       x:0 y:fontUsed ascent.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2667
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2668
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2669
     stamp-out foreground
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2670
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2671
    maskForm font:fontUsed.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2672
    maskForm paint:allColor on:noColor.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2673
    maskForm displayOpaqueString:s 
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2674
                            from:index1 to:index2 
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2675
                               x:0 y:fontUsed ascent.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2676
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2677
    fgForm function:#and.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2678
    fgForm copyFrom:maskForm x:0 y:0 toX:0 y:0 width:w height:h.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2679
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2680
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2681
     clear tempform
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2682
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2683
    tmpForm paint:noColor.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2684
    tmpForm fillRectangleX:0 y:0 width:w height:h.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2685
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2686
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2687
     merge fg-temp and bg-temp into tmp
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2688
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2689
    tmpForm function:#or.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2690
    tmpForm paint:noColor on:allColor.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2691
    tmpForm copyFrom:fgForm x:0 y:0 toX:0 y:0 width:w height:h.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2692
    tmpForm copyFrom:bgForm x:0 y:0 toX:0 y:0 width:w height:h.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2693
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2694
     finally, draw it
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2695
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2696
    device setForeground:0 background:allBits in:gcId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2697
    device
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2698
        copyFromId:tmpForm id
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2699
                 x:0 y:0
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2700
                to:drawableId
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2701
                 x:pX y:pY-fontUsed ascent
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2702
             width:w
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2703
            height:h
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2704
              with:gcId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2705
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2706
     flush foreground/background cache
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2707
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2708
    foreground := nil.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2709
    background := nil.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2710
832
064890dcfabd fixed opaque string draw with deep-dither
Claus Gittinger <cg@exept.de>
parents: 786
diff changeset
  2711
    "Modified: 12.6.1996 / 12:50:12 / cg"
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2712
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2713
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2714
displayDeviceOpaqueString:aString from:index1 to:index2 x:x y:y
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2715
    "draw a substring at the coordinate x/y - draw foreground pixels in
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2716
     paint-color and background pixels in bgPaint-color.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2717
     Assuming that device can only draw in device colors, we have to handle
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2718
     the case where paint and/or bgPaint are dithered colors.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2719
     No translation or scaling is done."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2720
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2721
    self displayDeviceOpaqueString:aString from:index1 to:index2 in:font x:x y:y
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2722
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2723
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2724
displayDeviceOpaqueString:aString x:x y:y
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2725
    "draw a string at the coordinate x/y - draw foreground pixels in
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2726
     paint-color and background pixels in bgPaint-color.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2727
     No translation or scaling is done"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2728
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2729
    self displayDeviceOpaqueString:aString from:1 to:(aString size) in:font x:x y:y
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2730
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2731
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2732
displayDeviceString:aString from:index1 to:index2 in:font x:x y:y
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2733
    "draw a substring at the coordinate x/y -  
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2734
     draw foreground-pixels only (in current paint-color), leaving background as-is.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2735
     No translation or scaling is done"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2736
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2737
    |id pX pY fontUsed s|
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2738
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2739
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2740
     hook for non-strings (i.e. attributed text)
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2741
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2742
    (aString isString not
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2743
    or:[aString isText]) ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2744
        ^ aString displayOn:self x:x y:y from:index1 to:index2
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2745
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2746
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2747
    gcId isNil ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2748
        self initGC
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2749
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2750
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2751
    pX := x rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2752
    pY := y rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2753
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2754
    fontUsed := font on:device.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2755
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2756
    id := fontUsed fontId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2757
    id isNil ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2758
        "hook for alien fonts"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2759
        font displayString:aString from:index1 to:index2 x:x y:y in:self
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2760
    ] ifFalse:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2761
        s := aString.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2762
        s encoding ~~ font encoding ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2763
            s := s encodeInto:(font encoding).
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2764
        ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2765
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2766
        deviceFont ~~ fontUsed ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2767
            device setFont:id in:gcId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2768
            deviceFont := fontUsed
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2769
        ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2770
        device displayString:s from:index1 to:index2
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2771
                           x:pX y:pY in:drawableId with:gcId
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2772
    ]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2773
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2774
    "Modified: 12.5.1996 / 17:49:22 / cg"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2775
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2776
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2777
displayDeviceString:aString from:index1 to:index2 x:x y:y
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2778
    "draw a substring at the coordinate x/y -  
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2779
     draw foreground-pixels only (in current paint-color), leaving background as-is.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2780
     No translation or scaling is done"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2781
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2782
    self displayDeviceString:aString from:index1 to:index2 in:font x:x y:y
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2783
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2784
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2785
displayDeviceString:aString x:x y:y
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2786
    "draw a string at the coordinate x/y -  
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2787
     draw foreground-pixels only (in current paint-color), leaving background as-is.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2788
     No translation or scaling is done"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2789
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2790
    self displayDeviceString:aString from:1 to:(aString size) in:font x:x y:y
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2791
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2792
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2793
fillDeviceRectangleX:x y:y width:w height:h
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2794
    "draw a filled rectangle in device coordinate space.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2795
     This ignores any transformations. The coordinates must be integers."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2796
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2797
    gcId isNil ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2798
	self initGC
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2799
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2800
    device
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2801
	fillRectangleX:x 
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2802
		     y:y
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2803
		 width:w
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2804
		height:h
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2805
		    in:drawableId with:gcId
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2806
! !
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2807
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2808
!DeviceGraphicsContext methodsFor:'evaluating in another context'!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2809
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2810
reverseDo:aBlock
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2811
    "evaluate aBlock with foreground and background interchanged.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2812
     This can be reimplemented here in a faster way."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2813
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2814
    |oldFg oldBg|
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2815
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2816
    oldFg := foreground on:device.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2817
    oldBg := background on:device.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2818
    self foreground:background background:foreground.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2819
    aBlock value.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2820
    self foreground:oldFg background:oldBg
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2821
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2822
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2823
withBackground:fgColor do:aBlock
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2824
    "evaluate aBlock with changed background."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2825
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2826
    |oldBg|
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2827
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2828
    oldBg := background.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2829
    self background:fgColor.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2830
    aBlock value.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2831
    self background:oldBg
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2832
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2833
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2834
withForeground:fgColor background:bgColor do:aBlock
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2835
    "evaluate aBlock with changed foreground and background."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2836
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2837
    |oldFg oldBg|
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2838
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2839
    oldFg := foreground.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2840
    oldBg := background.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2841
    self foreground:fgColor background:bgColor.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2842
    aBlock value.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2843
    self foreground:oldFg background:oldBg
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2844
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2845
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2846
withForeground:fgColor background:bgColor function:aFunction do:aBlock
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2847
    "evaluate aBlock with foreground, background and function"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2848
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2849
    |oldFg oldBg oldFun|
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2850
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2851
    oldFg := foreground.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2852
    oldBg := background.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2853
    oldFun := function.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2854
    self foreground:fgColor background:bgColor function:aFunction.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2855
    aBlock value.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2856
    self foreground:oldFg background:oldBg function:oldFun
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2857
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2858
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2859
withForeground:fgColor background:bgColor mask:aMask do:aBlock
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2860
    "evaluate aBlock with foreground, background and mask"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2861
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2862
    |oldFg oldBg oldMask|
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2863
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2864
    oldFg := foreground.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2865
    oldBg := background.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2866
    oldMask := mask.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2867
    self foreground:fgColor background:bgColor.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2868
    self mask:aMask.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2869
    aBlock value.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2870
    self foreground:oldFg background:oldBg.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2871
    self mask:oldMask
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2872
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2873
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2874
withForeground:fgColor do:aBlock
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2875
    "evaluate aBlock with changed foreground."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2876
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2877
    |oldFg|
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2878
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2879
    oldFg := foreground.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2880
    self foreground:fgColor.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2881
    aBlock value.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2882
    self foreground:oldFg
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2883
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2884
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2885
withForeground:fgColor function:aFunction do:aBlock
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2886
    "evaluate aBlock with changed foreground and function."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2887
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2888
    |oldFg oldFun|
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2889
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2890
    oldFg := foreground.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2891
    oldFun := function.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2892
    self foreground:fgColor background:background function:aFunction.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2893
    aBlock value.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2894
    self foreground:oldFg background:background function:oldFun
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2895
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2896
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2897
xoring:aBlock
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2898
    "evaluate aBlock with function xoring"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2899
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2900
    |fgPixel bgPixel oldFunction|
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2901
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2902
    fgPixel := (Black on:device) colorId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2903
    bgPixel := (White on:device) colorId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2904
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2905
    gcId isNil ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2906
	self initGC
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2907
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2908
    oldFunction := function.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2909
    device setForeground:(fgPixel bitXor:bgPixel)
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2910
	      background:bgPixel
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2911
		      in:gcId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2912
    device setFunction:#xor in:gcId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2913
    aBlock value.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2914
    paint := nil.        "invalidate"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2915
    foreground := Black.   
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2916
    background := White.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2917
    device setForeground:fgPixel
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2918
	      background:bgPixel
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2919
		      in:gcId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2920
    device setFunction:oldFunction in:gcId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2921
    function := oldFunction
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2922
! !
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2923
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2924
!DeviceGraphicsContext methodsFor:'filling'!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2925
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2926
fillArcX:x y:y width:w height:h from:startAngle angle:angle
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2927
    "draw a filled arc; apply transformation if nonNil"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2928
784
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
  2929
    |pX pY rpX rpY nW nH|
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2930
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2931
    gcId isNil ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2932
        self initGC
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2933
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2934
    transformation notNil ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2935
        pX := transformation applyToX:x.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2936
        pY := transformation applyToY:y.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2937
        nW := transformation applyScaleX:w.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2938
        nH := transformation applyScaleY:h.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2939
        nW < 0 ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2940
              nW := nW abs.  
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2941
              pX := pX - nW.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2942
        ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2943
        nH < 0 ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2944
              nH := nH abs.  
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2945
              pY := pY - nH.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2946
        ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2947
    ] ifFalse:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2948
        pX := x.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2949
        pY := y.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2950
        nW := w.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2951
        nH := h.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2952
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2953
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2954
    pX := pX rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2955
    pY := pY rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2956
    nW := nW rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2957
    nH := nH rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2958
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2959
    device
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2960
          fillArcX:pX 
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2961
                 y:pY 
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2962
             width:nW
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2963
            height:nH 
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2964
              from:startAngle
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2965
             angle:angle
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2966
                in:drawableId
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2967
              with:gcId
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2968
784
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
  2969
"/    rpX := pX rounded.
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
  2970
"/    rpY := pY rounded.
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
  2971
"/    nW := (nW + (rpX - pX)) rounded.
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
  2972
"/    nH := (nH + (rpY - pY)) rounded.
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
  2973
"/
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
  2974
"/    device
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
  2975
"/          fillArcX:rpX 
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
  2976
"/                 y:rpY 
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
  2977
"/             width:nW
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
  2978
"/            height:nH 
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
  2979
"/              from:startAngle
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
  2980
"/             angle:angle
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
  2981
"/                in:drawableId
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
  2982
"/              with:gcId
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
  2983
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2984
    "Created: 8.5.1996 / 08:29:45 / cg"
784
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
  2985
    "Modified: 4.6.1996 / 17:58:21 / cg"
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2986
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2987
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2988
fillPolygon:aPolygon
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2989
    "draw a filled polygon; apply transformation if nonNil"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2990
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2991
    |newPolygon|
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2992
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2993
    gcId isNil ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2994
	self initGC
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2995
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2996
    transformation notNil ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2997
	newPolygon := aPolygon collect:[:point | transformation applyTo:point].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2998
    ] ifFalse:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2999
	newPolygon := aPolygon
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3000
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3001
    (newPolygon findFirst:[:p | 
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3002
	(p isPoint not 
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3003
	or:[(p x class ~~ SmallInteger)
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3004
	or:[(p y class ~~ SmallInteger)]])
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3005
     ]) ~~ 0 ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3006
	newPolygon := newPolygon collect:[:p | p asPoint rounded]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3007
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3008
    device
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3009
	fillPolygon:newPolygon
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3010
		 in:drawableId
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3011
	       with:gcId
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3012
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3013
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3014
fillRectangleX:x y:y width:w height:h
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3015
    "draw a filled rectangle; apply transformation if nonNil"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3016
784
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
  3017
    |pX pY rpX rpY nW nH|
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3018
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3019
    gcId isNil ifTrue:[
784
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
  3020
        self initGC
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3021
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3022
    transformation notNil ifTrue:[
784
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
  3023
        pX := transformation applyToX:x.
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
  3024
        pY := transformation applyToY:y.
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
  3025
        nW := transformation applyScaleX:w.
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
  3026
        nH := transformation applyScaleY:h.
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
  3027
        nW < 0 ifTrue:[
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
  3028
              nW := nW abs.  
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
  3029
              pX := pX - nW.
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
  3030
        ].
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
  3031
        nH < 0 ifTrue:[
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
  3032
              nH := nH abs.  
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
  3033
              pY := pY - nH.
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
  3034
        ].
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3035
    ] ifFalse:[
784
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
  3036
        pX := x.
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
  3037
        pY := y.
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
  3038
        nW := w.
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
  3039
        nH := h.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3040
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3041
    pX := pX rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3042
    pY := pY rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3043
    nW := nW rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3044
    nH := nH rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3045
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3046
    device
784
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
  3047
        fillRectangleX:pX 
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
  3048
                     y:pY 
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
  3049
                 width:nW 
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
  3050
                height:nH 
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
  3051
                    in:drawableId with:gcId
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
  3052
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
  3053
"/    rpX := pX rounded.
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
  3054
"/    rpY := pY rounded.
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
  3055
"/    nW := (nW + (pX - rpX)) rounded.
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
  3056
"/    nH := (nH + (pY - rpY)) rounded.
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
  3057
"/
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
  3058
"/    device
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
  3059
"/        fillRectangleX:rpX 
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
  3060
"/                     y:rpY 
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
  3061
"/                 width:nW 
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
  3062
"/                height:nH 
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
  3063
"/                    in:drawableId with:gcId
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
  3064
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
  3065
    "Modified: 4.6.1996 / 17:58:49 / cg"
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3066
! !
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3067
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3068
!DeviceGraphicsContext methodsFor:'initialization'!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3069
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3070
createGC
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3071
    "since we do not need a gc-object for the drawable until something is
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3072
     really drawn, none is created.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3073
     This method is sent, when the first drawing happens"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3074
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3075
    |fgId bgId p|
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3076
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3077
    gcId := device gcFor:drawableId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3078
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3079
    foreground isNil ifTrue:[foreground := Black].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3080
    background isNil ifTrue:[background := White].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3081
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3082
    foreground isColor ifTrue:[
745
d4465098f2c0 gray vs. grey
Claus Gittinger <cg@exept.de>
parents: 735
diff changeset
  3083
        "get device colors from the device indep. colors"
d4465098f2c0 gray vs. grey
Claus Gittinger <cg@exept.de>
parents: 735
diff changeset
  3084
        foreground := foreground on:device.
d4465098f2c0 gray vs. grey
Claus Gittinger <cg@exept.de>
parents: 735
diff changeset
  3085
        fgId := foreground colorId.
d4465098f2c0 gray vs. grey
Claus Gittinger <cg@exept.de>
parents: 735
diff changeset
  3086
        fgId isNil ifTrue:[
d4465098f2c0 gray vs. grey
Claus Gittinger <cg@exept.de>
parents: 735
diff changeset
  3087
            (foreground grayIntensity >= 50) ifTrue:[
d4465098f2c0 gray vs. grey
Claus Gittinger <cg@exept.de>
parents: 735
diff changeset
  3088
                fgId := device whitepixel
d4465098f2c0 gray vs. grey
Claus Gittinger <cg@exept.de>
parents: 735
diff changeset
  3089
            ] ifFalse:[
d4465098f2c0 gray vs. grey
Claus Gittinger <cg@exept.de>
parents: 735
diff changeset
  3090
                fgId := device blackpixel
d4465098f2c0 gray vs. grey
Claus Gittinger <cg@exept.de>
parents: 735
diff changeset
  3091
            ]
d4465098f2c0 gray vs. grey
Claus Gittinger <cg@exept.de>
parents: 735
diff changeset
  3092
        ].
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3093
    ] ifFalse:[
745
d4465098f2c0 gray vs. grey
Claus Gittinger <cg@exept.de>
parents: 735
diff changeset
  3094
        fgId := device blackpixel.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3095
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3096
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3097
    background isColor ifTrue:[
745
d4465098f2c0 gray vs. grey
Claus Gittinger <cg@exept.de>
parents: 735
diff changeset
  3098
        background := background on:device.
d4465098f2c0 gray vs. grey
Claus Gittinger <cg@exept.de>
parents: 735
diff changeset
  3099
        bgId := background colorId.
d4465098f2c0 gray vs. grey
Claus Gittinger <cg@exept.de>
parents: 735
diff changeset
  3100
        bgId isNil ifTrue:[
d4465098f2c0 gray vs. grey
Claus Gittinger <cg@exept.de>
parents: 735
diff changeset
  3101
            (background grayIntensity >= 50) ifTrue:[
d4465098f2c0 gray vs. grey
Claus Gittinger <cg@exept.de>
parents: 735
diff changeset
  3102
                bgId := device whitepixel
d4465098f2c0 gray vs. grey
Claus Gittinger <cg@exept.de>
parents: 735
diff changeset
  3103
            ] ifFalse:[
d4465098f2c0 gray vs. grey
Claus Gittinger <cg@exept.de>
parents: 735
diff changeset
  3104
                bgId := device blackpixel
d4465098f2c0 gray vs. grey
Claus Gittinger <cg@exept.de>
parents: 735
diff changeset
  3105
            ]
d4465098f2c0 gray vs. grey
Claus Gittinger <cg@exept.de>
parents: 735
diff changeset
  3106
        ].
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3107
    ] ifFalse:[
745
d4465098f2c0 gray vs. grey
Claus Gittinger <cg@exept.de>
parents: 735
diff changeset
  3108
        bgId := device whitepixel
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3109
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3110
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3111
    "now, this is something the device can work with ..."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3112
    device setForeground:fgId background:bgId in:gcId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3113
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3114
    "switch to paint"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3115
    p := paint.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3116
    paint := nil.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3117
    self paint:p.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3118
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3119
    ((lineWidth ~~ 0) 
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3120
    or:[(lineStyle ~~ #solid) 
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3121
    or:[(capStyle ~~ #butt)
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3122
    or:[joinStyle ~~ #miter]]]) ifTrue:[
745
d4465098f2c0 gray vs. grey
Claus Gittinger <cg@exept.de>
parents: 735
diff changeset
  3123
        device setLineWidth:lineWidth 
d4465098f2c0 gray vs. grey
Claus Gittinger <cg@exept.de>
parents: 735
diff changeset
  3124
                      style:lineStyle
d4465098f2c0 gray vs. grey
Claus Gittinger <cg@exept.de>
parents: 735
diff changeset
  3125
                        cap:capStyle
d4465098f2c0 gray vs. grey
Claus Gittinger <cg@exept.de>
parents: 735
diff changeset
  3126
                       join:joinStyle
d4465098f2c0 gray vs. grey
Claus Gittinger <cg@exept.de>
parents: 735
diff changeset
  3127
                         in:gcId
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3128
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3129
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3130
    mask notNil ifTrue:[
745
d4465098f2c0 gray vs. grey
Claus Gittinger <cg@exept.de>
parents: 735
diff changeset
  3131
        (mask depth == 1) ifTrue:[
d4465098f2c0 gray vs. grey
Claus Gittinger <cg@exept.de>
parents: 735
diff changeset
  3132
            device setBitmapMask:(mask id) in:gcId
d4465098f2c0 gray vs. grey
Claus Gittinger <cg@exept.de>
parents: 735
diff changeset
  3133
        ] ifFalse:[
d4465098f2c0 gray vs. grey
Claus Gittinger <cg@exept.de>
parents: 735
diff changeset
  3134
            device setPixmapMask:(mask id) in:gcId
d4465098f2c0 gray vs. grey
Claus Gittinger <cg@exept.de>
parents: 735
diff changeset
  3135
        ].
d4465098f2c0 gray vs. grey
Claus Gittinger <cg@exept.de>
parents: 735
diff changeset
  3136
        maskOrigin notNil ifTrue:[
d4465098f2c0 gray vs. grey
Claus Gittinger <cg@exept.de>
parents: 735
diff changeset
  3137
            device setMaskOriginX:maskOrigin x y:maskOrigin y in:gcId
d4465098f2c0 gray vs. grey
Claus Gittinger <cg@exept.de>
parents: 735
diff changeset
  3138
        ]
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3139
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3140
    (function ~~ #copy) ifTrue:[device setFunction:function in:gcId].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3141
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3142
    "defer the getting of a device font 
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3143
     - this is now done when the first drawstring occurs,
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3144
     since many views (layout-views) will never draw strings and
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3145
     therefore, the overhead of aquiring a font can be avoided.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3146
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3147
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3148
"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3149
    font := font on:device.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3150
    id := font fontId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3151
    id notNil ifTrue:[
745
d4465098f2c0 gray vs. grey
Claus Gittinger <cg@exept.de>
parents: 735
diff changeset
  3152
        device setFont:id in:gcId
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3153
    ]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3154
"
745
d4465098f2c0 gray vs. grey
Claus Gittinger <cg@exept.de>
parents: 735
diff changeset
  3155
d4465098f2c0 gray vs. grey
Claus Gittinger <cg@exept.de>
parents: 735
diff changeset
  3156
    "Modified: 28.5.1996 / 20:45:24 / cg"
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3157
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3158
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3159
destroy
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3160
    "when the drawable is destroyed, the associated GC must be destroyed with it"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3161
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3162
    gcId notNil ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3163
	device destroyGC:gcId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3164
	gcId := nil.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3165
	Lobby registerChange:self.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3166
    ]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3167
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3168
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3169
initGC
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3170
    "since we do not need a gc-object for the drawable until something is
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3171
     really drawn, none is created.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3172
     This method is sent, when the first drawing happens"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3173
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3174
    self createGC.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3175
    Lobby registerChange:self.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3176
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3177
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3178
initialize
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3179
    "setup everything for later use; actual work is done in
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3180
     initColors and initFont, which are usually redefined."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3181
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3182
    "make certain Workstation is initialized - just a check - will vanish soon"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3183
    Display isNil ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3184
	'DEVDRAW: Display not initialized when first DeviceGraphicsContext created' errorPrintNL.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3185
	Workstation initialize
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3186
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3187
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3188
    super initialize.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3189
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3190
    foreground := Black.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3191
    background := White.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3192
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3193
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3194
prepareForReinit
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3195
    "kludge - clear drawableId and gcId 
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3196
     needed after snapin"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3197
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3198
    gcId := nil.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3199
    drawableId := nil.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3200
    deviceFont := nil
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3201
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3202
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3203
recreate
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3204
    "sent after a snapin, reinit draw stuff for new device"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3205
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3206
    gcId := nil.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3207
    foreground notNil ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3208
	foreground := foreground on:device
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3209
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3210
    background notNil ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3211
	background := background on:device
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3212
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3213
    paint notNil ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3214
	paint := paint on:device
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3215
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3216
    bgPaint notNil ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3217
	bgPaint := bgPaint on:device
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3218
    ]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3219
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3220
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3221
reinitialize
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3222
    'reinit of ' errorPrint. self classNameWithArticle errorPrint.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3223
    ' failed' errorPrintNL
832
064890dcfabd fixed opaque string draw with deep-dither
Claus Gittinger <cg@exept.de>
parents: 786
diff changeset
  3224
!
064890dcfabd fixed opaque string draw with deep-dither
Claus Gittinger <cg@exept.de>
parents: 786
diff changeset
  3225
064890dcfabd fixed opaque string draw with deep-dither
Claus Gittinger <cg@exept.de>
parents: 786
diff changeset
  3226
releaseGC
064890dcfabd fixed opaque string draw with deep-dither
Claus Gittinger <cg@exept.de>
parents: 786
diff changeset
  3227
    "destroy the associated GC - can be done to be nice to the 
064890dcfabd fixed opaque string draw with deep-dither
Claus Gittinger <cg@exept.de>
parents: 786
diff changeset
  3228
     display if you know that you are done with a drawable."
064890dcfabd fixed opaque string draw with deep-dither
Claus Gittinger <cg@exept.de>
parents: 786
diff changeset
  3229
844
17d0f74d7d02 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 832
diff changeset
  3230
    foreground := background := paint := bgPaint := nil.
832
064890dcfabd fixed opaque string draw with deep-dither
Claus Gittinger <cg@exept.de>
parents: 786
diff changeset
  3231
    gcId notNil ifTrue:[
064890dcfabd fixed opaque string draw with deep-dither
Claus Gittinger <cg@exept.de>
parents: 786
diff changeset
  3232
        device destroyGC:gcId.
064890dcfabd fixed opaque string draw with deep-dither
Claus Gittinger <cg@exept.de>
parents: 786
diff changeset
  3233
        gcId := nil.
064890dcfabd fixed opaque string draw with deep-dither
Claus Gittinger <cg@exept.de>
parents: 786
diff changeset
  3234
        Lobby registerChange:self.
844
17d0f74d7d02 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 832
diff changeset
  3235
    ].
832
064890dcfabd fixed opaque string draw with deep-dither
Claus Gittinger <cg@exept.de>
parents: 786
diff changeset
  3236
064890dcfabd fixed opaque string draw with deep-dither
Claus Gittinger <cg@exept.de>
parents: 786
diff changeset
  3237
    "Created: 11.6.1996 / 22:07:30 / cg"
844
17d0f74d7d02 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 832
diff changeset
  3238
    "Modified: 12.6.1996 / 20:52:34 / cg"
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3239
! !
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3240
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3241
!DeviceGraphicsContext methodsFor:'instance release'!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3242
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3243
disposed
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3244
    "some Drawable has been collected 
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3245
     - must release operating system resources"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3246
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3247
    ^ self subclassResponsibility
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3248
! !
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3249
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3250
!DeviceGraphicsContext methodsFor:'private'!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3251
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3252
setDevice:aDevice id:aDrawbleId gcId:aGCId
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3253
    "private"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3254
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3255
    device := aDevice.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3256
    gcId := aGCId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3257
    drawableId := aDrawbleId
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3258
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3259
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3260
setGCForPaint
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3261
    "private; given a complex color (i.e. a pixmap or dithered color,
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3262
     setup the GC to draw in this color.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3263
     A helper for paint and paint:on:"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3264
832
064890dcfabd fixed opaque string draw with deep-dither
Claus Gittinger <cg@exept.de>
parents: 786
diff changeset
  3265
    |dither map pixelId p fg bg vOrg ditherDepth deviceDepth|
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3266
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3267
    gcId notNil ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3268
        (p := paint) isColor ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3269
            paint := p := p on:device.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3270
            pixelId := p colorId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3271
            pixelId notNil ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3272
                "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3273
                 a real (undithered) color
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3274
                "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3275
                mask notNil ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3276
                    mask := nil.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3277
                    device setBitmapMask:nil in:gcId
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3278
                ]. 
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3279
                (p ~~ foreground) ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3280
                    foreground := paint.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3281
                    device setForeground:pixelId in:gcId
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3282
                ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3283
                ^ self
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3284
            ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3285
            "a dithered color"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3286
            dither := paint ditherForm.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3287
        ] ifFalse:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3288
            "mhmh - seems to be some kind of form ..."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3289
            paint := paint on:device.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3290
            dither := paint
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3291
        ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3292
        "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3293
         a dithered color or image
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3294
        "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3295
        (ditherDepth := dither depth) == 1 ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3296
            "a simple 0/1 bitmap"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3297
            map := dither colorMap.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3298
            "temporary (kludgy) fix for destroyed paint"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3299
            p := paint.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3300
            map isNil ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3301
                fg := Color black.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3302
                bg := Color white.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3303
            ] ifFalse:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3304
                fg := map at:2.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3305
                bg := map at:1.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3306
            ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3307
            self foreground:fg background:bg.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3308
            paint := p
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3309
        ] ifFalse:[
832
064890dcfabd fixed opaque string draw with deep-dither
Claus Gittinger <cg@exept.de>
parents: 786
diff changeset
  3310
            deviceDepth := device depth.
064890dcfabd fixed opaque string draw with deep-dither
Claus Gittinger <cg@exept.de>
parents: 786
diff changeset
  3311
            (ditherDepth ~~ deviceDepth) ifTrue:[
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3312
                dither := dither asFormOn:device.
832
064890dcfabd fixed opaque string draw with deep-dither
Claus Gittinger <cg@exept.de>
parents: 786
diff changeset
  3313
                ditherDepth := dither depth.
064890dcfabd fixed opaque string draw with deep-dither
Claus Gittinger <cg@exept.de>
parents: 786
diff changeset
  3314
                (dither isNil or:[ditherDepth ~~ deviceDepth]) ifTrue:[
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3315
                    self error:'bad dither'.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3316
                    ^ self
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3317
                ]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3318
            ]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3319
        ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3320
        self mask:dither.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3321
        vOrg := self viewOrigin.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3322
        self setMaskOriginX:vOrg x negated y:vOrg y negated.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3323
    ]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3324
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3325
    "Created: 16.5.1996 / 15:35:51 / cg"
832
064890dcfabd fixed opaque string draw with deep-dither
Claus Gittinger <cg@exept.de>
parents: 786
diff changeset
  3326
    "Modified: 12.6.1996 / 12:49:07 / cg"
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3327
! !
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3328
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3329
!DeviceGraphicsContext methodsFor:'queries'!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3330
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3331
horizontalIntegerPixelPerMillimeter
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3332
    "return the (rounded) number of pixels per millimeter"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3333
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3334
    ^ device horizontalPixelPerMillimeter rounded
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3335
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3336
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3337
horizontalPixelPerInch
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3338
    "return the number of horizontal pixels per inch of the display"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3339
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3340
    ^ device horizontalPixelPerMillimeter * 25.4
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3341
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3342
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3343
horizontalPixelPerMillimeter
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3344
    "return the number of pixels per millimeter (not rounded)"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3345
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3346
    ^ device horizontalPixelPerMillimeter
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3347
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3348
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3349
horizontalPixelPerMillimeter:millis
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3350
    "return the number of pixels (not rounded) for millis millimeter"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3351
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3352
    ^ device horizontalPixelPerMillimeter * millis
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3353
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3354
784
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
  3355
resolution
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
  3356
    "return a point consisting of pixel-per-inch horizontally and vertically."
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
  3357
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
  3358
    ^ device resolution
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
  3359
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
  3360
    "Created: 4.6.1996 / 15:23:55 / cg"
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
  3361
!
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
  3362
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3363
verticalIntegerPixelPerMillimeter
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3364
    "return the (rounded) number of pixels per millimeter"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3365
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3366
    ^ device verticalPixelPerMillimeter rounded
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3367
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3368
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3369
verticalPixelPerInch
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3370
    "return the number of vertical pixels per inch of the display"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3371
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3372
    ^ device verticalPixelPerMillimeter * 25.4
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3373
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3374
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3375
verticalPixelPerMillimeter
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3376
    "return the number of pixels per millimeter (not rounded)"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3377
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3378
    ^ device verticalPixelPerMillimeter
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3379
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3380
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3381
verticalPixelPerMillimeter:millis
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3382
    "return the number of pixels (not rounded) for millis millimeter"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3383
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3384
    ^ device verticalPixelPerMillimeter * millis
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3385
! !
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3386
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3387
!DeviceGraphicsContext class methodsFor:'documentation'!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3388
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3389
version
895
0d49372cded9 if a deep image has a mask, care for it (stamp out & or-in)
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
  3390
    ^ '$Header: /cvs/stx/stx/libview/DeviceGraphicsContext.st,v 1.10 1996-06-21 11:32:40 cg Exp $'
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3391
! !
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3392
DeviceGraphicsContext initialize!