DeviceGraphicsContext.st
author Claus Gittinger <cg@exept.de>
Sun, 08 May 2016 03:59:49 +0200
changeset 7345 8eea38c33a0b
parent 7301 153311545645
child 7350 cbe52e085dbf
child 7364 262ab56176cb
permissions -rw-r--r--
#DOCUMENTATION by cg class: DeviceGraphicsContext comment/format in: #displayOpaqueString:from:to:x:y: #displayOpaqueString:x:y: #displayString:from:to:x:y: #displayString:x:y:
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
"
3275
b40f47ec5661 comment
Claus Gittinger <cg@exept.de>
parents: 3188
diff changeset
    12
"{ Package: 'stx:libview' }"
b40f47ec5661 comment
Claus Gittinger <cg@exept.de>
parents: 3188
diff changeset
    13
6746
e63784ff3863 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6711
diff changeset
    14
"{ NameSpace: Smalltalk }"
e63784ff3863 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6711
diff changeset
    15
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    16
GraphicsContext subclass:#DeviceGraphicsContext
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    17
	instanceVariableNames:'drawableId gcId deviceFont foreground background'
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    18
	classVariableNames:'CachedScaledForms CachedScales Lobby'
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    19
	poolDictionaries:''
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    20
	category:'Graphics-Support'
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
1085
3513a4cae87b handle depth1-images with a mask
Claus Gittinger <cg@exept.de>
parents: 1064
diff changeset
    23
!DeviceGraphicsContext class methodsFor:'documentation'!
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    24
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    25
copyright
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
 COPYRIGHT (c) 1992 by Claus Gittinger
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    28
	      All Rights Reserved
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    29
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    30
 This software is furnished under a license and may be used
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    31
 only in accordance with the terms of that license and with the
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    32
 inclusion of the above copyright notice.   This software may not
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    33
 be provided or otherwise made available to, or used by, any
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    34
 other person.  No title to or ownership of the software is
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    35
 hereby transferred.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    36
"
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
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    39
documentation
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    40
"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    41
    I provide the common protocol for a graphicsContext which is associated with a particular
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
    42
    device (i.e. Bitmaps, Pixmaps, RootWindow and Windows in Xs world, but also postscript
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    43
    printer pages or fax pages).
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    44
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    45
    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
    46
    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
    47
    exist in the system.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    48
    All real work is done by my device, which is accessed via the device instance variable.
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
    49
    Most drawing requests are simply forwarded to it, others are simulated by using more basic
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    50
    drawing functions (see GraphicsContext drawing vs. basic drawing category).
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    51
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
    52
    The added variables foreground/background are the drawing colors actually
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    53
    used; these are the real (i.e. non dithered) colors supported by the device.
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
    54
    Direct access to fg/bg is discouraged, since in the future, these may be
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
    55
    totally replaced by paint/bgPaint
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
    56
    (there are some operations and special cases, for which a direct access to
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    57
     fg/bg makes sense)
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    58
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    59
    [Instance variables:]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    60
1029
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
    61
	drawableId      <SmallInteger>  my drawableId on the device (a device handle)
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
    62
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
    63
	gcId            <SmallInteger>  my gc's ID on the device (a device handle)
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
    64
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
    65
	deviceFont      <Font>          the actual font, currently set in the device
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
    66
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
    67
	foreground      <Color>         the device foreground color used for drawing
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
    68
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
    69
	background      <Color>         the device background color used for drawing
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    70
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    71
    [see also:]
1029
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
    72
	DeviceWorkstation
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
    73
	Color Font Cursor
732
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
    [author:]
1029
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
    76
	Claus Gittinger
732
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
"
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
1085
3513a4cae87b handle depth1-images with a mask
Claus Gittinger <cg@exept.de>
parents: 1064
diff changeset
    81
!DeviceGraphicsContext class methodsFor:'initialization'!
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    82
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    83
initialize
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    84
    Lobby isNil ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
    85
	Lobby := Registry new.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    86
    ]
2031
d369d38213cf dont use #error when drawing on a closed drawable;
Claus Gittinger <cg@exept.de>
parents: 2024
diff changeset
    87
d369d38213cf dont use #error when drawing on a closed drawable;
Claus Gittinger <cg@exept.de>
parents: 2024
diff changeset
    88
    "Modified: / 29.1.1998 / 12:56:12 / cg"
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    89
! !
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    90
1085
3513a4cae87b handle depth1-images with a mask
Claus Gittinger <cg@exept.de>
parents: 1064
diff changeset
    91
!DeviceGraphicsContext class methodsFor:'instance creation'!
732
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
new
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    94
    "create a new drawable - take the current display as
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    95
     its device (for now, this may be changed until the view is
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    96
     physically created)"
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
    '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
   100
"
6290
b6886e346ae9 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6273
diff changeset
   101
    |device|
b6886e346ae9 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6273
diff changeset
   102
b6886e346ae9 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6273
diff changeset
   103
    device := Screen current.
b6886e346ae9 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6273
diff changeset
   104
    device isNil ifTrue:[
6926
d04d6d93b921 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6765
diff changeset
   105
        device := Display.
d04d6d93b921 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6765
diff changeset
   106
        device isNil ifTrue:[
d04d6d93b921 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6765
diff changeset
   107
            (self class name,' [warning]: no Display') infoPrintCR.
d04d6d93b921 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6765
diff changeset
   108
            Smalltalk openDisplay.
d04d6d93b921 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6765
diff changeset
   109
            
7257
0507a7e2c35f #FEATURE
Claus Gittinger <cg@exept.de>
parents: 7237
diff changeset
   110
            device := Screen current ? Display.
6926
d04d6d93b921 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6765
diff changeset
   111
            device isNil ifTrue:[ self error:'no screen device' ]
d04d6d93b921 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6765
diff changeset
   112
        ].
6290
b6886e346ae9 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6273
diff changeset
   113
    ].
6926
d04d6d93b921 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6765
diff changeset
   114
    ^ self onDevice:device
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   115
!
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
on:aDevice
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   118
    "create a new drawable on aDevice"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   119
3429
7f87cd2ae010 Use <resource:#obsolete>
Stefan Vogel <sv@exept.de>
parents: 3300
diff changeset
   120
    <resource:#obsolete>
7f87cd2ae010 Use <resource:#obsolete>
Stefan Vogel <sv@exept.de>
parents: 3300
diff changeset
   121
1741
b84a2f4317e9 warn #on: vs. #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1722
diff changeset
   122
    "/ send out a warning: #on: is typically used to create a view
b84a2f4317e9 warn #on: vs. #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1722
diff changeset
   123
    "/ operating on a model.
b84a2f4317e9 warn #on: vs. #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1722
diff changeset
   124
    "/ Please use #onDevice: to avoid confusion.
b84a2f4317e9 warn #on: vs. #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1722
diff changeset
   125
1255
bdf4cbcae668 on: -> onDevice:
Claus Gittinger <cg@exept.de>
parents: 1249
diff changeset
   126
    self obsoleteMethodWarning:'use #onDevice:'.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   127
    ^ self onDevice:aDevice
1255
bdf4cbcae668 on: -> onDevice:
Claus Gittinger <cg@exept.de>
parents: 1249
diff changeset
   128
1741
b84a2f4317e9 warn #on: vs. #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1722
diff changeset
   129
    "Modified: 5.6.1997 / 21:04:16 / cg"
732
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
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   132
onDevice:aDevice
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   133
    "create a new drawable on aDevice"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   134
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   135
    |newDrawable|
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   136
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   137
    newDrawable := self basicNew.
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
    "
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   140
     set display before its initialized
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   141
     - 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
   142
     intitialize method(s)
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   143
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   144
    newDrawable device:aDevice.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   145
    newDrawable initialize.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   146
    ^ newDrawable
1517
ac751bb3dfdf no need for registration here;
Claus Gittinger <cg@exept.de>
parents: 1514
diff changeset
   147
ac751bb3dfdf no need for registration here;
Claus Gittinger <cg@exept.de>
parents: 1514
diff changeset
   148
    "Modified: 2.4.1997 / 19:19:35 / cg"
732
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
1085
3513a4cae87b handle depth1-images with a mask
Claus Gittinger <cg@exept.de>
parents: 1064
diff changeset
   151
!DeviceGraphicsContext class methodsFor:'cleanup'!
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   152
4436
05eadeb4b603 In #cleanUpLobbyForChildrenOfView...
Stefan Vogel <sv@exept.de>
parents: 4434
diff changeset
   153
cleanupLobbyForChildrenOfViewWithDevice:aDevice id:anId
05eadeb4b603 In #cleanUpLobbyForChildrenOfView...
Stefan Vogel <sv@exept.de>
parents: 4434
diff changeset
   154
    "clean all the subcomponents of the handle with id anId.
05eadeb4b603 In #cleanUpLobbyForChildrenOfView...
Stefan Vogel <sv@exept.de>
parents: 4434
diff changeset
   155
     This must be done on finalization, because descendent handles
05eadeb4b603 In #cleanUpLobbyForChildrenOfView...
Stefan Vogel <sv@exept.de>
parents: 4434
diff changeset
   156
     are destroyed implicitly when a parent handle is destroyed."
05eadeb4b603 In #cleanUpLobbyForChildrenOfView...
Stefan Vogel <sv@exept.de>
parents: 4434
diff changeset
   157
05eadeb4b603 In #cleanUpLobbyForChildrenOfView...
Stefan Vogel <sv@exept.de>
parents: 4434
diff changeset
   158
    |parents newChildren|
05eadeb4b603 In #cleanUpLobbyForChildrenOfView...
Stefan Vogel <sv@exept.de>
parents: 4434
diff changeset
   159
05eadeb4b603 In #cleanUpLobbyForChildrenOfView...
Stefan Vogel <sv@exept.de>
parents: 4434
diff changeset
   160
    parents := Array with:anId address.
05eadeb4b603 In #cleanUpLobbyForChildrenOfView...
Stefan Vogel <sv@exept.de>
parents: 4434
diff changeset
   161
05eadeb4b603 In #cleanUpLobbyForChildrenOfView...
Stefan Vogel <sv@exept.de>
parents: 4434
diff changeset
   162
    [
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   163
	newChildren := Set new.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   164
	Lobby unregisterAllForWhichHandle:[:handle |
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   165
	    |parentId|
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   166
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   167
	    (handle notNil
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   168
		and:[handle device == aDevice
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   169
		and:[(parentId := handle parentId) notNil
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   170
		and:[parents includes:parentId]]]
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   171
	    ) ifTrue:[newChildren add:handle id. true] ifFalse:[false]
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   172
	].
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   173
	parents := newChildren.
4436
05eadeb4b603 In #cleanUpLobbyForChildrenOfView...
Stefan Vogel <sv@exept.de>
parents: 4434
diff changeset
   174
    ] doWhile:[parents notEmpty].
4434
cbbb56b8d851 addons and fixes for X11-deviceHandle fix
Claus Gittinger <cg@exept.de>
parents: 4403
diff changeset
   175
!
cbbb56b8d851 addons and fixes for X11-deviceHandle fix
Claus Gittinger <cg@exept.de>
parents: 4403
diff changeset
   176
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   177
lowSpaceCleanup
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   178
    CachedScaledForms := CachedScales := nil
1224
2a2270ec4236 added #releaseResourcesOnDevice:, to allow cleanup when
Claus Gittinger <cg@exept.de>
parents: 1199
diff changeset
   179
!
2a2270ec4236 added #releaseResourcesOnDevice:, to allow cleanup when
Claus Gittinger <cg@exept.de>
parents: 1199
diff changeset
   180
2a2270ec4236 added #releaseResourcesOnDevice:, to allow cleanup when
Claus Gittinger <cg@exept.de>
parents: 1199
diff changeset
   181
releaseResourcesOnDevice:aDevice
2a2270ec4236 added #releaseResourcesOnDevice:, to allow cleanup when
Claus Gittinger <cg@exept.de>
parents: 1199
diff changeset
   182
    "this is sent when a display connection is closed,
2a2270ec4236 added #releaseResourcesOnDevice:, to allow cleanup when
Claus Gittinger <cg@exept.de>
parents: 1199
diff changeset
   183
     to release all cached bitmap/window objects from that device"
2a2270ec4236 added #releaseResourcesOnDevice:, to allow cleanup when
Claus Gittinger <cg@exept.de>
parents: 1199
diff changeset
   184
2a2270ec4236 added #releaseResourcesOnDevice:, to allow cleanup when
Claus Gittinger <cg@exept.de>
parents: 1199
diff changeset
   185
    Lobby unregisterAllForWhich:[:aDrawable | aDrawable graphicsDevice == aDevice]
2a2270ec4236 added #releaseResourcesOnDevice:, to allow cleanup when
Claus Gittinger <cg@exept.de>
parents: 1199
diff changeset
   186
2a2270ec4236 added #releaseResourcesOnDevice:, to allow cleanup when
Claus Gittinger <cg@exept.de>
parents: 1199
diff changeset
   187
    "Created: 16.1.1997 / 16:43:52 / cg"
732
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
3880
c4c8268a2d9f method category rename
Claus Gittinger <cg@exept.de>
parents: 3666
diff changeset
   190
!DeviceGraphicsContext methodsFor:'Compatibility-ST80'!
3188
67ce53b6b843 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3160
diff changeset
   191
67ce53b6b843 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3160
diff changeset
   192
key
67ce53b6b843 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3160
diff changeset
   193
    ^ self id
67ce53b6b843 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3160
diff changeset
   194
! !
67ce53b6b843 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3160
diff changeset
   195
3942
ee09c1391e61 some more dummies for VW widgets
Claus Gittinger <cg@exept.de>
parents: 3938
diff changeset
   196
!DeviceGraphicsContext methodsFor:'Compatibility-VW'!
ee09c1391e61 some more dummies for VW widgets
Claus Gittinger <cg@exept.de>
parents: 3938
diff changeset
   197
ee09c1391e61 some more dummies for VW widgets
Claus Gittinger <cg@exept.de>
parents: 3938
diff changeset
   198
displayBackgroundIfNeededOn: aGraphicsContext
4070
efd0ffb52d43 clear -> clearView
Claus Gittinger <cg@exept.de>
parents: 4056
diff changeset
   199
    aGraphicsContext clearView.
3942
ee09c1391e61 some more dummies for VW widgets
Claus Gittinger <cg@exept.de>
parents: 3938
diff changeset
   200
!
ee09c1391e61 some more dummies for VW widgets
Claus Gittinger <cg@exept.de>
parents: 3938
diff changeset
   201
ee09c1391e61 some more dummies for VW widgets
Claus Gittinger <cg@exept.de>
parents: 3938
diff changeset
   202
inactiveForegroundColor
3943
2d4dbd3f9aa6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3942
diff changeset
   203
    "a dummy method to support VW widgets"
2d4dbd3f9aa6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3942
diff changeset
   204
3942
ee09c1391e61 some more dummies for VW widgets
Claus Gittinger <cg@exept.de>
parents: 3938
diff changeset
   205
    ^ self foregroundColor
ee09c1391e61 some more dummies for VW widgets
Claus Gittinger <cg@exept.de>
parents: 3938
diff changeset
   206
!
ee09c1391e61 some more dummies for VW widgets
Claus Gittinger <cg@exept.de>
parents: 3938
diff changeset
   207
ee09c1391e61 some more dummies for VW widgets
Claus Gittinger <cg@exept.de>
parents: 3938
diff changeset
   208
selectionBackgroundColor
3943
2d4dbd3f9aa6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3942
diff changeset
   209
    "a dummy method to support VW widgets"
2d4dbd3f9aa6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3942
diff changeset
   210
3942
ee09c1391e61 some more dummies for VW widgets
Claus Gittinger <cg@exept.de>
parents: 3938
diff changeset
   211
    ^ self foregroundColor
ee09c1391e61 some more dummies for VW widgets
Claus Gittinger <cg@exept.de>
parents: 3938
diff changeset
   212
!
ee09c1391e61 some more dummies for VW widgets
Claus Gittinger <cg@exept.de>
parents: 3938
diff changeset
   213
ee09c1391e61 some more dummies for VW widgets
Claus Gittinger <cg@exept.de>
parents: 3938
diff changeset
   214
selectionForegroundColor
3943
2d4dbd3f9aa6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3942
diff changeset
   215
    "a dummy method to support VW widgets"
2d4dbd3f9aa6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3942
diff changeset
   216
3942
ee09c1391e61 some more dummies for VW widgets
Claus Gittinger <cg@exept.de>
parents: 3938
diff changeset
   217
    ^ self backgroundColor
ee09c1391e61 some more dummies for VW widgets
Claus Gittinger <cg@exept.de>
parents: 3938
diff changeset
   218
!
ee09c1391e61 some more dummies for VW widgets
Claus Gittinger <cg@exept.de>
parents: 3938
diff changeset
   219
ee09c1391e61 some more dummies for VW widgets
Claus Gittinger <cg@exept.de>
parents: 3938
diff changeset
   220
separatorColor
3943
2d4dbd3f9aa6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3942
diff changeset
   221
    "a dummy method to support VW widgets"
2d4dbd3f9aa6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3942
diff changeset
   222
3942
ee09c1391e61 some more dummies for VW widgets
Claus Gittinger <cg@exept.de>
parents: 3938
diff changeset
   223
    ^ self foregroundColor
ee09c1391e61 some more dummies for VW widgets
Claus Gittinger <cg@exept.de>
parents: 3938
diff changeset
   224
! !
ee09c1391e61 some more dummies for VW widgets
Claus Gittinger <cg@exept.de>
parents: 3938
diff changeset
   225
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   226
!DeviceGraphicsContext methodsFor:'accessing'!
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
at:aPoint
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   229
    "return the pixel at the coordinate given by aPoint"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   230
3160
89905f311a09 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3137
diff changeset
   231
    ^ self atX:aPoint x y:aPoint y
89905f311a09 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3137
diff changeset
   232
89905f311a09 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3137
diff changeset
   233
    "Modified: / 29.1.2000 / 12:17:42 / cg"
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   234
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   235
4204
947a5a5620d3 comments
Claus Gittinger <cg@exept.de>
parents: 4199
diff changeset
   236
at:aPoint put:aPixelColor
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   237
    "set a pixel"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   238
4204
947a5a5620d3 comments
Claus Gittinger <cg@exept.de>
parents: 4199
diff changeset
   239
    ^ self atX:aPoint x y:aPoint y put:aPixelColor
947a5a5620d3 comments
Claus Gittinger <cg@exept.de>
parents: 4199
diff changeset
   240
947a5a5620d3 comments
Claus Gittinger <cg@exept.de>
parents: 4199
diff changeset
   241
    "
947a5a5620d3 comments
Claus Gittinger <cg@exept.de>
parents: 4199
diff changeset
   242
     Display rootView at:(0@0) put:(Color red).
947a5a5620d3 comments
Claus Gittinger <cg@exept.de>
parents: 4199
diff changeset
   243
     Display rootView at:(1@1) put:(Color red).
947a5a5620d3 comments
Claus Gittinger <cg@exept.de>
parents: 4199
diff changeset
   244
     Display rootView at:(2@2) put:(Color red).
947a5a5620d3 comments
Claus Gittinger <cg@exept.de>
parents: 4199
diff changeset
   245
     Display rootView at:(3@3) put:(Color red).
947a5a5620d3 comments
Claus Gittinger <cg@exept.de>
parents: 4199
diff changeset
   246
     Display rootView at:(4@4) put:(Color red).
947a5a5620d3 comments
Claus Gittinger <cg@exept.de>
parents: 4199
diff changeset
   247
     Display rootView at:(5@5) put:(Color red).
947a5a5620d3 comments
Claus Gittinger <cg@exept.de>
parents: 4199
diff changeset
   248
    "
732
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
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   251
atX:x y:y
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   252
    "return the pixel at the coordinate given by x/y"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   253
2714
e5d16e41cbab need gcId-argument in getPixel
Claus Gittinger <cg@exept.de>
parents: 2680
diff changeset
   254
    ^ device getPixelX:x y:y from:drawableId with:gcId
e5d16e41cbab need gcId-argument in getPixel
Claus Gittinger <cg@exept.de>
parents: 2680
diff changeset
   255
e5d16e41cbab need gcId-argument in getPixel
Claus Gittinger <cg@exept.de>
parents: 2680
diff changeset
   256
    "Modified: / 22.5.1999 / 01:40:23 / cg"
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   257
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   258
4204
947a5a5620d3 comments
Claus Gittinger <cg@exept.de>
parents: 4199
diff changeset
   259
atX:x y:y put:aPixelColor
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   260
    "set a pixel"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   261
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   262
    |oldFg|
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   263
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   264
    oldFg := foreground.
4204
947a5a5620d3 comments
Claus Gittinger <cg@exept.de>
parents: 4199
diff changeset
   265
    self foreground:aPixelColor.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   266
    self displayPointX:x y:y.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   267
    self foreground:oldFg
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   268
!
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
backgroundPaint:aColor
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   271
    "set the background-paint color; this is used in opaque-draw
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   272
     operations"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   273
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   274
    (aColor ~~ bgPaint) ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   275
	aColor notNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   276
	    bgPaint := aColor.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   277
	    gcId notNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   278
		bgPaint isColor ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   279
		    bgPaint := aColor onDevice:device.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   280
		    bgPaint colorId notNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   281
			background := bgPaint.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   282
			gcId notNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   283
			    device setBackground:(bgPaint colorId) in:gcId.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   284
			].
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   285
			^ self
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   286
		    ]
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   287
		].
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   288
		self paint:paint on:aColor
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   289
	    ]
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   290
	]
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   291
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   292
!
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
basicFont
2918
1e777dc8588a #font answers device font if possible (cg)
Stefan Vogel <sv@exept.de>
parents: 2913
diff changeset
   295
    "return the font for drawing"
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   296
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   297
    ^ font
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   298
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   299
    "Created: 12.5.1996 / 11:17:59 / cg"
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
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   302
basicFont:aFont
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   303
    "set the font for drawing if it has changed.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   304
     This is a low level entry, which is not to be redefined
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   305
     (i.e. it must not imply a redraw operation)"
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
    |id|
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   308
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   309
    (aFont ~~ font) ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   310
	aFont notNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   311
	    font := aFont.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   312
	    device notNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   313
		font := font onDevice:device.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   314
		gcId notNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   315
		    id := font fontId.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   316
		    id notNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   317
			deviceFont := font.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   318
			device setFont:id in:gcId
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   319
		    ]
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   320
		]
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   321
	    ]
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   322
	]
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   323
    ]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   324
4664
02d160974029 fix remembering deviceFont everywhere.
Claus Gittinger <cg@exept.de>
parents: 4657
diff changeset
   325
    "Created: / 23-02-1996 / 17:16:51 / cg"
02d160974029 fix remembering deviceFont everywhere.
Claus Gittinger <cg@exept.de>
parents: 4657
diff changeset
   326
    "Modified: / 22-10-2006 / 14:11:37 / cg"
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   327
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   328
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   329
capStyle:aSymbol
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   330
    "set the style in which the endpoints of lines
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   331
     are drawn - aSymbol may be #notLast, #butt, #round, #projecting"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   332
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   333
    |s|
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   334
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   335
    (s := aSymbol) isNil ifTrue:[
1029
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
   336
	s := #butt.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   337
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   338
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   339
    (s ~~ capStyle) ifTrue:[
1029
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
   340
	capStyle := s.
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
   341
	gcId notNil ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   342
	    device setLineWidth:lineWidth
1029
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
   343
			  style:lineStyle
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
   344
			    cap:s
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
   345
			   join:joinStyle
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
   346
			     in:gcId
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
   347
	]
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   348
    ]
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
    "Modified: 12.5.1996 / 22:23:03 / cg"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   351
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   352
950
d4d907fc7d78 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 927
diff changeset
   353
clipByChildren
d4d907fc7d78 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 927
diff changeset
   354
    "drawing shall be done into my view only (default)"
d4d907fc7d78 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 927
diff changeset
   355
3429
7f87cd2ae010 Use <resource:#obsolete>
Stefan Vogel <sv@exept.de>
parents: 3300
diff changeset
   356
    <resource:#obsolete>
7f87cd2ae010 Use <resource:#obsolete>
Stefan Vogel <sv@exept.de>
parents: 3300
diff changeset
   357
1722
4ceaeda95cc3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1715
diff changeset
   358
    self obsoleteMethodWarning:'use #clippedByChildren:true'.
950
d4d907fc7d78 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 927
diff changeset
   359
    ^ self clippedByChildren:true
d4d907fc7d78 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 927
diff changeset
   360
d4d907fc7d78 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 927
diff changeset
   361
    "Created: 17.7.1996 / 13:25:55 / cg"
d4d907fc7d78 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 927
diff changeset
   362
!
d4d907fc7d78 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 927
diff changeset
   363
6222
2d670d3bcfd5 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6215
diff changeset
   364
clipRect
6502
6c4fe54e61f8 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   365
    "return the clipping rectangle for drawing.
6c4fe54e61f8 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   366
     Notice: this is in logical coordinates.
6c4fe54e61f8 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   367
     If there is currently no clipRect, a dummy is created."
6222
2d670d3bcfd5 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6215
diff changeset
   368
2d670d3bcfd5 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6215
diff changeset
   369
    |rect|
2d670d3bcfd5 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6215
diff changeset
   370
2d670d3bcfd5 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6215
diff changeset
   371
    (rect := clipRect) isNil ifTrue:[
6502
6c4fe54e61f8 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   372
        rect := 0@0 extent:(self extent).
6c4fe54e61f8 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   373
        transformation notNil ifTrue:[
6c4fe54e61f8 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   374
            rect := rect applyInverseTo:rect.
6c4fe54e61f8 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   375
        ].
6222
2d670d3bcfd5 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6215
diff changeset
   376
    ].
2d670d3bcfd5 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6215
diff changeset
   377
    ^ rect
2d670d3bcfd5 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6215
diff changeset
   378
2d670d3bcfd5 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6215
diff changeset
   379
    "Modified: / 20-10-2006 / 13:24:21 / cg"
2d670d3bcfd5 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6215
diff changeset
   380
!
2d670d3bcfd5 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6215
diff changeset
   381
950
d4d907fc7d78 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 927
diff changeset
   382
clippedByChildren:aBoolean
d4d907fc7d78 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 927
diff changeset
   383
    "turn on/off drawing over children.
d4d907fc7d78 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 927
diff changeset
   384
     If on, a superview may draw 'over' its children.
d4d907fc7d78 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 927
diff changeset
   385
     If off (the default), drawing is 'under' its children.
d4d907fc7d78 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 927
diff changeset
   386
     Only useful for the rootView, to draw over any visible views.
d4d907fc7d78 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 927
diff changeset
   387
     (for example, when dragging a rubber-line)"
d4d907fc7d78 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 927
diff changeset
   388
d4d907fc7d78 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 927
diff changeset
   389
    gcId isNil ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   390
	self initGC
950
d4d907fc7d78 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 927
diff changeset
   391
    ].
1715
c70e31496f91 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1714
diff changeset
   392
    device noClipIn:drawableId gc:gcId.
c70e31496f91 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1714
diff changeset
   393
    device setClipByChildren:aBoolean in:drawableId gc:gcId.
1722
4ceaeda95cc3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1715
diff changeset
   394
"/    device noClipIn:drawableId gc:gcId.
4ceaeda95cc3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1715
diff changeset
   395
1714
66143e4f3fcf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1712
diff changeset
   396
"/
66143e4f3fcf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1712
diff changeset
   397
"/    device setClipX:0 y:0 width:(self width) height:(self height) in:drawableId gc:gcId.
66143e4f3fcf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1712
diff changeset
   398
"/
950
d4d907fc7d78 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 927
diff changeset
   399
d4d907fc7d78 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 927
diff changeset
   400
    "Created: 17.7.1996 / 13:25:16 / cg"
1680
f47862c358fb pass both drawableId & gcID to setClipByChildren
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   401
    "Modified: 29.4.1997 / 15:33:55 / dq"
950
d4d907fc7d78 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 927
diff changeset
   402
!
d4d907fc7d78 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 927
diff changeset
   403
6215
701d3f1f91f7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6210
diff changeset
   404
clippingBounds:aRectangleOrNil
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   405
    "set the clipping rectangle for drawing (in logical coordinates);
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   406
     a nil argument turn off clipping (i.e. whole view is drawable)"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   407
6502
6c4fe54e61f8 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   408
    self clippingRectangle:aRectangleOrNil
6c4fe54e61f8 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   409
"/
6c4fe54e61f8 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   410
"/    |x y w h r|
6c4fe54e61f8 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   411
"/
6c4fe54e61f8 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   412
"/    (r := aRectangleOrNil) isNil ifTrue:[
6c4fe54e61f8 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   413
"/        clipRect isNil ifTrue:[^ self].
6c4fe54e61f8 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   414
"/        gcId notNil ifTrue:[
6c4fe54e61f8 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   415
"/            device noClipIn:drawableId gc:gcId
6c4fe54e61f8 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   416
"/        ]
6c4fe54e61f8 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   417
"/    ] ifFalse:[
6c4fe54e61f8 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   418
"/        clipRect notNil ifTrue:[
6c4fe54e61f8 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   419
"/            (clipRect = aRectangleOrNil) ifTrue:[^ self]
6c4fe54e61f8 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   420
"/        ].
6c4fe54e61f8 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   421
"/        gcId notNil ifTrue:[
6c4fe54e61f8 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   422
"/            x := aRectangleOrNil left.
6c4fe54e61f8 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   423
"/            y := aRectangleOrNil top.
6c4fe54e61f8 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   424
"/            w := aRectangleOrNil width.
6c4fe54e61f8 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   425
"/            h := aRectangleOrNil height.
6c4fe54e61f8 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   426
"/            transformation notNil ifTrue:[
6c4fe54e61f8 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   427
"/                x := transformation applyToX:x.
6c4fe54e61f8 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   428
"/                y := transformation applyToY:y.
6c4fe54e61f8 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   429
"/                w := transformation applyScaleX:w.
6c4fe54e61f8 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   430
"/                h := transformation applyScaleY:h.
6c4fe54e61f8 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   431
"/            ].
6c4fe54e61f8 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   432
"/            (x class == SmallInteger) ifFalse:[
6c4fe54e61f8 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   433
"/                w := w + (x - x truncated).
6c4fe54e61f8 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   434
"/                x := x truncated
6c4fe54e61f8 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   435
"/            ].
6c4fe54e61f8 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   436
"/            (y class == SmallInteger) ifFalse:[
6c4fe54e61f8 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   437
"/                h := h + (y - y truncated).
6c4fe54e61f8 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   438
"/                y := y truncated
6c4fe54e61f8 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   439
"/            ].
6c4fe54e61f8 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   440
"/            (w class == SmallInteger) ifFalse:[
6c4fe54e61f8 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   441
"/                w := w truncated + 1
6c4fe54e61f8 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   442
"/            ].
6c4fe54e61f8 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   443
"/            (h class == SmallInteger) ifFalse:[
6c4fe54e61f8 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   444
"/                h := h truncated + 1
6c4fe54e61f8 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   445
"/            ].
6c4fe54e61f8 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   446
"/            w := w max:0.
6c4fe54e61f8 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   447
"/            h := h max:0.
6c4fe54e61f8 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   448
"/            device setClipX:x y:y width:w height:h in:drawableId gc:gcId.
6c4fe54e61f8 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   449
"/            r := Rectangle left:x top:y width:w height:h
6c4fe54e61f8 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   450
"/        ]
6c4fe54e61f8 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   451
"/    ].
6c4fe54e61f8 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   452
"/    clipRect := r
2680
78abc6171873 always remember the deviceClipRect internally;
Claus Gittinger <cg@exept.de>
parents: 2572
diff changeset
   453
78abc6171873 always remember the deviceClipRect internally;
Claus Gittinger <cg@exept.de>
parents: 2572
diff changeset
   454
    "Created: / 28.5.1996 / 19:40:20 / cg"
78abc6171873 always remember the deviceClipRect internally;
Claus Gittinger <cg@exept.de>
parents: 2572
diff changeset
   455
    "Modified: / 16.5.1999 / 19:40:37 / cg"
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   456
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   457
6222
2d670d3bcfd5 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6215
diff changeset
   458
clippingRectangle:aRectangleOrNil
2d670d3bcfd5 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6215
diff changeset
   459
    "set the clipping rectangle for drawing (in logical coordinates);
2d670d3bcfd5 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6215
diff changeset
   460
     a nil argument turn off clipping (i.e. whole view is drawable)"
2d670d3bcfd5 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6215
diff changeset
   461
7066
ac2d03dac697 #REFACTORING
Stefan Vogel <sv@exept.de>
parents: 7064
diff changeset
   462
    |x y w h|
ac2d03dac697 #REFACTORING
Stefan Vogel <sv@exept.de>
parents: 7064
diff changeset
   463
ac2d03dac697 #REFACTORING
Stefan Vogel <sv@exept.de>
parents: 7064
diff changeset
   464
    aRectangleOrNil isNil ifTrue:[
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
   465
        clipRect isNil ifTrue:[^ self].
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
   466
        gcId notNil ifTrue:[
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
   467
            device noClipIn:drawableId gc:gcId
7066
ac2d03dac697 #REFACTORING
Stefan Vogel <sv@exept.de>
parents: 7064
diff changeset
   468
        ].
ac2d03dac697 #REFACTORING
Stefan Vogel <sv@exept.de>
parents: 7064
diff changeset
   469
        clipRect := nil.
6222
2d670d3bcfd5 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6215
diff changeset
   470
    ] ifFalse:[
7066
ac2d03dac697 #REFACTORING
Stefan Vogel <sv@exept.de>
parents: 7064
diff changeset
   471
        clipRect = aRectangleOrNil ifTrue:[
ac2d03dac697 #REFACTORING
Stefan Vogel <sv@exept.de>
parents: 7064
diff changeset
   472
            ^ self.
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
   473
        ].
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
   474
        gcId notNil ifTrue:[
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
   475
            transformation notNil ifTrue:[
7066
ac2d03dac697 #REFACTORING
Stefan Vogel <sv@exept.de>
parents: 7064
diff changeset
   476
                |deviceRectangle|
ac2d03dac697 #REFACTORING
Stefan Vogel <sv@exept.de>
parents: 7064
diff changeset
   477
ac2d03dac697 #REFACTORING
Stefan Vogel <sv@exept.de>
parents: 7064
diff changeset
   478
                deviceRectangle := transformation transformRectangle:aRectangleOrNil.
ac2d03dac697 #REFACTORING
Stefan Vogel <sv@exept.de>
parents: 7064
diff changeset
   479
                x := deviceRectangle left.
ac2d03dac697 #REFACTORING
Stefan Vogel <sv@exept.de>
parents: 7064
diff changeset
   480
                y := deviceRectangle top.
ac2d03dac697 #REFACTORING
Stefan Vogel <sv@exept.de>
parents: 7064
diff changeset
   481
                w := deviceRectangle width + 1.
ac2d03dac697 #REFACTORING
Stefan Vogel <sv@exept.de>
parents: 7064
diff changeset
   482
                h := deviceRectangle height + 1.
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
   483
            ] ifFalse:[
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
   484
                x := aRectangleOrNil left.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
   485
                y := aRectangleOrNil top.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
   486
                w := aRectangleOrNil width.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
   487
                h := aRectangleOrNil height.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
   488
            ].
7066
ac2d03dac697 #REFACTORING
Stefan Vogel <sv@exept.de>
parents: 7064
diff changeset
   489
            (x isMemberOf:SmallInteger) ifFalse:[
ac2d03dac697 #REFACTORING
Stefan Vogel <sv@exept.de>
parents: 7064
diff changeset
   490
                w := w + (x fractionPart).
ac2d03dac697 #REFACTORING
Stefan Vogel <sv@exept.de>
parents: 7064
diff changeset
   491
                x := x truncated.
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
   492
            ].
7066
ac2d03dac697 #REFACTORING
Stefan Vogel <sv@exept.de>
parents: 7064
diff changeset
   493
            (y isMemberOf:SmallInteger) ifFalse:[
ac2d03dac697 #REFACTORING
Stefan Vogel <sv@exept.de>
parents: 7064
diff changeset
   494
                h := h + (y fractionPart).
ac2d03dac697 #REFACTORING
Stefan Vogel <sv@exept.de>
parents: 7064
diff changeset
   495
                y := y truncated.
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
   496
            ].
7066
ac2d03dac697 #REFACTORING
Stefan Vogel <sv@exept.de>
parents: 7064
diff changeset
   497
            (w isMemberOf:SmallInteger) ifFalse:[
ac2d03dac697 #REFACTORING
Stefan Vogel <sv@exept.de>
parents: 7064
diff changeset
   498
                w := w ceiling.
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
   499
            ].
7066
ac2d03dac697 #REFACTORING
Stefan Vogel <sv@exept.de>
parents: 7064
diff changeset
   500
            (h isMemberOf:SmallInteger) ifFalse:[
ac2d03dac697 #REFACTORING
Stefan Vogel <sv@exept.de>
parents: 7064
diff changeset
   501
                h := h ceiling.
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
   502
            ].
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
   503
            w := w max:0.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
   504
            h := h max:0.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
   505
            device setClipX:x y:y width:w height:h in:drawableId gc:gcId.
7066
ac2d03dac697 #REFACTORING
Stefan Vogel <sv@exept.de>
parents: 7064
diff changeset
   506
        ].
ac2d03dac697 #REFACTORING
Stefan Vogel <sv@exept.de>
parents: 7064
diff changeset
   507
        clipRect := aRectangleOrNil.
6222
2d670d3bcfd5 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6215
diff changeset
   508
    ].
2d670d3bcfd5 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6215
diff changeset
   509
2d670d3bcfd5 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6215
diff changeset
   510
    "Created: / 28.5.1996 / 19:40:20 / cg"
2d670d3bcfd5 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6215
diff changeset
   511
    "Modified: / 16.5.1999 / 19:40:37 / cg"
2d670d3bcfd5 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6215
diff changeset
   512
!
2d670d3bcfd5 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6215
diff changeset
   513
1842
502aa16b146e added #colorAt:
Claus Gittinger <cg@exept.de>
parents: 1805
diff changeset
   514
colorAt:aPoint
502aa16b146e added #colorAt:
Claus Gittinger <cg@exept.de>
parents: 1805
diff changeset
   515
    "return the color of the pixel at the coordinate given by x@y"
502aa16b146e added #colorAt:
Claus Gittinger <cg@exept.de>
parents: 1805
diff changeset
   516
502aa16b146e added #colorAt:
Claus Gittinger <cg@exept.de>
parents: 1805
diff changeset
   517
    ^ self colorAtX:(aPoint x) y:(aPoint y)
502aa16b146e added #colorAt:
Claus Gittinger <cg@exept.de>
parents: 1805
diff changeset
   518
502aa16b146e added #colorAt:
Claus Gittinger <cg@exept.de>
parents: 1805
diff changeset
   519
    "Modified: 1.8.1997 / 20:01:58 / cg"
502aa16b146e added #colorAt:
Claus Gittinger <cg@exept.de>
parents: 1805
diff changeset
   520
!
502aa16b146e added #colorAt:
Claus Gittinger <cg@exept.de>
parents: 1805
diff changeset
   521
502aa16b146e added #colorAt:
Claus Gittinger <cg@exept.de>
parents: 1805
diff changeset
   522
colorAtX:x y:y
502aa16b146e added #colorAt:
Claus Gittinger <cg@exept.de>
parents: 1805
diff changeset
   523
    "return the color of the pixel at the coordinate given by aPoint"
502aa16b146e added #colorAt:
Claus Gittinger <cg@exept.de>
parents: 1805
diff changeset
   524
502aa16b146e added #colorAt:
Claus Gittinger <cg@exept.de>
parents: 1805
diff changeset
   525
    |pixel|
502aa16b146e added #colorAt:
Claus Gittinger <cg@exept.de>
parents: 1805
diff changeset
   526
502aa16b146e added #colorAt:
Claus Gittinger <cg@exept.de>
parents: 1805
diff changeset
   527
    pixel := self atX:x y:y.
502aa16b146e added #colorAt:
Claus Gittinger <cg@exept.de>
parents: 1805
diff changeset
   528
    device getScaledRGBFrom:pixel into:[:r :g :b |
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   529
	^ Color scaledRed:r scaledGreen:g scaledBlue:b
1842
502aa16b146e added #colorAt:
Claus Gittinger <cg@exept.de>
parents: 1805
diff changeset
   530
    ].
502aa16b146e added #colorAt:
Claus Gittinger <cg@exept.de>
parents: 1805
diff changeset
   531
502aa16b146e added #colorAt:
Claus Gittinger <cg@exept.de>
parents: 1805
diff changeset
   532
    "Created: 1.8.1997 / 20:01:32 / cg"
502aa16b146e added #colorAt:
Claus Gittinger <cg@exept.de>
parents: 1805
diff changeset
   533
!
502aa16b146e added #colorAt:
Claus Gittinger <cg@exept.de>
parents: 1805
diff changeset
   534
4199
c01c62e8c7a5 dummy container
Claus Gittinger <cg@exept.de>
parents: 4172
diff changeset
   535
container
c01c62e8c7a5 dummy container
Claus Gittinger <cg@exept.de>
parents: 4172
diff changeset
   536
    "return my container - for protocol compatibility"
c01c62e8c7a5 dummy container
Claus Gittinger <cg@exept.de>
parents: 4172
diff changeset
   537
c01c62e8c7a5 dummy container
Claus Gittinger <cg@exept.de>
parents: 4172
diff changeset
   538
    ^ nil
c01c62e8c7a5 dummy container
Claus Gittinger <cg@exept.de>
parents: 4172
diff changeset
   539
!
c01c62e8c7a5 dummy container
Claus Gittinger <cg@exept.de>
parents: 4172
diff changeset
   540
786
af5fecf93126 added dashStyle: ...
Claus Gittinger <cg@exept.de>
parents: 784
diff changeset
   541
dashStyle:aDashList offset:dashOffset
af5fecf93126 added dashStyle: ...
Claus Gittinger <cg@exept.de>
parents: 784
diff changeset
   542
    "define dashes. Each element of the dashList specifies the length
af5fecf93126 added dashStyle: ...
Claus Gittinger <cg@exept.de>
parents: 784
diff changeset
   543
     of a corresponding dash. For example, setting it to [4 4]
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   544
     defines 4on-4off dashing;
786
af5fecf93126 added dashStyle: ...
Claus Gittinger <cg@exept.de>
parents: 784
diff changeset
   545
     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
   546
     The dashOffset specifies where in the dashList the dashing starts.
af5fecf93126 added dashStyle: ...
Claus Gittinger <cg@exept.de>
parents: 784
diff changeset
   547
     This may not be supported by all graphics devices."
af5fecf93126 added dashStyle: ...
Claus Gittinger <cg@exept.de>
parents: 784
diff changeset
   548
af5fecf93126 added dashStyle: ...
Claus Gittinger <cg@exept.de>
parents: 784
diff changeset
   549
    gcId notNil ifTrue:[
1029
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
   550
	device setDashes:(ByteArray withAll:aDashList)
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
   551
	      dashOffset:dashOffset
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
   552
		      in:gcId
786
af5fecf93126 added dashStyle: ...
Claus Gittinger <cg@exept.de>
parents: 784
diff changeset
   553
    ]
af5fecf93126 added dashStyle: ...
Claus Gittinger <cg@exept.de>
parents: 784
diff changeset
   554
af5fecf93126 added dashStyle: ...
Claus Gittinger <cg@exept.de>
parents: 784
diff changeset
   555
    "Modified: 4.6.1996 / 19:03:06 / cg"
af5fecf93126 added dashStyle: ...
Claus Gittinger <cg@exept.de>
parents: 784
diff changeset
   556
!
af5fecf93126 added dashStyle: ...
Claus Gittinger <cg@exept.de>
parents: 784
diff changeset
   557
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   558
device
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   559
    "return the device, the receiver is associated with"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   560
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   561
    ^ device
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
device:aDevice
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   565
    "set the device"
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
    device := aDevice
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   568
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   569
7060
Stefan Vogel <sv@exept.de>
parents: 6926
diff changeset
   570
deviceClippingRectangle
Stefan Vogel <sv@exept.de>
parents: 6926
diff changeset
   571
    "answer the clipping rectangle for drawing in device coordinates, or nil."
Stefan Vogel <sv@exept.de>
parents: 6926
diff changeset
   572
Stefan Vogel <sv@exept.de>
parents: 6926
diff changeset
   573
    |x y w h transformedRectangle|
Stefan Vogel <sv@exept.de>
parents: 6926
diff changeset
   574
7062
21b62a5d9b98 #BUGFIX
Stefan Vogel <sv@exept.de>
parents: 7060
diff changeset
   575
    (clipRect isNil or:[transformation isNil]) ifTrue:[
7060
Stefan Vogel <sv@exept.de>
parents: 6926
diff changeset
   576
        ^ clipRect.
Stefan Vogel <sv@exept.de>
parents: 6926
diff changeset
   577
    ].
Stefan Vogel <sv@exept.de>
parents: 6926
diff changeset
   578
Stefan Vogel <sv@exept.de>
parents: 6926
diff changeset
   579
    transformedRectangle := transformation transformRectangle:clipRect.
Stefan Vogel <sv@exept.de>
parents: 6926
diff changeset
   580
Stefan Vogel <sv@exept.de>
parents: 6926
diff changeset
   581
    x := transformedRectangle left.
Stefan Vogel <sv@exept.de>
parents: 6926
diff changeset
   582
    y := transformedRectangle top.
Stefan Vogel <sv@exept.de>
parents: 6926
diff changeset
   583
    w := transformedRectangle width + 1.
Stefan Vogel <sv@exept.de>
parents: 6926
diff changeset
   584
    h := transformedRectangle height + 1.
Stefan Vogel <sv@exept.de>
parents: 6926
diff changeset
   585
Stefan Vogel <sv@exept.de>
parents: 6926
diff changeset
   586
    (x class == SmallInteger) ifFalse:[
Stefan Vogel <sv@exept.de>
parents: 6926
diff changeset
   587
        w := w + (x - x truncated).
Stefan Vogel <sv@exept.de>
parents: 6926
diff changeset
   588
        x := x truncated
Stefan Vogel <sv@exept.de>
parents: 6926
diff changeset
   589
    ].
Stefan Vogel <sv@exept.de>
parents: 6926
diff changeset
   590
    (y class == SmallInteger) ifFalse:[
Stefan Vogel <sv@exept.de>
parents: 6926
diff changeset
   591
        h := h + (y - y truncated).
Stefan Vogel <sv@exept.de>
parents: 6926
diff changeset
   592
        y := y truncated
Stefan Vogel <sv@exept.de>
parents: 6926
diff changeset
   593
    ].
Stefan Vogel <sv@exept.de>
parents: 6926
diff changeset
   594
    (w class == SmallInteger) ifFalse:[
7062
21b62a5d9b98 #BUGFIX
Stefan Vogel <sv@exept.de>
parents: 7060
diff changeset
   595
        w := w ceiling.
7060
Stefan Vogel <sv@exept.de>
parents: 6926
diff changeset
   596
    ].
Stefan Vogel <sv@exept.de>
parents: 6926
diff changeset
   597
    (h class == SmallInteger) ifFalse:[
7062
21b62a5d9b98 #BUGFIX
Stefan Vogel <sv@exept.de>
parents: 7060
diff changeset
   598
        h := h ceiling.
7060
Stefan Vogel <sv@exept.de>
parents: 6926
diff changeset
   599
    ].
Stefan Vogel <sv@exept.de>
parents: 6926
diff changeset
   600
    w := w max:0.
Stefan Vogel <sv@exept.de>
parents: 6926
diff changeset
   601
    h := h max:0.
Stefan Vogel <sv@exept.de>
parents: 6926
diff changeset
   602
Stefan Vogel <sv@exept.de>
parents: 6926
diff changeset
   603
    ^ Rectangle left:x top:y width:w height:h
Stefan Vogel <sv@exept.de>
parents: 6926
diff changeset
   604
!
Stefan Vogel <sv@exept.de>
parents: 6926
diff changeset
   605
2343
9e8d62561418 added #deviceClippingRectangle:
Claus Gittinger <cg@exept.de>
parents: 2322
diff changeset
   606
deviceClippingRectangle:aRectangleOrNil
9e8d62561418 added #deviceClippingRectangle:
Claus Gittinger <cg@exept.de>
parents: 2322
diff changeset
   607
    "set the clipping rectangle for drawing (in device coordinates);
3275
b40f47ec5661 comment
Claus Gittinger <cg@exept.de>
parents: 3188
diff changeset
   608
     a nil argument turns off clipping (i.e. whole view is drawable - incl. margins)"
2343
9e8d62561418 added #deviceClippingRectangle:
Claus Gittinger <cg@exept.de>
parents: 2322
diff changeset
   609
6501
ef63b2302cba class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6497
diff changeset
   610
    |x y w h newLogicalClipRect|
2343
9e8d62561418 added #deviceClippingRectangle:
Claus Gittinger <cg@exept.de>
parents: 2322
diff changeset
   611
9e8d62561418 added #deviceClippingRectangle:
Claus Gittinger <cg@exept.de>
parents: 2322
diff changeset
   612
    aRectangleOrNil isNil ifTrue:[
6501
ef63b2302cba class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6497
diff changeset
   613
        clipRect isNil ifTrue:[^ self].
ef63b2302cba class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6497
diff changeset
   614
        gcId notNil ifTrue:[
ef63b2302cba class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6497
diff changeset
   615
            device noClipIn:drawableId gc:gcId
ef63b2302cba class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6497
diff changeset
   616
        ].
ef63b2302cba class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6497
diff changeset
   617
        clipRect := nil.
ef63b2302cba class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6497
diff changeset
   618
        ^ self.
ef63b2302cba class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6497
diff changeset
   619
    ].
ef63b2302cba class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6497
diff changeset
   620
ef63b2302cba class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6497
diff changeset
   621
    transformation isNil ifTrue:[
ef63b2302cba class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6497
diff changeset
   622
        newLogicalClipRect := aRectangleOrNil
2343
9e8d62561418 added #deviceClippingRectangle:
Claus Gittinger <cg@exept.de>
parents: 2322
diff changeset
   623
    ] ifFalse:[
6501
ef63b2302cba class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6497
diff changeset
   624
        newLogicalClipRect := transformation applyInverseTo:aRectangleOrNil
ef63b2302cba class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6497
diff changeset
   625
    ].
ef63b2302cba class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6497
diff changeset
   626
6514
bf25c5e29291 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6502
diff changeset
   627
    (clipRect = newLogicalClipRect) ifTrue:[^ self].
6501
ef63b2302cba class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6497
diff changeset
   628
ef63b2302cba class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6497
diff changeset
   629
    gcId notNil ifTrue:[
6765
dd2a04d4f86e class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6751
diff changeset
   630
        x := aRectangleOrNil left rounded.
dd2a04d4f86e class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6751
diff changeset
   631
        y := aRectangleOrNil top rounded.
dd2a04d4f86e class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6751
diff changeset
   632
        w := aRectangleOrNil width rounded.
dd2a04d4f86e class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6751
diff changeset
   633
        h := aRectangleOrNil height rounded.
6501
ef63b2302cba class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6497
diff changeset
   634
        device setClipX:x y:y width:w height:h in:drawableId gc:gcId
ef63b2302cba class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6497
diff changeset
   635
    ].
ef63b2302cba class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6497
diff changeset
   636
    clipRect := newLogicalClipRect
2343
9e8d62561418 added #deviceClippingRectangle:
Claus Gittinger <cg@exept.de>
parents: 2322
diff changeset
   637
9e8d62561418 added #deviceClippingRectangle:
Claus Gittinger <cg@exept.de>
parents: 2322
diff changeset
   638
    "Modified: / 22.5.1996 / 13:12:07 / cg"
9e8d62561418 added #deviceClippingRectangle:
Claus Gittinger <cg@exept.de>
parents: 2322
diff changeset
   639
    "Created: / 14.9.1998 / 18:50:31 / cg"
9e8d62561418 added #deviceClippingRectangle:
Claus Gittinger <cg@exept.de>
parents: 2322
diff changeset
   640
!
9e8d62561418 added #deviceClippingRectangle:
Claus Gittinger <cg@exept.de>
parents: 2322
diff changeset
   641
6222
2d670d3bcfd5 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6215
diff changeset
   642
drawableId
2d670d3bcfd5 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6215
diff changeset
   643
    "return the id of the drawable on the device"
2d670d3bcfd5 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6215
diff changeset
   644
2d670d3bcfd5 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6215
diff changeset
   645
    ^ drawableId
2d670d3bcfd5 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6215
diff changeset
   646
!
2d670d3bcfd5 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6215
diff changeset
   647
2918
1e777dc8588a #font answers device font if possible (cg)
Stefan Vogel <sv@exept.de>
parents: 2913
diff changeset
   648
font
1e777dc8588a #font answers device font if possible (cg)
Stefan Vogel <sv@exept.de>
parents: 2913
diff changeset
   649
    "return the font for drawing - here, a device font is returned if
1e777dc8588a #font answers device font if possible (cg)
Stefan Vogel <sv@exept.de>
parents: 2913
diff changeset
   650
     the GC is realized."
1e777dc8588a #font answers device font if possible (cg)
Stefan Vogel <sv@exept.de>
parents: 2913
diff changeset
   651
7218
4c15124a9431 #BUGFIX
Stefan Vogel <sv@exept.de>
parents: 7066
diff changeset
   652
    (device notNil and:[font notNil]) ifTrue:[
4c15124a9431 #BUGFIX
Stefan Vogel <sv@exept.de>
parents: 7066
diff changeset
   653
        font := font onDevice:device
2918
1e777dc8588a #font answers device font if possible (cg)
Stefan Vogel <sv@exept.de>
parents: 2913
diff changeset
   654
    ].
1e777dc8588a #font answers device font if possible (cg)
Stefan Vogel <sv@exept.de>
parents: 2913
diff changeset
   655
    ^ font
1e777dc8588a #font answers device font if possible (cg)
Stefan Vogel <sv@exept.de>
parents: 2913
diff changeset
   656
!
1e777dc8588a #font answers device font if possible (cg)
Stefan Vogel <sv@exept.de>
parents: 2913
diff changeset
   657
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   658
font:aFont
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   659
    "set the font for drawing if it has changed.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   660
     This should be redefined in some widget to perform an automatic
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   661
     redraw. See also: #basicFont:"
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
    (aFont ~~ font) ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   664
	self basicFont:aFont.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   665
	self changed:#font.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   666
    ]
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
    "Modified: 6.3.1996 / 18:17:40 / cg"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   669
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   670
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   671
function:aSymbol
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   672
    "set the drawing function if it has changed"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   673
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   674
    (aSymbol ~~ function) ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   675
	function := aSymbol.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   676
	gcId notNil ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   677
	    device setFunction:aSymbol in:gcId
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   678
	]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   679
    ]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   680
!
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
gcId
7237
9482956af0f1 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 7218
diff changeset
   683
    "return the receiver's graphic context id on the device"
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   684
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   685
    ^ gcId
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   686
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   687
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   688
graphicsDevice
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   689
    "return the device, the receiver is associated with.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   690
     Same as #device, for ST-80 compatibility."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   691
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   692
    ^ device
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
    "Created: 9.5.1996 / 01:37:58 / cg"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   695
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   696
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   697
id
6222
2d670d3bcfd5 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6215
diff changeset
   698
    "return the id of the drawable on the device"
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   699
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   700
    ^ drawableId
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
joinStyle:aSymbol
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   704
    "set the style in which 2 lines are connected in polygons -
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   705
     aSymbol may be #miter, #bevel, #round"
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
    |s|
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   708
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   709
    (s := aSymbol) isNil ifTrue:[
1029
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
   710
	s := #miter
732
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
    (s ~~ joinStyle) ifTrue:[
1029
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
   713
	joinStyle := s.
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   714
1029
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
   715
	gcId notNil ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   716
	    device setLineWidth:lineWidth
1029
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
   717
			  style:lineStyle
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
   718
			    cap:capStyle
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
   719
			   join:s
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
   720
			     in:gcId
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
   721
	]
732
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
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   724
    "Modified: 12.5.1996 / 22:20:43 / cg"
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
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   727
lineStyle:aSymbol
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   728
    "set the style in which lines are drawn -
2360
c7ca5d55d8ce comment
Claus Gittinger <cg@exept.de>
parents: 2343
diff changeset
   729
     aSymbol may be #solid, #dashed, #doubleDashed,
c7ca5d55d8ce comment
Claus Gittinger <cg@exept.de>
parents: 2343
diff changeset
   730
     #dotted, #dashDot or #dashDotDot."
732
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
    |s|
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   733
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   734
    (s := aSymbol) isNil ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   735
	s := #solid
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   736
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   737
    (s ~~ lineStyle) ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   738
	lineStyle := s.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   739
	gcId notNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   740
	    device setLineWidth:lineWidth
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   741
			  style:s
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   742
			    cap:capStyle
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   743
			   join:joinStyle
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   744
			     in:gcId
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   745
	]
732
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
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   748
    "Modified: 12.5.1996 / 22:21:25 / cg"
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
lineWidth:aNumber
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   752
    "set the line width for drawing if it has changed"
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
    |n|
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   755
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   756
    (aNumber ~~ lineWidth) ifTrue:[
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
   757
        lineWidth := aNumber.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
   758
        transformation isNil ifTrue:[
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
   759
            n := aNumber.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
   760
        ] ifFalse:[
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
   761
            n := transformation applyScaleX:aNumber.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
   762
            n := n rounded
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
   763
        ].
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
   764
        gcId notNil ifTrue:[
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
   765
            device setLineWidth:n style:lineStyle cap:capStyle join:joinStyle in:gcId
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
   766
        ]
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   767
    ]
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
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   770
mask:aForm
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   771
    "set the mask form for drawing"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   772
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   773
    |id|
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   774
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   775
    (aForm ~~ mask) ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   776
	mask := aForm.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   777
	gcId notNil ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   778
	    (mask == nil) ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   779
		device setBitmapMask:nil in:gcId
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   780
	    ] ifFalse:[
1033
b5cd84ed805f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1029
diff changeset
   781
		mask := mask asFormOn:device.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   782
		id := mask id.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   783
		(mask depth == 1) ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   784
		    device setBitmapMask:id in:gcId
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   785
		] ifFalse:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   786
		    device setPixmapMask:id in:gcId
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   787
		]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   788
	    ]
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
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   792
2018
1ad552e97c67 maskOrigin
Claus Gittinger <cg@exept.de>
parents: 2016
diff changeset
   793
maskOrigin:aPoint
1ad552e97c67 maskOrigin
Claus Gittinger <cg@exept.de>
parents: 2016
diff changeset
   794
    "set the origin of the mask-pattern"
1ad552e97c67 maskOrigin
Claus Gittinger <cg@exept.de>
parents: 2016
diff changeset
   795
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
   796
    |x y pO|
2018
1ad552e97c67 maskOrigin
Claus Gittinger <cg@exept.de>
parents: 2016
diff changeset
   797
1ad552e97c67 maskOrigin
Claus Gittinger <cg@exept.de>
parents: 2016
diff changeset
   798
    x := aPoint x.
1ad552e97c67 maskOrigin
Claus Gittinger <cg@exept.de>
parents: 2016
diff changeset
   799
    y := aPoint y.
1ad552e97c67 maskOrigin
Claus Gittinger <cg@exept.de>
parents: 2016
diff changeset
   800
1ad552e97c67 maskOrigin
Claus Gittinger <cg@exept.de>
parents: 2016
diff changeset
   801
    (maskOrigin isNil or:[
1ad552e97c67 maskOrigin
Claus Gittinger <cg@exept.de>
parents: 2016
diff changeset
   802
     ((x ~= maskOrigin x) or:[y ~= maskOrigin y]) ]) ifTrue:[
1ad552e97c67 maskOrigin
Claus Gittinger <cg@exept.de>
parents: 2016
diff changeset
   803
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
   804
        maskOrigin := aPoint.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
   805
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
   806
        transformation notNil ifTrue:[
6711
2b50385f7257 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
   807
            pO := transformation transformPoint:aPoint.
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
   808
            x:= pO x.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
   809
            y := pO y.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
   810
        ].
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
   811
        x := x rounded.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
   812
        y := y rounded.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
   813
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
   814
        gcId notNil ifTrue:[
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
   815
            device setMaskOriginX:x y:y in:gcId
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
   816
        ]
2018
1ad552e97c67 maskOrigin
Claus Gittinger <cg@exept.de>
parents: 2016
diff changeset
   817
    ]
1ad552e97c67 maskOrigin
Claus Gittinger <cg@exept.de>
parents: 2016
diff changeset
   818
1ad552e97c67 maskOrigin
Claus Gittinger <cg@exept.de>
parents: 2016
diff changeset
   819
    "Created: / 26.1.1998 / 19:03:02 / cg"
1ad552e97c67 maskOrigin
Claus Gittinger <cg@exept.de>
parents: 2016
diff changeset
   820
!
1ad552e97c67 maskOrigin
Claus Gittinger <cg@exept.de>
parents: 2016
diff changeset
   821
2016
bef5fe2ec2ca checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2013
diff changeset
   822
maskOriginX:orgX y:orgY
bef5fe2ec2ca checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2013
diff changeset
   823
    "set the origin of the pattern"
bef5fe2ec2ca checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2013
diff changeset
   824
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
   825
    self maskOrigin:(orgX @ orgY)
2016
bef5fe2ec2ca checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2013
diff changeset
   826
!
bef5fe2ec2ca checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2013
diff changeset
   827
950
d4d907fc7d78 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 927
diff changeset
   828
noClipByChildren
d4d907fc7d78 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 927
diff changeset
   829
    "drawing shall also be done into subviews"
d4d907fc7d78 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 927
diff changeset
   830
3429
7f87cd2ae010 Use <resource:#obsolete>
Stefan Vogel <sv@exept.de>
parents: 3300
diff changeset
   831
    <resource:#obsolete>
7f87cd2ae010 Use <resource:#obsolete>
Stefan Vogel <sv@exept.de>
parents: 3300
diff changeset
   832
1722
4ceaeda95cc3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1715
diff changeset
   833
    self obsoleteMethodWarning:'use #clippedByChildren:false'.
950
d4d907fc7d78 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 927
diff changeset
   834
    ^ self clippedByChildren:false
d4d907fc7d78 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 927
diff changeset
   835
d4d907fc7d78 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 927
diff changeset
   836
    "Created: 17.7.1996 / 14:15:54 / cg"
d4d907fc7d78 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 927
diff changeset
   837
!
d4d907fc7d78 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 927
diff changeset
   838
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   839
paint:aColor
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   840
    "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
   841
     or even an image."
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
    (aColor ~~ paint) ifTrue:[
1029
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
   844
	aColor notNil ifTrue:[
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
   845
	    paint := aColor.
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
   846
	    self setGCForPaint.
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
   847
	]
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   848
    ]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   849
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   850
    "Modified: 16.5.1996 / 15:35:57 / cg"
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
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   853
paint:fgColor on:bgColor
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   854
    "set the paint and background-paint color.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   855
     The bg-paint is used in opaque-draw operations"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   856
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   857
    |fgId bgId|
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   858
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   859
    ((fgColor ~~ paint) or:[bgColor ~~ bgPaint]) ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   860
	fgColor notNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   861
	    paint := fgColor
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   862
	].
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   863
	bgColor notNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   864
	    bgPaint := bgColor
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   865
	].
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   866
	gcId notNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   867
	    paint isColor ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   868
		paint := paint onDevice:device.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   869
	    ].
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   870
	    paint isColor ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   871
		fgId := paint colorId.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   872
		fgId notNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   873
		    mask notNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   874
			mask := nil.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   875
			device setBitmapMask:nil in:gcId
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   876
		    ].
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   877
		    bgPaint isColor ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   878
			bgPaint := bgPaint onDevice:device.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   879
		    ].
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   880
		    bgPaint isColor ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   881
			bgId := bgPaint colorId.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   882
			bgId notNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   883
			    "the common case, both are real colors"
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   884
			    (paint ~~ foreground) ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   885
				foreground := paint.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   886
				(bgPaint ~~ background) ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   887
				    background := bgPaint.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   888
				    device setForeground:fgId background:bgId in:gcId.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   889
				    ^ self
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   890
				].
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   891
				device setForeground:fgId in:gcId.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   892
				^ self
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   893
			    ].
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   894
			    (bgPaint ~~ background) ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   895
				background := bgPaint.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   896
				device setBackground:bgId in:gcId.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   897
			    ].
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   898
			    ^ self
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   899
			].
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   900
			"bgPaint is dithered, setup paint here, leave bgPaint
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   901
			 till next opaque draw comes around."
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   902
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   903
			(paint ~~ foreground) ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   904
			    foreground := paint.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   905
			    device setForeground:fgId in:gcId
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   906
			].
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   907
			^ self
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   908
		    ]
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   909
		]
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   910
	    ].
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   911
	    "either paint or bgPaint (or both) are dithered colors,
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   912
	     setup for paint, leave bg-problem till next opaque draw
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   913
	     comes around.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   914
	    "
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   915
	    self setGCForPaint.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   916
	]
732
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
4797
91ee43d3acf5 changed #paint:on:
Claus Gittinger <cg@exept.de>
parents: 4781
diff changeset
   919
    "Modified: / 31-08-2007 / 10:56:49 / cg"
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   920
!
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
paint:fgColor on:bgColor function:f
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   923
    "set paint, background-paint and function"
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
    self paint:fgColor on:bgColor.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   926
    self function:f
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   927
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   928
    "Modified: 16.5.1996 / 15:36:35 / cg"
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
6266
1503c5e038d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   931
setClippingBounds:aRectangleOrNil
6501
ef63b2302cba class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6497
diff changeset
   932
    "set the clipping rectangle for drawing (in logical coordinates).
6266
1503c5e038d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   933
     Only set the variable, do not change the gc"
1503c5e038d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   934
1503c5e038d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   935
    clipRect := aRectangleOrNil
1503c5e038d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   936
!
1503c5e038d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   937
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   938
setGraphicsExposures:aBoolean
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   939
    "want to if aBoolean is true - or dont want to be notified
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   940
     of graphics exposures"
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
    gcId notNil ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   943
	device setGraphicsExposures:aBoolean in:gcId
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   944
    ]
6266
1503c5e038d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   945
!
1503c5e038d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   946
1503c5e038d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   947
setPaint:fgColor on:bgColor
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   948
    "set the paint and background-paint color.
6266
1503c5e038d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   949
     The bg-paint is used in opaque-draw operations.
1503c5e038d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   950
     Only set the variables, but do not send it to the device,
1503c5e038d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   951
     Used on initialization."
1503c5e038d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   952
1503c5e038d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   953
    fgColor notNil ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   954
	foreground := paint := fgColor
6266
1503c5e038d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   955
    ].
1503c5e038d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   956
    bgColor notNil ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   957
	background := bgPaint := bgColor
6266
1503c5e038d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   958
    ].
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   959
! !
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   960
1092
1b6391f333de category rename
Claus Gittinger <cg@exept.de>
parents: 1085
diff changeset
   961
!DeviceGraphicsContext methodsFor:'accessing-internals'!
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   962
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   963
background
6266
1503c5e038d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   964
    <resource: #obsolete>
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   965
    "return the current background drawing color.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   966
     OBSOLETE: use #paint: / #backgroundPaint: / #paint:on:"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   967
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   968
    ^ background
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   969
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   970
    "Modified: 12.5.1996 / 22:28:09 / cg"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   971
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   972
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   973
background:aColor
6266
1503c5e038d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   974
    <resource: #obsolete>
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   975
    "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
   976
     OBSOLETE: this method will vanish; use #paint: / #backgroundPaint: / #paint:on:"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   977
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   978
    |bgId|
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   979
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   980
    (aColor ~~ background) ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   981
	aColor notNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   982
	    background := aColor.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   983
	    gcId notNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   984
		background := background onDevice:device.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   985
		bgId := background colorId.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   986
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   987
		"
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   988
		 mhmh the following is a kludge ....
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   989
		"
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   990
		bgId isNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   991
		    (background grayIntensity >= 50) ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   992
			bgId := device whitepixel
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   993
		    ] ifFalse:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   994
			bgId := device blackpixel
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   995
		    ]
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   996
		].
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   997
		device setBackground:bgId in:gcId
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   998
	    ]
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   999
	]
732
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
745
d4465098f2c0 gray vs. grey
Claus Gittinger <cg@exept.de>
parents: 735
diff changeset
  1002
    "Modified: 28.5.1996 / 20:44:55 / cg"
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1003
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1004
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1005
foreground
6266
1503c5e038d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1006
    <resource: #obsolete>
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1007
    "return the current foreground drawing color.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1008
     OBSOLETE: use #paint: / #paint:on:"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1009
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1010
    ^ foreground
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1011
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1012
    "Modified: 12.5.1996 / 22:28:03 / cg"
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
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1015
foreground:aColor
6266
1503c5e038d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1016
    <resource: #obsolete>
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1017
    "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
  1018
     OBSOLETE: this method will vanish; use #paint: / #paint:on:"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1019
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1020
    |fgId|
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1021
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1022
    (aColor ~~ foreground) ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1023
	aColor notNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1024
	    foreground := aColor.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1025
	    gcId notNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1026
		(foreground class == SmallInteger) ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1027
		    fgId := foreground
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1028
		] ifFalse:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1029
		    foreground := foreground onDevice:device.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1030
		    fgId := foreground colorId.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1031
		].
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1032
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1033
		"mhmh the following is a kludge ...."
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1034
		fgId isNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1035
		    (foreground grayIntensity >= 50) ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1036
			fgId := device whitepixel
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1037
		    ] ifFalse:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1038
			fgId := device blackpixel
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1039
		    ]
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1040
		].
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1041
		device setForeground:fgId in:gcId.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1042
		paint := foreground
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1043
	    ]
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1044
	]
732
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
745
d4465098f2c0 gray vs. grey
Claus Gittinger <cg@exept.de>
parents: 735
diff changeset
  1047
    "Modified: 28.5.1996 / 20:45:02 / cg"
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1048
!
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
foreground:fgColor background:bgColor
6266
1503c5e038d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1051
    <resource: #obsolete>
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1052
    "set both internal foreground and internal background colors
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1053
     - these must be real colors.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1054
     OBSOLETE: this method will vanish; use #paint: / #paint:on:"
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
    |fgPixel bgPixel|
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1057
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1058
    ((fgColor ~~ foreground) or:[bgColor ~~ background]) ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1059
	fgColor notNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1060
	    foreground := fgColor
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1061
	].
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1062
	bgColor notNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1063
	    background := bgColor
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1064
	].
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1065
	gcId notNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1066
	    foreground := foreground onDevice:device.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1067
	    background := background onDevice:device.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1068
	    fgPixel := foreground colorId.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1069
	    bgPixel := background colorId.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1070
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1071
	    "mhmh the following is a kludge ...."
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1072
	    fgPixel isNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1073
		(foreground grayIntensity >= 50) ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1074
		    fgPixel := device whitepixel
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1075
		] ifFalse:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1076
		    fgPixel := device blackpixel
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1077
		]
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1078
	    ].
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1079
	    bgPixel isNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1080
		(background grayIntensity >= 50) ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1081
		    bgPixel := device whitepixel
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1082
		] ifFalse:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1083
		    bgPixel := device blackpixel
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1084
		]
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1085
	    ].
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1086
	    device setForeground:fgPixel background:bgPixel in:gcId.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1087
	    paint := foreground
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1088
	]
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1089
    ]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1090
745
d4465098f2c0 gray vs. grey
Claus Gittinger <cg@exept.de>
parents: 735
diff changeset
  1091
    "Modified: 28.5.1996 / 20:45:27 / cg"
732
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
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1094
foreground:fgColor background:bgColor function:fun
6266
1503c5e038d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1095
    <resource: #obsolete>
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1096
    "set foreground, background colors and function.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1097
     OBSOLETE: this method will vanish; use #paint: / #paint:on:"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1098
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1099
    self foreground:fgColor background:bgColor.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1100
    self function:fun
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1101
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1102
    "Modified: 12.5.1996 / 22:28:34 / cg"
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
foreground:aColor function:fun
6266
1503c5e038d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1106
    <resource: #obsolete>
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1107
    "set the foreground color and function for drawing.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1108
     OBSOLETE: this method will vanish; use #paint: / #paint:on:"
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
    |fgPixel|
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
    ((aColor ~~ foreground) or:[fun ~~ function]) ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1113
	foreground := aColor.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1114
	function := fun.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1115
	gcId notNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1116
	    foreground := foreground onDevice:device.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1117
	    fgPixel := foreground colorId.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1118
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1119
	    "mhmh the following is a kludge ...."
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1120
	    fgPixel isNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1121
		(foreground grayIntensity >= 50) ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1122
		    fgPixel := device whitepixel
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1123
		] ifFalse:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1124
		    fgPixel := device blackpixel
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1125
		]
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1126
	    ].
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1127
	    device setForeground:fgPixel in:gcId.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1128
	    device setFunction:fun in:gcId.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1129
	    paint := foreground
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1130
	]
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1131
    ]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1132
745
d4465098f2c0 gray vs. grey
Claus Gittinger <cg@exept.de>
parents: 735
diff changeset
  1133
    "Modified: 28.5.1996 / 20:45:09 / cg"
732
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
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1136
!DeviceGraphicsContext methodsFor:'bit blitting'!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1137
2016
bef5fe2ec2ca checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2013
diff changeset
  1138
copyBitsFrom:aByteArray bitsPerPixel:bpp depth:depth padding:pad width:srcW height:srcH x:srcX y:srcY toX:dstX y:dstY
bef5fe2ec2ca checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2013
diff changeset
  1139
    "copy bits from a smalltalk byteArray.
bef5fe2ec2ca checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2013
diff changeset
  1140
     The bits found there are supposed to be in the devices native format (i.e.
bef5fe2ec2ca checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2013
diff changeset
  1141
     translated to allocated color indices on pseudoColor devices and padded as required.
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1142
     The byteOrder is MSB and will be converted as appropriate by the underlying devices
2016
bef5fe2ec2ca checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2013
diff changeset
  1143
     method to whatever the device needs."
bef5fe2ec2ca checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2013
diff changeset
  1144
bef5fe2ec2ca checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2013
diff changeset
  1145
    device
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1146
	drawBits:aByteArray
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1147
	bitsPerPixel:bpp
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1148
	depth:depth
2016
bef5fe2ec2ca checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2013
diff changeset
  1149
	padding:pad
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1150
	width:srcW height:srcH
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1151
	x:srcX y:srcY
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1152
	into:drawableId
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1153
	x:dstX y:dstY
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1154
	width:(self width) height:(self height)
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1155
	with:gcId.
2016
bef5fe2ec2ca checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2013
diff changeset
  1156
!
bef5fe2ec2ca checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2013
diff changeset
  1157
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1158
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
  1159
    "copy bits from a smalltalk byteArray.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1160
     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
  1161
     translated to allocated color indices on pseudoColor devices and padded as required.
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1162
     The byteOrder is MSB and will be converted as appropriate by the underlying devices
1996
d8b8149ab79d added interface to specify padding in drawBits method
Claus Gittinger <cg@exept.de>
parents: 1842
diff changeset
  1163
     method to whatever the device needs.
d8b8149ab79d added interface to specify padding in drawBits method
Claus Gittinger <cg@exept.de>
parents: 1842
diff changeset
  1164
     Assumes the source bits are in ST/X's natural padding (i.e. 8-bit padded)"
d8b8149ab79d added interface to specify padding in drawBits method
Claus Gittinger <cg@exept.de>
parents: 1842
diff changeset
  1165
d8b8149ab79d added interface to specify padding in drawBits method
Claus Gittinger <cg@exept.de>
parents: 1842
diff changeset
  1166
    device
d8b8149ab79d added interface to specify padding in drawBits method
Claus Gittinger <cg@exept.de>
parents: 1842
diff changeset
  1167
	drawBits:aByteArray
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1168
	bitsPerPixel:bpp
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1169
	depth:depth
1996
d8b8149ab79d added interface to specify padding in drawBits method
Claus Gittinger <cg@exept.de>
parents: 1842
diff changeset
  1170
	padding:8
d8b8149ab79d added interface to specify padding in drawBits method
Claus Gittinger <cg@exept.de>
parents: 1842
diff changeset
  1171
	width:srcW height:srcH
d8b8149ab79d added interface to specify padding in drawBits method
Claus Gittinger <cg@exept.de>
parents: 1842
diff changeset
  1172
	x:srcX y:srcY
d8b8149ab79d added interface to specify padding in drawBits method
Claus Gittinger <cg@exept.de>
parents: 1842
diff changeset
  1173
	into:drawableId
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1174
	x:dstX y:dstY
1996
d8b8149ab79d added interface to specify padding in drawBits method
Claus Gittinger <cg@exept.de>
parents: 1842
diff changeset
  1175
	width:(self width) height:(self height)
d8b8149ab79d added interface to specify padding in drawBits method
Claus Gittinger <cg@exept.de>
parents: 1842
diff changeset
  1176
	with:gcId.
d8b8149ab79d added interface to specify padding in drawBits method
Claus Gittinger <cg@exept.de>
parents: 1842
diff changeset
  1177
d8b8149ab79d added interface to specify padding in drawBits method
Claus Gittinger <cg@exept.de>
parents: 1842
diff changeset
  1178
    "Created: 21.10.1995 / 00:04:22 / cg"
d8b8149ab79d added interface to specify padding in drawBits method
Claus Gittinger <cg@exept.de>
parents: 1842
diff changeset
  1179
!
d8b8149ab79d added interface to specify padding in drawBits method
Claus Gittinger <cg@exept.de>
parents: 1842
diff changeset
  1180
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1181
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
  1182
    "copy from aDrawable into the receiver;
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1183
     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
  1184
     All coordinates are in device coordinates."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1185
1291
1480f8aae3bb explicit sync/async bitBlt.
Claus Gittinger <cg@exept.de>
parents: 1255
diff changeset
  1186
    ^ self
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1187
	copyFrom:aDrawable
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1188
	x:srcX y:srcY
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1189
	toX:dstX y:dstY
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1190
	width:w height:h
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1191
	async:false
1291
1480f8aae3bb explicit sync/async bitBlt.
Claus Gittinger <cg@exept.de>
parents: 1255
diff changeset
  1192
1480f8aae3bb explicit sync/async bitBlt.
Claus Gittinger <cg@exept.de>
parents: 1255
diff changeset
  1193
    "Modified: 29.1.1997 / 13:12:36 / cg"
1480f8aae3bb explicit sync/async bitBlt.
Claus Gittinger <cg@exept.de>
parents: 1255
diff changeset
  1194
!
1480f8aae3bb explicit sync/async bitBlt.
Claus Gittinger <cg@exept.de>
parents: 1255
diff changeset
  1195
1480f8aae3bb explicit sync/async bitBlt.
Claus Gittinger <cg@exept.de>
parents: 1255
diff changeset
  1196
copyFrom:aDrawable x:srcX y:srcY toX:dstX y:dstY width:w height:h async:async
1480f8aae3bb explicit sync/async bitBlt.
Claus Gittinger <cg@exept.de>
parents: 1255
diff changeset
  1197
    "copy from aDrawable into the receiver;
1480f8aae3bb explicit sync/async bitBlt.
Claus Gittinger <cg@exept.de>
parents: 1255
diff changeset
  1198
     the source may be the receiver as well - in this case its a scroll.
1480f8aae3bb explicit sync/async bitBlt.
Claus Gittinger <cg@exept.de>
parents: 1255
diff changeset
  1199
     All coordinates are in device coordinates.
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1200
     If the receiver is a view AND async is true, the call returns immediately
1291
1480f8aae3bb explicit sync/async bitBlt.
Claus Gittinger <cg@exept.de>
parents: 1255
diff changeset
  1201
     - otherwise, it returns when the scroll operation is finished.
1480f8aae3bb explicit sync/async bitBlt.
Claus Gittinger <cg@exept.de>
parents: 1255
diff changeset
  1202
     (not all devices care for this).
1480f8aae3bb explicit sync/async bitBlt.
Claus Gittinger <cg@exept.de>
parents: 1255
diff changeset
  1203
     If the receiver is a pixmap, the call always returns immediately."
1480f8aae3bb explicit sync/async bitBlt.
Claus Gittinger <cg@exept.de>
parents: 1255
diff changeset
  1204
1480f8aae3bb explicit sync/async bitBlt.
Claus Gittinger <cg@exept.de>
parents: 1255
diff changeset
  1205
    |deviceDrawable id srcGCId asy|
976
807b42b00353 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 975
diff changeset
  1206
2210
18d4e83d08ad care for images being passed to #copyFrom: as source.
Claus Gittinger <cg@exept.de>
parents: 2192
diff changeset
  1207
    ((aDrawable graphicsDevice ~~ device)
18d4e83d08ad care for images being passed to #copyFrom: as source.
Claus Gittinger <cg@exept.de>
parents: 2192
diff changeset
  1208
    or:[aDrawable isImage]) ifTrue:[
6746
e63784ff3863 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6711
diff changeset
  1209
        deviceDrawable := aDrawable asFormOn:device.
976
807b42b00353 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 975
diff changeset
  1210
    ] ifFalse:[
6746
e63784ff3863 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6711
diff changeset
  1211
        deviceDrawable := aDrawable
976
807b42b00353 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 975
diff changeset
  1212
    ].
807b42b00353 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 975
diff changeset
  1213
807b42b00353 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 975
diff changeset
  1214
    id := deviceDrawable id.
732
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
    "temporary ...
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1217
     this fixes a problem after restart on another display,
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1218
     when a file-bitmap was not found.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1219
     In this case, the id of the bitmap will be nil.
976
807b42b00353 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 975
diff changeset
  1220
     This will be fixed soon (no longer use device>>bitmapFromFile:).
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1221
    "
976
807b42b00353 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 975
diff changeset
  1222
    id isNil ifTrue:[
6746
e63784ff3863 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6711
diff changeset
  1223
        Smalltalk isStandAloneApp ifFalse:[
e63784ff3863 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6711
diff changeset
  1224
            'DeviceGraphicsContext [warning]: invalid bitmap copy - ignored' infoPrintCR.
e63784ff3863 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6711
diff changeset
  1225
        ].
e63784ff3863 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6711
diff changeset
  1226
        ^ self
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1227
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1228
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1229
    gcId isNil ifTrue:[
6746
e63784ff3863 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6711
diff changeset
  1230
        self initGC
732
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
2065
27bf0cf42e45 changes for WIN32
Claus Gittinger <cg@exept.de>
parents: 2049
diff changeset
  1233
    deviceDrawable gcId isNil ifTrue:[deviceDrawable initGC].
976
807b42b00353 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 975
diff changeset
  1234
    srcGCId := deviceDrawable gcId.
807b42b00353 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 975
diff changeset
  1235
807b42b00353 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 975
diff changeset
  1236
    ((deviceDrawable depth == 1) and:[device depth ~~ 1]) ifTrue:[
6746
e63784ff3863 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6711
diff changeset
  1237
        deviceDrawable isForm ifTrue:[
e63784ff3863 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6711
diff changeset
  1238
            device
e63784ff3863 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6711
diff changeset
  1239
                copyPlaneFromPixmapId:id
e63784ff3863 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6711
diff changeset
  1240
                x:srcX
e63784ff3863 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6711
diff changeset
  1241
                y:srcY
e63784ff3863 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6711
diff changeset
  1242
                gc:srcGCId
e63784ff3863 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6711
diff changeset
  1243
                to:drawableId
e63784ff3863 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6711
diff changeset
  1244
                x:dstX
e63784ff3863 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6711
diff changeset
  1245
                y:dstY
e63784ff3863 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6711
diff changeset
  1246
                gc:gcId
e63784ff3863 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6711
diff changeset
  1247
                width:w
e63784ff3863 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6711
diff changeset
  1248
                height:h
e63784ff3863 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6711
diff changeset
  1249
        ] ifFalse:[
e63784ff3863 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6711
diff changeset
  1250
            device
e63784ff3863 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6711
diff changeset
  1251
                copyPlaneFromId:id
e63784ff3863 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6711
diff changeset
  1252
                x:srcX
e63784ff3863 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6711
diff changeset
  1253
                y:srcY
e63784ff3863 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6711
diff changeset
  1254
                gc:srcGCId
e63784ff3863 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6711
diff changeset
  1255
                to:drawableId
e63784ff3863 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6711
diff changeset
  1256
                x:dstX
e63784ff3863 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6711
diff changeset
  1257
                y:dstY
e63784ff3863 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6711
diff changeset
  1258
                gc:gcId
e63784ff3863 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6711
diff changeset
  1259
                width:w
e63784ff3863 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6711
diff changeset
  1260
                height:h
e63784ff3863 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6711
diff changeset
  1261
        ]
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1262
    ] ifFalse:[
6746
e63784ff3863 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6711
diff changeset
  1263
        deviceDrawable isForm ifTrue:[
e63784ff3863 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6711
diff changeset
  1264
            device
e63784ff3863 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6711
diff changeset
  1265
                copyFromPixmapId:id
e63784ff3863 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6711
diff changeset
  1266
                x:srcX
e63784ff3863 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6711
diff changeset
  1267
                y:srcY
e63784ff3863 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6711
diff changeset
  1268
                gc:srcGCId
e63784ff3863 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6711
diff changeset
  1269
                to:drawableId
e63784ff3863 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6711
diff changeset
  1270
                x:dstX
e63784ff3863 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6711
diff changeset
  1271
                y:dstY
e63784ff3863 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6711
diff changeset
  1272
                gc:gcId
e63784ff3863 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6711
diff changeset
  1273
                width:w
e63784ff3863 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6711
diff changeset
  1274
                height:h
e63784ff3863 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6711
diff changeset
  1275
        ] ifFalse:[
e63784ff3863 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6711
diff changeset
  1276
            asy := async or:[self isView not].
e63784ff3863 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6711
diff changeset
  1277
            asy ifFalse:[
e63784ff3863 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6711
diff changeset
  1278
                self catchExpose
e63784ff3863 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6711
diff changeset
  1279
            ].
e63784ff3863 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6711
diff changeset
  1280
            device
e63784ff3863 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6711
diff changeset
  1281
                copyFromId:id
e63784ff3863 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6711
diff changeset
  1282
                x:srcX
e63784ff3863 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6711
diff changeset
  1283
                y:srcY
e63784ff3863 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6711
diff changeset
  1284
                gc:srcGCId
e63784ff3863 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6711
diff changeset
  1285
                to:drawableId
e63784ff3863 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6711
diff changeset
  1286
                x:dstX
e63784ff3863 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6711
diff changeset
  1287
                y:dstY
e63784ff3863 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6711
diff changeset
  1288
                gc:gcId
e63784ff3863 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6711
diff changeset
  1289
                width:w
e63784ff3863 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6711
diff changeset
  1290
                height:h.
e63784ff3863 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6711
diff changeset
  1291
            asy ifFalse:[
e63784ff3863 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6711
diff changeset
  1292
                device flush.
e63784ff3863 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6711
diff changeset
  1293
                self waitForExpose
e63784ff3863 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6711
diff changeset
  1294
            ]
e63784ff3863 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6711
diff changeset
  1295
        ]
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1296
    ]
868
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
  1297
2210
18d4e83d08ad care for images being passed to #copyFrom: as source.
Claus Gittinger <cg@exept.de>
parents: 2192
diff changeset
  1298
    "Created: / 29.1.1997 / 13:02:10 / cg"
18d4e83d08ad care for images being passed to #copyFrom: as source.
Claus Gittinger <cg@exept.de>
parents: 2192
diff changeset
  1299
    "Modified: / 31.7.1998 / 17:23:43 / cg"
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1300
!
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
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
  1303
    "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
  1304
     background, while 1's are drawn with foreground color.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1305
     The depth of aDrawable must (should) be 1.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1306
     The drawable must have been allocated on the same device.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1307
     All coordinates are in device coordinates."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1308
1064
2d0783c97f32 removed unused vars
Claus Gittinger <cg@exept.de>
parents: 1034
diff changeset
  1309
    |deviceDrawable id|
976
807b42b00353 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 975
diff changeset
  1310
2210
18d4e83d08ad care for images being passed to #copyFrom: as source.
Claus Gittinger <cg@exept.de>
parents: 2192
diff changeset
  1311
    ((aDrawable graphicsDevice ~~ device)
18d4e83d08ad care for images being passed to #copyFrom: as source.
Claus Gittinger <cg@exept.de>
parents: 2192
diff changeset
  1312
    or:[aDrawable isImage]) ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1313
	deviceDrawable := aDrawable asFormOn:device.
976
807b42b00353 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 975
diff changeset
  1314
    ] ifFalse:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1315
	deviceDrawable := aDrawable
976
807b42b00353 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 975
diff changeset
  1316
    ].
807b42b00353 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 975
diff changeset
  1317
807b42b00353 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 975
diff changeset
  1318
    id := deviceDrawable id.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1319
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1320
    "temporary ...
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1321
     this fixes a problem after restart on another display,
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1322
     when a file-bitmap was not found.
976
807b42b00353 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 975
diff changeset
  1323
     In this case, the id of the bitmap will be nil.
807b42b00353 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 975
diff changeset
  1324
     This will be fixed soon (no longer use device>>bitmapFromFile:).
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1325
    "
976
807b42b00353 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 975
diff changeset
  1326
    id isNil ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1327
	'DeviceGraphicsContext [warning]: invalid copyPlane - ignored' errorPrintCR.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1328
	^ self
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1329
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1330
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1331
    gcId isNil ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1332
	self initGC
732
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
1249
5224bb7a97bf use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  1335
    deviceDrawable isForm ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1336
	deviceDrawable gcId isNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1337
	    deviceDrawable initGC
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1338
	].
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1339
	device
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1340
	    copyPlaneFromPixmapId:id
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1341
	    x:srcX
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1342
	    y:srcY
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1343
	    gc:(deviceDrawable gcId)
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1344
	    to:drawableId
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1345
	    x:dstX
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1346
	    y:dstY
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1347
	    gc:gcId
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1348
	    width:w
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1349
	    height:h
1249
5224bb7a97bf use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  1350
    ] ifFalse:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1351
	device
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1352
	    copyPlaneFromId:id
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1353
	    x:srcX
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1354
	    y:srcY
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1355
	    gc:(deviceDrawable gcId)
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1356
	    to:drawableId
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1357
	    x:dstX
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1358
	    y:dstY
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1359
	    gc:gcId
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1360
	    width:w
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1361
	    height:h
1249
5224bb7a97bf use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  1362
    ]
5224bb7a97bf use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  1363
2271
46b68ae54cbc win32 needs source-gc to be initialized in a bitBlt.
Claus Gittinger <cg@exept.de>
parents: 2268
diff changeset
  1364
    "Modified: / 22.8.1998 / 15:15:52 / cg"
732
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
!DeviceGraphicsContext methodsFor:'copying'!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1368
3611
8b4384c9e660 Use #finalize instead of #disposed
Stefan Vogel <sv@exept.de>
parents: 3569
diff changeset
  1369
executor
8b4384c9e660 Use #finalize instead of #disposed
Stefan Vogel <sv@exept.de>
parents: 3569
diff changeset
  1370
    "I am abstract"
8b4384c9e660 Use #finalize instead of #disposed
Stefan Vogel <sv@exept.de>
parents: 3569
diff changeset
  1371
8b4384c9e660 Use #finalize instead of #disposed
Stefan Vogel <sv@exept.de>
parents: 3569
diff changeset
  1372
    self subclassResponsibility.
8b4384c9e660 Use #finalize instead of #disposed
Stefan Vogel <sv@exept.de>
parents: 3569
diff changeset
  1373
8b4384c9e660 Use #finalize instead of #disposed
Stefan Vogel <sv@exept.de>
parents: 3569
diff changeset
  1374
    "Created: 2.4.1997 / 19:22:11 / cg"
8b4384c9e660 Use #finalize instead of #disposed
Stefan Vogel <sv@exept.de>
parents: 3569
diff changeset
  1375
!
8b4384c9e660 Use #finalize instead of #disposed
Stefan Vogel <sv@exept.de>
parents: 3569
diff changeset
  1376
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1377
postCopy
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1378
    "this may not be enough to allow copying of views ..."
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
    super postCopy.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1381
    device := drawableId := gcId := nil.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1382
    self recreate
4403
3342601d3fed +postDeepCopy
Claus Gittinger <cg@exept.de>
parents: 4389
diff changeset
  1383
!
3342601d3fed +postDeepCopy
Claus Gittinger <cg@exept.de>
parents: 4389
diff changeset
  1384
3342601d3fed +postDeepCopy
Claus Gittinger <cg@exept.de>
parents: 4389
diff changeset
  1385
postDeepCopy
3342601d3fed +postDeepCopy
Claus Gittinger <cg@exept.de>
parents: 4389
diff changeset
  1386
    device := drawableId := gcId := nil.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1387
! !
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
!DeviceGraphicsContext methodsFor:'drawing'!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1390
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1391
displayArcX:x y:y width:w height:h from:startAngle angle:angle
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1392
    "draw an arc; apply transformation if nonNil"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1393
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1394
    |pX pY nW nH sA a pO pC|
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1395
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1396
    gcId isNil ifTrue:[
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1397
        self initGC
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1398
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1399
    transformation notNil ifTrue:[
6711
2b50385f7257 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
  1400
        pO := transformation transformPoint:x@y.
2b50385f7257 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
  1401
        pC := transformation transformPoint:(x+w-1)@(y+h-1).
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1402
        pX := pO x.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1403
        pY := pO y.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1404
        nW := pC x - pX + 1.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1405
        nH := pC y - pY + 1.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1406
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1407
        nW < 0 ifTrue:[
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1408
              nW := nW abs.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1409
              pX := pX - nW.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1410
        ].
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1411
        nH < 0 ifTrue:[
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1412
              nH := nH abs.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1413
              pY := pY - nH.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1414
        ].
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1415
    ] ifFalse:[
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1416
        pX := x.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1417
        pY := y.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1418
        nW := w.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1419
        nH := h.
732
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
    pX := pX rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1423
    pY := pY rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1424
    nW := nW rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1425
    nH := nH rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1426
2268
1a774fc02c83 fixed non-float (i.e. fraction) args to fillArc/ displayArc
Claus Gittinger <cg@exept.de>
parents: 2259
diff changeset
  1427
    sA := startAngle.
1a774fc02c83 fixed non-float (i.e. fraction) args to fillArc/ displayArc
Claus Gittinger <cg@exept.de>
parents: 2259
diff changeset
  1428
    sA isInteger ifFalse:[sA := sA asFloat].
1a774fc02c83 fixed non-float (i.e. fraction) args to fillArc/ displayArc
Claus Gittinger <cg@exept.de>
parents: 2259
diff changeset
  1429
    a := angle.
1a774fc02c83 fixed non-float (i.e. fraction) args to fillArc/ displayArc
Claus Gittinger <cg@exept.de>
parents: 2259
diff changeset
  1430
    a isInteger ifFalse:[a := a asFloat].
1a774fc02c83 fixed non-float (i.e. fraction) args to fillArc/ displayArc
Claus Gittinger <cg@exept.de>
parents: 2259
diff changeset
  1431
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1432
    device
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1433
          displayArcX:pX
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1434
                    y:pY
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1435
                width:nW
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1436
               height:nH
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1437
                 from:sA
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1438
                angle:a
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1439
                   in:drawableId
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1440
                 with:gcId
732
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
    "Created: 8.5.1996 / 08:31:30 / cg"
784
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
  1443
    "Modified: 4.6.1996 / 17:59:28 / cg"
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1444
!
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
displayForm:formToDraw x:x y:y
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1447
    "draw a form or image non opaque;
1592
7ec770f2047a faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents: 1517
diff changeset
  1448
     if its a 1-plane bitmap, 1-bits are drawn in the
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1449
     current paint-color, leaving pixels with 0-bits unchanged
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1450
     (i.e. only 1-bits are drawn from the form).
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1451
     If its a deep form (i.e. a pixmap) the current paint
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1452
     settings are ignored and the form is drawn as-is.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1453
     Care must be taken, that the paint color is correctly allocated
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1454
     (by sending #on: to the color) before doing so.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1455
     Using functions other than #copy only makes sense if you are
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1456
     certain, that the colors are real colors (actually, only for
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1457
     noColor or allColor)."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1458
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1459
    |realForm pX pY w h nW nH pO pC|
732
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
    realForm := formToDraw.
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
    transformation notNil ifTrue:[
6711
2b50385f7257 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
  1464
        pO := transformation transformPoint:x@y.
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1465
        pX := pO x.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1466
        pY := pO y.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1467
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1468
        transformation isNoScale ifFalse:[
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1469
            w := formToDraw width.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1470
            h := formToDraw height.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1471
            pC := transformation applyTo:(x+w-1)@(y+h-1).
6751
9d7cb6c4d04a class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6746
diff changeset
  1472
            nW := pC x - pX + 1.
9d7cb6c4d04a class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6746
diff changeset
  1473
            nH := pC y - pY + 1.
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1474
            "/ nW := (transformation applyScaleX:w) rounded.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1475
            "/ nH := (transformation applyScaleY:h) rounded.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1476
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1477
            ((nW ~= w) or:[nH ~= h]) ifTrue:[
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1478
                "/
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1479
                "/ hard case - someone is drawing forms with scaling in effect
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1480
                "/ look if we have a scaled version in our pocket ...
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1481
                "/
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1482
                realForm := nil.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1483
                CachedScaledForms notNil ifTrue:[
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1484
                    (CachedScales at:formToDraw ifAbsent:nil) = transformation scale ifTrue:[
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1485
                        realForm := CachedScaledForms at:formToDraw ifAbsent:nil.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1486
                    ]
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1487
                ].
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1488
                realForm isNil ifTrue:[
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1489
                    "/
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1490
                    "/ nope - must do the work ...
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1491
                    "/
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1492
                    realForm := formToDraw magnifiedBy:(nW / w) @ (nH / h).
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1493
                    CachedScaledForms isNil ifTrue:[
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1494
                        CachedScaledForms := WeakIdentityDictionary new.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1495
                        CachedScales := WeakIdentityDictionary new.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1496
                    ].
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1497
                    CachedScaledForms at:formToDraw put:realForm.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1498
                    CachedScales at:formToDraw put:transformation scale.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1499
                ]
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1500
            ]
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1501
        ]
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1502
    ] ifFalse:[
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1503
        pX := x.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1504
        pY := y.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1505
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1506
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1507
    self displayDeviceForm:realForm x:pX y:pY
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1508
1592
7ec770f2047a faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents: 1517
diff changeset
  1509
    "Modified: 12.4.1997 / 12:47:29 / cg"
732
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
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1512
displayLineFrom:p0 to:p1
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1513
    "draw a line (with current paint-color); apply transformation if nonNil"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1514
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1515
    |pX0 pY0 pX1 pY1 easy fgId bgId tp0 tp1|
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1516
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1517
    gcId isNil ifTrue:[
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1518
        self initGC
732
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
    lineStyle == #doubleDashed ifTrue:[
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1522
        "
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1523
         if bgPaint or paint is not a real color, we have to do it the hard way ...
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1524
        "
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1525
        easy := true.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1526
        paint isColor ifFalse:[
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1527
            easy := false
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1528
        ] ifTrue:[
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1529
            fgId := paint colorId.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1530
            fgId isNil ifTrue:[
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1531
                easy := false
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1532
            ]
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1533
        ].
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1534
        bgPaint isColor ifFalse:[
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1535
            easy := false
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1536
        ] ifTrue:[
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1537
            bgId := bgPaint colorId.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1538
            bgId isNil ifTrue:[
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1539
                easy := false
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1540
            ]
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1541
        ].
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1542
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1543
        easy ifTrue:[
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1544
            ((foreground ~~ paint) or:[background ~~ bgPaint]) ifTrue:[
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1545
                device setForeground:fgId background:bgId in:gcId.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1546
                foreground := paint.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1547
                background := bgPaint.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1548
            ].
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1549
        ] ifFalse:[
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1550
            'DeviceGraphicsContext [warning]: cannot draw dashes with dithered colors' errorPrintCR
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1551
        ].
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1552
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1553
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1554
    transformation notNil ifTrue:[
6711
2b50385f7257 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
  1555
        tp0 := transformation transformPoint:p0.
2b50385f7257 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
  1556
        tp1 := transformation transformPoint:p1.
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1557
        pX0 := tp0 x.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1558
        pY0 := tp0 y.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1559
        pX1 := tp1 x.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1560
        pY1 := tp1 y.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1561
    ] ifFalse:[
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1562
        pX0 := p0 x.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1563
        pY0 := p0 y.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1564
        pX1 := p1 x.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1565
        pY1 := p1 y
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1566
    ].
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1567
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1568
    pX0 := pX0 rounded.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1569
    pY0 := pY0 rounded.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1570
    pX1 := pX1 rounded.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1571
    pY1 := pY1 rounded.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1572
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1573
    device displayLineFromX:pX0 y:pY0 toX:pX1 y:pY1 in:drawableId with:gcId
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1574
!
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1575
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1576
displayLineFromX:x0 y:y0 toX:x1 y:y1
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1577
    "draw a line (with current paint-color); apply transformation if nonNil"
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1578
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1579
    |pX0 pY0 pX1 pY1 easy fgId bgId p0 p1|
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1580
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1581
    gcId isNil ifTrue:[
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1582
        self initGC
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1583
    ].
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1584
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1585
    lineStyle == #doubleDashed ifTrue:[
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1586
        "
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1587
         if bgPaint or paint is not a real color, we have to do it the hard way ...
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1588
        "
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1589
        easy := true.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1590
        paint isColor ifFalse:[
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1591
            easy := false
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1592
        ] ifTrue:[
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1593
            fgId := paint colorId.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1594
            fgId isNil ifTrue:[
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1595
                easy := false
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1596
            ]
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1597
        ].
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1598
        bgPaint isColor ifFalse:[
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1599
            easy := false
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1600
        ] ifTrue:[
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1601
            bgId := bgPaint colorId.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1602
            bgId isNil ifTrue:[
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1603
                easy := false
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1604
            ]
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1605
        ].
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1606
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1607
        easy ifTrue:[
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1608
            ((foreground ~~ paint) or:[background ~~ bgPaint]) ifTrue:[
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1609
                device setForeground:fgId background:bgId in:gcId.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1610
                foreground := paint.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1611
                background := bgPaint.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1612
            ].
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1613
        ] ifFalse:[
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1614
            'DeviceGraphicsContext [warning]: cannot draw dashes with dithered colors' errorPrintCR
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1615
        ].
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1616
    ].
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1617
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1618
    transformation notNil ifTrue:[
6711
2b50385f7257 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
  1619
        p0 := transformation transformPoint:x0@y0.
2b50385f7257 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
  1620
        p1 := transformation transformPoint:x1@y1.
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1621
        pX0 := p0 x.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1622
        pY0 := p0 y.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1623
        pX1 := p1 x.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1624
        pY1 := p1 y.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1625
    ] ifFalse:[
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1626
        pX0 := x0.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1627
        pY0 := y0.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1628
        pX1 := x1.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1629
        pY1 := y1
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1630
    ].
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
    pX0 := pX0 rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1633
    pY0 := pY0 rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1634
    pX1 := pX1 rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1635
    pY1 := pY1 rounded.
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
    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
  1638
1177
e89408c15bb5 newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 1138
diff changeset
  1639
    "Modified: 10.1.1997 / 17:46:32 / cg"
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1640
!
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
displayOpaqueForm:formToDraw x:x y:y
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1643
    "draw a form or image opaque;
1592
7ec770f2047a faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents: 1517
diff changeset
  1644
     if its a 1-plane bitmap, 1-bits are drawn in the
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1645
     current paint-color and 0-bits in the bgPaint color.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1646
     If its a deep form (i.e. a pixmap) the current paint/bgPaint
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1647
     settings are ignored and the form drawn as-is.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1648
     In the 1-plane case, special care must be taken if paint and/or bgPaint
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1649
     dithered colors or patterns, since are that the colors are correctly allocated
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1650
     (by sending #on: to the colors) before doing so.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1651
     If there is a transformation, the image is scaled as appropiate."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1652
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1653
    |w h realForm pX pY nW nH pO pC|
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1654
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1655
    bgPaint isNil ifTrue:[
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1656
        "/
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1657
        "/ actually not an opaque draw
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1658
        "/
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1659
        self displayForm:formToDraw x:x y:y.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1660
        ^ self
732
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
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1663
    realForm := formToDraw.
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
    transformation notNil ifTrue:[
6711
2b50385f7257 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
  1666
        pO := transformation transformPoint:x@y.
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1667
        pX := pO x.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1668
        pY := pO y.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1669
        "/ pX := transformation applyToX:x.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1670
        "/ pY := transformation applyToY:y.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1671
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1672
        transformation isNoScale ifFalse:[
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1673
            w := formToDraw width.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1674
            h := formToDraw height.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1675
            pC := transformation applyTo:(x+w-1)@(y+h-1).
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1676
            nW := pX - x + 1.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1677
            nH := pY - y + 1.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1678
            "/ nW := (transformation applyScaleX:w) rounded.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1679
            "/ nH := (transformation applyScaleY:h) rounded.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1680
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1681
            ((nW ~= w) or:[nH ~= h]) ifTrue:[
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1682
                "/
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1683
                "/ hard case - someone is drawing forms with scaling in effect
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1684
                "/ look if we have a scaled version in our pocket ...
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1685
                "/
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1686
                realForm := nil.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1687
                CachedScaledForms notNil ifTrue:[
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1688
                    (CachedScales at:formToDraw ifAbsent:nil) = transformation scale ifTrue:[
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1689
                        realForm := CachedScaledForms at:formToDraw ifAbsent:nil.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1690
                    ]
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1691
                ].
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1692
                realForm isNil ifTrue:[
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1693
                    "/
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1694
                    "/ nope - must do the work ...
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1695
                    "/
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1696
                    realForm := formToDraw magnifiedBy:(nW / w) @ (nH / h).
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1697
                    CachedScaledForms isNil ifTrue:[
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1698
                        CachedScaledForms := WeakIdentityDictionary new.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1699
                        CachedScales := WeakIdentityDictionary new.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1700
                    ].
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1701
                    CachedScaledForms at:formToDraw put:realForm.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1702
                    CachedScales at:formToDraw put:transformation scale.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1703
                ]
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1704
            ]
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1705
        ]
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1706
    ] ifFalse:[
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1707
        pX := x.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1708
        pY := y.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1709
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1710
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1711
    self displayDeviceOpaqueForm:realForm x:pX y:pY
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1712
1592
7ec770f2047a faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents: 1517
diff changeset
  1713
    "Modified: 12.4.1997 / 12:49:02 / cg"
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1714
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1715
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1716
displayOpaqueString:aString from:index1 to:index2 x:x y:y
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1717
    "draw a substring at the coordinate x/y - draw foreground pixels in
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1718
     paint-color and background pixels in bgPaint-color.
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1719
     If the transformation involves scaling,
7345
8eea38c33a0b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7301
diff changeset
  1720
     the font's point-size is scaled as appropriate.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1721
     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
  1722
     the case where paint and/or bgPaint are dithered colors"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1723
5360
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1724
    self displayString:aString from:index1 to:index2 x:x y:y opaque:true
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1725
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1726
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1727
displayOpaqueString:aString x:x y:y
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1728
    "draw a string at the coordinate x/y - draw foreground pixels in paint-color,
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1729
     background pixels in bgPaint color. If the transformation involves scaling,
7345
8eea38c33a0b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7301
diff changeset
  1730
     the font's point-size is scaled as appropriate.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1731
     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
  1732
     the case where paint and/or bgPaint are dithered colors or images."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1733
7064
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  1734
    aString isPlainString ifFalse:[
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  1735
        "
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  1736
         hook for non-strings (i.e. attributed text)
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  1737
         that 'thing' should know how to display itself ...
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  1738
        "
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  1739
        aString displayOpaqueOn:self x:x y:y.
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  1740
        ^ self
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1741
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1742
5360
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1743
    self displayOpaqueString:aString from:1 to:(aString size) x:x y:y
732
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
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1746
displayPointX:x y:y
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1747
    "draw a point (with current paint-color); apply transformation if nonNil"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1748
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1749
    |pX pY pO|
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1750
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1751
    gcId isNil ifTrue:[
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1752
        self initGC
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1753
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1754
    transformation notNil ifTrue:[
6711
2b50385f7257 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
  1755
        pO := transformation transformPoint:x@y.
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1756
        pX := pO x.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1757
        pY := pO y.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1758
    ] ifFalse:[
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1759
        pX := x.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1760
        pY := y
732
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 := pX rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1763
    pY := pY rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1764
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1765
    device displayPointX:pX y:pY in:drawableId with:gcId
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1766
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1767
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1768
displayPolygon:aPolygon
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1769
    "draw (the outline of) a polygon (with current paint-color).
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1770
     Apply transformation if nonNil"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1771
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1772
    |newPolygon|
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
    gcId isNil ifTrue:[
6645
6066dcf16c20 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6626
diff changeset
  1775
        self initGC
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1776
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1777
    transformation notNil ifTrue:[
6711
2b50385f7257 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
  1778
        newPolygon := aPolygon collect:[:point | transformation transformPoint:point].
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1779
    ] ifFalse:[
6645
6066dcf16c20 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6626
diff changeset
  1780
        newPolygon := aPolygon
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1781
    ].
6645
6066dcf16c20 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6626
diff changeset
  1782
    (newPolygon contains:[:p |
6066dcf16c20 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6626
diff changeset
  1783
        (p isPoint not
6066dcf16c20 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6626
diff changeset
  1784
        or:[(p x class ~~ SmallInteger)
6066dcf16c20 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6626
diff changeset
  1785
        or:[(p y class ~~ SmallInteger)]])
6066dcf16c20 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6626
diff changeset
  1786
     ]) ifTrue:[
6066dcf16c20 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6626
diff changeset
  1787
        newPolygon := newPolygon collect:[:p | p asPoint rounded]
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1788
    ].
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1789
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1790
    device displayPolygon:newPolygon in:drawableId with:gcId
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1791
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1792
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1793
displayRectangleX:x y:y width:w height:h
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1794
    "draw a rectangle (with current paint-color).
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1795
     If transformation is nonNil, drawing is in logical coordinates."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1796
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1797
    |pX pY nW nH easy fgId bgId pO pC|
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1798
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1799
    gcId isNil ifTrue:[
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1800
        self initGC
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1801
    ].
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
    lineStyle == #doubleDashed ifTrue:[
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1804
        "
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1805
         if bgPaint or paint is not a real color, we have to do it the hard way ...
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1806
        "
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1807
        easy := true.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1808
        paint isColor ifFalse:[
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1809
            easy := false
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1810
        ] ifTrue:[
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1811
            fgId := paint colorId.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1812
            fgId isNil ifTrue:[
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1813
                easy := false
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1814
            ]
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1815
        ].
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1816
        bgPaint isColor ifFalse:[
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1817
            easy := false
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1818
        ] ifTrue:[
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1819
            bgId := bgPaint colorId.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1820
            bgId isNil ifTrue:[
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1821
                easy := false
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1822
            ]
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1823
        ].
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1824
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1825
        easy ifTrue:[
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1826
            ((foreground ~~ paint) or:[background ~~ bgPaint]) ifTrue:[
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1827
                device setForeground:fgId background:bgId in:gcId.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1828
                foreground := paint.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1829
                background := bgPaint.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1830
            ].
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1831
        ] ifFalse:[
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1832
            'DeviceGraphicsContext [warning]: cannot draw dashes with dithered colors' errorPrintCR
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1833
        ].
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1834
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1835
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1836
    transformation notNil ifTrue:[
6711
2b50385f7257 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
  1837
        pO := transformation transformPoint:x@y.
2b50385f7257 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
  1838
        pC := transformation transformPoint:(x+w-1)@(y+h-1).
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1839
        pX := pO x.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1840
        pY := pO y.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1841
        nW := pC x - pX + 1.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1842
        nH := pC y - pY + 1.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1843
"/        pX := transformation applyToX:x.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1844
"/        pY := transformation applyToY:y.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1845
"/        nW := transformation applyScaleX:w.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1846
"/        nH := transformation applyScaleY:h.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1847
        nW < 0 ifTrue:[
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1848
              nW := nW abs.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1849
              pX := pX - nW.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1850
        ].
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1851
        nH < 0 ifTrue:[
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1852
              nH := nH abs.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1853
              pY := pY - nH.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1854
        ].
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1855
    ] ifFalse:[
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1856
        pX := x.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1857
        pY := y.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1858
        nW := w.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1859
        nH := h
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1860
    ].
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
    pX := pX rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1863
    pY := pY rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1864
    nW := nW rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1865
    nH := nH rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1866
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1867
    "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
  1868
     this one seems mathematically incorrect but allows to draw and fill
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1869
     a rectangle using the same extents.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1870
     I'm not certain if is the right thing to do ...
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1871
    "
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1872
    device displayRectangleX:pX
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1873
                           y:pY
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1874
                       width:(nW - 1)
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1875
                      height:(nH - 1)
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1876
                          in:drawableId with:gcId
1177
e89408c15bb5 newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 1138
diff changeset
  1877
e89408c15bb5 newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 1138
diff changeset
  1878
    "Modified: 10.1.1997 / 17:46:41 / cg"
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1879
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1880
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1881
displayString:aString from:index1 to:index2 x:x y:y
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1882
    "draw a substring at the coordinate x/y -
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1883
     draw foreground-pixels only (in current paint-color),
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1884
     leaving background as-is. If the transformation involves scaling,
7345
8eea38c33a0b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7301
diff changeset
  1885
     the font's point-size is scaled as appropriate."
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1886
5360
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1887
    self displayString:aString from:index1 to:index2 x:x y:y opaque:false
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1888
!
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1889
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1890
displayString:aString from:index1Arg to:index2Arg x:x y:y opaque:opaqueArg
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1891
    "draw a substring at the coordinate x/y - draw foreground pixels in
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1892
     paint-color and (if opaque is true), background pixels in bgPaint-color.
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1893
     If the transformation involves scaling, the font's point-size is scaled as appropriate.
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1894
     Assuming that device can only draw in device colors, we have to handle
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1895
     the case where paint and/or bgPaint are dithered colors"
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1896
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1897
    |opaque index1 index2 easy w h savedPaint fgId bgId
6108
6ecfb89408d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6107
diff changeset
  1898
     fontId pX pY fontUsed fontsEncoding sz s
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1899
     nSkipLeft nChars wString wSkipLeft wMax index2Guess pO|
5360
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1900
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1901
    index1 := index1Arg.
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1902
    index2 := index2Arg.
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1903
    opaque := opaqueArg.
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1904
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1905
    "
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1906
     if backgroundPaint color is nil, we assume
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1907
     this is a non-opaque draw
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1908
    "
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1909
    bgPaint isNil ifTrue:[
6626
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1910
        opaque := false.
5360
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1911
    ].
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1912
7064
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  1913
    aString isPlainString ifFalse:[
6626
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1914
        "
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1915
         hook for non-strings (i.e. attributed text)
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1916
         that 'thing' should know how to display itself ...
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1917
        "
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1918
        aString displayOn:self x:x y:y from:index1 to:index2 opaque:opaque.
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1919
        ^ self
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1920
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1921
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1922
    gcId isNil ifTrue:[
6626
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1923
        self initGC
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1924
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1925
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1926
    fontUsed := font.
7064
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  1927
    (transformation isNil or:[transformation isNoScale]) ifFalse:[
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  1928
        sz := font size.
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  1929
        sz isNil ifTrue:[
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  1930
            "/ oops - not a real font; use original font
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  1931
            fontUsed := font
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  1932
        ] ifFalse:[
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  1933
            fontUsed := font asSize:(transformation applyScaleY:sz) rounded.
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  1934
        ].
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1935
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1936
5360
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1937
    fontUsed := fontUsed onDevice:device.
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1938
7288
fec0c6c1087b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7257
diff changeset
  1939
    "/ transcode the string into the font's encoding...
4026
882de378f763 no longer as string for its encoding;
Claus Gittinger <cg@exept.de>
parents: 3943
diff changeset
  1940
    s := aString.
882de378f763 no longer as string for its encoding;
Claus Gittinger <cg@exept.de>
parents: 3943
diff changeset
  1941
    fontsEncoding := fontUsed encoding.
7288
fec0c6c1087b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7257
diff changeset
  1942
fec0c6c1087b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7257
diff changeset
  1943
    "/ This is now obsolete, as we are always using unicode internally.
fec0c6c1087b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7257
diff changeset
  1944
    "/ so the next line should be changed to fontsEncoding ~~ #unicode
4056
67c4686afbc6 characterEncoding stuff
Claus Gittinger <cg@exept.de>
parents: 4031
diff changeset
  1945
    (characterEncoding ~~ fontsEncoding) ifTrue:[
6626
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1946
        [
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1947
            s := CharacterEncoder encodeString:s from:characterEncoding into:fontsEncoding.
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1948
        ] on:CharacterEncoderError do:[:ex|
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1949
            "substitute a default value for codes that cannot be represented
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1950
             in the new character set"
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1951
            ex proceedWith:ex defaultValue.
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1952
        ].
4026
882de378f763 no longer as string for its encoding;
Claus Gittinger <cg@exept.de>
parents: 3943
diff changeset
  1953
    ].
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1954
7063
2be1214a5dcf #BUGFIX
Stefan Vogel <sv@exept.de>
parents: 7062
diff changeset
  1955
    fontUsed isAlienFont ifTrue:[
2be1214a5dcf #BUGFIX
Stefan Vogel <sv@exept.de>
parents: 7062
diff changeset
  1956
        "
2be1214a5dcf #BUGFIX
Stefan Vogel <sv@exept.de>
parents: 7062
diff changeset
  1957
         hook for alien fonts
2be1214a5dcf #BUGFIX
Stefan Vogel <sv@exept.de>
parents: 7062
diff changeset
  1958
         that 'font' should know how to display the string...
2be1214a5dcf #BUGFIX
Stefan Vogel <sv@exept.de>
parents: 7062
diff changeset
  1959
        "
2be1214a5dcf #BUGFIX
Stefan Vogel <sv@exept.de>
parents: 7062
diff changeset
  1960
        self backgroundPaint isImage ifTrue:[
2be1214a5dcf #BUGFIX
Stefan Vogel <sv@exept.de>
parents: 7062
diff changeset
  1961
            "/ #todo: fill background rectangle
2be1214a5dcf #BUGFIX
Stefan Vogel <sv@exept.de>
parents: 7062
diff changeset
  1962
            fontUsed displayString:aString from:index1 to:index2 x:x rounded y:y rounded in:self opaque:false.
2be1214a5dcf #BUGFIX
Stefan Vogel <sv@exept.de>
parents: 7062
diff changeset
  1963
        ] ifFalse:[
2be1214a5dcf #BUGFIX
Stefan Vogel <sv@exept.de>
parents: 7062
diff changeset
  1964
            self paint isImage ifTrue:[
2be1214a5dcf #BUGFIX
Stefan Vogel <sv@exept.de>
parents: 7062
diff changeset
  1965
                "/ #todo: fill mask rectangle
2be1214a5dcf #BUGFIX
Stefan Vogel <sv@exept.de>
parents: 7062
diff changeset
  1966
            ] ifFalse:[
2be1214a5dcf #BUGFIX
Stefan Vogel <sv@exept.de>
parents: 7062
diff changeset
  1967
                fontUsed displayString:aString from:index1 to:index2 x:x rounded y:y rounded in:self opaque:opaque.
2be1214a5dcf #BUGFIX
Stefan Vogel <sv@exept.de>
parents: 7062
diff changeset
  1968
            ].
2be1214a5dcf #BUGFIX
Stefan Vogel <sv@exept.de>
parents: 7062
diff changeset
  1969
        ].
2be1214a5dcf #BUGFIX
Stefan Vogel <sv@exept.de>
parents: 7062
diff changeset
  1970
        ^ self
2be1214a5dcf #BUGFIX
Stefan Vogel <sv@exept.de>
parents: 7062
diff changeset
  1971
    ].
2be1214a5dcf #BUGFIX
Stefan Vogel <sv@exept.de>
parents: 7062
diff changeset
  1972
2be1214a5dcf #BUGFIX
Stefan Vogel <sv@exept.de>
parents: 7062
diff changeset
  1973
6108
6ecfb89408d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6107
diff changeset
  1974
    fontId := fontUsed fontId.
6ecfb89408d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6107
diff changeset
  1975
    fontId isNil ifTrue:[
6626
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1976
        "this should not happen, since #onDevice tries replacement fonts"
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1977
        'STX[DeviceGraphicsContext] no font: ' errorPrint. fontUsed errorPrintCR.
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1978
        ^ self
5360
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1979
    ].
7064
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  1980
    deviceFont ~~ fontUsed ifTrue:[
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  1981
        device setFont:fontId in:gcId.
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  1982
        deviceFont := fontUsed
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  1983
    ].
5360
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1984
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1985
    "
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1986
     if bgPaint or paint is not a real Color (aka a pattern), we have to do it the hard way ...
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1987
    "
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1988
    easy := true.
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1989
    paint isColor ifFalse:[
6626
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1990
        easy := false
5360
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1991
    ] ifTrue:[
6626
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1992
        fgId := paint colorId.
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1993
        fgId isNil ifTrue:[
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1994
            easy := false
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1995
        ]
5360
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1996
    ].
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1997
    opaque ifTrue:[
6626
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1998
        bgPaint isColor ifFalse:[
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1999
            easy := false
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  2000
        ] ifTrue:[
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  2001
            bgId := bgPaint colorId.
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  2002
            bgId isNil ifTrue:[
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  2003
                easy := false
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  2004
            ]
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  2005
        ].
5360
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  2006
    ].
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  2007
7064
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  2008
    transformation notNil ifTrue:[
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  2009
        pO := transformation transformPoint:(x@y).
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  2010
        pX := pO x.
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  2011
        pY := pO y.
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  2012
    ] ifFalse:[
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  2013
        pX := x.
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  2014
        pY := y.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2015
    ].
7064
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  2016
    pX := pX rounded.
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  2017
    pY := pY rounded.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2018
5360
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  2019
    "/ check if this string is too long and cut it into a managable size.
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  2020
    "/ this is due to win32 limitations which seems to be unable to handle strings
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  2021
    "/ which are drawn longer than 32k pixels.
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  2022
    (index2 - index1) > 500 ifTrue:[
6626
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  2023
        nSkipLeft := wSkipLeft := 0.
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  2024
        wMax := self width.
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  2025
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  2026
        "/ if the draw starts to the left of the window start,
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  2027
        "/ skip some characters at the beginning...
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  2028
        pX < 0 ifTrue:[
5360
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  2029
"/ ('x=%d wMax=%d l=%d i1=%d i2=%d' printfWith:x with:wMax with:aString size with:index1 with:index2) printCR.
6626
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  2030
            nSkipLeft := (pX negated // font width) min:index2.                         "/ estimate
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  2031
            wSkipLeft := fontUsed widthOf:aString from:index1 to:index1+nSkipLeft-1.    "/ actual number of pixels
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  2032
            [ ((pX+wSkipLeft) > 0) and:[nSkipLeft > 0]] whileTrue:[                      "/ too many
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  2033
                nSkipLeft := (nSkipLeft * 0.9) rounded.
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  2034
                wSkipLeft := fontUsed widthOf:aString from:index1 to:index1+nSkipLeft-1.
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  2035
            ].
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  2036
            index1 := index1 + nSkipLeft.
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  2037
            pX := pX + wSkipLeft.
5360
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  2038
"/ ('skip %d w=%d x=%d' printfWith:nSkipLeft with:wSkipLeft with:x) printCR.
6626
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  2039
        ].
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  2040
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  2041
        "/ if the draw ends to the right of the window ends,
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  2042
        "/ skip some characters at the end...
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  2043
        nChars := wMax // font width + 2.                                       "/ estimate
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  2044
        index2Guess := (index1+nChars-1) min:index2.
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  2045
        wString := fontUsed widthOf:aString from:index1 to:index2Guess.     "/ actual number of pixels
5360
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  2046
"/ ('n=%d w=%d' printfWith:nChars with:wString) printCR.
6626
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  2047
        [ ((pX+wString) < wMax) and:[ index2Guess < index2] ] whileTrue:[  "/ not enough...
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  2048
            nChars := (nChars * 1.1) rounded.
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  2049
            index2Guess := (index1+nChars-1) min:index2.
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  2050
            wString := fontUsed widthOf:aString from:index1 to:index2Guess.
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  2051
        ].
5360
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  2052
"/ ('n=%d w=%d' printfWith:nChars with:wString) printCR.
6626
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  2053
        index2 := index2Guess.
5360
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  2054
    ].
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  2055
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  2056
    easy ifTrue:[
6626
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  2057
        opaque ifTrue:[
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  2058
            device setForeground:fgId background:bgId in:gcId.
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  2059
            background := bgPaint.
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  2060
        ] ifFalse:[
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  2061
            device setForeground:fgId in:gcId.
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  2062
        ].
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  2063
        foreground := paint.
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  2064
        device displayString:s from:index1 to:index2 x:pX y:pY in:drawableId with:gcId opaque:opaque.
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  2065
        ^ self
5360
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  2066
    ].
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  2067
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  2068
    w := fontUsed widthOf:s from:index1 to:index2.
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  2069
    h := fontUsed height.
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  2070
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  2071
    (fgId notNil and:[function == #copy]) ifTrue:[
6626
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  2072
        "
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  2073
         only bg is dithered or a pattern; fill with bg first ...
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  2074
        "
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  2075
        savedPaint := paint.
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  2076
        self paint:bgPaint.
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  2077
        self fillDeviceRectangleX:pX y:(pY - fontUsed ascent) width:w height:h.
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  2078
        self paint:savedPaint.
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  2079
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  2080
        "
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  2081
         then draw using fgPaint (which is a real color)
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  2082
        "
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  2083
        device displayString:s from:index1 to:index2 x:pX y:pY in:drawableId with:gcId opaque:false.
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  2084
        ^ self
5360
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  2085
    ].
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  2086
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  2087
    "/ the very hard case (fg-dither)
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  2088
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  2089
    self displayDeviceOpaqueString:s from:index1 to:index2 in:fontUsed x:pX y:pY.
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  2090
5742
3edcdffa74ec changed: #displayString:from:to:x:y:opaque:
Stefan Vogel <sv@exept.de>
parents: 5406
diff changeset
  2091
    "Modified: / 30-06-1997 / 15:06:15 / cg"
3edcdffa74ec changed: #displayString:from:to:x:y:opaque:
Stefan Vogel <sv@exept.de>
parents: 5406
diff changeset
  2092
    "Modified: / 14-04-2011 / 11:11:00 / Stefan Vogel <sv@exept.de>"
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2093
!
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
displayString:aString x:x y:y
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2096
    "draw a string at the coordinate x/y -
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2097
     draw foreground-pixels only (in current paint-color),
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2098
     leaving background as-is. If the transformation involves scaling,
7345
8eea38c33a0b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7301
diff changeset
  2099
     the font's point-size is scaled as appropriate."
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2100
7064
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  2101
    aString isPlainString ifFalse:[
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  2102
        "
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  2103
         hook for non-strings (i.e. attributed text)
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  2104
         that 'thing' should know how to display itself ...
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  2105
        "
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  2106
        ^ aString displayOn:self x:x y:y
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  2107
    ].
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  2108
7060
Stefan Vogel <sv@exept.de>
parents: 6926
diff changeset
  2109
    self displayString:aString from:1 to:aString size x:x y:y opaque:false.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2110
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2111
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2112
displayUnscaledForm:formToDraw x:x y:y
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2113
    "draw a form or image non opaque and unscaled;
1592
7ec770f2047a faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents: 1517
diff changeset
  2114
     if its a 1-plane bitmap, 1-bits are drawn in the
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2115
     current paint-color, leaving pixels with 0-bits unchanged
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2116
     (i.e. only 1-bits are drawn from the form).
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2117
     If its a deep form (i.e. a pixmap) the current paint
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2118
     settings are ignored and the form is drawn as-is.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2119
     Care must be taken, that the paint color is correctly allocated
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2120
     (by sending #on: to the color) before doing so.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2121
     Using functions other than #copy only makes sense if you are
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2122
     certain, that the colors are real colors (actually, only for
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2123
     noColor or allColor).
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2124
     The origins coordinate is transformed, but the image itself is unscaled."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2125
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  2126
    |pX pY pO|
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2127
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2128
    transformation notNil ifTrue:[
6711
2b50385f7257 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
  2129
        pO := transformation transformPoint:(x@y).
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  2130
        pX := pO x.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  2131
        pY := pO y.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2132
    ] ifFalse:[
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  2133
        pX := x.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  2134
        pY := y.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2135
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2136
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2137
    self displayDeviceForm:formToDraw x:pX y:pY
1592
7ec770f2047a faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents: 1517
diff changeset
  2138
7ec770f2047a faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents: 1517
diff changeset
  2139
    "Modified: 12.4.1997 / 12:48:04 / cg"
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
displayUnscaledOpaqueForm:formToDraw x:x y:y
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2143
    "draw a form or image opaque and unscaled;
1592
7ec770f2047a faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents: 1517
diff changeset
  2144
     if its a 1-plane bitmap, 1-bits are drawn in the
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2145
     current paint-color, 0 bits in background color.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2146
     If its a deep form (i.e. a pixmap) the current paint
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2147
     settings are ignored and the form is drawn as-is (opaque).
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2148
     The origins coordinate is transformed, but the image itself is unscaled."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2149
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  2150
    |pX pY pO|
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2151
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2152
    transformation notNil ifTrue:[
6711
2b50385f7257 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
  2153
        pO := transformation transformPoint:(x@y).
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  2154
        pX := pO x.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  2155
        pY := pO y.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2156
    ] ifFalse:[
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  2157
        pX := x.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  2158
        pY := y.
732
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
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2161
    self displayDeviceOpaqueForm:formToDraw x:pX y:pY
1592
7ec770f2047a faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents: 1517
diff changeset
  2162
7ec770f2047a faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents: 1517
diff changeset
  2163
    "Modified: 12.4.1997 / 12:49:21 / cg"
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2164
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2165
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2166
displayUnscaledOpaqueString:aString from:index1 to:index2 x:x y:y
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2167
    "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
  2168
     Draw foreground pixels in paint-color, background pixels in bgPaint color."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2169
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  2170
    |pX pY pO|
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2171
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2172
    transformation notNil ifTrue:[
6711
2b50385f7257 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
  2173
        pO := transformation transformPoint:(x@y).
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  2174
        pX := pO x.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  2175
        pY := pO y.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2176
    ] ifFalse:[
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  2177
        pX := x.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  2178
        pY := y.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2179
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2180
    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
  2181
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2182
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2183
displayUnscaledOpaqueString:aString x:x y:y
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2184
    "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
  2185
     Draw foreground pixels in paint-color, background pixels in bgPaint color."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2186
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  2187
    |pX pY pO|
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2188
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2189
    transformation notNil ifTrue:[
6711
2b50385f7257 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
  2190
        pO := transformation transformPoint:(x@y).
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  2191
        pX := pO x.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  2192
        pY := pO y.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2193
    ] ifFalse:[
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  2194
        pX := x.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  2195
        pY := y.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2196
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2197
    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
  2198
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2199
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2200
displayUnscaledString:aString from:index1 to:index2 x:x y:y
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2201
    "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
  2202
     draw foreground-pixels only (in current paint-color), leaving background as-is."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2203
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  2204
    |pX pY pO|
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2205
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2206
    transformation notNil ifTrue:[
6711
2b50385f7257 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
  2207
        pO := transformation transformPoint:(x@y).
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  2208
        pX := pO x.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  2209
        pY := pO y.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2210
    ] ifFalse:[
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  2211
        pX := x.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  2212
        pY := y.
732
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
    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
  2215
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2216
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2217
displayUnscaledString:aString x:x y:y
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2218
    "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
  2219
     draw foreground-pixels only (in current paint-color), leaving background as-is."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2220
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  2221
    |pX pY pO|
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2222
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2223
    transformation notNil ifTrue:[
6711
2b50385f7257 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
  2224
        pO := transformation transformPoint:(x@y).
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  2225
        pX := pO x.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  2226
        pY := pO y.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2227
    ] ifFalse:[
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  2228
        pX := x.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  2229
        pY := y.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2230
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2231
    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
  2232
! !
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2233
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2234
!DeviceGraphicsContext methodsFor:'drawing in device coordinates'!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2235
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2236
displayDeviceForm:aForm x:x y:y
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2237
    "draw a form or image non opaque (i.e. only foreground color is drawn);
1592
7ec770f2047a faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents: 1517
diff changeset
  2238
     If its a 1-plane bitmap, 1-bits are drawn in the
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2239
     current paint-color, leaving pixels with 0-bits unchanged
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2240
     (i.e. only 1-bits are drawn from the form).
1592
7ec770f2047a faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents: 1517
diff changeset
  2241
     If its a deep form (i.e. a pixmap) the current paint
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2242
     settings are ignored and the form is drawn as-is;
1592
7ec770f2047a faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents: 1517
diff changeset
  2243
     however, the mask is applied if present.
7ec770f2047a faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents: 1517
diff changeset
  2244
7ec770f2047a faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents: 1517
diff changeset
  2245
     The form should must have been allocated on the same device,
7ec770f2047a faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents: 1517
diff changeset
  2246
     otherwise its converted here, which slows down the draw.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2247
     No transformation or scaling is done.
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2248
     Care must be taken, that the paint color is correctly allocated
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2249
     (by sending #on: to the color) before doing so.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2250
     Using functions other than #copy only makes sense if you are
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2251
     certain, that the colors are real colors (actually, only for
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2252
     noColor or allColor)."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2253
6497
8edaeadf6658 Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents: 6484
diff changeset
  2254
    |id w h easy paintDither depth tmpForm tmpId tmpGCId
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2255
     fgId noColor allColor allBits pX pY
2865
a97dc9f1e21a no need to create a GC for source bitmap under X
Claus Gittinger <cg@exept.de>
parents: 2835
diff changeset
  2256
     mask maskId deviceForm deviceFormGCId deviceMask colorMap|
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2257
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2258
    w := aForm width.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2259
    h := aForm height.
6612
5c05ccaf6275 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6514
diff changeset
  2260
    (w = 0 or:[h = 0]) ifTrue:[^ self].
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2261
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2262
    pX := x rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2263
    pY := y rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2264
1034
5f6f417dcb12 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1033
diff changeset
  2265
    deviceForm := aForm asFormOn:device.
2192
01f76f23f03f handle case when no deviceForms can be created,
Claus Gittinger <cg@exept.de>
parents: 2065
diff changeset
  2266
    deviceForm isNil ifTrue:[
6484
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2267
        'DeviceGraphicsContext [warning]: cannot create device-form' errorPrintCR.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2268
        ^self
2192
01f76f23f03f handle case when no deviceForms can be created,
Claus Gittinger <cg@exept.de>
parents: 2065
diff changeset
  2269
    ].
976
807b42b00353 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 975
diff changeset
  2270
    id := deviceForm id.
807b42b00353 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 975
diff changeset
  2271
807b42b00353 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 975
diff changeset
  2272
    id isNil ifTrue:[
6484
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2273
        'DeviceGraphicsContext [warning]: invalid form draw - ignored' errorPrintCR.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2274
        ^ self
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2275
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2276
    gcId isNil ifTrue:[
6484
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2277
        self initGC
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2278
    ].
2865
a97dc9f1e21a no need to create a GC for source bitmap under X
Claus Gittinger <cg@exept.de>
parents: 2835
diff changeset
  2279
    (deviceFormGCId := deviceForm gcId) isNil ifTrue:[
6484
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2280
        "/ device needGCForBitmapSource  - i.e. WIN32
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2281
        device platformName ~= 'X11' ifTrue:[
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2282
            deviceForm initGC.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2283
            deviceFormGCId := deviceForm gcId.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2284
        ]
2865
a97dc9f1e21a no need to create a GC for source bitmap under X
Claus Gittinger <cg@exept.de>
parents: 2835
diff changeset
  2285
    ].
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2286
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2287
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2288
     a deep form ignores paint/bgPaint settings
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2289
    "
1085
3513a4cae87b handle depth1-images with a mask
Claus Gittinger <cg@exept.de>
parents: 1064
diff changeset
  2290
    mask := aForm mask.
6497
8edaeadf6658 Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents: 6484
diff changeset
  2291
    depth := aForm depth.
8edaeadf6658 Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents: 6484
diff changeset
  2292
8edaeadf6658 Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents: 6484
diff changeset
  2293
    (mask notNil or:[depth ~~ 1]) ifTrue:[
6484
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2294
        mask notNil ifTrue:[
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2295
            mask depth ~~ 1 ifTrue:[
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2296
                'DEVGC: alpha channel not yet supported' errorPrintCR.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2297
            ] ifFalse:[
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2298
                deviceMask := mask asFormOn:device.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2299
                deviceMask isNil ifTrue:[
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2300
                    'DeviceGraphicsContext [warning]: cannot create device-mask' errorPrintCR.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2301
                    ^self
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2302
                ].
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2303
                maskId := deviceMask id.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2304
                maskId notNil ifTrue:[
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2305
                    deviceMask gcId isNil ifTrue:[deviceMask initGC].
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2306
                    allColor := Color allColor.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2307
                    allBits := allColor colorId.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2308
6497
8edaeadf6658 Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents: 6484
diff changeset
  2309
                    (aForm maskedPixelsAre0
8edaeadf6658 Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents: 6484
diff changeset
  2310
                     and:[depth == 1 or:[deviceForm depth == device depth]]) ifTrue:[
6484
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2311
                        "/ can do it without a temporary pixmap:
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2312
                        "/   or-in the form into the inverse stamped-out area
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2313
                        "/   of the destination.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2314
                        "/   Oring is of course only possible if we know that
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2315
                        "/   masked pixels are already zero in the form.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2316
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2317
                        "/ stamp out using mask
6497
8edaeadf6658 Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents: 6484
diff changeset
  2318
                        device 
8edaeadf6658 Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents: 6484
diff changeset
  2319
                            setForeground:0 background:allBits in:gcId;
8edaeadf6658 Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents: 6484
diff changeset
  2320
                            setFunction:#and in:gcId;
6484
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2321
                            copyPlaneFromPixmapId:maskId
6497
8edaeadf6658 Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents: 6484
diff changeset
  2322
                                x:0
8edaeadf6658 Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents: 6484
diff changeset
  2323
                                y:0
8edaeadf6658 Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents: 6484
diff changeset
  2324
                                gc:(deviceMask gcId)
8edaeadf6658 Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents: 6484
diff changeset
  2325
                                to:drawableId
8edaeadf6658 Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents: 6484
diff changeset
  2326
                                x:pX
8edaeadf6658 Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents: 6484
diff changeset
  2327
                                y:pY
8edaeadf6658 Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents: 6484
diff changeset
  2328
                                gc:gcId
8edaeadf6658 Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents: 6484
diff changeset
  2329
                                width:w
8edaeadf6658 Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents: 6484
diff changeset
  2330
                                height:h.
8edaeadf6658 Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents: 6484
diff changeset
  2331
6484
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2332
                        "/ or-in the form
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2333
                        device setFunction:#or in:gcId.
6497
8edaeadf6658 Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents: 6484
diff changeset
  2334
                        depth == 1 ifTrue:[
8edaeadf6658 Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents: 6484
diff changeset
  2335
                            (colorMap := deviceForm colorMap) notNil ifTrue:[
8edaeadf6658 Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents: 6484
diff changeset
  2336
                                colorMap size < 2 ifTrue:[
8edaeadf6658 Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents: 6484
diff changeset
  2337
                                    device
8edaeadf6658 Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents: 6484
diff changeset
  2338
                                        setForegroundColor:(colorMap at:1)
8edaeadf6658 Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents: 6484
diff changeset
  2339
                                        backgroundColor:(Color noColor)
8edaeadf6658 Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents: 6484
diff changeset
  2340
                                        in:gcId.
8edaeadf6658 Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents: 6484
diff changeset
  2341
                                ] ifFalse:[
8edaeadf6658 Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents: 6484
diff changeset
  2342
                                    device
8edaeadf6658 Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents: 6484
diff changeset
  2343
                                        setForegroundColor:(colorMap at:2)
8edaeadf6658 Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents: 6484
diff changeset
  2344
                                        backgroundColor:(colorMap at:1)
8edaeadf6658 Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents: 6484
diff changeset
  2345
                                        in:gcId.
8edaeadf6658 Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents: 6484
diff changeset
  2346
                                ]
8edaeadf6658 Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents: 6484
diff changeset
  2347
                            ].
8edaeadf6658 Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents: 6484
diff changeset
  2348
                            device
8edaeadf6658 Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents: 6484
diff changeset
  2349
                                copyPlaneFromPixmapId:id
8edaeadf6658 Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents: 6484
diff changeset
  2350
                                x:0
8edaeadf6658 Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents: 6484
diff changeset
  2351
                                y:0
8edaeadf6658 Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents: 6484
diff changeset
  2352
                                gc:deviceFormGCId
8edaeadf6658 Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents: 6484
diff changeset
  2353
                                to:drawableId
8edaeadf6658 Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents: 6484
diff changeset
  2354
                                x:pX
8edaeadf6658 Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents: 6484
diff changeset
  2355
                                y:pY
8edaeadf6658 Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents: 6484
diff changeset
  2356
                                gc:gcId
8edaeadf6658 Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents: 6484
diff changeset
  2357
                                width:w
8edaeadf6658 Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents: 6484
diff changeset
  2358
                                height:h.
8edaeadf6658 Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents: 6484
diff changeset
  2359
                        ] ifFalse:[
8edaeadf6658 Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents: 6484
diff changeset
  2360
                            device
8edaeadf6658 Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents: 6484
diff changeset
  2361
                                copyFromPixmapId:id
8edaeadf6658 Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents: 6484
diff changeset
  2362
                                x:0
8edaeadf6658 Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents: 6484
diff changeset
  2363
                                y:0
8edaeadf6658 Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents: 6484
diff changeset
  2364
                                gc:deviceFormGCId
8edaeadf6658 Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents: 6484
diff changeset
  2365
                                to:drawableId
8edaeadf6658 Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents: 6484
diff changeset
  2366
                                x:pX
8edaeadf6658 Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents: 6484
diff changeset
  2367
                                y:pY
8edaeadf6658 Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents: 6484
diff changeset
  2368
                                gc:gcId
8edaeadf6658 Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents: 6484
diff changeset
  2369
                                width:w
8edaeadf6658 Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents: 6484
diff changeset
  2370
                                height:h.
8edaeadf6658 Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents: 6484
diff changeset
  2371
                        ].
6484
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2372
                    ] ifFalse:[
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2373
                        "/ must do it slow, using a temporary form ..
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2374
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2375
                        "
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2376
                         create temp-form;
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2377
                        "
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2378
                        tmpForm := Form width:w height:h depth:device depth onDevice:device.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2379
                        tmpForm isNil ifTrue:[
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2380
                            'DeviceGraphicsContext [warning]: cannot create temp form' errorPrintCR.
6497
8edaeadf6658 Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents: 6484
diff changeset
  2381
                            ^ self
6484
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2382
                        ].
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2383
                        tmpForm initGC.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2384
                        tmpId := tmpForm id.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2385
                        tmpGCId := tmpForm gcId.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2386
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2387
                        "
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2388
                         fill tempform with image
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2389
                        "
6497
8edaeadf6658 Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents: 6484
diff changeset
  2390
                        depth == 1 ifTrue:[
6484
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2391
                            (colorMap := deviceForm colorMap) notNil ifTrue:[
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2392
                                colorMap size < 2 ifTrue:[
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2393
                                    device
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2394
                                        setForegroundColor:(colorMap at:1)
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2395
                                        in:tmpGCId.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2396
                                ] ifFalse:[
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2397
                                    device
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2398
                                        setForegroundColor:(colorMap at:2)
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2399
                                        backgroundColor:(colorMap at:1)
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2400
                                        in:tmpGCId.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2401
                                ]
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2402
                            ].
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2403
                            device
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2404
                                copyPlaneFromPixmapId:id
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2405
                                x:0
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2406
                                y:0
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2407
                                gc:deviceFormGCId
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2408
                                to:tmpId
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2409
                                x:0
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2410
                                y:0
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2411
                                gc:tmpGCId
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2412
                                width:w
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2413
                                height:h.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2414
                        ] ifFalse:[
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2415
                            device
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2416
                                copyFromPixmapId:id
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2417
                                x:0
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2418
                                y:0
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2419
                                gc:deviceFormGCId
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2420
                                to:tmpId
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2421
                                x:0
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2422
                                y:0
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2423
                                gc:tmpGCId
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2424
                                width:w
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2425
                                height:h.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2426
                        ].
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2427
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2428
                        "
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2429
                         stamp out mask in temp form
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2430
                        "
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2431
                        device 
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2432
                            setForeground:allBits background:0 in:tmpGCId;
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2433
                            setFunction:#and in:tmpGCId;
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2434
                            copyPlaneFromPixmapId:maskId
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2435
                                x:0
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2436
                                y:0
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2437
                                gc:(deviceMask gcId)
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2438
                                to:tmpId
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2439
                                x:0
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2440
                                y:0
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2441
                                gc:tmpGCId
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2442
                                width:w
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2443
                                height:h.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2444
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2445
                        "
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2446
                         stamp out mask in destination
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2447
                        "
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2448
                        device 
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2449
                            setForeground:0 background:allBits in:gcId;
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2450
                            setFunction:#and in:gcId;
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2451
                            copyPlaneFromPixmapId:maskId
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2452
                                x:0
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2453
                                y:0
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2454
                                gc:(deviceMask gcId)
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2455
                                to:drawableId
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2456
                                x:pX
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2457
                                y:pY
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2458
                                gc:gcId
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2459
                                width:w
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2460
                                height:h.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2461
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2462
                        "
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2463
                         or-in tempform-bits ...
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2464
                        "
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2465
                        device 
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2466
                            setFunction:#or in:gcId;
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2467
                            copyFromPixmapId:tmpId
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2468
                                x:0
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2469
                                y:0
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2470
                                gc:tmpGCId
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2471
                                to:drawableId
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2472
                                x:pX
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2473
                                y:pY
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2474
                                gc:gcId
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2475
                                width:w
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2476
                                height:h.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2477
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2478
                        "
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2479
                         release tempForm immediately
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2480
                         (although GC will eventually do it,
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2481
                          this creates less stress to the Xserver in the meanwhile ...)
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2482
                        "
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2483
                        tmpForm destroy.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2484
                    ].
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2485
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2486
                    "/ restore GC
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2487
                    foreground notNil ifTrue:[
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2488
                        device setForegroundColor:foreground in:gcId.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2489
                    ].
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2490
                    background notNil ifTrue:[
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2491
                        device setBackgroundColor:background in:gcId
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2492
                    ].
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2493
                    device setFunction:function in:gcId.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2494
                    ^ self
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2495
                ]
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2496
            ]
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2497
        ].
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2498
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2499
        device
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2500
            copyFromPixmapId:id
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2501
            x:0
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2502
            y:0
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2503
            gc:deviceForm gcId
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2504
            to:drawableId
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2505
            x:pX
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2506
            y:pY
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2507
            gc:gcId
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2508
            width:w
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2509
            height:h.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2510
        ^ self
732
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
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2514
     the following code is somewhat complicated, since it has to deal
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2515
     with dithered paint colors, which cannot be done directly on most
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2516
     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
  2517
     (just assume drawing a bitmap with dithered paint color ... sigh)
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
1507
358603f58138 faster drawing in or-mode.
Claus Gittinger <cg@exept.de>
parents: 1453
diff changeset
  2520
    easy := (function == #copy).
358603f58138 faster drawing in or-mode.
Claus Gittinger <cg@exept.de>
parents: 1453
diff changeset
  2521
732
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
     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
  2524
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2525
    easy ifTrue:[
6484
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2526
        paint isColor ifTrue:[
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2527
            paintDither := paint ditherForm.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2528
            paintDither notNil ifTrue:[
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2529
                easy := false.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2530
            ]
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2531
        ] ifFalse:[
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2532
            paintDither := paint.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2533
            easy := false
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2534
        ].
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2535
    ].
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
    allColor := Color allColor.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2538
    allBits := allColor colorId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2539
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2540
    easy ifTrue:[
6484
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2541
        "
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2542
         paint is a real color
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2543
        "
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2544
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2545
        "
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2546
         if paint color is all-0 or all-1's, we can do it in one
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2547
         operation ...
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2548
        "
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2549
        fgId := paint colorId.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2550
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2551
        ((fgId ~~ ((1 bitShift:device depth)-1))
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2552
        and:[fgId ~~ allBits]) ifTrue:[
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2553
            "
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2554
             clear fg-bits ...
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2555
            "
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2556
            device setForeground:0 background:allBits in:gcId.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2557
            device setFunction:#and in:gcId.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2558
            device
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2559
                copyPlaneFromPixmapId:id
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2560
                x:0
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2561
                y:0
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2562
                gc:deviceFormGCId
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2563
                to:drawableId
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2564
                x:pX
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2565
                y:pY
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2566
                gc:gcId
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2567
                width:w
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2568
                height:h.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2569
        ].
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2570
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2571
        fgId ~~ 0 ifTrue:[
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2572
            "
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2573
             or-in fg-bits ...
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2574
            "
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2575
            device setForeground:fgId background:0 in:gcId.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2576
            device setFunction:#or in:gcId.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2577
            device
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2578
                copyPlaneFromPixmapId:id
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2579
                x:0
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2580
                y:0
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2581
                gc:deviceFormGCId
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2582
                to:drawableId
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2583
                x:pX
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2584
                y:pY
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2585
                gc:gcId
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2586
                width:w
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2587
                height:h
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2588
        ].
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2589
        "
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2590
         flush foreground/background cache
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2591
        "
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2592
        foreground := nil.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2593
        background := nil.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2594
        device setFunction:function in:gcId.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2595
        ^ self
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2596
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2597
1507
358603f58138 faster drawing in or-mode.
Claus Gittinger <cg@exept.de>
parents: 1453
diff changeset
  2598
    function == #or ifTrue:[
6484
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2599
        easy := paint notNil
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2600
                and:[paint isColor
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2601
                and:[paint ditherForm isNil]].
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2602
        easy ifTrue:[
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2603
            easy := bgPaint isNil
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2604
                        or:[bgPaint isColor
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2605
                            and:[bgPaint colorId == 0]]
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2606
        ].
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2607
        easy ifTrue:[
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2608
            fgId := paint colorId.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2609
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2610
            fgId ~~ 0 ifTrue:[
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2611
                "
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2612
                 or-in fg-bits ...
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2613
                "
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2614
                device setForeground:fgId background:0 in:gcId.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2615
                device
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2616
                    copyPlaneFromPixmapId:id
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2617
                    x:0
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2618
                    y:0
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2619
                    gc:deviceFormGCId
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2620
                    to:drawableId
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2621
                    x:pX
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2622
                    y:pY
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2623
                    gc:gcId
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2624
                    width:w
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2625
                    height:h
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2626
            ].
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2627
            "
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2628
             flush foreground/background cache
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2629
            "
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2630
            foreground := nil.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2631
            background := nil.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2632
            ^ self
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2633
        ].
1507
358603f58138 faster drawing in or-mode.
Claus Gittinger <cg@exept.de>
parents: 1453
diff changeset
  2634
    ].
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2635
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2636
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2637
     hard case; paint is a dithered color
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2638
    "
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
    noColor := Color noColor.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2641
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
     create temp-form;
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2644
    "
4756
dd597f8839cb changed #displayDeviceForm:x:y:
Claus Gittinger <cg@exept.de>
parents: 4752
diff changeset
  2645
    tmpForm := Form width:w height:h depth:device depth onDevice:device.
2192
01f76f23f03f handle case when no deviceForms can be created,
Claus Gittinger <cg@exept.de>
parents: 2065
diff changeset
  2646
    tmpForm isNil ifTrue:[
6484
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2647
        'DeviceGraphicsContext [warning]: cannot create temp form' errorPrintCR.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2648
        ^self
2192
01f76f23f03f handle case when no deviceForms can be created,
Claus Gittinger <cg@exept.de>
parents: 2065
diff changeset
  2649
    ].
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2650
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2651
     fill tempform
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2652
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2653
    tmpForm paint:paint.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2654
    tmpForm fillRectangleX:0 y:0 width:w height:h.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2655
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2656
     stamp out background
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
    tmpForm paint:allColor on:noColor.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2659
    tmpForm function:#and.
976
807b42b00353 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 975
diff changeset
  2660
    tmpForm displayOpaqueForm:deviceForm x:0 y:0.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2661
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2662
     stamp out foreground from destination
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2663
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2664
    device setForeground:0 background:allBits in:gcId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2665
    device setFunction:#and in:gcId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2666
    device
6484
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2667
        copyPlaneFromPixmapId:id
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2668
        x:0
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2669
        y:0
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2670
        gc:deviceFormGCId
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2671
        to:drawableId
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2672
        x:pX
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2673
        y:pY
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2674
        gc:gcId
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2675
        width:w
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2676
        height:h.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2677
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2678
     or-in temp into destination
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
    device setForeground:allBits background:0 in:gcId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2681
    device setFunction:#or in:gcId.
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
    device
6484
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2684
        copyFromPixmapId:tmpForm id
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2685
        x:0
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2686
        y:0
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2687
        gc:tmpForm gcId
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2688
        to:drawableId
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2689
        x:pX
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2690
        y:pY
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2691
        gc:gcId
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2692
        width:w
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2693
        height:h.
1637
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  2694
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  2695
    "
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  2696
     release tempForm immediately
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2697
     (although GC will eventually do it,
1637
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  2698
      this creates less stress to the Xserver in the meanwhile ...)
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  2699
    "
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  2700
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  2701
    tmpForm destroy.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2702
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2703
     flush foreground/background cache
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2704
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2705
    foreground := nil.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2706
    background := nil.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2707
    device setFunction:function in:gcId.
768
77e4f9d30a22 fixes for b&w screens
Claus Gittinger <cg@exept.de>
parents: 745
diff changeset
  2708
4756
dd597f8839cb changed #displayDeviceForm:x:y:
Claus Gittinger <cg@exept.de>
parents: 4752
diff changeset
  2709
    "Modified: / 27-05-2007 / 12:45:10 / cg"
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2710
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2711
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2712
displayDeviceLineFromX:x0 y:y0 toX:x1 y:y1
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2713
    "draw a line (with current paint-color) in device coordinate space.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2714
     This ignores any transformations. The coordinates must be integers."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2715
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2716
    gcId isNil ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2717
	self initGC
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2718
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2719
    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
  2720
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2721
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2722
displayDeviceOpaqueForm:aForm x:x y:y
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2723
    "draw a form or image opaque (i.e. both fg and bg is drawn);
1592
7ec770f2047a faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents: 1517
diff changeset
  2724
     If its a 1-plane bitmap, 1-bits are drawn in the
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2725
     current paint-color and 0-bits in the bgPaint color.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2726
     If its a deep form (i.e. a pixmap) the current paint/bgPaint
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2727
     settings are ignored and the form drawn as-is.
1592
7ec770f2047a faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents: 1517
diff changeset
  2728
     Any mask is ignored.
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2729
     In the 1-plane case, special care must be taken if paint and/or bgPaint
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2730
     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
  2731
     to the colors) before doing so.
1592
7ec770f2047a faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents: 1517
diff changeset
  2732
     The form should have been allocated on the same device; otherwise,
7ec770f2047a faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents: 1517
diff changeset
  2733
     its converted here, which slows down the draw.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2734
     Drawing is in device coordinates; no scaling is done."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2735
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2736
    |id w h easy savedPaint bgForm fgForm tmpForm
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2737
     fgId bgId noColor allColor allBits dx dy
976
807b42b00353 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 975
diff changeset
  2738
     pX pY deviceDepth deviceForm|
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2739
1033
b5cd84ed805f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1029
diff changeset
  2740
    deviceForm := aForm asFormOn:device.
976
807b42b00353 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 975
diff changeset
  2741
    id := deviceForm id.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2742
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2743
    "temporary ..."
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2744
    (id isNil
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2745
    or:[aForm graphicsDevice ~~ device]) ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2746
	deviceForm := deviceForm asFormOn:device.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2747
	id := deviceForm id.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2748
	id isNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2749
	    'DeviceGraphicsContext [warning]: invalid form draw - ignored' errorPrintCR.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2750
	    ^ self
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2751
	].
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2752
    ].
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
    gcId isNil ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2755
	self initGC
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2756
    ].
2065
27bf0cf42e45 changes for WIN32
Claus Gittinger <cg@exept.de>
parents: 2049
diff changeset
  2757
    deviceForm gcId isNil ifTrue:[deviceForm initGC].
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2758
1592
7ec770f2047a faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents: 1517
diff changeset
  2759
    w := aForm width.
7ec770f2047a faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents: 1517
diff changeset
  2760
    h := aForm height.
7ec770f2047a faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents: 1517
diff changeset
  2761
7ec770f2047a faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents: 1517
diff changeset
  2762
    pX := x rounded.
7ec770f2047a faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents: 1517
diff changeset
  2763
    pY := y rounded.
7ec770f2047a faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents: 1517
diff changeset
  2764
902
7f5d81d377de opaque image display fix
Claus Gittinger <cg@exept.de>
parents: 895
diff changeset
  2765
    "
7f5d81d377de opaque image display fix
Claus Gittinger <cg@exept.de>
parents: 895
diff changeset
  2766
     a deep form ignores paint/bgPaint settings
7f5d81d377de opaque image display fix
Claus Gittinger <cg@exept.de>
parents: 895
diff changeset
  2767
     and is always drawn opaque.
7f5d81d377de opaque image display fix
Claus Gittinger <cg@exept.de>
parents: 895
diff changeset
  2768
    "
7f5d81d377de opaque image display fix
Claus Gittinger <cg@exept.de>
parents: 895
diff changeset
  2769
    (aForm depth ~~ 1) ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2770
	device
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2771
	    copyFromPixmapId:id
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2772
	    x:0
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2773
	    y:0
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2774
	    gc:deviceForm gcId
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2775
	    to:drawableId
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2776
	    x:pX
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2777
	    y:pY
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2778
	    gc:gcId
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2779
	    width:w
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2780
	    height:h.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2781
	^ self
902
7f5d81d377de opaque image display fix
Claus Gittinger <cg@exept.de>
parents: 895
diff changeset
  2782
    ].
7f5d81d377de opaque image display fix
Claus Gittinger <cg@exept.de>
parents: 895
diff changeset
  2783
7f5d81d377de opaque image display fix
Claus Gittinger <cg@exept.de>
parents: 895
diff changeset
  2784
    "/ if no bgPaint is set, this is a non-opaque draw
7f5d81d377de opaque image display fix
Claus Gittinger <cg@exept.de>
parents: 895
diff changeset
  2785
7f5d81d377de opaque image display fix
Claus Gittinger <cg@exept.de>
parents: 895
diff changeset
  2786
    bgPaint isNil ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2787
	self displayDeviceForm:aForm x:x y:y.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2788
	^ self
902
7f5d81d377de opaque image display fix
Claus Gittinger <cg@exept.de>
parents: 895
diff changeset
  2789
    ].
7f5d81d377de opaque image display fix
Claus Gittinger <cg@exept.de>
parents: 895
diff changeset
  2790
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2791
    "the following code is somewhat complicated, since it has to deal
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2792
     with dithered fg/bg colors, which cannot be done directly on most
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2793
     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
  2794
     (just assume drawing a bitmap with dithered fg/bg colors ... sigh)
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2795
    "
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
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2798
     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
  2799
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2800
    easy := true.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2801
    paint isColor ifFalse:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2802
	easy := false
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2803
    ] ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2804
	fgId := paint colorId.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2805
	fgId isNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2806
	    easy := false
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2807
	]
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2808
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2809
    bgPaint isColor ifFalse:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2810
	easy := false
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2811
    ] ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2812
	bgId := bgPaint colorId.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2813
	bgId isNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2814
	    easy := false
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2815
	]
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2816
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2817
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2818
    easy ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2819
	"
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2820
	 easy: both paint and bgPaint are real colors
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2821
	"
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2822
	((foreground ~~ paint) or:[background ~~ bgPaint]) ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2823
	    device setForeground:fgId background:bgId in:gcId.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2824
	    foreground := paint.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2825
	    background := bgPaint.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2826
	].
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2827
	device
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2828
	    copyPlaneFromPixmapId:id
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2829
	    x:0
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2830
	    y:0
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2831
	    gc:(deviceForm gcId)
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2832
	    to:drawableId
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2833
	    x:pX
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2834
	    y:pY
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2835
	    gc:gcId
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2836
	    width:w
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2837
	    height:h.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2838
	^ self
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2839
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2840
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2841
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2842
     hard case: paint and/or bgPaint are dithered or patterns
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2843
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2844
    allColor := Color allColor.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2845
    allBits := allColor colorId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2846
    deviceDepth := device depth.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2847
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2848
    (fgId notNil and:[function == #copy]) ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2849
	"
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2850
	 only bg is dithered; fill with bg first ...
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2851
	"
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2852
	savedPaint := paint.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2853
	self paint:bgPaint.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2854
	self fillDeviceRectangleX:pX y:pY width:w height:h.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2855
	self paint:savedPaint.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2856
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2857
	"
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2858
	 if paint color is all-0 or all-1's, we can do it in one
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2859
	 operation ...
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2860
	"
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2861
	((fgId ~~ ((1 bitShift:deviceDepth)-1))
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2862
	and:[fgId ~~ allBits]) ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2863
	    "
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2864
	     clear fg-bits ...
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2865
	    "
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2866
	    device setForeground:0 background:allBits in:gcId.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2867
	    device setFunction:#and in:gcId.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2868
	    device
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2869
		copyPlaneFromPixmapId:id
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2870
		x:0
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2871
		y:0
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2872
		gc:(deviceForm gcId)
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2873
		to:drawableId
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2874
		x:pX
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2875
		y:pY
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2876
		gc:gcId
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2877
		width:w
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2878
		height:h
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2879
	].
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2880
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2881
	fgId ~~ 0 ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2882
	    "
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2883
	     or-in fg-bits ...
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2884
	    "
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2885
	    device setForeground:fgId background:0 in:gcId.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2886
	    device setFunction:#or in:gcId.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2887
	    device
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2888
		copyPlaneFromPixmapId:id
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2889
		x:0
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2890
		y:0
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2891
		gc:(deviceForm gcId)
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2892
		to:drawableId
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2893
		x:pX
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2894
		y:pY
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2895
		gc:gcId
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2896
		width:w
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2897
		height:h
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2898
	].
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2899
	"
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2900
	 flush foreground/background cache
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2901
	"
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2902
	foreground := nil.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2903
	background := nil.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2904
	device setFunction:function in:gcId.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2905
	^ self
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2906
    ].
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
    (bgId notNil and:[function == #copy]) ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2909
	"
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2910
	 only fg is dithered; fill with fg first ...
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2911
	"
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2912
	self fillDeviceRectangleX:pX y:pY width:w height:h.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2913
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2914
	"
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2915
	 if paint color is all-0 or all-1's, we can do it in one
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2916
	 operation ...
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2917
	"
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2918
	((bgId ~~ ((1 bitShift:deviceDepth)-1))
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2919
	and:[bgId ~~ allBits]) ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2920
	    "
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2921
	     clear bg-bits ...
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2922
	    "
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2923
	    device setForeground:allBits background:0 in:gcId.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2924
	    device setFunction:#and in:gcId.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2925
	    device
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2926
		copyPlaneFromPixmapId:id
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2927
		x:0
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2928
		y:0
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2929
		gc:(deviceForm gcId)
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2930
		to:drawableId
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2931
		x:pX
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2932
		y:pY
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2933
		gc:gcId
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2934
		width:w
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2935
		height:h
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2936
	].
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2937
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2938
	"
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2939
	 or-in bg-bits ...
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2940
	"
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2941
	bgId ~~ 0 ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2942
	    device setForeground:0 background:bgId in:gcId.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2943
	    device setFunction:#or in:gcId.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2944
	    device
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2945
		copyPlaneFromPixmapId:id
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2946
		x:0
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2947
		y:0
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2948
		gc:(deviceForm gcId)
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2949
		to:drawableId
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2950
		x:pX
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2951
		y:pY
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2952
		gc:gcId
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2953
		width:w
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2954
		height:h
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2955
	].
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2956
	"
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2957
	 flush foreground/background cache
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2958
	"
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2959
	foreground := nil.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2960
	background := nil.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2961
	device setFunction:function in:gcId.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2962
	^ self
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2963
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2964
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2965
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2966
     very hard case; both fg and bg are dithered colors
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2967
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2968
    noColor := Color noColor.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2969
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2970
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2971
     create temp-forms;
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2972
    "
4781
7f2473db5652 Change senders of obsolete messages Form>>...on: to ...onDevice:
Stefan Vogel <sv@exept.de>
parents: 4756
diff changeset
  2973
    bgForm := Form width:w height:h depth:deviceDepth onDevice:device.
7f2473db5652 Change senders of obsolete messages Form>>...on: to ...onDevice:
Stefan Vogel <sv@exept.de>
parents: 4756
diff changeset
  2974
    fgForm := Form width:w height:h depth:deviceDepth onDevice:device.
7f2473db5652 Change senders of obsolete messages Form>>...on: to ...onDevice:
Stefan Vogel <sv@exept.de>
parents: 4756
diff changeset
  2975
    tmpForm := Form width:w height:h depth:deviceDepth onDevice:device.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2976
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2977
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2978
     fill
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2979
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2980
    dx := dy := 0.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2981
    maskOrigin notNil ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2982
	dx := maskOrigin x.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2983
	dy := maskOrigin y
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2984
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2985
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2986
    bgForm paint:bgPaint.
4983
14c28ec55880 Replace usage of obsolete methods
Stefan Vogel <sv@exept.de>
parents: 4914
diff changeset
  2987
    bgForm maskOriginX:(x negated + dx) y:(y negated + dy).
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2988
    bgForm fillRectangleX:0 y:0 width:w height:h.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2989
    fgForm paint:paint.
4983
14c28ec55880 Replace usage of obsolete methods
Stefan Vogel <sv@exept.de>
parents: 4914
diff changeset
  2990
    fgForm maskOriginX:(x negated + dx) y:(y negated + dy).
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2991
    fgForm fillRectangleX:0 y:0 width:w height:h.
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
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2994
     stamp-out background
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
    bgForm paint:noColor on:allColor.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2997
    bgForm function:#and.
976
807b42b00353 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 975
diff changeset
  2998
    bgForm displayOpaqueForm:deviceForm x:0 y:0.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2999
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
     stamp-out foreground
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3002
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3003
    fgForm paint:allColor on:noColor.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3004
    fgForm function:#and.
976
807b42b00353 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 975
diff changeset
  3005
    fgForm displayOpaqueForm:deviceForm x:0 y:0.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3006
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
     clear tempform
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3009
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3010
    tmpForm paint:noColor.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3011
    tmpForm fillRectangleX:0 y:0 width:w height:h.
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
     merge fg-temp and bg-temp into tmp
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3015
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3016
    tmpForm function:#or.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3017
    tmpForm paint:noColor on:allColor.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3018
    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
  3019
    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
  3020
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
     finally, draw it
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3023
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3024
    device setForeground:0 background:allBits in:gcId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3025
    device
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3026
	copyFromPixmapId:tmpForm id
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3027
	x:0
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3028
	y:0
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3029
	gc:tmpForm gcId
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3030
	to:drawableId
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3031
	x:pX
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3032
	y:pY
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3033
	gc:gcId
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3034
	width:w
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3035
	height:h.
1637
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  3036
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  3037
    "
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  3038
     release tempForms immediately
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3039
     (although GC will eventually do it,
1637
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  3040
      this creates less stress to the Xserver in the meanwhile ...)
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  3041
    "
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  3042
    fgForm destroy.
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  3043
    bgForm destroy.
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  3044
    tmpForm destroy.
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  3045
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3046
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3047
     flush foreground/background cache
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3048
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3049
    foreground := nil.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3050
    background := nil.
868
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
  3051
1637
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  3052
    "Modified: 22.4.1997 / 21:44:10 / cg"
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3053
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3054
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3055
displayDeviceOpaqueString:aString from:index1 to:index2 in:font x:x y:y
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3056
    "draw a substring at the coordinate x/y - draw foreground pixels in
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3057
     paint-color and background pixels in bgPaint-color.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3058
     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
  3059
     the case where paint and/or bgPaint are dithered colors.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3060
     No translation or scaling is done."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3061
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3062
    |easy w h savedPaint fgId bgId allColor allBits noColor
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3063
     id bgForm fgForm tmpForm maskForm dx dy pX pY fontUsed s
4026
882de378f763 no longer as string for its encoding;
Claus Gittinger <cg@exept.de>
parents: 3943
diff changeset
  3064
     deviceDepth fontsEncoding ascent|
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3065
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
     if backgroundPaint color is nil, we assume
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3068
     this is a non-opaque draw
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
    bgPaint isNil ifTrue:[
7064
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3071
        self displayDeviceString:aString from:index1 to:index2 x:x y:y.
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3072
        ^ self
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3073
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3074
7064
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3075
    aString isPlainString ifFalse:[
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3076
        "
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3077
         hook for non-strings (i.e. attributed text)
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3078
         that 'thing' should know how to display itself ...
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3079
        "
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3080
        aString displayOpaqueOn:self x:x y:y from:index1 to:index2.
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3081
        ^ self
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3082
    ].
6210
af0bf039ec07 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6108
diff changeset
  3083
af0bf039ec07 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6108
diff changeset
  3084
    pX := x rounded.
af0bf039ec07 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6108
diff changeset
  3085
    pY := y rounded.
af0bf039ec07 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6108
diff changeset
  3086
6108
6ecfb89408d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6107
diff changeset
  3087
    font isAlienFont ifTrue:[
7064
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3088
        "
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3089
         hook for alien fonts
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3090
         that 'font' should know how to display the string ...
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3091
        "
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3092
        font displayOpaqueString:aString from:index1 to:index2 x:pX y:pY in:self.
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3093
        ^ self
6108
6ecfb89408d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6107
diff changeset
  3094
    ].
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
    gcId isNil ifTrue:[
7064
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3097
        self initGC
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3098
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3099
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3100
4026
882de378f763 no longer as string for its encoding;
Claus Gittinger <cg@exept.de>
parents: 3943
diff changeset
  3101
    s := aString.
4172
0d5bc2a70b83 Do not refer to uninitialized variable fontUsed
Stefan Vogel <sv@exept.de>
parents: 4146
diff changeset
  3102
    fontUsed := font onDevice:device.
4026
882de378f763 no longer as string for its encoding;
Claus Gittinger <cg@exept.de>
parents: 3943
diff changeset
  3103
    fontsEncoding := fontUsed encoding.
7288
fec0c6c1087b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7257
diff changeset
  3104
fec0c6c1087b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7257
diff changeset
  3105
    "/ This is now obsolete, as we are always using unicode internally.
fec0c6c1087b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7257
diff changeset
  3106
    "/ so the next line should be changed to fontsEncoding ~~ #unicode
4056
67c4686afbc6 characterEncoding stuff
Claus Gittinger <cg@exept.de>
parents: 4031
diff changeset
  3107
    (characterEncoding ~~ fontsEncoding) ifTrue:[
7064
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3108
        [
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3109
            s := CharacterEncoder encodeString:s from:characterEncoding into:fontsEncoding.
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3110
        ] on:CharacterEncoderError do:[:ex|
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3111
            "substitute a default value for codes that cannot be represented
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3112
             in the new character set"
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3113
            ex proceedWith:ex defaultValue.
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3114
        ].
4026
882de378f763 no longer as string for its encoding;
Claus Gittinger <cg@exept.de>
parents: 3943
diff changeset
  3115
    ].
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3116
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3117
    id := fontUsed fontId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3118
    id isNil ifTrue:[
7064
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3119
        "this should not happen, since #onDevice tries replacement fonts"
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3120
        'STX[DeviceGraphicsContext] no font: ' errorPrint. fontUsed errorPrintCR.
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3121
        ^ self
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3122
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3123
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3124
    deviceFont ~~ fontUsed ifTrue:[
7064
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3125
        device setFont:id in:gcId.
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3126
        deviceFont := fontUsed
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3127
    ].
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
     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
  3131
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3132
    easy := true.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3133
    paint isColor ifFalse:[
7064
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3134
        easy := false
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3135
    ] ifTrue:[
7064
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3136
        fgId := paint colorId.
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3137
        fgId isNil ifTrue:[
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3138
            easy := false
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3139
        ]
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3140
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3141
    bgPaint isColor ifFalse:[
7064
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3142
        easy := false
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3143
    ] ifTrue:[
7064
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3144
        bgId := bgPaint colorId.
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3145
        bgId isNil ifTrue:[
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3146
            easy := false
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3147
        ]
732
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
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3150
    easy ifTrue:[
7064
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3151
        device setForeground:fgId background:bgId in:gcId.
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3152
        foreground := paint.
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3153
        background := bgPaint.
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3154
        device displayOpaqueString:s from:index1 to:index2 x:pX y:pY in:drawableId with:gcId.
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3155
        ^ self
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3156
    ].
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
    w := fontUsed widthOf:s from:index1 to:index2.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3159
    h := fontUsed height.
3666
01d7bf1d2333 fixed Text drawing in displayString
Michael Beyl <mb@exept.de>
parents: 3630
diff changeset
  3160
    ascent := fontUsed ascent.
732
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
    (fgId notNil and:[function == #copy]) ifTrue:[
7064
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3163
        "
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3164
         only bg is dithered; fill with bg first ...
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3165
        "
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3166
        savedPaint := paint.
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3167
        self paint:bgPaint.
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3168
        self fillRectangleX:pX y:(pY - ascent) width:w height:h.
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3169
        self paint:savedPaint.
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3170
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3171
        "
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3172
         then draw using fgPaint (which is a real color)
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3173
        "
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3174
        device displayString:s from:index1 to:index2 x:pX y:pY in:drawableId with:gcId.
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3175
        ^ self
732
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
    allColor := Color allColor.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3179
    allBits := allColor colorId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3180
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3181
    deviceDepth := device depth.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3182
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3183
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3184
     the code below is correct, but some (all?) implementations of the
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3185
     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
  3186
     Therefore we use the slower code below.
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
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3189
"/    (bgId notNil and:[function == #copy]) ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3190
"/      "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3191
"/       only fg is dithered; fill with fg first ...
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
"/      self fillRectangleX:pX y:(pY - fontUsed ascent) width:w height:h.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3194
"/
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3195
"/      "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3196
"/       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
  3197
"/       operation ...
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3198
"/      "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3199
"/      ((bgId ~~ ((1 bitShift:deviceDepth)-1))
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3200
"/      and:[bgId ~~ allBits]) ifTrue:[
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
"/           clear bg bits ...
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3203
"/          "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3204
"/          device setForeground:allBits background:0 in:gcId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3205
"/          device setFunction:#and in:gcId.
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3206
"/          device displayOpaqueString:s
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3207
"/                                from:index1 to:index2
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3208
"/                                   x:pX y:pY
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3209
"/                                  in:drawableId with:gcId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3210
"/      ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3211
"/
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
"/       or-in bg bits ...
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3214
"/      "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3215
"/      bgId ~~ 0 ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3216
"/          device setForeground:0 background:bgId in:gcId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3217
"/          device setFunction:#or in:gcId.
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3218
"/          device displayOpaqueString:s
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3219
"/                                from:index1 to:index2
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3220
"/                                   x:pX y:pY
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3221
"/                                  in:drawableId with:gcId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3222
"/      ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3223
"/      "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3224
"/       flush foreground/background cache
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3225
"/      "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3226
"/      foreground := nil.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3227
"/      background := nil.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3228
"/      device setFunction:function in:gcId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3229
"/      ^ self
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3230
"/  ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3231
768
77e4f9d30a22 fixes for b&w screens
Claus Gittinger <cg@exept.de>
parents: 745
diff changeset
  3232
    (bgId notNil and:[function == #copy]) ifTrue:[
7064
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3233
        "
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3234
         only fg is dithered; fill with bg first ...
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3235
        "
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3236
        device setForeground:bgId in:gcId.
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3237
        device setFunction:#copy in:gcId.
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3238
        device setBitmapMask:nil in:gcId.
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3239
        self fillRectangleX:pX y:(pY - ascent) width:w height:h.
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3240
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3241
        mask notNil ifTrue:[
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3242
            "/ draw fg dithered
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3243
            (mask depth == 1) ifTrue:[
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3244
                device setBitmapMask:mask id in:gcId.
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3245
                device setForegroundColor:foreground backgroundColor:background in:gcId.
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3246
            ] ifFalse:[
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3247
                device setPixmapMask:mask id in:gcId
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3248
            ].
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3249
        ].
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3250
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3251
        device displayString:s from:index1 to:index2 x:pX y:pY in:drawableId with:gcId.
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3252
        ^ self.
832
064890dcfabd fixed opaque string draw with deep-dither
Claus Gittinger <cg@exept.de>
parents: 786
diff changeset
  3253
    ].
064890dcfabd fixed opaque string draw with deep-dither
Claus Gittinger <cg@exept.de>
parents: 786
diff changeset
  3254
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3255
    "
832
064890dcfabd fixed opaque string draw with deep-dither
Claus Gittinger <cg@exept.de>
parents: 786
diff changeset
  3256
     very hard case, both fg and bg are dithered colors/images
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3257
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3258
    noColor := Color noColor.
4026
882de378f763 no longer as string for its encoding;
Claus Gittinger <cg@exept.de>
parents: 3943
diff changeset
  3259
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3260
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3261
     create temp-forms;
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3262
    "
4781
7f2473db5652 Change senders of obsolete messages Form>>...on: to ...onDevice:
Stefan Vogel <sv@exept.de>
parents: 4756
diff changeset
  3263
    bgForm := Form width:w height:h depth:deviceDepth onDevice:device.
7f2473db5652 Change senders of obsolete messages Form>>...on: to ...onDevice:
Stefan Vogel <sv@exept.de>
parents: 4756
diff changeset
  3264
    fgForm := Form width:w height:h depth:deviceDepth onDevice:device.
7f2473db5652 Change senders of obsolete messages Form>>...on: to ...onDevice:
Stefan Vogel <sv@exept.de>
parents: 4756
diff changeset
  3265
    tmpForm := Form width:w height:h depth:deviceDepth onDevice:device.
7f2473db5652 Change senders of obsolete messages Form>>...on: to ...onDevice:
Stefan Vogel <sv@exept.de>
parents: 4756
diff changeset
  3266
    maskForm := Form width:w height:h depth:deviceDepth onDevice:device.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3267
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3268
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3269
     fill
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3270
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3271
    dx := 0.
3666
01d7bf1d2333 fixed Text drawing in displayString
Michael Beyl <mb@exept.de>
parents: 3630
diff changeset
  3272
    dy := ascent.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3273
    maskOrigin notNil ifTrue:[
7064
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3274
        dx := maskOrigin x.
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3275
        dy := dy + maskOrigin y
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3276
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3277
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3278
    bgForm paint:bgPaint.
4983
14c28ec55880 Replace usage of obsolete methods
Stefan Vogel <sv@exept.de>
parents: 4914
diff changeset
  3279
    bgForm maskOriginX:(pX negated + dx) y:(pY negated + dy).
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3280
    bgForm fillRectangleX:0 y:0 width:w height:h.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3281
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3282
    fgForm paint:paint.
4983
14c28ec55880 Replace usage of obsolete methods
Stefan Vogel <sv@exept.de>
parents: 4914
diff changeset
  3283
    fgForm maskOriginX:(pX negated + dx) y:(pY negated + dy).
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3284
    fgForm fillRectangleX:0 y:0 width:w height:h.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3285
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3286
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3287
     stamp-out background (have now bg-bits with fg=0 in bgForm)
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3288
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3289
    bgForm font:fontUsed.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3290
    bgForm paint:noColor on:allColor.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3291
    bgForm function:#and.
4026
882de378f763 no longer as string for its encoding;
Claus Gittinger <cg@exept.de>
parents: 3943
diff changeset
  3292
    bgForm displayString:s from:index1 to:index2 x:0 y:ascent.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3293
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
     stamp-out foreground
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3296
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3297
    maskForm font:fontUsed.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3298
    maskForm paint:allColor on:noColor.
4026
882de378f763 no longer as string for its encoding;
Claus Gittinger <cg@exept.de>
parents: 3943
diff changeset
  3299
    maskForm displayOpaqueString:s from:index1 to:index2 x:0 y:ascent.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3300
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3301
    fgForm function:#and.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3302
    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
  3303
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3304
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3305
     clear tempform
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
    tmpForm paint:noColor.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3308
    tmpForm fillRectangleX:0 y:0 width:w height:h.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3309
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3310
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3311
     merge fg-temp and bg-temp into tmp
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3312
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3313
    tmpForm function:#or.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3314
    tmpForm paint:noColor on:allColor.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3315
    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
  3316
    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
  3317
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3318
     finally, draw it
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
    device setForeground:0 background:allBits in:gcId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3321
    device
7064
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3322
        copyFromId:tmpForm id
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3323
        x:0 y:0 gc:tmpForm gcId
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3324
        to:drawableId
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3325
        x:pX y:(pY-ascent) gc:gcId
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3326
        width:w height:h.
1637
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  3327
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  3328
    "
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  3329
     release tempForms immediately
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3330
     (although GC will eventually do it,
1637
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  3331
      this creates less stress to the Xserver in the meanwhile ...)
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  3332
    "
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  3333
    tmpForm destroy.
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  3334
    fgForm destroy.
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  3335
    bgForm destroy.
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  3336
    maskForm destroy.
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  3337
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3338
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3339
     flush foreground/background cache
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3340
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3341
    foreground := nil.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3342
    background := nil.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3343
1805
532a11ba8458 tuned-out another send if encoding is wrong in display-string
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  3344
    "Modified: 1.7.1997 / 17:08:46 / cg"
732
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
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3347
displayDeviceOpaqueString:aString from:index1 to:index2 x:x y:y
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3348
    "draw a substring at the coordinate x/y - draw foreground pixels in
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3349
     paint-color and background pixels in bgPaint-color.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3350
     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
  3351
     the case where paint and/or bgPaint are dithered colors.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3352
     No translation or scaling is done."
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
    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
  3355
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3356
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3357
displayDeviceOpaqueString:aString x:x y:y
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3358
    "draw a string at the coordinate x/y - draw foreground pixels in
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3359
     paint-color and background pixels in bgPaint-color.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3360
     No translation or scaling is done"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3361
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3362
    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
  3363
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3364
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3365
displayDeviceString:aString from:index1 to:index2 in:font x:x y:y
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3366
    "draw a substring at the coordinate x/y -
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3367
     draw foreground-pixels only (in current paint-color), leaving background as-is.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3368
     No translation or scaling is done"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3369
4026
882de378f763 no longer as string for its encoding;
Claus Gittinger <cg@exept.de>
parents: 3943
diff changeset
  3370
    |id pX pY fontUsed s fontsEncoding|
732
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
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3373
     hook for non-strings (i.e. attributed text)
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3374
    "
7064
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3375
    aString isPlainString ifFalse:[
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3376
        ^ aString displayOn:self x:x y:y from:index1 to:index2
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3377
    ].
6210
af0bf039ec07 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6108
diff changeset
  3378
af0bf039ec07 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6108
diff changeset
  3379
    pX := x rounded.
af0bf039ec07 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6108
diff changeset
  3380
    pY := y rounded.
af0bf039ec07 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6108
diff changeset
  3381
6108
6ecfb89408d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6107
diff changeset
  3382
    font isAlienFont ifTrue:[
7064
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3383
        "
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3384
         hook for alien fonts
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3385
         that 'font' should know how to display the string ...
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3386
        "
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3387
        font displayOpaqueString:aString from:index1 to:index2 x:pX y:pY in:self.
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3388
        ^ self
6108
6ecfb89408d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6107
diff changeset
  3389
    ].
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3390
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3391
    gcId isNil ifTrue:[
7064
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3392
        self initGC
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3393
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3394
4026
882de378f763 no longer as string for its encoding;
Claus Gittinger <cg@exept.de>
parents: 3943
diff changeset
  3395
    s := aString.
4172
0d5bc2a70b83 Do not refer to uninitialized variable fontUsed
Stefan Vogel <sv@exept.de>
parents: 4146
diff changeset
  3396
    fontUsed := font onDevice:device.
4026
882de378f763 no longer as string for its encoding;
Claus Gittinger <cg@exept.de>
parents: 3943
diff changeset
  3397
    fontsEncoding := fontUsed encoding.
7288
fec0c6c1087b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7257
diff changeset
  3398
fec0c6c1087b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7257
diff changeset
  3399
    "/ This is now obsolete, as we are always using unicode internally.
fec0c6c1087b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7257
diff changeset
  3400
    "/ so the next line should be changed to fontsEncoding ~~ #unicode
4056
67c4686afbc6 characterEncoding stuff
Claus Gittinger <cg@exept.de>
parents: 4031
diff changeset
  3401
    (characterEncoding ~~ fontsEncoding) ifTrue:[
7064
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3402
        [
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3403
            s := CharacterEncoder encodeString:s from:characterEncoding into:fontsEncoding.
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3404
        ] on:CharacterEncoderError do:[:ex|
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3405
            "substitute a default value for codes that cannot be represented
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3406
             in the new character set"
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3407
            ex proceedWith:ex defaultValue.
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3408
        ].
4026
882de378f763 no longer as string for its encoding;
Claus Gittinger <cg@exept.de>
parents: 3943
diff changeset
  3409
    ].
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3410
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3411
    id := fontUsed fontId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3412
    id isNil ifTrue:[
7064
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3413
        "this should not happen, since #onDevice tries replacement fonts"
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3414
        'STX[DeviceGraphicsContext] no font: ' errorPrint. fontUsed errorPrintCR.
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3415
        ^ self
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3416
    ] ifFalse:[
7064
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3417
        deviceFont ~~ fontUsed ifTrue:[
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3418
            device setFont:id in:gcId.
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3419
            deviceFont := fontUsed
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3420
        ].
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3421
        device displayString:s from:index1 to:index2 x:pX y:pY in:drawableId with:gcId
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3422
    ]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3423
1805
532a11ba8458 tuned-out another send if encoding is wrong in display-string
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  3424
    "Modified: 1.7.1997 / 17:08:48 / cg"
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3425
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3426
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3427
displayDeviceString:aString from:index1 to:index2 x:x y:y
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3428
    "draw a substring at the coordinate x/y -
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3429
     draw foreground-pixels only (in current paint-color), leaving background as-is.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3430
     No translation or scaling is done"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3431
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3432
    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
  3433
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3434
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3435
displayDeviceString:aString x:x y:y
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3436
    "draw a string at the coordinate x/y -
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3437
     draw foreground-pixels only (in current paint-color), leaving background as-is.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3438
     No translation or scaling is done"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3439
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3440
    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
  3441
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3442
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3443
fillDeviceRectangleX:x y:y width:w height:h
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3444
    "draw a filled rectangle in device coordinate space.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3445
     This ignores any transformations. The coordinates must be integers."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3446
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3447
    gcId isNil ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3448
	self initGC
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3449
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3450
    device
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3451
	fillRectangleX:x
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3452
		     y:y
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3453
		 width:w
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3454
		height:h
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3455
		    in:drawableId with:gcId
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3456
! !
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3457
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3458
!DeviceGraphicsContext methodsFor:'evaluating in another context'!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3459
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3460
reverseDo:aBlock
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3461
    "evaluate aBlock with foreground and background interchanged.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3462
     This can be reimplemented here in a faster way."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3463
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3464
    |oldFg oldBg|
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3465
2835
963425946ff3 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 2714
diff changeset
  3466
    oldFg := foreground.
963425946ff3 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 2714
diff changeset
  3467
    oldBg := background.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3468
    self foreground:background background:foreground.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3469
    aBlock value.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3470
    self foreground:oldFg background:oldBg
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3471
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3472
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3473
withBackground:fgColor do:aBlock
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3474
    "evaluate aBlock with changed background."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3475
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3476
    |oldBg|
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3477
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3478
    oldBg := background.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3479
    self background:fgColor.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3480
    aBlock value.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3481
    self background:oldBg
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3482
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3483
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3484
withForeground:fgColor background:bgColor do:aBlock
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3485
    "evaluate aBlock with changed foreground and background."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3486
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3487
    |oldFg oldBg|
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3488
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3489
    oldFg := foreground.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3490
    oldBg := background.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3491
    self foreground:fgColor background:bgColor.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3492
    aBlock value.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3493
    self foreground:oldFg background:oldBg
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3494
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3495
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3496
withForeground:fgColor background:bgColor function:aFunction do:aBlock
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3497
    "evaluate aBlock with foreground, background and function"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3498
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3499
    |oldFg oldBg oldFun|
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3500
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3501
    oldFg := foreground.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3502
    oldBg := background.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3503
    oldFun := function.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3504
    self foreground:fgColor background:bgColor function:aFunction.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3505
    aBlock value.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3506
    self foreground:oldFg background:oldBg function:oldFun
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3507
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3508
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3509
withForeground:fgColor background:bgColor mask:aMask do:aBlock
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3510
    "evaluate aBlock with foreground, background and mask"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3511
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3512
    |oldFg oldBg oldMask|
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3513
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3514
    oldFg := foreground.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3515
    oldBg := background.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3516
    oldMask := mask.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3517
    self foreground:fgColor background:bgColor.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3518
    self mask:aMask.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3519
    aBlock value.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3520
    self foreground:oldFg background:oldBg.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3521
    self mask:oldMask
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3522
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3523
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3524
withForeground:fgColor do:aBlock
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3525
    "evaluate aBlock with changed foreground."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3526
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3527
    |oldFg|
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3528
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3529
    oldFg := foreground.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3530
    self foreground:fgColor.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3531
    aBlock value.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3532
    self foreground:oldFg
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3533
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3534
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3535
withForeground:fgColor function:aFunction do:aBlock
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3536
    "evaluate aBlock with changed foreground and function."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3537
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3538
    |oldFg oldFun|
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3539
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3540
    oldFg := foreground.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3541
    oldFun := function.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3542
    self foreground:fgColor background:background function:aFunction.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3543
    aBlock value.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3544
    self foreground:oldFg background:background function:oldFun
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3545
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3546
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3547
xoring:aBlock
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3548
    "evaluate aBlock with function xoring"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3549
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3550
    |fgPixel bgPixel oldFunction|
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3551
2322
6c42f2e0213c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2271
diff changeset
  3552
    fgPixel := device blackpixel.
6c42f2e0213c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2271
diff changeset
  3553
    bgPixel := device whitepixel.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3554
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3555
    gcId isNil ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3556
	self initGC
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3557
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3558
    oldFunction := function.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3559
    device setForeground:(fgPixel bitXor:bgPixel)
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3560
	      background:bgPixel
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3561
		      in:gcId.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3562
    device setFunction:#xor in:gcId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3563
    aBlock value.
2322
6c42f2e0213c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2271
diff changeset
  3564
2879
f1e9b8310d4e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2865
diff changeset
  3565
    paint := bgPaint := nil.        "invalidate"
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3566
    foreground := device blackColor.
1199
f113f6a4c04a use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents: 1177
diff changeset
  3567
    background := device whiteColor.
2322
6c42f2e0213c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2271
diff changeset
  3568
    device setForeground:fgPixel background:bgPixel in:gcId.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3569
    device setFunction:oldFunction in:gcId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3570
    function := oldFunction
1199
f113f6a4c04a use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents: 1177
diff changeset
  3571
2322
6c42f2e0213c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2271
diff changeset
  3572
    "Modified: / 10.9.1998 / 12:17:39 / cg"
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3573
! !
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3574
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3575
!DeviceGraphicsContext methodsFor:'filling'!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3576
5837
28301409379c added: #clearDeviceRectangleX:y:width:height:
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3577
clearDeviceRectangleX:x y:y width:w height:h
28301409379c added: #clearDeviceRectangleX:y:width:height:
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3578
    "clear a rectangular area to viewBackground -
28301409379c added: #clearDeviceRectangleX:y:width:height:
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3579
     redefined since GraphicsMedium fills with background
28301409379c added: #clearDeviceRectangleX:y:width:height:
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3580
     - not viewBackground as we want here."
28301409379c added: #clearDeviceRectangleX:y:width:height:
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3581
7301
153311545645 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 7288
diff changeset
  3582
    |oldPaint viewBackground|
153311545645 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 7288
diff changeset
  3583
153311545645 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 7288
diff changeset
  3584
    viewBackground := self viewBackground.
153311545645 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 7288
diff changeset
  3585
    viewBackground isNil ifTrue:[^ self]. "/ how can this happen?
153311545645 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 7288
diff changeset
  3586
    
5837
28301409379c added: #clearDeviceRectangleX:y:width:height:
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3587
    "
28301409379c added: #clearDeviceRectangleX:y:width:height:
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3588
     fill in device coordinates - not logical coordinates
28301409379c added: #clearDeviceRectangleX:y:width:height:
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3589
    "
28301409379c added: #clearDeviceRectangleX:y:width:height:
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3590
    oldPaint := paint.
7301
153311545645 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 7288
diff changeset
  3591
    self paint:viewBackground.
5837
28301409379c added: #clearDeviceRectangleX:y:width:height:
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3592
    self fillDeviceRectangleX:x y:y width:w height:h "with:viewBackground".
28301409379c added: #clearDeviceRectangleX:y:width:height:
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3593
    self paint:oldPaint
28301409379c added: #clearDeviceRectangleX:y:width:height:
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3594
28301409379c added: #clearDeviceRectangleX:y:width:height:
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3595
    "Modified: / 04-05-1999 / 13:00:34 / cg"
28301409379c added: #clearDeviceRectangleX:y:width:height:
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3596
    "Created: / 30-12-2011 / 14:32:14 / cg"
28301409379c added: #clearDeviceRectangleX:y:width:height:
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3597
!
28301409379c added: #clearDeviceRectangleX:y:width:height:
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3598
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3599
fillArcX:x y:y width:w height:h from:startAngle angle:angle
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3600
    "draw a filled arc; apply transformation if nonNil"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3601
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  3602
    |pX pY nW nH sA a pO pC|
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3603
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3604
    gcId isNil ifTrue:[
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  3605
        self initGC
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3606
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3607
    transformation notNil ifTrue:[
6711
2b50385f7257 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
  3608
        pO := transformation transformPoint:x@y.
2b50385f7257 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
  3609
        pC := transformation transformPoint:(x+w-1)@(y+h-1).
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  3610
        pX := pO x.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  3611
        pY := pO y.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  3612
        nW := pC x - pX + 1.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  3613
        nH := pC y - pY + 1.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  3614
        nW < 0 ifTrue:[
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  3615
              nW := nW abs.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  3616
              pX := pX - nW.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  3617
        ].
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  3618
        nH < 0 ifTrue:[
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  3619
              nH := nH abs.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  3620
              pY := pY - nH.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  3621
        ].
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3622
    ] ifFalse:[
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  3623
        pX := x.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  3624
        pY := y.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  3625
        nW := w.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  3626
        nH := h.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3627
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3628
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3629
    pX := pX rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3630
    pY := pY rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3631
    nW := nW rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3632
    nH := nH rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3633
2268
1a774fc02c83 fixed non-float (i.e. fraction) args to fillArc/ displayArc
Claus Gittinger <cg@exept.de>
parents: 2259
diff changeset
  3634
    sA := startAngle.
1a774fc02c83 fixed non-float (i.e. fraction) args to fillArc/ displayArc
Claus Gittinger <cg@exept.de>
parents: 2259
diff changeset
  3635
    sA isInteger ifFalse:[sA := sA asFloat].
1a774fc02c83 fixed non-float (i.e. fraction) args to fillArc/ displayArc
Claus Gittinger <cg@exept.de>
parents: 2259
diff changeset
  3636
    a := angle.
1a774fc02c83 fixed non-float (i.e. fraction) args to fillArc/ displayArc
Claus Gittinger <cg@exept.de>
parents: 2259
diff changeset
  3637
    a isInteger ifFalse:[a := a asFloat].
1a774fc02c83 fixed non-float (i.e. fraction) args to fillArc/ displayArc
Claus Gittinger <cg@exept.de>
parents: 2259
diff changeset
  3638
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3639
    device
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  3640
          fillArcX:pX
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  3641
                 y:pY
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  3642
             width:nW
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  3643
            height:nH
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  3644
              from:sA
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  3645
             angle:a
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  3646
                in:drawableId
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  3647
              with:gcId
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3648
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3649
    "Created: 8.5.1996 / 08:29:45 / cg"
784
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
  3650
    "Modified: 4.6.1996 / 17:58:21 / cg"
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3651
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3652
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3653
fillPolygon:aPolygon
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3654
    "draw a filled polygon; apply transformation if nonNil"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3655
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3656
    |newPolygon|
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3657
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3658
    gcId isNil ifTrue:[
6711
2b50385f7257 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
  3659
        self initGC
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3660
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3661
    transformation notNil ifTrue:[
6711
2b50385f7257 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
  3662
        newPolygon := aPolygon collect:[:point | transformation transformPoint:point].
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3663
    ] ifFalse:[
6711
2b50385f7257 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
  3664
        newPolygon := aPolygon
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3665
    ].
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3666
    (newPolygon contains:[:p |
6711
2b50385f7257 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
  3667
        (p isPoint not
2b50385f7257 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
  3668
        or:[(p x class ~~ SmallInteger)
2b50385f7257 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
  3669
        or:[(p y class ~~ SmallInteger)]])
4521
6f065906e740 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4477
diff changeset
  3670
     ]) ifTrue:[
6711
2b50385f7257 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
  3671
        newPolygon := newPolygon collect:[:p | p asPoint rounded]
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3672
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3673
    device
6711
2b50385f7257 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
  3674
        fillPolygon:newPolygon
2b50385f7257 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
  3675
                 in:drawableId
2b50385f7257 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
  3676
               with:gcId
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3677
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3678
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3679
fillRectangleX:x y:y width:w height:h
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3680
    "draw a filled rectangle; apply transformation if nonNil"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3681
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  3682
    |pX pY nW nH pO pC|
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3683
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3684
    gcId isNil ifTrue:[
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  3685
        self initGC
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3686
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3687
    transformation notNil ifTrue:[
6711
2b50385f7257 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
  3688
        pO := transformation transformPoint:x@y.
2b50385f7257 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
  3689
        pC := transformation transformPoint:(x+w-1)@(y+h-1).
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  3690
        pX := pO x.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  3691
        pY := pO y.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  3692
        nW := pC x - pX + 1.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  3693
        nH := pC y - pY + 1.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  3694
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  3695
        nW < 0 ifTrue:[
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  3696
              nW := nW abs.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  3697
              pX := pX - nW.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  3698
        ].
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  3699
        nH < 0 ifTrue:[
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  3700
              nH := nH abs.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  3701
              pY := pY - nH.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  3702
        ].
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3703
    ] ifFalse:[
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  3704
        pX := x.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  3705
        pY := y.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  3706
        nW := w.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  3707
        nH := h.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3708
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3709
    pX := pX rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3710
    pY := pY rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3711
    nW := nW rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3712
    nH := nH rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3713
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3714
    device
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  3715
        fillRectangleX:pX
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  3716
                     y:pY
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  3717
                 width:nW
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  3718
                height:nH
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  3719
                    in:drawableId with:gcId
784
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
  3720
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
  3721
    "Modified: 4.6.1996 / 17:58:49 / cg"
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3722
! !
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3723
3883
4e01a59afccb method category rename
Claus Gittinger <cg@exept.de>
parents: 3880
diff changeset
  3724
!DeviceGraphicsContext methodsFor:'initialization & release'!
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3725
1517
ac751bb3dfdf no need for registration here;
Claus Gittinger <cg@exept.de>
parents: 1514
diff changeset
  3726
close
ac751bb3dfdf no need for registration here;
Claus Gittinger <cg@exept.de>
parents: 1514
diff changeset
  3727
    "same as destroy - for ST-80 compatibility"
ac751bb3dfdf no need for registration here;
Claus Gittinger <cg@exept.de>
parents: 1514
diff changeset
  3728
ac751bb3dfdf no need for registration here;
Claus Gittinger <cg@exept.de>
parents: 1514
diff changeset
  3729
    self destroy
ac751bb3dfdf no need for registration here;
Claus Gittinger <cg@exept.de>
parents: 1514
diff changeset
  3730
ac751bb3dfdf no need for registration here;
Claus Gittinger <cg@exept.de>
parents: 1514
diff changeset
  3731
    "Created: 2.4.1997 / 19:31:27 / cg"
ac751bb3dfdf no need for registration here;
Claus Gittinger <cg@exept.de>
parents: 1514
diff changeset
  3732
!
ac751bb3dfdf no need for registration here;
Claus Gittinger <cg@exept.de>
parents: 1514
diff changeset
  3733
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3734
createGC
1453
e93293618275 only fetch id's once in displayForm.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  3735
    "physically create a device GC.
e93293618275 only fetch id's once in displayForm.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  3736
     Since we do not need a gc-object for the drawable until something is
e93293618275 only fetch id's once in displayForm.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  3737
     really drawn, none is created up to the first draw.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3738
     This method is sent, when the first drawing happens"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3739
1138
4a2b3b407cae need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents: 1094
diff changeset
  3740
    gcId := device gcFor:drawableId.
4a2b3b407cae need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents: 1094
diff changeset
  3741
    Lobby registerChange:self.
1453
e93293618275 only fetch id's once in displayForm.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  3742
e93293618275 only fetch id's once in displayForm.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  3743
    "Modified: 19.3.1997 / 11:07:52 / cg"
1138
4a2b3b407cae need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents: 1094
diff changeset
  3744
!
4a2b3b407cae need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents: 1094
diff changeset
  3745
6234
404d91662d49 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6225
diff changeset
  3746
createGCForBitmap
404d91662d49 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6225
diff changeset
  3747
    "physically create a device GC.
404d91662d49 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6225
diff changeset
  3748
     Since we do not need a gc-object for the drawable until something is
404d91662d49 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6225
diff changeset
  3749
     really drawn, none is created up to the first draw.
404d91662d49 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6225
diff changeset
  3750
     This method is sent, when the first drawing happens.
404d91662d49 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6225
diff changeset
  3751
     Redefined here to create a bitmap GC (some devices (i.e. windows) require
404d91662d49 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6225
diff changeset
  3752
     different GC's for different canvases."
404d91662d49 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6225
diff changeset
  3753
404d91662d49 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6225
diff changeset
  3754
    gcId := device gcForBitmap:drawableId.
404d91662d49 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6225
diff changeset
  3755
    Lobby registerChange:self.
404d91662d49 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6225
diff changeset
  3756
!
404d91662d49 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6225
diff changeset
  3757
1138
4a2b3b407cae need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents: 1094
diff changeset
  3758
destroy
1517
ac751bb3dfdf no need for registration here;
Claus Gittinger <cg@exept.de>
parents: 1514
diff changeset
  3759
    "I am abstract"
ac751bb3dfdf no need for registration here;
Claus Gittinger <cg@exept.de>
parents: 1514
diff changeset
  3760
2913
c51ac85e9aa2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2879
diff changeset
  3761
    self subclassResponsibility.
1517
ac751bb3dfdf no need for registration here;
Claus Gittinger <cg@exept.de>
parents: 1514
diff changeset
  3762
ac751bb3dfdf no need for registration here;
Claus Gittinger <cg@exept.de>
parents: 1514
diff changeset
  3763
"/    "when the drawable is destroyed, the associated GC must be destroyed with it"
ac751bb3dfdf no need for registration here;
Claus Gittinger <cg@exept.de>
parents: 1514
diff changeset
  3764
"/
ac751bb3dfdf no need for registration here;
Claus Gittinger <cg@exept.de>
parents: 1514
diff changeset
  3765
"/    gcId notNil ifTrue:[
ac751bb3dfdf no need for registration here;
Claus Gittinger <cg@exept.de>
parents: 1514
diff changeset
  3766
"/        device destroyGC:gcId.
ac751bb3dfdf no need for registration here;
Claus Gittinger <cg@exept.de>
parents: 1514
diff changeset
  3767
"/        gcId := nil.
ac751bb3dfdf no need for registration here;
Claus Gittinger <cg@exept.de>
parents: 1514
diff changeset
  3768
"/        Lobby registerChange:self.
ac751bb3dfdf no need for registration here;
Claus Gittinger <cg@exept.de>
parents: 1514
diff changeset
  3769
"/    ]
ac751bb3dfdf no need for registration here;
Claus Gittinger <cg@exept.de>
parents: 1514
diff changeset
  3770
ac751bb3dfdf no need for registration here;
Claus Gittinger <cg@exept.de>
parents: 1514
diff changeset
  3771
    "Modified: 2.4.1997 / 19:37:53 / cg"
1138
4a2b3b407cae need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents: 1094
diff changeset
  3772
!
4a2b3b407cae need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents: 1094
diff changeset
  3773
6222
2d670d3bcfd5 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6215
diff changeset
  3774
destroyGC
2d670d3bcfd5 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6215
diff changeset
  3775
    |id|
2d670d3bcfd5 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6215
diff changeset
  3776
2d670d3bcfd5 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6215
diff changeset
  3777
    id := gcId.
2d670d3bcfd5 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6215
diff changeset
  3778
    id notNil ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3779
	gcId := nil.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3780
	device destroyGC:id.
6222
2d670d3bcfd5 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6215
diff changeset
  3781
    ].
6266
1503c5e038d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  3782
!
1503c5e038d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  3783
1503c5e038d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  3784
destroyPixmap
1503c5e038d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  3785
    "physically destroy the pixmap."
1503c5e038d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  3786
1503c5e038d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  3787
    |id|
1503c5e038d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  3788
1503c5e038d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  3789
    (id := drawableId) notNil ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3790
	drawableId := nil.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3791
	device destroyPixmap:id.
6266
1503c5e038d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  3792
    ].
1503c5e038d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  3793
    Lobby unregister:self.
1503c5e038d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  3794
!
1503c5e038d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  3795
1503c5e038d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  3796
destroyView
1503c5e038d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  3797
    "physically destroy the view."
1503c5e038d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  3798
1503c5e038d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  3799
    |id|
1503c5e038d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  3800
6222
2d670d3bcfd5 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6215
diff changeset
  3801
    (id := drawableId) notNil ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3802
	drawableId := nil.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3803
	device destroyView:self withId:id.
6222
2d670d3bcfd5 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6215
diff changeset
  3804
    ].
2d670d3bcfd5 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6215
diff changeset
  3805
    Lobby unregister:self.
2d670d3bcfd5 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6215
diff changeset
  3806
!
2d670d3bcfd5 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6215
diff changeset
  3807
3612
6e0f462e0b7a Allow #registerForFinalization for classes defining their own Lobby.
Stefan Vogel <sv@exept.de>
parents: 3611
diff changeset
  3808
finalizationLobby
6e0f462e0b7a Allow #registerForFinalization for classes defining their own Lobby.
Stefan Vogel <sv@exept.de>
parents: 3611
diff changeset
  3809
    "answer the registry used for finalization.
6e0f462e0b7a Allow #registerForFinalization for classes defining their own Lobby.
Stefan Vogel <sv@exept.de>
parents: 3611
diff changeset
  3810
     DeviceGraphicContexts have their own Registry"
6e0f462e0b7a Allow #registerForFinalization for classes defining their own Lobby.
Stefan Vogel <sv@exept.de>
parents: 3611
diff changeset
  3811
6e0f462e0b7a Allow #registerForFinalization for classes defining their own Lobby.
Stefan Vogel <sv@exept.de>
parents: 3611
diff changeset
  3812
    ^ Lobby
2572
447398073628 category change
Claus Gittinger <cg@exept.de>
parents: 2360
diff changeset
  3813
!
447398073628 category change
Claus Gittinger <cg@exept.de>
parents: 2360
diff changeset
  3814
1138
4a2b3b407cae need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents: 1094
diff changeset
  3815
initGC
4a2b3b407cae need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents: 1094
diff changeset
  3816
    "since we do not need a gc-object for the drawable until something is
4a2b3b407cae need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents: 1094
diff changeset
  3817
     really drawn, none is created.
4a2b3b407cae need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents: 1094
diff changeset
  3818
     This method is sent, when the first drawing happens"
4a2b3b407cae need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents: 1094
diff changeset
  3819
4135
a47337e09c40 preset font if already ok for device
werner
parents: 4070
diff changeset
  3820
    |fgId bgId p fontId|
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3821
1453
e93293618275 only fetch id's once in displayForm.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  3822
    gcId notNil ifTrue:[^ self].
1514
7c2a921ae46b better error report when drawing on closed view.
Claus Gittinger <cg@exept.de>
parents: 1507
diff changeset
  3823
    drawableId isNil ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3824
	"/
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3825
	"/ the drawable has been closed (or was never open)
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3826
	"/ no drawing is possible.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3827
	"/
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3828
	^ DrawingOnClosedDrawableSignal raiseRequest
1514
7c2a921ae46b better error report when drawing on closed view.
Claus Gittinger <cg@exept.de>
parents: 1507
diff changeset
  3829
    ].
1138
4a2b3b407cae need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents: 1094
diff changeset
  3830
    self createGC.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3831
1199
f113f6a4c04a use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents: 1177
diff changeset
  3832
    foreground isNil ifTrue:[foreground := device blackColor].
f113f6a4c04a use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents: 1177
diff changeset
  3833
    background isNil ifTrue:[background := device whiteColor].
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3834
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3835
    foreground isColor ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3836
	"get device colors from the device indep. colors"
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3837
	foreground := foreground onDevice:device.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3838
	fgId := foreground colorId.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3839
	fgId isNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3840
	    (foreground grayIntensity >= 50) ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3841
		fgId := device whitepixel
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3842
	    ] ifFalse:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3843
		fgId := device blackpixel
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3844
	    ]
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3845
	].
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3846
    ] ifFalse:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3847
	fgId := device blackpixel.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3848
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3849
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3850
    background isColor ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3851
	background := background onDevice:device.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3852
	bgId := background colorId.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3853
	bgId isNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3854
	    (background grayIntensity >= 50) ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3855
		bgId := device whitepixel
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3856
	    ] ifFalse:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3857
		bgId := device blackpixel
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3858
	    ]
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3859
	].
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3860
    ] ifFalse:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3861
	bgId := device whitepixel
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3862
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3863
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3864
    "now, this is something the device can work with ..."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3865
    device setForeground:fgId background:bgId in:gcId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3866
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3867
    "switch to paint"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3868
    p := paint.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3869
    paint := nil.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3870
    self paint:p.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3871
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3872
    ((lineWidth ~~ 0)
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3873
    or:[(lineStyle ~~ #solid)
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3874
    or:[(capStyle ~~ #butt)
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3875
    or:[joinStyle ~~ #miter]]]) ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3876
	device setLineWidth:lineWidth
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3877
		      style:lineStyle
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3878
			cap:capStyle
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3879
		       join:joinStyle
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3880
			 in:gcId
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3881
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3882
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3883
    mask notNil ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3884
	(mask depth == 1) ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3885
	    device setBitmapMask:(mask id) in:gcId
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3886
	] ifFalse:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3887
	    device setPixmapMask:(mask id) in:gcId
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3888
	].
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3889
	maskOrigin notNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3890
	    device setMaskOriginX:maskOrigin x y:maskOrigin y in:gcId
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3891
	]
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3892
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3893
    (function ~~ #copy) ifTrue:[device setFunction:function in:gcId].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3894
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3895
    "defer the getting of a device font
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3896
     - this is now done when the first drawstring occurs,
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3897
     since many views (layout-views) will never draw strings and
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3898
     therefore, the overhead of aquiring a font can be avoided.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3899
    "
1138
4a2b3b407cae need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents: 1094
diff changeset
  3900
"/    font := font on:device.
4a2b3b407cae need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents: 1094
diff changeset
  3901
"/    id := font fontId.
4a2b3b407cae need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents: 1094
diff changeset
  3902
"/    id notNil ifTrue:[
4a2b3b407cae need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents: 1094
diff changeset
  3903
"/        device setFont:id in:gcId
4a2b3b407cae need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents: 1094
diff changeset
  3904
"/    ]
1199
f113f6a4c04a use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents: 1177
diff changeset
  3905
4135
a47337e09c40 preset font if already ok for device
werner
parents: 4070
diff changeset
  3906
    font notNil ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3907
	font graphicsDevice == device ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3908
	    (fontId := font fontId) notNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3909
		deviceFont := font.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3910
		device setFont:fontId in:gcId
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3911
	    ]
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3912
	]
4135
a47337e09c40 preset font if already ok for device
werner
parents: 4070
diff changeset
  3913
    ]
4664
02d160974029 fix remembering deviceFont everywhere.
Claus Gittinger <cg@exept.de>
parents: 4657
diff changeset
  3914
02d160974029 fix remembering deviceFont everywhere.
Claus Gittinger <cg@exept.de>
parents: 4657
diff changeset
  3915
    "Modified: / 22-10-2006 / 14:10:53 / cg"
4291
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3916
!
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3917
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3918
initialize
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3919
    "setup everything for later use; actual work is done in
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3920
     initColors and initFont, which are usually redefined."
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3921
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3922
    super initialize.
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3923
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3924
    "/ just in case, someone redefined new without setting device
6234
404d91662d49 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6225
diff changeset
  3925
    (device isNil and:[Screen notNil]) ifTrue:[device := Screen current].
4291
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3926
6273
d1000b29b5b2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6271
diff changeset
  3927
    foreground isNil ifTrue:[foreground := self blackColor].
d1000b29b5b2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6271
diff changeset
  3928
    background isNil ifTrue:[background := self whiteColor].
4291
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3929
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3930
    "Modified: 10.1.1997 / 17:46:51 / cg"
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3931
!
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3932
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3933
prepareForReinit
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3934
    "kludge - clear drawableId and gcId
4291
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3935
     needed after snapin"
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3936
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3937
    gcId := nil.
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3938
    drawableId := nil.
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3939
    deviceFont := nil
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3940
!
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3941
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3942
recreate
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3943
    "sent after a snapin or a migration, reinit draw stuff for new device"
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3944
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3945
    gcId := nil.
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3946
    foreground notNil ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3947
	foreground := foreground onDevice:device
4291
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3948
    ].
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3949
    background notNil ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3950
	background := background onDevice:device
4291
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3951
    ].
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3952
    paint notNil ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3953
	paint := paint onDevice:device
4291
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3954
    ].
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3955
    bgPaint notNil ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3956
	bgPaint := bgPaint onDevice:device
4291
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3957
    ].
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3958
    font notNil ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3959
	font := font onDevice:device
4291
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3960
    ]
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3961
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3962
    "Modified: 28.10.1996 / 13:25:02 / cg"
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3963
!
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3964
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3965
reinitialize
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3966
    'DeviceGraphicsContext [warning]: reinit of ' errorPrint. self classNameWithArticle errorPrint.
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3967
    ' failed' errorPrintCR
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3968
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3969
    "Modified: 10.1.1997 / 17:47:06 / cg"
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3970
!
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3971
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3972
releaseGC
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3973
    "destroy the associated device GC resource - can be done to be nice to the
4291
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3974
     display if you know that you are done with a drawable."
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3975
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3976
    |id|
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3977
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3978
    foreground := background := paint := bgPaint := nil.
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3979
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3980
    id := gcId.
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3981
    id notNil ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3982
	gcId := nil.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3983
	device destroyGC:id.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3984
	Lobby registerChange:self.
4291
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3985
    ].
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3986
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3987
    "Created: 11.6.1996 / 22:07:30 / cg"
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3988
    "Modified: 2.4.1997 / 19:36:30 / cg"
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3989
! !
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3990
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3991
!DeviceGraphicsContext methodsFor:'private'!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3992
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3993
setDevice:aDevice id:aDrawbleId gcId:aGCId
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3994
    "private"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3995
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3996
    device := aDevice.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3997
    gcId := aGCId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3998
    drawableId := aDrawbleId
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3999
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4000
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4001
setGCForPaint
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4002
    "private; given a complex color (i.e. a pixmap or dithered color,
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4003
     setup the GC to draw in this color.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4004
     A helper for paint and paint:on:"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4005
832
064890dcfabd fixed opaque string draw with deep-dither
Claus Gittinger <cg@exept.de>
parents: 786
diff changeset
  4006
    |dither map pixelId p fg bg vOrg ditherDepth deviceDepth|
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4007
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4008
    gcId notNil ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  4009
	paint isSymbol ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  4010
	    "map symbols to colors"
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  4011
	    paint := Color perform:paint ifNotUnderstood:[Color yellow].
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  4012
	].
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  4013
	p := paint.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  4014
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  4015
	p isColor ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  4016
	    paint := p := p onDevice:device.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  4017
	    pixelId := p colorId.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  4018
	    pixelId notNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  4019
		"
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  4020
		 a real (undithered) color
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  4021
		"
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  4022
		mask notNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  4023
		    mask := nil.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  4024
		    device setBitmapMask:nil in:gcId
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  4025
		].
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  4026
		(p ~~ foreground) ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  4027
		    foreground := paint.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  4028
		    device setForeground:pixelId in:gcId
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  4029
		].
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  4030
		^ self
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  4031
	    ].
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  4032
	    "a dithered color"
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  4033
	    dither := paint ditherForm.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  4034
	] ifFalse:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  4035
	    "mhmh - seems to be some kind of form ..."
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  4036
	    paint := paint onDevice:device.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  4037
	    dither := paint.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  4038
	].
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  4039
	"
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  4040
	 a dithered color or image
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  4041
	"
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  4042
	(ditherDepth := dither depth) == 1 ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  4043
	    "a simple 0/1 bitmap"
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  4044
	    map := dither colorMap.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  4045
	    "temporary (kludgy) fix for destroyed paint"
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  4046
	    p := paint.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  4047
	    map isNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  4048
		fg := Color black.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  4049
		bg := Color white.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  4050
	    ] ifFalse:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  4051
		fg := map at:2.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  4052
		bg := map at:1.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  4053
	    ].
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  4054
	    self foreground:fg background:bg.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  4055
	    paint := p
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  4056
	] ifFalse:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  4057
	    deviceDepth := device depth.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  4058
	    (ditherDepth ~~ deviceDepth) ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  4059
		dither := dither asFormOn:device.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  4060
		ditherDepth := dither depth.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  4061
		(dither isNil or:[ditherDepth ~~ deviceDepth]) ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  4062
		    self error:'bad dither'.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  4063
		    ^ self
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  4064
		]
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  4065
	    ]
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  4066
	].
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  4067
	self mask:dither.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  4068
	vOrg := self viewOrigin.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  4069
	self maskOriginX:vOrg x negated y:vOrg y negated.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4070
    ]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4071
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4072
    "Created: 16.5.1996 / 15:35:51 / cg"
1742
ca904d85a84c #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1741
diff changeset
  4073
    "Modified: 6.6.1997 / 12:55:38 / cg"
2049
1ceec8ef240e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2031
diff changeset
  4074
!
1ceec8ef240e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2031
diff changeset
  4075
1ceec8ef240e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2031
diff changeset
  4076
setId:aDrawbleId
1ceec8ef240e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2031
diff changeset
  4077
    "private"
1ceec8ef240e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2031
diff changeset
  4078
1ceec8ef240e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2031
diff changeset
  4079
    drawableId := aDrawbleId
1ceec8ef240e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2031
diff changeset
  4080
1ceec8ef240e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2031
diff changeset
  4081
    "Created: / 6.2.1998 / 12:44:45 / cg"
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4082
! !
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4083
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4084
!DeviceGraphicsContext methodsFor:'queries'!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4085
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4086
horizontalIntegerPixelPerMillimeter
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4087
    "return the (rounded) number of pixels per millimeter"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4088
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4089
    ^ device horizontalPixelPerMillimeter rounded
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4090
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4091
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4092
horizontalPixelPerInch
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4093
    "return the number of horizontal pixels per inch of the display"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4094
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4095
    ^ device horizontalPixelPerMillimeter * 25.4
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4096
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4097
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4098
horizontalPixelPerMillimeter
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4099
    "return the number of pixels per millimeter (not rounded)"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4100
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4101
    ^ device horizontalPixelPerMillimeter
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4102
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4103
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4104
horizontalPixelPerMillimeter:millis
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4105
    "return the number of pixels (not rounded) for millis millimeter"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4106
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4107
    ^ device horizontalPixelPerMillimeter * millis
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4108
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4109
784
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
  4110
resolution
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
  4111
    "return a point consisting of pixel-per-inch horizontally and vertically."
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
  4112
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
  4113
    ^ device resolution
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
  4114
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
  4115
    "Created: 4.6.1996 / 15:23:55 / cg"
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
  4116
!
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
  4117
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4118
verticalIntegerPixelPerMillimeter
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4119
    "return the (rounded) number of pixels per millimeter"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4120
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4121
    ^ device verticalPixelPerMillimeter rounded
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4122
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4123
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4124
verticalPixelPerInch
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4125
    "return the number of vertical pixels per inch of the display"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4126
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4127
    ^ device verticalPixelPerMillimeter * 25.4
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4128
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4129
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4130
verticalPixelPerMillimeter
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4131
    "return the number of pixels per millimeter (not rounded)"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4132
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4133
    ^ device verticalPixelPerMillimeter
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4134
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4135
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4136
verticalPixelPerMillimeter:millis
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4137
    "return the number of pixels (not rounded) for millis millimeter"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4138
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4139
    ^ device verticalPixelPerMillimeter * millis
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4140
! !
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4141
6225
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4142
!DeviceGraphicsContext methodsFor:'view creation'!
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4143
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4144
createBitmapFromArray:data width:width height:height
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4145
    "create a bitmap from data and set the drawableId"
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  4146
6225
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4147
    drawableId := device createBitmapFromArray:data width:width height:height.
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4148
!
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4149
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4150
createPixmapWidth:w height:h depth:d
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4151
    "create a pixmap and set the drawableId"
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  4152
6225
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4153
    drawableId := device createPixmapWidth:w height:h depth:d.
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4154
!
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4155
6234
404d91662d49 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6225
diff changeset
  4156
createRootWindow
6235
7cdc094296b2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6234
diff changeset
  4157
    drawableId := device rootWindowFor:self.
6234
404d91662d49 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6225
diff changeset
  4158
!
404d91662d49 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6225
diff changeset
  4159
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  4160
createWindowFor:aView type:typeSymbol origin:org extent:ext minExtent:minE maxExtent:maxE borderWidth:bw subViewOf:sv style:styleSymbol inputOnly:inp label:label owner:owner icon:icn iconMask:icnM iconView:icnV
6225
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4161
    "create a window and set the drawableId"
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  4162
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  4163
    drawableId := device
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  4164
	    createWindowFor:aView
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  4165
	    type:typeSymbol
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  4166
	    origin:org
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  4167
	    extent:ext
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  4168
	    minExtent:minE
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  4169
	    maxExtent:maxE
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  4170
	    borderWidth:bw
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  4171
	    subViewOf:sv
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  4172
	    style:styleSymbol
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  4173
	    inputOnly:inp
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  4174
	    label:label
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  4175
	    owner:owner
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  4176
	    icon:icn
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  4177
	    iconMask:icnM
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  4178
	    iconView:icnV.
6225
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4179
! !
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4180
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4181
!DeviceGraphicsContext methodsFor:'view properties'!
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4182
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4183
backingStore:how
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4184
    "turn on/off backingStore (saving my pixels)
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4185
     how may true/false, but also #always, #whenMapped or #never."
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4186
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4187
    drawableId notNil ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  4188
	device setBackingStore:how in:drawableId
6225
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4189
    ]
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4190
!
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4191
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4192
bitGravity:gravity
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4193
    "set the bitGravity - thats the direction where the contents will move
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4194
     when the view is resized."
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4195
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4196
    drawableId notNil ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  4197
	device setBitGravity:gravity in:drawableId
6225
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4198
    ]
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4199
!
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4200
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4201
saveUnder:aBoolean
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4202
    "turn on/off saveUnder (saving pixels under myself)
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4203
     - used for temporary views (i.e. PopUps and ModalBoxes)"
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4204
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4205
    drawableId notNil ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  4206
	device setSaveUnder:aBoolean in:drawableId
6225
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4207
    ]
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4208
!
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4209
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4210
setCursorId:id
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4211
    drawableId notNil ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  4212
	device setCursor:id in:drawableId.
6225
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4213
    ]
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4214
!
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4215
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4216
setWindowPid: pid
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4217
    "Sets the _NET_WM_PID property for the window.
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4218
     This may be used by the window manager to group windows.
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4219
     If anIntegerOrNil is nil, then PID of currently running
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4220
     Smalltalk is used"
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4221
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4222
    drawableId notNil ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  4223
	device setWindowPid:pid in:drawableId.
6225
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4224
    ].
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4225
!
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4226
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4227
viewGravity:gravity
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4228
    "set the viewGravity - thats the direction where the view will move
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4229
     when the superView is resized."
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4230
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4231
    drawableId notNil ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  4232
	device setWindowGravity:gravity in:drawableId
6225
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4233
    ].
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4234
!
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4235
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4236
windowBorderShape:aForm
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4237
    "set the windows border shape"
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4238
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4239
    drawableId notNil ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  4240
	device setWindowBorderShape:(aForm id) in:drawableId
6225
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4241
    ].
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4242
!
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4243
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4244
windowClass:windowClassNameString name:nameString
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4245
    "define class and name of a window.
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4246
     This may be used by the window manager to
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4247
     select client specific resources."
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4248
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4249
    drawableId notNil ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  4250
	device setWindowClass:windowClassNameString name:nameString in:drawableId.
6225
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4251
    ].
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4252
!
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4253
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4254
windowName:aString
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4255
    "define the views name in the windows title area."
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4256
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4257
    drawableId notNil ifTrue: [
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  4258
	device setWindowName:aString in:drawableId.
6225
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4259
    ]
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4260
!
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4261
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4262
windowShape:aForm
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4263
    "set the windows shape.
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4264
     Returns false, if the display does not support the
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4265
     X shape extension."
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4266
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4267
    drawableId notNil ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  4268
	^ device setWindowShape:(aForm id) in:drawableId
6225
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4269
    ].
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4270
    ^ false.
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4271
! !
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4272
1085
3513a4cae87b handle depth1-images with a mask
Claus Gittinger <cg@exept.de>
parents: 1064
diff changeset
  4273
!DeviceGraphicsContext class methodsFor:'documentation'!
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4274
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4275
version
6926
d04d6d93b921 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6765
diff changeset
  4276
    ^ '$Header$'
5360
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  4277
!
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  4278
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  4279
version_CVS
6926
d04d6d93b921 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6765
diff changeset
  4280
    ^ '$Header$'
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4281
! !
3880
c4c8268a2d9f method category rename
Claus Gittinger <cg@exept.de>
parents: 3666
diff changeset
  4282
6107
afaac69e9310 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 5837
diff changeset
  4283
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4284
DeviceGraphicsContext initialize!