DeviceGraphicsContext.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Fri, 22 Apr 2016 08:34:13 +0100
branchjv
changeset 7312 e69b73023aea
parent 7311 9ca5a89f4805
child 7316 b06d9392b4cc
permissions -rw-r--r--
Merge
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
6472
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
    17
	instanceVariableNames:'drawableId gcId deviceFont foreground background drawableType
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
    18
		parentId'
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    19
	classVariableNames:'CachedScaledForms CachedScales Lobby'
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    20
	poolDictionaries:''
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    21
	category:'Graphics-Support'
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    22
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    23
6472
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
    24
DeviceHandle subclass:#DevicePixmapGCHandle
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
    25
	instanceVariableNames:''
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
    26
	classVariableNames:''
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
    27
	poolDictionaries:''
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
    28
	privateIn:DeviceGraphicsContext
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
    29
!
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
    30
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
    31
DeviceHandle subclass:#DeviceWindowGCHandle
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
    32
	instanceVariableNames:'parentId'
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
    33
	classVariableNames:''
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
    34
	poolDictionaries:''
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
    35
	privateIn:DeviceGraphicsContext
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
    36
!
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
    37
1085
3513a4cae87b handle depth1-images with a mask
Claus Gittinger <cg@exept.de>
parents: 1064
diff changeset
    38
!DeviceGraphicsContext class methodsFor:'documentation'!
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    39
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    40
copyright
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    41
"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    42
 COPYRIGHT (c) 1992 by Claus Gittinger
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    43
	      All Rights Reserved
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
 This software is furnished under a license and may be used
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    46
 only in accordance with the terms of that license and with the
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    47
 inclusion of the above copyright notice.   This software may not
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    48
 be provided or otherwise made available to, or used by, any
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    49
 other person.  No title to or ownership of the software is
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    50
 hereby transferred.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    51
"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    52
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    53
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    54
documentation
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    55
"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    56
    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
    57
    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
    58
    printer pages or fax pages).
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    59
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    60
    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
    61
    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
    62
    exist in the system.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    63
    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
    64
    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
    65
    drawing functions (see GraphicsContext drawing vs. basic drawing category).
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    66
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
    67
    The added variables foreground/background are the drawing colors actually
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    68
    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
    69
    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
    70
    totally replaced by paint/bgPaint
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
    71
    (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
    72
     fg/bg makes sense)
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    73
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    74
    [Instance variables:]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    75
1029
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
    76
	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
    77
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
    78
	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
    79
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
    80
	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
    81
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
    82
	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
    83
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
    84
	background      <Color>         the device background color used for drawing
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    85
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    86
    [see also:]
1029
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
    87
	DeviceWorkstation
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
    88
	Color Font Cursor
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
    [author:]
1029
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
    91
	Claus Gittinger
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
"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    94
! !
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    95
1085
3513a4cae87b handle depth1-images with a mask
Claus Gittinger <cg@exept.de>
parents: 1064
diff changeset
    96
!DeviceGraphicsContext class methodsFor:'initialization'!
732
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
initialize
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    99
    Lobby isNil ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   100
	Lobby := Registry new.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   101
    ]
2031
d369d38213cf dont use #error when drawing on a closed drawable;
Claus Gittinger <cg@exept.de>
parents: 2024
diff changeset
   102
d369d38213cf dont use #error when drawing on a closed drawable;
Claus Gittinger <cg@exept.de>
parents: 2024
diff changeset
   103
    "Modified: / 29.1.1998 / 12:56:12 / cg"
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   104
! !
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   105
1085
3513a4cae87b handle depth1-images with a mask
Claus Gittinger <cg@exept.de>
parents: 1064
diff changeset
   106
!DeviceGraphicsContext class methodsFor:'instance creation'!
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   107
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   108
new
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   109
    "create a new drawable - take the current display as
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   110
     its device (for now, this may be changed until the view is
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   111
     physically created)"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   112
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   113
"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   114
    '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
   115
"
6290
b6886e346ae9 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6273
diff changeset
   116
    |device|
b6886e346ae9 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6273
diff changeset
   117
b6886e346ae9 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6273
diff changeset
   118
    device := Screen current.
b6886e346ae9 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6273
diff changeset
   119
    device isNil ifTrue:[
6926
d04d6d93b921 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6765
diff changeset
   120
        device := Display.
d04d6d93b921 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6765
diff changeset
   121
        device isNil ifTrue:[
d04d6d93b921 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6765
diff changeset
   122
            (self class name,' [warning]: no Display') infoPrintCR.
d04d6d93b921 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6765
diff changeset
   123
            Smalltalk openDisplay.
d04d6d93b921 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6765
diff changeset
   124
            
7257
0507a7e2c35f #FEATURE
Claus Gittinger <cg@exept.de>
parents: 7237
diff changeset
   125
            device := Screen current ? Display.
6926
d04d6d93b921 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6765
diff changeset
   126
            device isNil ifTrue:[ self error:'no screen device' ]
d04d6d93b921 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6765
diff changeset
   127
        ].
6290
b6886e346ae9 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6273
diff changeset
   128
    ].
6926
d04d6d93b921 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6765
diff changeset
   129
    ^ self onDevice:device
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
on: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
3429
7f87cd2ae010 Use <resource:#obsolete>
Stefan Vogel <sv@exept.de>
parents: 3300
diff changeset
   135
    <resource:#obsolete>
7f87cd2ae010 Use <resource:#obsolete>
Stefan Vogel <sv@exept.de>
parents: 3300
diff changeset
   136
1741
b84a2f4317e9 warn #on: vs. #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1722
diff changeset
   137
    "/ 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
   138
    "/ operating on a model.
b84a2f4317e9 warn #on: vs. #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1722
diff changeset
   139
    "/ Please use #onDevice: to avoid confusion.
b84a2f4317e9 warn #on: vs. #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1722
diff changeset
   140
1255
bdf4cbcae668 on: -> onDevice:
Claus Gittinger <cg@exept.de>
parents: 1249
diff changeset
   141
    self obsoleteMethodWarning:'use #onDevice:'.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   142
    ^ self onDevice:aDevice
1255
bdf4cbcae668 on: -> onDevice:
Claus Gittinger <cg@exept.de>
parents: 1249
diff changeset
   143
1741
b84a2f4317e9 warn #on: vs. #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1722
diff changeset
   144
    "Modified: 5.6.1997 / 21:04:16 / cg"
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   145
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   146
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   147
onDevice:aDevice
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   148
    "create a new drawable on aDevice"
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
    |newDrawable|
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   151
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   152
    newDrawable := self basicNew.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   153
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   154
    "
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   155
     set display before its initialized
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   156
     - 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
   157
     intitialize method(s)
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   158
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   159
    newDrawable device:aDevice.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   160
    newDrawable initialize.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   161
    ^ newDrawable
1517
ac751bb3dfdf no need for registration here;
Claus Gittinger <cg@exept.de>
parents: 1514
diff changeset
   162
ac751bb3dfdf no need for registration here;
Claus Gittinger <cg@exept.de>
parents: 1514
diff changeset
   163
    "Modified: 2.4.1997 / 19:19:35 / cg"
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   164
! !
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   165
1085
3513a4cae87b handle depth1-images with a mask
Claus Gittinger <cg@exept.de>
parents: 1064
diff changeset
   166
!DeviceGraphicsContext class methodsFor:'cleanup'!
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   167
4436
05eadeb4b603 In #cleanUpLobbyForChildrenOfView...
Stefan Vogel <sv@exept.de>
parents: 4434
diff changeset
   168
cleanupLobbyForChildrenOfViewWithDevice:aDevice id:anId
6472
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   169
    "recursively clean all the subcomponents of the handle with id anId.
4436
05eadeb4b603 In #cleanUpLobbyForChildrenOfView...
Stefan Vogel <sv@exept.de>
parents: 4434
diff changeset
   170
     This must be done on finalization, because descendent handles
05eadeb4b603 In #cleanUpLobbyForChildrenOfView...
Stefan Vogel <sv@exept.de>
parents: 4434
diff changeset
   171
     are destroyed implicitly when a parent handle is destroyed."
05eadeb4b603 In #cleanUpLobbyForChildrenOfView...
Stefan Vogel <sv@exept.de>
parents: 4434
diff changeset
   172
05eadeb4b603 In #cleanUpLobbyForChildrenOfView...
Stefan Vogel <sv@exept.de>
parents: 4434
diff changeset
   173
    |parents newChildren|
05eadeb4b603 In #cleanUpLobbyForChildrenOfView...
Stefan Vogel <sv@exept.de>
parents: 4434
diff changeset
   174
05eadeb4b603 In #cleanUpLobbyForChildrenOfView...
Stefan Vogel <sv@exept.de>
parents: 4434
diff changeset
   175
    parents := Array with:anId address.
05eadeb4b603 In #cleanUpLobbyForChildrenOfView...
Stefan Vogel <sv@exept.de>
parents: 4434
diff changeset
   176
05eadeb4b603 In #cleanUpLobbyForChildrenOfView...
Stefan Vogel <sv@exept.de>
parents: 4434
diff changeset
   177
    [
7071
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 7033 7066
diff changeset
   178
        newChildren := Set new.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 7033 7066
diff changeset
   179
        Lobby unregisterAllForWhichHandle:[:handle |
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 7033 7066
diff changeset
   180
            |parentId|
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 7033 7066
diff changeset
   181
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 7033 7066
diff changeset
   182
            (handle notNil
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 7033 7066
diff changeset
   183
                and:[handle device == aDevice
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 7033 7066
diff changeset
   184
                and:[(parentId := handle parentId) notNil
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 7033 7066
diff changeset
   185
                and:[parents includes:parentId]]]
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 7033 7066
diff changeset
   186
            ) ifTrue:[newChildren add:handle id. true] ifFalse:[false]
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 7033 7066
diff changeset
   187
        ].
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 7033 7066
diff changeset
   188
        parents := newChildren.
4436
05eadeb4b603 In #cleanUpLobbyForChildrenOfView...
Stefan Vogel <sv@exept.de>
parents: 4434
diff changeset
   189
    ] doWhile:[parents notEmpty].
4434
cbbb56b8d851 addons and fixes for X11-deviceHandle fix
Claus Gittinger <cg@exept.de>
parents: 4403
diff changeset
   190
!
cbbb56b8d851 addons and fixes for X11-deviceHandle fix
Claus Gittinger <cg@exept.de>
parents: 4403
diff changeset
   191
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   192
lowSpaceCleanup
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   193
    CachedScaledForms := CachedScales := nil
1224
2a2270ec4236 added #releaseResourcesOnDevice:, to allow cleanup when
Claus Gittinger <cg@exept.de>
parents: 1199
diff changeset
   194
!
2a2270ec4236 added #releaseResourcesOnDevice:, to allow cleanup when
Claus Gittinger <cg@exept.de>
parents: 1199
diff changeset
   195
2a2270ec4236 added #releaseResourcesOnDevice:, to allow cleanup when
Claus Gittinger <cg@exept.de>
parents: 1199
diff changeset
   196
releaseResourcesOnDevice:aDevice
2a2270ec4236 added #releaseResourcesOnDevice:, to allow cleanup when
Claus Gittinger <cg@exept.de>
parents: 1199
diff changeset
   197
    "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
   198
     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
   199
2a2270ec4236 added #releaseResourcesOnDevice:, to allow cleanup when
Claus Gittinger <cg@exept.de>
parents: 1199
diff changeset
   200
    Lobby unregisterAllForWhich:[:aDrawable | aDrawable graphicsDevice == aDevice]
2a2270ec4236 added #releaseResourcesOnDevice:, to allow cleanup when
Claus Gittinger <cg@exept.de>
parents: 1199
diff changeset
   201
2a2270ec4236 added #releaseResourcesOnDevice:, to allow cleanup when
Claus Gittinger <cg@exept.de>
parents: 1199
diff changeset
   202
    "Created: 16.1.1997 / 16:43:52 / cg"
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   203
! !
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   204
3880
c4c8268a2d9f method category rename
Claus Gittinger <cg@exept.de>
parents: 3666
diff changeset
   205
!DeviceGraphicsContext methodsFor:'Compatibility-ST80'!
3188
67ce53b6b843 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3160
diff changeset
   206
67ce53b6b843 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3160
diff changeset
   207
key
67ce53b6b843 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3160
diff changeset
   208
    ^ self id
67ce53b6b843 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3160
diff changeset
   209
! !
67ce53b6b843 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3160
diff changeset
   210
3942
ee09c1391e61 some more dummies for VW widgets
Claus Gittinger <cg@exept.de>
parents: 3938
diff changeset
   211
!DeviceGraphicsContext methodsFor:'Compatibility-VW'!
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
displayBackgroundIfNeededOn: aGraphicsContext
4070
efd0ffb52d43 clear -> clearView
Claus Gittinger <cg@exept.de>
parents: 4056
diff changeset
   214
    aGraphicsContext clearView.
3942
ee09c1391e61 some more dummies for VW widgets
Claus Gittinger <cg@exept.de>
parents: 3938
diff changeset
   215
!
ee09c1391e61 some more dummies for VW widgets
Claus Gittinger <cg@exept.de>
parents: 3938
diff changeset
   216
ee09c1391e61 some more dummies for VW widgets
Claus Gittinger <cg@exept.de>
parents: 3938
diff changeset
   217
inactiveForegroundColor
3943
2d4dbd3f9aa6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3942
diff changeset
   218
    "a dummy method to support VW widgets"
2d4dbd3f9aa6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3942
diff changeset
   219
3942
ee09c1391e61 some more dummies for VW widgets
Claus Gittinger <cg@exept.de>
parents: 3938
diff changeset
   220
    ^ self foregroundColor
ee09c1391e61 some more dummies for VW widgets
Claus Gittinger <cg@exept.de>
parents: 3938
diff changeset
   221
!
ee09c1391e61 some more dummies for VW widgets
Claus Gittinger <cg@exept.de>
parents: 3938
diff changeset
   222
ee09c1391e61 some more dummies for VW widgets
Claus Gittinger <cg@exept.de>
parents: 3938
diff changeset
   223
selectionBackgroundColor
3943
2d4dbd3f9aa6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3942
diff changeset
   224
    "a dummy method to support VW widgets"
2d4dbd3f9aa6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3942
diff changeset
   225
3942
ee09c1391e61 some more dummies for VW widgets
Claus Gittinger <cg@exept.de>
parents: 3938
diff changeset
   226
    ^ self foregroundColor
ee09c1391e61 some more dummies for VW widgets
Claus Gittinger <cg@exept.de>
parents: 3938
diff changeset
   227
!
ee09c1391e61 some more dummies for VW widgets
Claus Gittinger <cg@exept.de>
parents: 3938
diff changeset
   228
ee09c1391e61 some more dummies for VW widgets
Claus Gittinger <cg@exept.de>
parents: 3938
diff changeset
   229
selectionForegroundColor
3943
2d4dbd3f9aa6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3942
diff changeset
   230
    "a dummy method to support VW widgets"
2d4dbd3f9aa6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3942
diff changeset
   231
3942
ee09c1391e61 some more dummies for VW widgets
Claus Gittinger <cg@exept.de>
parents: 3938
diff changeset
   232
    ^ self backgroundColor
ee09c1391e61 some more dummies for VW widgets
Claus Gittinger <cg@exept.de>
parents: 3938
diff changeset
   233
!
ee09c1391e61 some more dummies for VW widgets
Claus Gittinger <cg@exept.de>
parents: 3938
diff changeset
   234
ee09c1391e61 some more dummies for VW widgets
Claus Gittinger <cg@exept.de>
parents: 3938
diff changeset
   235
separatorColor
3943
2d4dbd3f9aa6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3942
diff changeset
   236
    "a dummy method to support VW widgets"
2d4dbd3f9aa6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3942
diff changeset
   237
3942
ee09c1391e61 some more dummies for VW widgets
Claus Gittinger <cg@exept.de>
parents: 3938
diff changeset
   238
    ^ self foregroundColor
ee09c1391e61 some more dummies for VW widgets
Claus Gittinger <cg@exept.de>
parents: 3938
diff changeset
   239
! !
ee09c1391e61 some more dummies for VW widgets
Claus Gittinger <cg@exept.de>
parents: 3938
diff changeset
   240
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   241
!DeviceGraphicsContext methodsFor:'accessing'!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   242
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   243
at:aPoint
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   244
    "return the pixel at the coordinate given by aPoint"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   245
3160
89905f311a09 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3137
diff changeset
   246
    ^ self atX:aPoint x y:aPoint y
89905f311a09 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3137
diff changeset
   247
89905f311a09 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3137
diff changeset
   248
    "Modified: / 29.1.2000 / 12:17:42 / cg"
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
4204
947a5a5620d3 comments
Claus Gittinger <cg@exept.de>
parents: 4199
diff changeset
   251
at:aPoint put:aPixelColor
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   252
    "set a pixel"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   253
4204
947a5a5620d3 comments
Claus Gittinger <cg@exept.de>
parents: 4199
diff changeset
   254
    ^ self atX:aPoint x y:aPoint y put:aPixelColor
947a5a5620d3 comments
Claus Gittinger <cg@exept.de>
parents: 4199
diff changeset
   255
947a5a5620d3 comments
Claus Gittinger <cg@exept.de>
parents: 4199
diff changeset
   256
    "
947a5a5620d3 comments
Claus Gittinger <cg@exept.de>
parents: 4199
diff changeset
   257
     Display rootView at:(0@0) put:(Color red).
947a5a5620d3 comments
Claus Gittinger <cg@exept.de>
parents: 4199
diff changeset
   258
     Display rootView at:(1@1) put:(Color red).
947a5a5620d3 comments
Claus Gittinger <cg@exept.de>
parents: 4199
diff changeset
   259
     Display rootView at:(2@2) put:(Color red).
947a5a5620d3 comments
Claus Gittinger <cg@exept.de>
parents: 4199
diff changeset
   260
     Display rootView at:(3@3) put:(Color red).
947a5a5620d3 comments
Claus Gittinger <cg@exept.de>
parents: 4199
diff changeset
   261
     Display rootView at:(4@4) put:(Color red).
947a5a5620d3 comments
Claus Gittinger <cg@exept.de>
parents: 4199
diff changeset
   262
     Display rootView at:(5@5) put:(Color red).
947a5a5620d3 comments
Claus Gittinger <cg@exept.de>
parents: 4199
diff changeset
   263
    "
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   264
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   265
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   266
atX:x y:y
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   267
    "return the pixel at the coordinate given by x/y"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   268
2714
e5d16e41cbab need gcId-argument in getPixel
Claus Gittinger <cg@exept.de>
parents: 2680
diff changeset
   269
    ^ device getPixelX:x y:y from:drawableId with:gcId
e5d16e41cbab need gcId-argument in getPixel
Claus Gittinger <cg@exept.de>
parents: 2680
diff changeset
   270
e5d16e41cbab need gcId-argument in getPixel
Claus Gittinger <cg@exept.de>
parents: 2680
diff changeset
   271
    "Modified: / 22.5.1999 / 01:40:23 / cg"
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   272
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   273
4204
947a5a5620d3 comments
Claus Gittinger <cg@exept.de>
parents: 4199
diff changeset
   274
atX:x y:y put:aPixelColor
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   275
    "set a pixel"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   276
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   277
    |oldFg|
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   278
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   279
    oldFg := foreground.
4204
947a5a5620d3 comments
Claus Gittinger <cg@exept.de>
parents: 4199
diff changeset
   280
    self foreground:aPixelColor.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   281
    self displayPointX:x y:y.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   282
    self foreground:oldFg
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   283
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   284
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   285
backgroundPaint:aColor
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   286
    "set the background-paint color; this is used in opaque-draw
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   287
     operations"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   288
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   289
    (aColor ~~ bgPaint) ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   290
	aColor notNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   291
	    bgPaint := aColor.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   292
	    gcId notNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   293
		bgPaint isColor ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   294
		    bgPaint := aColor onDevice:device.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   295
		    bgPaint colorId notNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   296
			background := bgPaint.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   297
			gcId notNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   298
			    device setBackground:(bgPaint colorId) in:gcId.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   299
			].
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   300
			^ self
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   301
		    ]
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   302
		].
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   303
		self paint:paint on:aColor
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   304
	    ]
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   305
	]
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   306
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   307
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   308
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   309
basicFont
2918
1e777dc8588a #font answers device font if possible (cg)
Stefan Vogel <sv@exept.de>
parents: 2913
diff changeset
   310
    "return the font for drawing"
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   311
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   312
    ^ font
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   313
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   314
    "Created: 12.5.1996 / 11:17:59 / cg"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   315
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   316
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   317
basicFont:aFont
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   318
    "set the font for drawing if it has changed.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   319
     This is a low level entry, which is not to be redefined
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   320
     (i.e. it must not imply a redraw operation)"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   321
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   322
    |id|
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
    (aFont ~~ font) ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   325
	aFont notNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   326
	    font := aFont.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   327
	    device notNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   328
		font := font onDevice:device.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   329
		gcId notNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   330
		    id := font fontId.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   331
		    id notNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   332
			deviceFont := font.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   333
			device setFont:id in:gcId
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   334
		    ]
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   335
		]
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   336
	    ]
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   337
	]
732
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
4664
02d160974029 fix remembering deviceFont everywhere.
Claus Gittinger <cg@exept.de>
parents: 4657
diff changeset
   340
    "Created: / 23-02-1996 / 17:16:51 / cg"
02d160974029 fix remembering deviceFont everywhere.
Claus Gittinger <cg@exept.de>
parents: 4657
diff changeset
   341
    "Modified: / 22-10-2006 / 14:11:37 / cg"
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   342
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   343
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   344
capStyle:aSymbol
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   345
    "set the style in which the endpoints of lines
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   346
     are drawn - aSymbol may be #notLast, #butt, #round, #projecting"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   347
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   348
    |s|
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
    (s := aSymbol) isNil ifTrue:[
1029
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
   351
	s := #butt.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   352
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   353
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   354
    (s ~~ capStyle) ifTrue:[
1029
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
   355
	capStyle := s.
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
   356
	gcId notNil ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   357
	    device setLineWidth:lineWidth
1029
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
   358
			  style:lineStyle
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
   359
			    cap:s
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
   360
			   join:joinStyle
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
   361
			     in:gcId
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
   362
	]
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   363
    ]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   364
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   365
    "Modified: 12.5.1996 / 22:23:03 / cg"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   366
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   367
950
d4d907fc7d78 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 927
diff changeset
   368
clipByChildren
d4d907fc7d78 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 927
diff changeset
   369
    "drawing shall be done into my view only (default)"
d4d907fc7d78 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 927
diff changeset
   370
3429
7f87cd2ae010 Use <resource:#obsolete>
Stefan Vogel <sv@exept.de>
parents: 3300
diff changeset
   371
    <resource:#obsolete>
7f87cd2ae010 Use <resource:#obsolete>
Stefan Vogel <sv@exept.de>
parents: 3300
diff changeset
   372
1722
4ceaeda95cc3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1715
diff changeset
   373
    self obsoleteMethodWarning:'use #clippedByChildren:true'.
950
d4d907fc7d78 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 927
diff changeset
   374
    ^ self clippedByChildren:true
d4d907fc7d78 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 927
diff changeset
   375
d4d907fc7d78 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 927
diff changeset
   376
    "Created: 17.7.1996 / 13:25:55 / cg"
d4d907fc7d78 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 927
diff changeset
   377
!
d4d907fc7d78 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 927
diff changeset
   378
6222
2d670d3bcfd5 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6215
diff changeset
   379
clipRect
2d670d3bcfd5 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6215
diff changeset
   380
    "return the clipping rectangle for drawing. If there is currently no clipRect,
2d670d3bcfd5 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6215
diff changeset
   381
     a dummy is created."
2d670d3bcfd5 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6215
diff changeset
   382
2d670d3bcfd5 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6215
diff changeset
   383
    |rect|
2d670d3bcfd5 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6215
diff changeset
   384
2d670d3bcfd5 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6215
diff changeset
   385
    (rect := clipRect) isNil ifTrue:[
6472
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   386
	rect := 0@0 extent:(self extent).
6222
2d670d3bcfd5 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6215
diff changeset
   387
    ].
2d670d3bcfd5 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6215
diff changeset
   388
"/ nope - it is already kept in logical coordinates
2d670d3bcfd5 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6215
diff changeset
   389
"/    transformation notNil ifTrue:[
2d670d3bcfd5 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6215
diff changeset
   390
"/        rect := transformation applyInverseTo:rect.
2d670d3bcfd5 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6215
diff changeset
   391
"/    ].
2d670d3bcfd5 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6215
diff changeset
   392
    ^ rect
2d670d3bcfd5 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6215
diff changeset
   393
2d670d3bcfd5 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6215
diff changeset
   394
    "Modified: / 20-10-2006 / 13:24:21 / cg"
2d670d3bcfd5 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6215
diff changeset
   395
!
2d670d3bcfd5 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6215
diff changeset
   396
950
d4d907fc7d78 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 927
diff changeset
   397
clippedByChildren:aBoolean
d4d907fc7d78 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 927
diff changeset
   398
    "turn on/off drawing over children.
d4d907fc7d78 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 927
diff changeset
   399
     If on, a superview may draw 'over' its children.
d4d907fc7d78 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 927
diff changeset
   400
     If off (the default), drawing is 'under' its children.
d4d907fc7d78 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 927
diff changeset
   401
     Only useful for the rootView, to draw over any visible views.
d4d907fc7d78 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 927
diff changeset
   402
     (for example, when dragging a rubber-line)"
d4d907fc7d78 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 927
diff changeset
   403
d4d907fc7d78 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 927
diff changeset
   404
    gcId isNil ifTrue:[
1680
f47862c358fb pass both drawableId & gcID to setClipByChildren
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   405
        self initGC
950
d4d907fc7d78 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 927
diff changeset
   406
    ].
1715
c70e31496f91 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1714
diff changeset
   407
    device noClipIn:drawableId gc:gcId.
c70e31496f91 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1714
diff changeset
   408
    device setClipByChildren:aBoolean in:drawableId gc:gcId.
950
d4d907fc7d78 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 927
diff changeset
   409
d4d907fc7d78 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 927
diff changeset
   410
    "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
   411
    "Modified: 29.4.1997 / 15:33:55 / dq"
950
d4d907fc7d78 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 927
diff changeset
   412
!
d4d907fc7d78 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 927
diff changeset
   413
6215
701d3f1f91f7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6210
diff changeset
   414
clippingBounds:aRectangleOrNil
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   415
    "set the clipping rectangle for drawing (in logical coordinates);
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   416
     a nil argument turn off clipping (i.e. whole view is drawable)"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   417
6472
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   418
    |x y w h newBounds|
7066
ac2d03dac697 #REFACTORING
Stefan Vogel <sv@exept.de>
parents: 7064
diff changeset
   419
ac2d03dac697 #REFACTORING
Stefan Vogel <sv@exept.de>
parents: 7064
diff changeset
   420
    aRectangleOrNil isNil ifTrue:[
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
   421
        clipRect isNil ifTrue:[^ self].
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
   422
        gcId notNil ifTrue:[
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
   423
            device noClipIn:drawableId gc:gcId
7066
ac2d03dac697 #REFACTORING
Stefan Vogel <sv@exept.de>
parents: 7064
diff changeset
   424
        ].
ac2d03dac697 #REFACTORING
Stefan Vogel <sv@exept.de>
parents: 7064
diff changeset
   425
        clipRect := nil.
6472
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   426
        ^ self.
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   427
    ].
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   428
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   429
    x := aRectangleOrNil left.
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   430
    y := aRectangleOrNil top.
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   431
    w := aRectangleOrNil width.
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   432
    h := aRectangleOrNil height.
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   433
    transformation notNil ifTrue:[
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   434
        x := transformation applyToX:x.
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   435
        y := transformation applyToY:y.
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   436
        w := transformation applyScaleX:w.
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   437
        h := transformation applyScaleY:h.
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   438
    ].
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   439
    (x class == SmallInteger) ifFalse:[
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   440
        w := w + (x - x truncated).
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   441
        x := x truncated
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   442
    ].
6472
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   443
    (y class == SmallInteger) ifFalse:[
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   444
        h := h + (y - y truncated).
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   445
        y := y truncated
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   446
    ].
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   447
    (w class == SmallInteger) ifFalse:[
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   448
        w := w truncated + 1
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   449
    ].
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   450
    (h class == SmallInteger) ifFalse:[
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   451
        h := h truncated + 1
6222
2d670d3bcfd5 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6215
diff changeset
   452
    ].
6472
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   453
    w := w max:0.
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   454
    h := h max:0.
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   455
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   456
    newBounds := Rectangle left:x top:y width:w height:h.
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   457
    (clipRect notNil and:[clipRect = newBounds]) ifTrue:[
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   458
        ^ self
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   459
    ].
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   460
    clipRect := newBounds.
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   461
    gcId notNil ifTrue:[
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   462
        device setClipX:x y:y width:w height:h in:drawableId gc:gcId.
6222
2d670d3bcfd5 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6215
diff changeset
   463
    ].
2d670d3bcfd5 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6215
diff changeset
   464
2d670d3bcfd5 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6215
diff changeset
   465
    "Created: / 28.5.1996 / 19:40:20 / cg"
2d670d3bcfd5 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6215
diff changeset
   466
    "Modified: / 16.5.1999 / 19:40:37 / cg"
2d670d3bcfd5 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6215
diff changeset
   467
!
2d670d3bcfd5 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6215
diff changeset
   468
1842
502aa16b146e added #colorAt:
Claus Gittinger <cg@exept.de>
parents: 1805
diff changeset
   469
colorAt:aPoint
502aa16b146e added #colorAt:
Claus Gittinger <cg@exept.de>
parents: 1805
diff changeset
   470
    "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
   471
502aa16b146e added #colorAt:
Claus Gittinger <cg@exept.de>
parents: 1805
diff changeset
   472
    ^ self colorAtX:(aPoint x) y:(aPoint y)
502aa16b146e added #colorAt:
Claus Gittinger <cg@exept.de>
parents: 1805
diff changeset
   473
502aa16b146e added #colorAt:
Claus Gittinger <cg@exept.de>
parents: 1805
diff changeset
   474
    "Modified: 1.8.1997 / 20:01:58 / cg"
502aa16b146e added #colorAt:
Claus Gittinger <cg@exept.de>
parents: 1805
diff changeset
   475
!
502aa16b146e added #colorAt:
Claus Gittinger <cg@exept.de>
parents: 1805
diff changeset
   476
502aa16b146e added #colorAt:
Claus Gittinger <cg@exept.de>
parents: 1805
diff changeset
   477
colorAtX:x y:y
502aa16b146e added #colorAt:
Claus Gittinger <cg@exept.de>
parents: 1805
diff changeset
   478
    "return the color of the pixel at the coordinate given by aPoint"
502aa16b146e added #colorAt:
Claus Gittinger <cg@exept.de>
parents: 1805
diff changeset
   479
502aa16b146e added #colorAt:
Claus Gittinger <cg@exept.de>
parents: 1805
diff changeset
   480
    |pixel|
502aa16b146e added #colorAt:
Claus Gittinger <cg@exept.de>
parents: 1805
diff changeset
   481
502aa16b146e added #colorAt:
Claus Gittinger <cg@exept.de>
parents: 1805
diff changeset
   482
    pixel := self atX:x y:y.
502aa16b146e added #colorAt:
Claus Gittinger <cg@exept.de>
parents: 1805
diff changeset
   483
    device getScaledRGBFrom:pixel into:[:r :g :b |
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   484
	^ Color scaledRed:r scaledGreen:g scaledBlue:b
1842
502aa16b146e added #colorAt:
Claus Gittinger <cg@exept.de>
parents: 1805
diff changeset
   485
    ].
502aa16b146e added #colorAt:
Claus Gittinger <cg@exept.de>
parents: 1805
diff changeset
   486
502aa16b146e added #colorAt:
Claus Gittinger <cg@exept.de>
parents: 1805
diff changeset
   487
    "Created: 1.8.1997 / 20:01:32 / cg"
502aa16b146e added #colorAt:
Claus Gittinger <cg@exept.de>
parents: 1805
diff changeset
   488
!
502aa16b146e added #colorAt:
Claus Gittinger <cg@exept.de>
parents: 1805
diff changeset
   489
4199
c01c62e8c7a5 dummy container
Claus Gittinger <cg@exept.de>
parents: 4172
diff changeset
   490
container
c01c62e8c7a5 dummy container
Claus Gittinger <cg@exept.de>
parents: 4172
diff changeset
   491
    "return my container - for protocol compatibility"
c01c62e8c7a5 dummy container
Claus Gittinger <cg@exept.de>
parents: 4172
diff changeset
   492
c01c62e8c7a5 dummy container
Claus Gittinger <cg@exept.de>
parents: 4172
diff changeset
   493
    ^ nil
c01c62e8c7a5 dummy container
Claus Gittinger <cg@exept.de>
parents: 4172
diff changeset
   494
!
c01c62e8c7a5 dummy container
Claus Gittinger <cg@exept.de>
parents: 4172
diff changeset
   495
786
af5fecf93126 added dashStyle: ...
Claus Gittinger <cg@exept.de>
parents: 784
diff changeset
   496
dashStyle:aDashList offset:dashOffset
af5fecf93126 added dashStyle: ...
Claus Gittinger <cg@exept.de>
parents: 784
diff changeset
   497
    "define dashes. Each element of the dashList specifies the length
af5fecf93126 added dashStyle: ...
Claus Gittinger <cg@exept.de>
parents: 784
diff changeset
   498
     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
   499
     defines 4on-4off dashing;
786
af5fecf93126 added dashStyle: ...
Claus Gittinger <cg@exept.de>
parents: 784
diff changeset
   500
     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
   501
     The dashOffset specifies where in the dashList the dashing starts.
af5fecf93126 added dashStyle: ...
Claus Gittinger <cg@exept.de>
parents: 784
diff changeset
   502
     This may not be supported by all graphics devices."
af5fecf93126 added dashStyle: ...
Claus Gittinger <cg@exept.de>
parents: 784
diff changeset
   503
af5fecf93126 added dashStyle: ...
Claus Gittinger <cg@exept.de>
parents: 784
diff changeset
   504
    gcId notNil ifTrue:[
1029
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
   505
	device setDashes:(ByteArray withAll:aDashList)
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
   506
	      dashOffset:dashOffset
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
   507
		      in:gcId
786
af5fecf93126 added dashStyle: ...
Claus Gittinger <cg@exept.de>
parents: 784
diff changeset
   508
    ]
af5fecf93126 added dashStyle: ...
Claus Gittinger <cg@exept.de>
parents: 784
diff changeset
   509
af5fecf93126 added dashStyle: ...
Claus Gittinger <cg@exept.de>
parents: 784
diff changeset
   510
    "Modified: 4.6.1996 / 19:03:06 / cg"
af5fecf93126 added dashStyle: ...
Claus Gittinger <cg@exept.de>
parents: 784
diff changeset
   511
!
af5fecf93126 added dashStyle: ...
Claus Gittinger <cg@exept.de>
parents: 784
diff changeset
   512
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   513
device
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   514
    "return the device, the receiver is associated with"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   515
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   516
    ^ device
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   517
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   518
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   519
device:aDevice
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   520
    "set the device"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   521
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   522
    device := aDevice
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   523
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   524
6472
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   525
deviceClippingBounds:aRectangleOrNil
2343
9e8d62561418 added #deviceClippingRectangle:
Claus Gittinger <cg@exept.de>
parents: 2322
diff changeset
   526
    "set the clipping rectangle for drawing (in device coordinates);
3275
b40f47ec5661 comment
Claus Gittinger <cg@exept.de>
parents: 3188
diff changeset
   527
     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
   528
6472
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   529
    clipRect = aRectangleOrNil ifTrue:[
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   530
        ^ self
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   531
    ].
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   532
    clipRect := aRectangleOrNil.
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   533
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   534
    gcId isNil ifTrue:[
6501
ef63b2302cba class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6497
diff changeset
   535
        ^ self.
ef63b2302cba class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6497
diff changeset
   536
    ].
ef63b2302cba class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6497
diff changeset
   537
2343
9e8d62561418 added #deviceClippingRectangle:
Claus Gittinger <cg@exept.de>
parents: 2322
diff changeset
   538
    aRectangleOrNil isNil ifTrue:[
6472
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   539
        device noClipIn:drawableId gc:gcId
2343
9e8d62561418 added #deviceClippingRectangle:
Claus Gittinger <cg@exept.de>
parents: 2322
diff changeset
   540
    ] ifFalse:[
6472
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   541
        device setClipX:aRectangleOrNil left 
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   542
                    y:aRectangleOrNil top 
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   543
                    width:aRectangleOrNil width 
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   544
                    height:aRectangleOrNil height 
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   545
                    in:drawableId
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   546
                    gc:gcId
6501
ef63b2302cba class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6497
diff changeset
   547
    ].
ef63b2302cba class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6497
diff changeset
   548
2343
9e8d62561418 added #deviceClippingRectangle:
Claus Gittinger <cg@exept.de>
parents: 2322
diff changeset
   549
    "Modified: / 22.5.1996 / 13:12:07 / cg"
9e8d62561418 added #deviceClippingRectangle:
Claus Gittinger <cg@exept.de>
parents: 2322
diff changeset
   550
    "Created: / 14.9.1998 / 18:50:31 / cg"
9e8d62561418 added #deviceClippingRectangle:
Claus Gittinger <cg@exept.de>
parents: 2322
diff changeset
   551
!
9e8d62561418 added #deviceClippingRectangle:
Claus Gittinger <cg@exept.de>
parents: 2322
diff changeset
   552
6472
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   553
deviceClippingBoundsOrNil
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   554
    "get the clipping rectangle for drawing (in device coordinates);
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   555
     a nil clipping rectangle means: no clipping (i.e. whole view is drawable - incl. margins)"
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   556
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   557
    ^ clipRect
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   558
!
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   559
7060
Stefan Vogel <sv@exept.de>
parents: 6926
diff changeset
   560
deviceClippingRectangle
Stefan Vogel <sv@exept.de>
parents: 6926
diff changeset
   561
    "answer the clipping rectangle for drawing in device coordinates, or nil."
Stefan Vogel <sv@exept.de>
parents: 6926
diff changeset
   562
Stefan Vogel <sv@exept.de>
parents: 6926
diff changeset
   563
    |x y w h transformedRectangle|
Stefan Vogel <sv@exept.de>
parents: 6926
diff changeset
   564
7062
21b62a5d9b98 #BUGFIX
Stefan Vogel <sv@exept.de>
parents: 7060
diff changeset
   565
    (clipRect isNil or:[transformation isNil]) ifTrue:[
7060
Stefan Vogel <sv@exept.de>
parents: 6926
diff changeset
   566
        ^ clipRect.
Stefan Vogel <sv@exept.de>
parents: 6926
diff changeset
   567
    ].
Stefan Vogel <sv@exept.de>
parents: 6926
diff changeset
   568
Stefan Vogel <sv@exept.de>
parents: 6926
diff changeset
   569
    transformedRectangle := transformation transformRectangle:clipRect.
Stefan Vogel <sv@exept.de>
parents: 6926
diff changeset
   570
Stefan Vogel <sv@exept.de>
parents: 6926
diff changeset
   571
    x := transformedRectangle left.
Stefan Vogel <sv@exept.de>
parents: 6926
diff changeset
   572
    y := transformedRectangle top.
Stefan Vogel <sv@exept.de>
parents: 6926
diff changeset
   573
    w := transformedRectangle width + 1.
Stefan Vogel <sv@exept.de>
parents: 6926
diff changeset
   574
    h := transformedRectangle height + 1.
Stefan Vogel <sv@exept.de>
parents: 6926
diff changeset
   575
Stefan Vogel <sv@exept.de>
parents: 6926
diff changeset
   576
    (x class == SmallInteger) ifFalse:[
Stefan Vogel <sv@exept.de>
parents: 6926
diff changeset
   577
        w := w + (x - x truncated).
Stefan Vogel <sv@exept.de>
parents: 6926
diff changeset
   578
        x := x truncated
Stefan Vogel <sv@exept.de>
parents: 6926
diff changeset
   579
    ].
Stefan Vogel <sv@exept.de>
parents: 6926
diff changeset
   580
    (y class == SmallInteger) ifFalse:[
Stefan Vogel <sv@exept.de>
parents: 6926
diff changeset
   581
        h := h + (y - y truncated).
Stefan Vogel <sv@exept.de>
parents: 6926
diff changeset
   582
        y := y truncated
Stefan Vogel <sv@exept.de>
parents: 6926
diff changeset
   583
    ].
Stefan Vogel <sv@exept.de>
parents: 6926
diff changeset
   584
    (w class == SmallInteger) ifFalse:[
7062
21b62a5d9b98 #BUGFIX
Stefan Vogel <sv@exept.de>
parents: 7060
diff changeset
   585
        w := w ceiling.
7060
Stefan Vogel <sv@exept.de>
parents: 6926
diff changeset
   586
    ].
Stefan Vogel <sv@exept.de>
parents: 6926
diff changeset
   587
    (h class == SmallInteger) ifFalse:[
7062
21b62a5d9b98 #BUGFIX
Stefan Vogel <sv@exept.de>
parents: 7060
diff changeset
   588
        h := h ceiling.
7060
Stefan Vogel <sv@exept.de>
parents: 6926
diff changeset
   589
    ].
Stefan Vogel <sv@exept.de>
parents: 6926
diff changeset
   590
    w := w max:0.
Stefan Vogel <sv@exept.de>
parents: 6926
diff changeset
   591
    h := h max:0.
Stefan Vogel <sv@exept.de>
parents: 6926
diff changeset
   592
Stefan Vogel <sv@exept.de>
parents: 6926
diff changeset
   593
    ^ Rectangle left:x top:y width:w height:h
Stefan Vogel <sv@exept.de>
parents: 6926
diff changeset
   594
!
Stefan Vogel <sv@exept.de>
parents: 6926
diff changeset
   595
2343
9e8d62561418 added #deviceClippingRectangle:
Claus Gittinger <cg@exept.de>
parents: 2322
diff changeset
   596
deviceClippingRectangle:aRectangleOrNil
6819
f91377f97414 Merged 1e33b4eeb725 and ee648b604f67 (branch default)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 6800 6765
diff changeset
   597
<conflict>
f91377f97414 Merged 1e33b4eeb725 and ee648b604f67 (branch default)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 6800 6765
diff changeset
   598
<conflict>
f91377f97414 Merged 1e33b4eeb725 and ee648b604f67 (branch default)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 6800 6765
diff changeset
   599
<conflict>
f91377f97414 Merged 1e33b4eeb725 and ee648b604f67 (branch default)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 6800 6765
diff changeset
   600
<conflict>
f91377f97414 Merged 1e33b4eeb725 and ee648b604f67 (branch default)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 6800 6765
diff changeset
   601
<conflict>
f91377f97414 Merged 1e33b4eeb725 and ee648b604f67 (branch default)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 6800 6765
diff changeset
   602
<conflict>
f91377f97414 Merged 1e33b4eeb725 and ee648b604f67 (branch default)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 6800 6765
diff changeset
   603
<conflict>
f91377f97414 Merged 1e33b4eeb725 and ee648b604f67 (branch default)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 6800 6765
diff changeset
   604
<conflict>
f91377f97414 Merged 1e33b4eeb725 and ee648b604f67 (branch default)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 6800 6765
diff changeset
   605
<conflict>
f91377f97414 Merged 1e33b4eeb725 and ee648b604f67 (branch default)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 6800 6765
diff changeset
   606
<conflict>
f91377f97414 Merged 1e33b4eeb725 and ee648b604f67 (branch default)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 6800 6765
diff changeset
   607
<conflict>
f91377f97414 Merged 1e33b4eeb725 and ee648b604f67 (branch default)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 6800 6765
diff changeset
   608
<conflict>
f91377f97414 Merged 1e33b4eeb725 and ee648b604f67 (branch default)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 6800 6765
diff changeset
   609
<conflict>
f91377f97414 Merged 1e33b4eeb725 and ee648b604f67 (branch default)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 6800 6765
diff changeset
   610
<conflict>
f91377f97414 Merged 1e33b4eeb725 and ee648b604f67 (branch default)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 6800 6765
diff changeset
   611
<conflict>
f91377f97414 Merged 1e33b4eeb725 and ee648b604f67 (branch default)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 6800 6765
diff changeset
   612
<conflict>
f91377f97414 Merged 1e33b4eeb725 and ee648b604f67 (branch default)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 6800 6765
diff changeset
   613
<conflict>
f91377f97414 Merged 1e33b4eeb725 and ee648b604f67 (branch default)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 6800 6765
diff changeset
   614
<conflict>
f91377f97414 Merged 1e33b4eeb725 and ee648b604f67 (branch default)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 6800 6765
diff changeset
   615
<conflict>
f91377f97414 Merged 1e33b4eeb725 and ee648b604f67 (branch default)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 6800 6765
diff changeset
   616
<conflict>
f91377f97414 Merged 1e33b4eeb725 and ee648b604f67 (branch default)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 6800 6765
diff changeset
   617
<conflict>
f91377f97414 Merged 1e33b4eeb725 and ee648b604f67 (branch default)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 6800 6765
diff changeset
   618
<conflict>
f91377f97414 Merged 1e33b4eeb725 and ee648b604f67 (branch default)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 6800 6765
diff changeset
   619
<conflict>
f91377f97414 Merged 1e33b4eeb725 and ee648b604f67 (branch default)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 6800 6765
diff changeset
   620
<conflict>
f91377f97414 Merged 1e33b4eeb725 and ee648b604f67 (branch default)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 6800 6765
diff changeset
   621
<conflict>
f91377f97414 Merged 1e33b4eeb725 and ee648b604f67 (branch default)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 6800 6765
diff changeset
   622
<conflict>
f91377f97414 Merged 1e33b4eeb725 and ee648b604f67 (branch default)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 6800 6765
diff changeset
   623
<conflict>
f91377f97414 Merged 1e33b4eeb725 and ee648b604f67 (branch default)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 6800 6765
diff changeset
   624
<conflict>
f91377f97414 Merged 1e33b4eeb725 and ee648b604f67 (branch default)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 6800 6765
diff changeset
   625
<conflict>
f91377f97414 Merged 1e33b4eeb725 and ee648b604f67 (branch default)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 6800 6765
diff changeset
   626
<conflict>
f91377f97414 Merged 1e33b4eeb725 and ee648b604f67 (branch default)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 6800 6765
diff changeset
   627
<conflict>
f91377f97414 Merged 1e33b4eeb725 and ee648b604f67 (branch default)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 6800 6765
diff changeset
   628
<conflict>
f91377f97414 Merged 1e33b4eeb725 and ee648b604f67 (branch default)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 6800 6765
diff changeset
   629
<conflict>
6222
2d670d3bcfd5 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6215
diff changeset
   630
!
2d670d3bcfd5 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6215
diff changeset
   631
2918
1e777dc8588a #font answers device font if possible (cg)
Stefan Vogel <sv@exept.de>
parents: 2913
diff changeset
   632
font
1e777dc8588a #font answers device font if possible (cg)
Stefan Vogel <sv@exept.de>
parents: 2913
diff changeset
   633
    "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
   634
     the GC is realized."
1e777dc8588a #font answers device font if possible (cg)
Stefan Vogel <sv@exept.de>
parents: 2913
diff changeset
   635
7218
4c15124a9431 #BUGFIX
Stefan Vogel <sv@exept.de>
parents: 7066
diff changeset
   636
    (device notNil and:[font notNil]) ifTrue:[
4c15124a9431 #BUGFIX
Stefan Vogel <sv@exept.de>
parents: 7066
diff changeset
   637
        font := font onDevice:device
2918
1e777dc8588a #font answers device font if possible (cg)
Stefan Vogel <sv@exept.de>
parents: 2913
diff changeset
   638
    ].
1e777dc8588a #font answers device font if possible (cg)
Stefan Vogel <sv@exept.de>
parents: 2913
diff changeset
   639
    ^ font
1e777dc8588a #font answers device font if possible (cg)
Stefan Vogel <sv@exept.de>
parents: 2913
diff changeset
   640
!
1e777dc8588a #font answers device font if possible (cg)
Stefan Vogel <sv@exept.de>
parents: 2913
diff changeset
   641
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   642
font:aFont
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   643
    "set the font for drawing if it has changed.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   644
     This should be redefined in some widget to perform an automatic
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   645
     redraw. See also: #basicFont:"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   646
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   647
    (aFont ~~ font) ifTrue:[
4031
31728329be82 font-change sends a change notification
Claus Gittinger <cg@exept.de>
parents: 4026
diff changeset
   648
        self basicFont:aFont.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   649
    ]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   650
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   651
    "Modified: 6.3.1996 / 18:17:40 / cg"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   652
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   653
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   654
function:aSymbol
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   655
    "set the drawing function if it has changed"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   656
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   657
    (aSymbol ~~ function) ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   658
	function := aSymbol.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   659
	gcId notNil ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   660
	    device setFunction:aSymbol in:gcId
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   661
	]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   662
    ]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   663
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   664
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   665
gcId
7237
9482956af0f1 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 7218
diff changeset
   666
    "return the receiver's graphic context id on the device"
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   667
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   668
    ^ gcId
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
graphicsDevice
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   672
    "return the device, the receiver is associated with.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   673
     Same as #device, for ST-80 compatibility."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   674
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   675
    ^ device
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   676
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   677
    "Created: 9.5.1996 / 01:37:58 / cg"
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
id
6222
2d670d3bcfd5 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6215
diff changeset
   681
    "return the id of the drawable on the device"
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   682
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   683
    ^ drawableId
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
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   686
joinStyle:aSymbol
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   687
    "set the style in which 2 lines are connected in polygons -
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   688
     aSymbol may be #miter, #bevel, #round"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   689
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   690
    |s|
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
    (s := aSymbol) isNil ifTrue:[
1029
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
   693
	s := #miter
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   694
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   695
    (s ~~ joinStyle) ifTrue:[
1029
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
   696
	joinStyle := s.
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   697
1029
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
   698
	gcId notNil ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   699
	    device setLineWidth:lineWidth
1029
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
   700
			  style:lineStyle
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
   701
			    cap:capStyle
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
   702
			   join:s
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
   703
			     in:gcId
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
   704
	]
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   705
    ]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   706
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   707
    "Modified: 12.5.1996 / 22:20:43 / cg"
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
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   710
lineStyle:aSymbol
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   711
    "set the style in which lines are drawn -
2360
c7ca5d55d8ce comment
Claus Gittinger <cg@exept.de>
parents: 2343
diff changeset
   712
     aSymbol may be #solid, #dashed, #doubleDashed,
c7ca5d55d8ce comment
Claus Gittinger <cg@exept.de>
parents: 2343
diff changeset
   713
     #dotted, #dashDot or #dashDotDot."
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   714
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   715
    |s|
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   716
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   717
    (s := aSymbol) isNil ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   718
	s := #solid
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   719
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   720
    (s ~~ lineStyle) ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   721
	lineStyle := s.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   722
	gcId notNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   723
	    device setLineWidth:lineWidth
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   724
			  style:s
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   725
			    cap:capStyle
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   726
			   join:joinStyle
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   727
			     in:gcId
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   728
	]
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   729
    ]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   730
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   731
    "Modified: 12.5.1996 / 22:21:25 / cg"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   732
!
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
lineWidth:aNumber
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   735
    "set the line width for drawing if it has changed"
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
    |n|
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   738
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   739
    (aNumber ~~ lineWidth) ifTrue:[
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
   740
        lineWidth := aNumber.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
   741
        transformation isNil ifTrue:[
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
   742
            n := aNumber.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
   743
        ] ifFalse:[
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
   744
            n := transformation applyScaleX:aNumber.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
   745
            n := n rounded
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
   746
        ].
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
   747
        gcId notNil ifTrue:[
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
   748
            device setLineWidth:n style:lineStyle cap:capStyle join:joinStyle in:gcId
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
   749
        ]
732
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
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   752
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   753
mask:aForm
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   754
    "set the mask form for drawing"
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
    |id|
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   757
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   758
    (aForm ~~ mask) ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   759
	mask := aForm.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   760
	gcId notNil ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   761
	    (mask == nil) ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   762
		device setBitmapMask:nil in:gcId
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   763
	    ] ifFalse:[
1033
b5cd84ed805f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1029
diff changeset
   764
		mask := mask asFormOn:device.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   765
		id := mask id.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   766
		(mask depth == 1) ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   767
		    device setBitmapMask:id in:gcId
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   768
		] ifFalse:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   769
		    device setPixmapMask:id in:gcId
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   770
		]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   771
	    ]
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
    ]
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
2018
1ad552e97c67 maskOrigin
Claus Gittinger <cg@exept.de>
parents: 2016
diff changeset
   776
maskOrigin:aPoint
1ad552e97c67 maskOrigin
Claus Gittinger <cg@exept.de>
parents: 2016
diff changeset
   777
    "set the origin of the mask-pattern"
1ad552e97c67 maskOrigin
Claus Gittinger <cg@exept.de>
parents: 2016
diff changeset
   778
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
   779
    |x y pO|
2018
1ad552e97c67 maskOrigin
Claus Gittinger <cg@exept.de>
parents: 2016
diff changeset
   780
1ad552e97c67 maskOrigin
Claus Gittinger <cg@exept.de>
parents: 2016
diff changeset
   781
    x := aPoint x.
1ad552e97c67 maskOrigin
Claus Gittinger <cg@exept.de>
parents: 2016
diff changeset
   782
    y := aPoint y.
1ad552e97c67 maskOrigin
Claus Gittinger <cg@exept.de>
parents: 2016
diff changeset
   783
1ad552e97c67 maskOrigin
Claus Gittinger <cg@exept.de>
parents: 2016
diff changeset
   784
    (maskOrigin isNil or:[
1ad552e97c67 maskOrigin
Claus Gittinger <cg@exept.de>
parents: 2016
diff changeset
   785
     ((x ~= maskOrigin x) or:[y ~= maskOrigin y]) ]) ifTrue:[
1ad552e97c67 maskOrigin
Claus Gittinger <cg@exept.de>
parents: 2016
diff changeset
   786
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
   787
        maskOrigin := aPoint.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
   788
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
   789
        transformation notNil ifTrue:[
6711
2b50385f7257 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
   790
            pO := transformation transformPoint:aPoint.
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
   791
            x:= pO x.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
   792
            y := pO y.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
   793
        ].
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
   794
        x := x rounded.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
   795
        y := y rounded.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
   796
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
   797
        gcId notNil ifTrue:[
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
   798
            device setMaskOriginX:x y:y in:gcId
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
   799
        ]
2018
1ad552e97c67 maskOrigin
Claus Gittinger <cg@exept.de>
parents: 2016
diff changeset
   800
    ]
1ad552e97c67 maskOrigin
Claus Gittinger <cg@exept.de>
parents: 2016
diff changeset
   801
1ad552e97c67 maskOrigin
Claus Gittinger <cg@exept.de>
parents: 2016
diff changeset
   802
    "Created: / 26.1.1998 / 19:03:02 / cg"
1ad552e97c67 maskOrigin
Claus Gittinger <cg@exept.de>
parents: 2016
diff changeset
   803
!
1ad552e97c67 maskOrigin
Claus Gittinger <cg@exept.de>
parents: 2016
diff changeset
   804
2016
bef5fe2ec2ca checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2013
diff changeset
   805
maskOriginX:orgX y:orgY
bef5fe2ec2ca checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2013
diff changeset
   806
    "set the origin of the pattern"
bef5fe2ec2ca checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2013
diff changeset
   807
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
   808
    self maskOrigin:(orgX @ orgY)
2016
bef5fe2ec2ca checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2013
diff changeset
   809
!
bef5fe2ec2ca checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2013
diff changeset
   810
950
d4d907fc7d78 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 927
diff changeset
   811
noClipByChildren
d4d907fc7d78 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 927
diff changeset
   812
    "drawing shall also be done into subviews"
d4d907fc7d78 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 927
diff changeset
   813
3429
7f87cd2ae010 Use <resource:#obsolete>
Stefan Vogel <sv@exept.de>
parents: 3300
diff changeset
   814
    <resource:#obsolete>
7f87cd2ae010 Use <resource:#obsolete>
Stefan Vogel <sv@exept.de>
parents: 3300
diff changeset
   815
1722
4ceaeda95cc3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1715
diff changeset
   816
    self obsoleteMethodWarning:'use #clippedByChildren:false'.
950
d4d907fc7d78 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 927
diff changeset
   817
    ^ self clippedByChildren:false
d4d907fc7d78 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 927
diff changeset
   818
d4d907fc7d78 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 927
diff changeset
   819
    "Created: 17.7.1996 / 14:15:54 / cg"
d4d907fc7d78 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 927
diff changeset
   820
!
d4d907fc7d78 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 927
diff changeset
   821
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   822
paint:aColor
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   823
    "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
   824
     or even an image."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   825
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   826
    (aColor ~~ paint) ifTrue:[
1029
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
   827
	aColor notNil ifTrue:[
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
   828
	    paint := aColor.
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
   829
	    self setGCForPaint.
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
   830
	]
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   831
    ]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   832
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   833
    "Modified: 16.5.1996 / 15:35:57 / cg"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   834
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   835
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   836
paint:fgColor on:bgColor
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   837
    "set the paint and background-paint color.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   838
     The bg-paint is used in opaque-draw operations"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   839
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   840
    |fgId bgId|
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   841
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   842
    ((fgColor ~~ paint) or:[bgColor ~~ bgPaint]) ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   843
	fgColor notNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   844
	    paint := fgColor
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   845
	].
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   846
	bgColor notNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   847
	    bgPaint := bgColor
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   848
	].
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   849
	gcId notNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   850
	    paint isColor ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   851
		paint := paint onDevice:device.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   852
	    ].
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   853
	    paint isColor ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   854
		fgId := paint colorId.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   855
		fgId notNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   856
		    mask notNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   857
			mask := nil.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   858
			device setBitmapMask:nil in:gcId
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   859
		    ].
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   860
		    bgPaint isColor ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   861
			bgPaint := bgPaint onDevice:device.
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
		    bgPaint isColor ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   864
			bgId := bgPaint colorId.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   865
			bgId notNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   866
			    "the common case, both are real colors"
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   867
			    (paint ~~ foreground) ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   868
				foreground := paint.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   869
				(bgPaint ~~ background) ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   870
				    background := bgPaint.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   871
				    device setForeground:fgId background:bgId in:gcId.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   872
				    ^ self
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   873
				].
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   874
				device setForeground:fgId in:gcId.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   875
				^ self
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 ~~ background) ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   878
				background := bgPaint.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   879
				device setBackground:bgId in:gcId.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   880
			    ].
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   881
			    ^ self
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   882
			].
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   883
			"bgPaint is dithered, setup paint here, leave bgPaint
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   884
			 till next opaque draw comes around."
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   885
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   886
			(paint ~~ foreground) ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   887
			    foreground := paint.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   888
			    device setForeground:fgId in:gcId
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   889
			].
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   890
			^ self
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   891
		    ]
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   892
		]
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
	    "either paint or bgPaint (or both) are dithered colors,
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   895
	     setup for paint, leave bg-problem till next opaque draw
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   896
	     comes around.
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 setGCForPaint.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   899
	]
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   900
    ]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   901
4797
91ee43d3acf5 changed #paint:on:
Claus Gittinger <cg@exept.de>
parents: 4781
diff changeset
   902
    "Modified: / 31-08-2007 / 10:56:49 / cg"
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   903
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   904
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   905
paint:fgColor on:bgColor function:f
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   906
    "set paint, background-paint and function"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   907
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   908
    self paint:fgColor on:bgColor.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   909
    self function:f
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   910
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   911
    "Modified: 16.5.1996 / 15:36:35 / cg"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   912
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   913
6266
1503c5e038d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   914
setClippingBounds:aRectangleOrNil
6472
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   915
    "set the clipping rectangle for drawing (in physical coordinates.
6266
1503c5e038d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   916
     Only set the variable, do not change the gc"
1503c5e038d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   917
1503c5e038d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   918
    clipRect := aRectangleOrNil
1503c5e038d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   919
!
1503c5e038d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   920
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   921
setGraphicsExposures:aBoolean
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   922
    "want to if aBoolean is true - or dont want to be notified
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   923
     of graphics exposures"
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
    gcId notNil ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   926
	device setGraphicsExposures:aBoolean in:gcId
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   927
    ]
6266
1503c5e038d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   928
!
1503c5e038d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   929
1503c5e038d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   930
setPaint:fgColor on:bgColor
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   931
    "set the paint and background-paint color.
6266
1503c5e038d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   932
     The bg-paint is used in opaque-draw operations.
1503c5e038d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   933
     Only set the variables, but do not send it to the device,
1503c5e038d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   934
     Used on initialization."
1503c5e038d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   935
1503c5e038d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   936
    fgColor notNil ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   937
	foreground := paint := fgColor
6266
1503c5e038d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   938
    ].
1503c5e038d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   939
    bgColor notNil ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   940
	background := bgPaint := bgColor
6266
1503c5e038d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   941
    ].
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   942
! !
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   943
1092
1b6391f333de category rename
Claus Gittinger <cg@exept.de>
parents: 1085
diff changeset
   944
!DeviceGraphicsContext methodsFor:'accessing-internals'!
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   945
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   946
background
6266
1503c5e038d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   947
    <resource: #obsolete>
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   948
    "return the current background drawing color.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   949
     OBSOLETE: use #paint: / #backgroundPaint: / #paint:on:"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   950
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   951
    ^ background
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   952
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   953
    "Modified: 12.5.1996 / 22:28:09 / cg"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   954
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   955
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   956
background:aColor
6266
1503c5e038d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   957
    <resource: #obsolete>
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   958
    "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
   959
     OBSOLETE: this method will vanish; use #paint: / #backgroundPaint: / #paint:on:"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   960
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   961
    |bgId|
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
    (aColor ~~ background) ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   964
	aColor notNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   965
	    background := aColor.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   966
	    gcId notNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   967
		background := background onDevice:device.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   968
		bgId := background colorId.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   969
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   970
		"
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   971
		 mhmh the following is a kludge ....
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   972
		"
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   973
		bgId isNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   974
		    (background grayIntensity >= 50) ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   975
			bgId := device whitepixel
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   976
		    ] ifFalse:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   977
			bgId := device blackpixel
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   978
		    ]
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   979
		].
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   980
		device setBackground:bgId in:gcId
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   981
	    ]
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   982
	]
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   983
    ]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   984
745
d4465098f2c0 gray vs. grey
Claus Gittinger <cg@exept.de>
parents: 735
diff changeset
   985
    "Modified: 28.5.1996 / 20:44:55 / cg"
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   986
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   987
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   988
foreground
6266
1503c5e038d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   989
    <resource: #obsolete>
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   990
    "return the current foreground drawing color.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   991
     OBSOLETE: use #paint: / #paint:on:"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   992
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   993
    ^ foreground
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   994
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   995
    "Modified: 12.5.1996 / 22:28:03 / cg"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   996
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   997
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   998
foreground:aColor
6266
1503c5e038d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   999
    <resource: #obsolete>
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1000
    "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
  1001
     OBSOLETE: this method will vanish; use #paint: / #paint:on:"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1002
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1003
    |fgId|
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
    (aColor ~~ foreground) ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1006
	aColor notNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1007
	    foreground := aColor.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1008
	    gcId notNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1009
		(foreground class == SmallInteger) ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1010
		    fgId := foreground
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1011
		] ifFalse:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1012
		    foreground := foreground onDevice:device.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1013
		    fgId := foreground colorId.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1014
		].
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1015
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1016
		"mhmh the following is a kludge ...."
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1017
		fgId isNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1018
		    (foreground grayIntensity >= 50) ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1019
			fgId := device whitepixel
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1020
		    ] ifFalse:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1021
			fgId := device blackpixel
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1022
		    ]
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1023
		].
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1024
		device setForeground:fgId in:gcId.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1025
		paint := foreground
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1026
	    ]
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1027
	]
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1028
    ]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1029
745
d4465098f2c0 gray vs. grey
Claus Gittinger <cg@exept.de>
parents: 735
diff changeset
  1030
    "Modified: 28.5.1996 / 20:45:02 / cg"
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1031
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1032
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1033
foreground:fgColor background:bgColor
6266
1503c5e038d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1034
    <resource: #obsolete>
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1035
    "set both internal foreground and internal background colors
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1036
     - these must be real colors.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1037
     OBSOLETE: this method will vanish; use #paint: / #paint:on:"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1038
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1039
    |fgPixel bgPixel|
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1040
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1041
    ((fgColor ~~ foreground) or:[bgColor ~~ background]) ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1042
	fgColor notNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1043
	    foreground := fgColor
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1044
	].
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1045
	bgColor notNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1046
	    background := bgColor
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1047
	].
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1048
	gcId notNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1049
	    foreground := foreground onDevice:device.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1050
	    background := background onDevice:device.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1051
	    fgPixel := foreground colorId.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1052
	    bgPixel := background colorId.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1053
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1054
	    "mhmh the following is a kludge ...."
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1055
	    fgPixel isNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1056
		(foreground grayIntensity >= 50) ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1057
		    fgPixel := device whitepixel
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1058
		] ifFalse:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1059
		    fgPixel := device blackpixel
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1060
		]
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
	    bgPixel isNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1063
		(background grayIntensity >= 50) ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1064
		    bgPixel := device whitepixel
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1065
		] ifFalse:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1066
		    bgPixel := device blackpixel
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1067
		]
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1068
	    ].
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1069
	    device setForeground:fgPixel background:bgPixel in:gcId.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1070
	    paint := foreground
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1071
	]
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1072
    ]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1073
745
d4465098f2c0 gray vs. grey
Claus Gittinger <cg@exept.de>
parents: 735
diff changeset
  1074
    "Modified: 28.5.1996 / 20:45:27 / cg"
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1075
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1076
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1077
foreground:fgColor background:bgColor function:fun
6266
1503c5e038d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1078
    <resource: #obsolete>
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1079
    "set foreground, background colors and function.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1080
     OBSOLETE: this method will vanish; use #paint: / #paint:on:"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1081
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1082
    self foreground:fgColor background:bgColor.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1083
    self function:fun
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1084
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1085
    "Modified: 12.5.1996 / 22:28:34 / cg"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1086
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1087
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1088
foreground:aColor function:fun
6266
1503c5e038d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1089
    <resource: #obsolete>
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1090
    "set the foreground color and function for drawing.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1091
     OBSOLETE: this method will vanish; use #paint: / #paint:on:"
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
    |fgPixel|
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1094
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1095
    ((aColor ~~ foreground) or:[fun ~~ function]) ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1096
	foreground := aColor.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1097
	function := fun.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1098
	gcId notNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1099
	    foreground := foreground onDevice:device.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1100
	    fgPixel := foreground colorId.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1101
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1102
	    "mhmh the following is a kludge ...."
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1103
	    fgPixel isNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1104
		(foreground grayIntensity >= 50) ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1105
		    fgPixel := device whitepixel
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1106
		] ifFalse:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1107
		    fgPixel := device blackpixel
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1108
		]
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1109
	    ].
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1110
	    device setForeground:fgPixel in:gcId.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1111
	    device setFunction:fun in:gcId.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1112
	    paint := foreground
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1113
	]
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1114
    ]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1115
745
d4465098f2c0 gray vs. grey
Claus Gittinger <cg@exept.de>
parents: 735
diff changeset
  1116
    "Modified: 28.5.1996 / 20:45:09 / cg"
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1117
! !
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1118
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1119
!DeviceGraphicsContext methodsFor:'bit blitting'!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1120
2016
bef5fe2ec2ca checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2013
diff changeset
  1121
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
  1122
    "copy bits from a smalltalk byteArray.
bef5fe2ec2ca checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2013
diff changeset
  1123
     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
  1124
     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
  1125
     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
  1126
     method to whatever the device needs."
bef5fe2ec2ca checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2013
diff changeset
  1127
bef5fe2ec2ca checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2013
diff changeset
  1128
    device
bef5fe2ec2ca checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2013
diff changeset
  1129
        drawBits:aByteArray
6472
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1130
        bitsPerPixel:bpp
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1131
        depth:depth
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1132
        padding:pad
2016
bef5fe2ec2ca checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2013
diff changeset
  1133
        width:srcW height:srcH
bef5fe2ec2ca checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2013
diff changeset
  1134
        x:srcX y:srcY
bef5fe2ec2ca checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2013
diff changeset
  1135
        into:drawableId
6472
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1136
        x:dstX y:dstY
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1137
        width:srcW height:srcH       "all senders set srcW/srcH to self width / self height"
2016
bef5fe2ec2ca checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2013
diff changeset
  1138
        with:gcId.
bef5fe2ec2ca checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2013
diff changeset
  1139
!
bef5fe2ec2ca checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2013
diff changeset
  1140
6472
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1141
copyBitsFrom:aByteArray bitsPerPixel:bpp depth:depth width:srcW height:srcH x:srcX y:srcY toX:dstX y:dstY 
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1142
    "copy bits from a smalltalk byteArray.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1143
     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
  1144
     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
  1145
     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
  1146
     method to whatever the device needs.
d8b8149ab79d added interface to specify padding in drawBits method
Claus Gittinger <cg@exept.de>
parents: 1842
diff changeset
  1147
     Assumes the source bits are in ST/X's natural padding (i.e. 8-bit padded)"
6472
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1148
    
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1149
    self 
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1150
        copyBitsFrom:aByteArray
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1151
        bitsPerPixel:bpp
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1152
        depth:depth
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1153
        padding:8
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1154
        width:srcW
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1155
        height:srcH
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1156
        x:srcX
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1157
        y:srcY
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1158
        toX:dstX
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1159
        y:dstY
1996
d8b8149ab79d added interface to specify padding in drawBits method
Claus Gittinger <cg@exept.de>
parents: 1842
diff changeset
  1160
!
d8b8149ab79d added interface to specify padding in drawBits method
Claus Gittinger <cg@exept.de>
parents: 1842
diff changeset
  1161
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1162
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
  1163
    "copy from aDrawable into the receiver;
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1164
     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
  1165
     All coordinates are in device coordinates."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1166
1291
1480f8aae3bb explicit sync/async bitBlt.
Claus Gittinger <cg@exept.de>
parents: 1255
diff changeset
  1167
    ^ self
6819
f91377f97414 Merged 1e33b4eeb725 and ee648b604f67 (branch default)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 6800 6765
diff changeset
  1168
        copyFrom:aDrawable
f91377f97414 Merged 1e33b4eeb725 and ee648b604f67 (branch default)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 6800 6765
diff changeset
  1169
        x:srcX y:srcY
f91377f97414 Merged 1e33b4eeb725 and ee648b604f67 (branch default)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 6800 6765
diff changeset
  1170
        toX:dstX y:dstY
f91377f97414 Merged 1e33b4eeb725 and ee648b604f67 (branch default)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 6800 6765
diff changeset
  1171
        width:w height:h
f91377f97414 Merged 1e33b4eeb725 and ee648b604f67 (branch default)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 6800 6765
diff changeset
  1172
        async:false
1291
1480f8aae3bb explicit sync/async bitBlt.
Claus Gittinger <cg@exept.de>
parents: 1255
diff changeset
  1173
1480f8aae3bb explicit sync/async bitBlt.
Claus Gittinger <cg@exept.de>
parents: 1255
diff changeset
  1174
    "Modified: 29.1.1997 / 13:12:36 / cg"
1480f8aae3bb explicit sync/async bitBlt.
Claus Gittinger <cg@exept.de>
parents: 1255
diff changeset
  1175
!
1480f8aae3bb explicit sync/async bitBlt.
Claus Gittinger <cg@exept.de>
parents: 1255
diff changeset
  1176
1480f8aae3bb explicit sync/async bitBlt.
Claus Gittinger <cg@exept.de>
parents: 1255
diff changeset
  1177
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
  1178
    "copy from aDrawable into the receiver;
1480f8aae3bb explicit sync/async bitBlt.
Claus Gittinger <cg@exept.de>
parents: 1255
diff changeset
  1179
     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
  1180
     All coordinates are in device coordinates.
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1181
     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
  1182
     - otherwise, it returns when the scroll operation is finished.
1480f8aae3bb explicit sync/async bitBlt.
Claus Gittinger <cg@exept.de>
parents: 1255
diff changeset
  1183
     (not all devices care for this).
1480f8aae3bb explicit sync/async bitBlt.
Claus Gittinger <cg@exept.de>
parents: 1255
diff changeset
  1184
     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
  1185
1480f8aae3bb explicit sync/async bitBlt.
Claus Gittinger <cg@exept.de>
parents: 1255
diff changeset
  1186
    |deviceDrawable id srcGCId asy|
976
807b42b00353 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 975
diff changeset
  1187
2210
18d4e83d08ad care for images being passed to #copyFrom: as source.
Claus Gittinger <cg@exept.de>
parents: 2192
diff changeset
  1188
    ((aDrawable graphicsDevice ~~ device)
18d4e83d08ad care for images being passed to #copyFrom: as source.
Claus Gittinger <cg@exept.de>
parents: 2192
diff changeset
  1189
    or:[aDrawable isImage]) ifTrue:[
6746
e63784ff3863 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6711
diff changeset
  1190
        deviceDrawable := aDrawable asFormOn:device.
976
807b42b00353 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 975
diff changeset
  1191
    ] ifFalse:[
6746
e63784ff3863 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6711
diff changeset
  1192
        deviceDrawable := aDrawable
976
807b42b00353 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 975
diff changeset
  1193
    ].
807b42b00353 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 975
diff changeset
  1194
807b42b00353 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 975
diff changeset
  1195
    id := deviceDrawable id.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1196
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1197
    "temporary ...
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1198
     this fixes a problem after restart on another display,
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1199
     when a file-bitmap was not found.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1200
     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
  1201
     This will be fixed soon (no longer use device>>bitmapFromFile:).
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1202
    "
976
807b42b00353 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 975
diff changeset
  1203
    id isNil ifTrue:[
6746
e63784ff3863 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6711
diff changeset
  1204
        Smalltalk isStandAloneApp ifFalse:[
e63784ff3863 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6711
diff changeset
  1205
            'DeviceGraphicsContext [warning]: invalid bitmap copy - ignored' infoPrintCR.
e63784ff3863 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6711
diff changeset
  1206
        ].
e63784ff3863 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6711
diff changeset
  1207
        ^ self
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1208
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1209
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1210
    gcId isNil ifTrue:[
6746
e63784ff3863 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6711
diff changeset
  1211
        self initGC
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1212
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1213
2065
27bf0cf42e45 changes for WIN32
Claus Gittinger <cg@exept.de>
parents: 2049
diff changeset
  1214
    deviceDrawable gcId isNil ifTrue:[deviceDrawable initGC].
976
807b42b00353 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 975
diff changeset
  1215
    srcGCId := deviceDrawable gcId.
807b42b00353 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 975
diff changeset
  1216
807b42b00353 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 975
diff changeset
  1217
    ((deviceDrawable depth == 1) and:[device depth ~~ 1]) ifTrue:[
6746
e63784ff3863 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6711
diff changeset
  1218
        deviceDrawable isForm ifTrue:[
e63784ff3863 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6711
diff changeset
  1219
            device
e63784ff3863 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6711
diff changeset
  1220
                copyPlaneFromPixmapId:id
e63784ff3863 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6711
diff changeset
  1221
                x:srcX
e63784ff3863 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6711
diff changeset
  1222
                y:srcY
e63784ff3863 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6711
diff changeset
  1223
                gc:srcGCId
e63784ff3863 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6711
diff changeset
  1224
                to:drawableId
e63784ff3863 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6711
diff changeset
  1225
                x:dstX
e63784ff3863 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6711
diff changeset
  1226
                y:dstY
e63784ff3863 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6711
diff changeset
  1227
                gc:gcId
e63784ff3863 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6711
diff changeset
  1228
                width:w
e63784ff3863 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6711
diff changeset
  1229
                height:h
e63784ff3863 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6711
diff changeset
  1230
        ] ifFalse:[
e63784ff3863 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6711
diff changeset
  1231
            device
e63784ff3863 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6711
diff changeset
  1232
                copyPlaneFromId:id
e63784ff3863 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6711
diff changeset
  1233
                x:srcX
e63784ff3863 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6711
diff changeset
  1234
                y:srcY
e63784ff3863 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6711
diff changeset
  1235
                gc:srcGCId
e63784ff3863 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6711
diff changeset
  1236
                to:drawableId
e63784ff3863 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6711
diff changeset
  1237
                x:dstX
e63784ff3863 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6711
diff changeset
  1238
                y:dstY
e63784ff3863 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6711
diff changeset
  1239
                gc:gcId
e63784ff3863 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6711
diff changeset
  1240
                width:w
e63784ff3863 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6711
diff changeset
  1241
                height:h
e63784ff3863 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6711
diff changeset
  1242
        ]
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1243
    ] ifFalse:[
6746
e63784ff3863 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6711
diff changeset
  1244
        deviceDrawable isForm ifTrue:[
e63784ff3863 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6711
diff changeset
  1245
            device
e63784ff3863 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6711
diff changeset
  1246
                copyFromPixmapId:id
e63784ff3863 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6711
diff changeset
  1247
                x:srcX
e63784ff3863 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6711
diff changeset
  1248
                y:srcY
e63784ff3863 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6711
diff changeset
  1249
                gc:srcGCId
e63784ff3863 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6711
diff changeset
  1250
                to:drawableId
e63784ff3863 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6711
diff changeset
  1251
                x:dstX
e63784ff3863 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6711
diff changeset
  1252
                y:dstY
e63784ff3863 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6711
diff changeset
  1253
                gc:gcId
e63784ff3863 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6711
diff changeset
  1254
                width:w
e63784ff3863 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6711
diff changeset
  1255
                height:h
e63784ff3863 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6711
diff changeset
  1256
        ] ifFalse:[
e63784ff3863 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6711
diff changeset
  1257
            asy := async or:[self isView not].
e63784ff3863 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6711
diff changeset
  1258
            asy ifFalse:[
e63784ff3863 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6711
diff changeset
  1259
                self catchExpose
e63784ff3863 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6711
diff changeset
  1260
            ].
e63784ff3863 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6711
diff changeset
  1261
            device
e63784ff3863 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6711
diff changeset
  1262
                copyFromId:id
e63784ff3863 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6711
diff changeset
  1263
                x:srcX
e63784ff3863 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6711
diff changeset
  1264
                y:srcY
e63784ff3863 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6711
diff changeset
  1265
                gc:srcGCId
e63784ff3863 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6711
diff changeset
  1266
                to:drawableId
e63784ff3863 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6711
diff changeset
  1267
                x:dstX
e63784ff3863 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6711
diff changeset
  1268
                y:dstY
e63784ff3863 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6711
diff changeset
  1269
                gc:gcId
e63784ff3863 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6711
diff changeset
  1270
                width:w
e63784ff3863 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6711
diff changeset
  1271
                height:h.
e63784ff3863 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6711
diff changeset
  1272
            asy ifFalse:[
e63784ff3863 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6711
diff changeset
  1273
                device flush.
e63784ff3863 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6711
diff changeset
  1274
                self waitForExpose
e63784ff3863 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6711
diff changeset
  1275
            ]
e63784ff3863 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6711
diff changeset
  1276
        ]
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1277
    ]
868
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
  1278
2210
18d4e83d08ad care for images being passed to #copyFrom: as source.
Claus Gittinger <cg@exept.de>
parents: 2192
diff changeset
  1279
    "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
  1280
    "Modified: / 31.7.1998 / 17:23:43 / cg"
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1281
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1282
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1283
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
  1284
    "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
  1285
     background, while 1's are drawn with foreground color.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1286
     The depth of aDrawable must (should) be 1.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1287
     The drawable must have been allocated on the same device.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1288
     All coordinates are in device coordinates."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1289
1064
2d0783c97f32 removed unused vars
Claus Gittinger <cg@exept.de>
parents: 1034
diff changeset
  1290
    |deviceDrawable id|
976
807b42b00353 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 975
diff changeset
  1291
2210
18d4e83d08ad care for images being passed to #copyFrom: as source.
Claus Gittinger <cg@exept.de>
parents: 2192
diff changeset
  1292
    ((aDrawable graphicsDevice ~~ device)
18d4e83d08ad care for images being passed to #copyFrom: as source.
Claus Gittinger <cg@exept.de>
parents: 2192
diff changeset
  1293
    or:[aDrawable isImage]) ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1294
	deviceDrawable := aDrawable asFormOn:device.
976
807b42b00353 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 975
diff changeset
  1295
    ] ifFalse:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1296
	deviceDrawable := aDrawable
976
807b42b00353 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 975
diff changeset
  1297
    ].
807b42b00353 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 975
diff changeset
  1298
807b42b00353 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 975
diff changeset
  1299
    id := deviceDrawable id.
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
    "temporary ...
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1302
     this fixes a problem after restart on another display,
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1303
     when a file-bitmap was not found.
976
807b42b00353 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 975
diff changeset
  1304
     In this case, the id of the bitmap will be nil.
807b42b00353 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 975
diff changeset
  1305
     This will be fixed soon (no longer use device>>bitmapFromFile:).
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1306
    "
976
807b42b00353 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 975
diff changeset
  1307
    id isNil ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1308
	'DeviceGraphicsContext [warning]: invalid copyPlane - ignored' errorPrintCR.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1309
	^ self
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1310
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1311
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1312
    gcId isNil ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1313
	self initGC
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1314
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1315
1249
5224bb7a97bf use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  1316
    deviceDrawable isForm ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1317
	deviceDrawable gcId isNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1318
	    deviceDrawable initGC
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1319
	].
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1320
	device
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1321
	    copyPlaneFromPixmapId:id
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1322
	    x:srcX
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1323
	    y:srcY
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1324
	    gc:(deviceDrawable gcId)
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1325
	    to:drawableId
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1326
	    x:dstX
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1327
	    y:dstY
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1328
	    gc:gcId
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1329
	    width:w
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1330
	    height:h
1249
5224bb7a97bf use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  1331
    ] ifFalse:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1332
	device
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1333
	    copyPlaneFromId:id
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1334
	    x:srcX
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1335
	    y:srcY
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1336
	    gc:(deviceDrawable gcId)
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1337
	    to:drawableId
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1338
	    x:dstX
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1339
	    y:dstY
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1340
	    gc:gcId
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1341
	    width:w
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1342
	    height:h
1249
5224bb7a97bf use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  1343
    ]
5224bb7a97bf use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  1344
2271
46b68ae54cbc win32 needs source-gc to be initialized in a bitBlt.
Claus Gittinger <cg@exept.de>
parents: 2268
diff changeset
  1345
    "Modified: / 22.8.1998 / 15:15:52 / cg"
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1346
! !
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1347
7253
1b427e95d77c Inform GC (DeviceGraphicsContext) when it's size or children's size or origin changes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 7244
diff changeset
  1348
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1349
!DeviceGraphicsContext methodsFor:'copying'!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1350
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1351
postCopy
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1352
    "this may not be enough to allow copying of views ..."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1353
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1354
    super postCopy.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1355
    device := drawableId := gcId := nil.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1356
    self recreate
4403
3342601d3fed +postDeepCopy
Claus Gittinger <cg@exept.de>
parents: 4389
diff changeset
  1357
!
3342601d3fed +postDeepCopy
Claus Gittinger <cg@exept.de>
parents: 4389
diff changeset
  1358
3342601d3fed +postDeepCopy
Claus Gittinger <cg@exept.de>
parents: 4389
diff changeset
  1359
postDeepCopy
3342601d3fed +postDeepCopy
Claus Gittinger <cg@exept.de>
parents: 4389
diff changeset
  1360
    device := drawableId := gcId := nil.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1361
! !
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1362
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1363
!DeviceGraphicsContext methodsFor:'drawing'!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1364
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1365
displayArcX:x y:y width:w height:h from:startAngle angle:angle
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1366
    "draw an arc; apply transformation if nonNil"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1367
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1368
    |pX pY nW nH sA a pO pC|
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1369
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1370
    gcId isNil ifTrue:[
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1371
        self initGC
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1372
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1373
    transformation notNil ifTrue:[
6711
2b50385f7257 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
  1374
        pO := transformation transformPoint:x@y.
2b50385f7257 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
  1375
        pC := transformation transformPoint:(x+w-1)@(y+h-1).
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1376
        pX := pO x.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1377
        pY := pO y.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1378
        nW := pC x - pX + 1.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1379
        nH := pC y - pY + 1.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1380
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1381
        nW < 0 ifTrue:[
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1382
              nW := nW abs.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1383
              pX := pX - nW.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1384
        ].
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1385
        nH < 0 ifTrue:[
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1386
              nH := nH abs.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1387
              pY := pY - nH.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1388
        ].
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1389
    ] ifFalse:[
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1390
        pX := x.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1391
        pY := y.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1392
        nW := w.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1393
        nH := h.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1394
    ].
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
    pX := pX rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1397
    pY := pY rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1398
    nW := nW rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1399
    nH := nH rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1400
2268
1a774fc02c83 fixed non-float (i.e. fraction) args to fillArc/ displayArc
Claus Gittinger <cg@exept.de>
parents: 2259
diff changeset
  1401
    sA := startAngle.
1a774fc02c83 fixed non-float (i.e. fraction) args to fillArc/ displayArc
Claus Gittinger <cg@exept.de>
parents: 2259
diff changeset
  1402
    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
  1403
    a := angle.
1a774fc02c83 fixed non-float (i.e. fraction) args to fillArc/ displayArc
Claus Gittinger <cg@exept.de>
parents: 2259
diff changeset
  1404
    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
  1405
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1406
    device
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1407
          displayArcX:pX
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1408
                    y:pY
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1409
                width:nW
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1410
               height:nH
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1411
                 from:sA
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1412
                angle:a
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1413
                   in:drawableId
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1414
                 with:gcId
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1415
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1416
    "Created: 8.5.1996 / 08:31:30 / cg"
784
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
  1417
    "Modified: 4.6.1996 / 17:59:28 / cg"
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1418
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1419
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1420
displayForm:formToDraw x:x y:y
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1421
    "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
  1422
     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
  1423
     current paint-color, leaving pixels with 0-bits unchanged
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1424
     (i.e. only 1-bits are drawn from the form).
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1425
     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
  1426
     settings are ignored and the form is drawn as-is.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1427
     Care must be taken, that the paint color is correctly allocated
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1428
     (by sending #on: to the color) before doing so.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1429
     Using functions other than #copy only makes sense if you are
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1430
     certain, that the colors are real colors (actually, only for
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1431
     noColor or allColor)."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1432
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1433
    |realForm pX pY w h nW nH pO pC|
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1434
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1435
    realForm := formToDraw.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1436
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1437
    transformation notNil ifTrue:[
6711
2b50385f7257 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
  1438
        pO := transformation transformPoint:x@y.
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1439
        pX := pO x.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1440
        pY := pO y.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1441
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1442
        transformation isNoScale ifFalse:[
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1443
            w := formToDraw width.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1444
            h := formToDraw height.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1445
            pC := transformation applyTo:(x+w-1)@(y+h-1).
6751
9d7cb6c4d04a class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6746
diff changeset
  1446
            nW := pC x - pX + 1.
9d7cb6c4d04a class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6746
diff changeset
  1447
            nH := pC y - pY + 1.
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1448
            "/ nW := (transformation applyScaleX:w) rounded.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1449
            "/ nH := (transformation applyScaleY:h) rounded.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1450
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1451
            ((nW ~= w) or:[nH ~= h]) ifTrue:[
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1452
                "/
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1453
                "/ hard case - someone is drawing forms with scaling in effect
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1454
                "/ look if we have a scaled version in our pocket ...
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1455
                "/
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1456
                realForm := nil.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1457
                CachedScaledForms notNil ifTrue:[
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1458
                    (CachedScales at:formToDraw ifAbsent:nil) = transformation scale ifTrue:[
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1459
                        realForm := CachedScaledForms at:formToDraw ifAbsent:nil.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1460
                    ]
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1461
                ].
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1462
                realForm isNil ifTrue:[
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1463
                    "/
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1464
                    "/ nope - must do the work ...
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1465
                    "/
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1466
                    realForm := formToDraw magnifiedBy:(nW / w) @ (nH / h).
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1467
                    CachedScaledForms isNil ifTrue:[
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1468
                        CachedScaledForms := WeakIdentityDictionary new.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1469
                        CachedScales := WeakIdentityDictionary new.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1470
                    ].
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1471
                    CachedScaledForms at:formToDraw put:realForm.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1472
                    CachedScales at:formToDraw put:transformation scale.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1473
                ]
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1474
            ]
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1475
        ]
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1476
    ] ifFalse:[
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1477
        pX := x.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1478
        pY := y.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1479
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1480
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1481
    self displayDeviceForm:realForm x:pX y:pY
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1482
1592
7ec770f2047a faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents: 1517
diff changeset
  1483
    "Modified: 12.4.1997 / 12:47:29 / cg"
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1484
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1485
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1486
displayLineFrom:p0 to:p1
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1487
    "draw a line (with current paint-color); apply transformation if nonNil"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1488
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1489
    |pX0 pY0 pX1 pY1 easy fgId bgId tp0 tp1|
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1490
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1491
    gcId isNil ifTrue:[
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1492
        self initGC
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1493
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1494
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1495
    lineStyle == #doubleDashed ifTrue:[
6691
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
         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
  1498
        "
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1499
        easy := true.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1500
        paint isColor ifFalse:[
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1501
            easy := false
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1502
        ] ifTrue:[
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1503
            fgId := paint colorId.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1504
            fgId isNil ifTrue:[
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1505
                easy := false
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1506
            ]
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1507
        ].
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1508
        bgPaint isColor ifFalse:[
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1509
            easy := false
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1510
        ] ifTrue:[
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1511
            bgId := bgPaint colorId.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1512
            bgId isNil ifTrue:[
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1513
                easy := false
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1514
            ]
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1515
        ].
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1516
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1517
        easy ifTrue:[
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1518
            ((foreground ~~ paint) or:[background ~~ bgPaint]) ifTrue:[
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1519
                device setForeground:fgId background:bgId in:gcId.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1520
                foreground := paint.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1521
                background := bgPaint.
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
        ] ifFalse:[
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1524
            'DeviceGraphicsContext [warning]: cannot draw dashes with dithered colors' errorPrintCR
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1525
        ].
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1526
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1527
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1528
    transformation notNil ifTrue:[
6711
2b50385f7257 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
  1529
        tp0 := transformation transformPoint:p0.
2b50385f7257 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
  1530
        tp1 := transformation transformPoint:p1.
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1531
        pX0 := tp0 x.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1532
        pY0 := tp0 y.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1533
        pX1 := tp1 x.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1534
        pY1 := tp1 y.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1535
    ] ifFalse:[
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1536
        pX0 := p0 x.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1537
        pY0 := p0 y.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1538
        pX1 := p1 x.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1539
        pY1 := p1 y
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
    pX0 := pX0 rounded.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1543
    pY0 := pY0 rounded.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1544
    pX1 := pX1 rounded.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1545
    pY1 := pY1 rounded.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1546
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1547
    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
  1548
!
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1549
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1550
displayLineFromX:x0 y:y0 toX:x1 y:y1
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1551
    "draw a line (with current paint-color); apply transformation if nonNil"
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1552
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1553
    |pX0 pY0 pX1 pY1 easy fgId bgId p0 p1|
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1554
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1555
    gcId isNil ifTrue:[
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1556
        self initGC
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1557
    ].
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1558
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1559
    lineStyle == #doubleDashed ifTrue:[
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1560
        "
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1561
         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
  1562
        "
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1563
        easy := true.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1564
        paint isColor ifFalse:[
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1565
            easy := false
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1566
        ] ifTrue:[
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1567
            fgId := paint colorId.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1568
            fgId isNil ifTrue:[
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1569
                easy := false
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1570
            ]
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1571
        ].
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1572
        bgPaint isColor ifFalse:[
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1573
            easy := false
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1574
        ] ifTrue:[
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1575
            bgId := bgPaint colorId.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1576
            bgId isNil ifTrue:[
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1577
                easy := false
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
        ].
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
        easy ifTrue:[
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1582
            ((foreground ~~ paint) or:[background ~~ bgPaint]) ifTrue:[
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1583
                device setForeground:fgId background:bgId in:gcId.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1584
                foreground := paint.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1585
                background := bgPaint.
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
        ] ifFalse:[
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1588
            'DeviceGraphicsContext [warning]: cannot draw dashes with dithered colors' errorPrintCR
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1589
        ].
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1590
    ].
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1591
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1592
    transformation notNil ifTrue:[
6711
2b50385f7257 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
  1593
        p0 := transformation transformPoint:x0@y0.
2b50385f7257 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
  1594
        p1 := transformation transformPoint:x1@y1.
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1595
        pX0 := p0 x.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1596
        pY0 := p0 y.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1597
        pX1 := p1 x.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1598
        pY1 := p1 y.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1599
    ] ifFalse:[
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1600
        pX0 := x0.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1601
        pY0 := y0.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1602
        pX1 := x1.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1603
        pY1 := y1
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1604
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1605
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1606
    pX0 := pX0 rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1607
    pY0 := pY0 rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1608
    pX1 := pX1 rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1609
    pY1 := pY1 rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1610
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1611
    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
  1612
1177
e89408c15bb5 newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 1138
diff changeset
  1613
    "Modified: 10.1.1997 / 17:46:32 / cg"
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1614
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1615
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1616
displayOpaqueForm:formToDraw x:x y:y
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1617
    "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
  1618
     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
  1619
     current paint-color and 0-bits in the bgPaint color.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1620
     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
  1621
     settings are ignored and the form drawn as-is.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1622
     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
  1623
     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
  1624
     (by sending #on: to the colors) before doing so.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1625
     If there is a transformation, the image is scaled as appropiate."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1626
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1627
    |w h realForm pX pY nW nH pO pC|
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1628
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1629
    bgPaint isNil ifTrue:[
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1630
        "/
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1631
        "/ actually not an opaque draw
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1632
        "/
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1633
        self displayForm:formToDraw x:x y:y.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1634
        ^ self
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1635
    ].
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
    realForm := formToDraw.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1638
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1639
    transformation notNil ifTrue:[
6711
2b50385f7257 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
  1640
        pO := transformation transformPoint:x@y.
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1641
        pX := pO x.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1642
        pY := pO y.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1643
        "/ pX := transformation applyToX:x.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1644
        "/ pY := transformation applyToY:y.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1645
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1646
        transformation isNoScale ifFalse:[
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1647
            w := formToDraw width.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1648
            h := formToDraw height.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1649
            pC := transformation applyTo:(x+w-1)@(y+h-1).
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1650
            nW := pX - x + 1.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1651
            nH := pY - y + 1.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1652
            "/ nW := (transformation applyScaleX:w) rounded.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1653
            "/ nH := (transformation applyScaleY:h) rounded.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1654
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1655
            ((nW ~= w) or:[nH ~= h]) ifTrue:[
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
                "/ hard case - someone is drawing forms with scaling in effect
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1658
                "/ look if we have a scaled version in our pocket ...
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1659
                "/
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1660
                realForm := nil.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1661
                CachedScaledForms notNil ifTrue:[
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1662
                    (CachedScales at:formToDraw ifAbsent:nil) = transformation scale ifTrue:[
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1663
                        realForm := CachedScaledForms at:formToDraw ifAbsent:nil.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1664
                    ]
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1665
                ].
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1666
                realForm isNil ifTrue:[
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1667
                    "/
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1668
                    "/ nope - must do the work ...
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1669
                    "/
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1670
                    realForm := formToDraw magnifiedBy:(nW / w) @ (nH / h).
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1671
                    CachedScaledForms isNil ifTrue:[
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1672
                        CachedScaledForms := WeakIdentityDictionary new.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1673
                        CachedScales := WeakIdentityDictionary new.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1674
                    ].
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1675
                    CachedScaledForms at:formToDraw put:realForm.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1676
                    CachedScales at:formToDraw put:transformation scale.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1677
                ]
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1678
            ]
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1679
        ]
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1680
    ] ifFalse:[
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1681
        pX := x.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1682
        pY := y.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1683
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1684
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1685
    self displayDeviceOpaqueForm:realForm x:pX y:pY
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1686
1592
7ec770f2047a faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents: 1517
diff changeset
  1687
    "Modified: 12.4.1997 / 12:49:02 / cg"
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1688
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1689
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1690
displayOpaqueString:aString from:index1 to:index2 x:x y:y
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1691
    "draw a substring at the coordinate x/y - draw foreground pixels in
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1692
     paint-color and background pixels in bgPaint-color.
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1693
     If the transformation involves scaling,
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1694
     the fonts point-size is scaled as appropriate.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1695
     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
  1696
     the case where paint and/or bgPaint are dithered colors"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1697
6472
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1698
    self displayString:aString from:index1 to:index2 x:x y:y opaque:true maxWidth:nil
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1699
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1700
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1701
displayOpaqueString:aString x:x y:y
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1702
    "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
  1703
     background pixels in bgPaint color. If the transformation involves scaling,
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1704
     the fonts point-size is scaled as appropriate.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1705
     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
  1706
     the case where paint and/or bgPaint are dithered colors or images."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1707
7064
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  1708
    aString isPlainString ifFalse:[
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  1709
        "
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  1710
         hook for non-strings (i.e. attributed text)
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  1711
         that 'thing' should know how to display itself ...
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  1712
        "
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  1713
        aString displayOpaqueOn:self x:x y:y.
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  1714
        ^ self
732
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
5360
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1717
    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
  1718
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1719
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1720
displayPointX:x y:y
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1721
    "draw a point (with current paint-color); apply transformation if nonNil"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1722
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1723
    |pX pY pO|
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1724
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1725
    gcId isNil ifTrue:[
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1726
        self initGC
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1727
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1728
    transformation notNil ifTrue:[
6711
2b50385f7257 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
  1729
        pO := transformation transformPoint:x@y.
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1730
        pX := pO x.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1731
        pY := pO y.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1732
    ] ifFalse:[
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1733
        pX := x.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1734
        pY := y
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1735
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1736
    pX := pX rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1737
    pY := pY rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1738
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1739
    device displayPointX:pX y:pY in:drawableId with:gcId
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1740
!
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
displayPolygon:aPolygon
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1743
    "draw (the outline of) a polygon (with current paint-color).
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1744
     Apply transformation if nonNil"
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
    |newPolygon|
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1747
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1748
    gcId isNil ifTrue:[
6645
6066dcf16c20 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6626
diff changeset
  1749
        self initGC
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
    transformation notNil ifTrue:[
6711
2b50385f7257 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
  1752
        newPolygon := aPolygon collect:[:point | transformation transformPoint:point].
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1753
    ] ifFalse:[
6645
6066dcf16c20 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6626
diff changeset
  1754
        newPolygon := aPolygon
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1755
    ].
6645
6066dcf16c20 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6626
diff changeset
  1756
    (newPolygon contains:[:p |
6066dcf16c20 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6626
diff changeset
  1757
        (p isPoint not
6066dcf16c20 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6626
diff changeset
  1758
        or:[(p x class ~~ SmallInteger)
6066dcf16c20 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6626
diff changeset
  1759
        or:[(p y class ~~ SmallInteger)]])
6066dcf16c20 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6626
diff changeset
  1760
     ]) ifTrue:[
6066dcf16c20 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6626
diff changeset
  1761
        newPolygon := newPolygon collect:[:p | p asPoint rounded]
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1762
    ].
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1763
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1764
    device displayPolygon:newPolygon in:drawableId with:gcId
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1765
!
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
displayRectangleX:x y:y width:w height:h
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1768
    "draw a rectangle (with current paint-color).
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1769
     If transformation is nonNil, drawing is in logical coordinates."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1770
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1771
    |pX pY nW nH easy fgId bgId pO pC|
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1772
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1773
    gcId isNil ifTrue:[
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1774
        self initGC
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1775
    ].
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
    lineStyle == #doubleDashed ifTrue:[
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1778
        "
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1779
         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
  1780
        "
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1781
        easy := true.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1782
        paint isColor ifFalse:[
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1783
            easy := false
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1784
        ] ifTrue:[
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1785
            fgId := paint colorId.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1786
            fgId isNil ifTrue:[
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1787
                easy := false
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1788
            ]
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1789
        ].
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1790
        bgPaint isColor ifFalse:[
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1791
            easy := false
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1792
        ] ifTrue:[
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1793
            bgId := bgPaint colorId.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1794
            bgId isNil ifTrue:[
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1795
                easy := false
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1796
            ]
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1797
        ].
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1798
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1799
        easy ifTrue:[
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1800
            ((foreground ~~ paint) or:[background ~~ bgPaint]) ifTrue:[
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1801
                device setForeground:fgId background:bgId in:gcId.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1802
                foreground := paint.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1803
                background := bgPaint.
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
        ] ifFalse:[
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1806
            'DeviceGraphicsContext [warning]: cannot draw dashes with dithered colors' errorPrintCR
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1807
        ].
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1808
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1809
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1810
    transformation notNil ifTrue:[
6711
2b50385f7257 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
  1811
        pO := transformation transformPoint:x@y.
2b50385f7257 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
  1812
        pC := transformation transformPoint:(x+w-1)@(y+h-1).
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1813
        pX := pO x.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1814
        pY := pO y.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1815
        nW := pC x - pX + 1.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1816
        nH := pC y - pY + 1.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1817
"/        pX := transformation applyToX:x.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1818
"/        pY := transformation applyToY:y.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1819
"/        nW := transformation applyScaleX:w.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1820
"/        nH := transformation applyScaleY:h.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1821
        nW < 0 ifTrue:[
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1822
              nW := nW abs.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1823
              pX := pX - nW.
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
        nH < 0 ifTrue:[
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1826
              nH := nH abs.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1827
              pY := pY - nH.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1828
        ].
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1829
    ] ifFalse:[
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1830
        pX := x.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1831
        pY := y.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1832
        nW := w.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1833
        nH := h
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
    pX := pX rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1837
    pY := pY rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1838
    nW := nW rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1839
    nH := nH rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1840
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1841
    "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
  1842
     this one seems mathematically incorrect but allows to draw and fill
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1843
     a rectangle using the same extents.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1844
     I'm not certain if is the right thing to do ...
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1845
    "
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1846
    device displayRectangleX:pX
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1847
                           y:pY
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1848
                       width:(nW - 1)
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1849
                      height:(nH - 1)
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1850
                          in:drawableId with:gcId
1177
e89408c15bb5 newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 1138
diff changeset
  1851
e89408c15bb5 newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 1138
diff changeset
  1852
    "Modified: 10.1.1997 / 17:46:41 / cg"
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1853
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1854
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1855
displayString:aString from:index1 to:index2 x:x y:y
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1856
    "draw a substring at the coordinate x/y -
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1857
     draw foreground-pixels only (in current paint-color),
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1858
     leaving background as-is. If the transformation involves scaling,
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1859
     the fonts point-size is scaled as appropriate."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1860
6472
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1861
    self displayString:aString from:index1 to:index2 x:x y:y opaque:false maxWidth:nil
5360
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1862
!
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1863
6472
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1864
displayString:aString from:index1 to:index2 x:x y:y opaque:opaque
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1865
    "draw part of a string with both fg and bg at x/y in current font"
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1866
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1867
    ^ self displayString:aString from:index1 to:index2 x:x y:y opaque:opaque maxWidth:nil.
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1868
!
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1869
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1870
displayString:aStringArg from:index1Arg to:index2Arg x:x y:y opaque:opaqueArg maxWidth:maxWidth
5360
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1871
    "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
  1872
     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
  1873
     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
  1874
     Assuming that device can only draw in device colors, we have to handle
6472
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1875
     the case where paint and/or bgPaint are dithered colors.
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1876
     maxWidth is the maximum width of the string in pixels or nil if unknown."
5360
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1877
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1878
    |opaque index1 index2 easy w h savedPaint fgId bgId
6472
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1879
     fontId pX pY fontUsed fontsEncoding aString
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1880
     nSkipLeft nChars wString wSkipLeft index2Guess|
5360
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1881
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1882
    index1 := index1Arg.
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1883
    index2 := index2Arg.
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1884
    opaque := opaqueArg.
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1885
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1886
    "
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1887
     if backgroundPaint color is nil, we assume
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1888
     this is a non-opaque draw
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
    bgPaint isNil ifTrue:[
6626
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1891
        opaque := false.
5360
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1892
    ].
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1893
6472
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1894
    gcId isNil ifTrue:[
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1895
        self initGC
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1896
    ].
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1897
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1898
    (aStringArg isString not or:[aStringArg isText]) ifTrue:[
6626
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1899
        "
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1900
         hook for non-strings (i.e. attributed text)
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1901
         that 'thing' should know how to display itself ...
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1902
        "
6472
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1903
        aStringArg displayOn:self x:x y:y from:index1 to:index2 opaque:opaque.
6626
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1904
        ^ self
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1905
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1906
7288
fec0c6c1087b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7257
diff changeset
  1907
    "/ transcode the string into the font's encoding...
6472
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1908
    aString := aStringArg.
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1909
    fontsEncoding := font encoding.
7288
fec0c6c1087b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7257
diff changeset
  1910
fec0c6c1087b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7257
diff changeset
  1911
    "/ This is now obsolete, as we are always using unicode internally.
fec0c6c1087b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7257
diff changeset
  1912
    "/ so the next line should be changed to fontsEncoding ~~ #unicode
4056
67c4686afbc6 characterEncoding stuff
Claus Gittinger <cg@exept.de>
parents: 4031
diff changeset
  1913
    (characterEncoding ~~ fontsEncoding) ifTrue:[
6626
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1914
        [
6472
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1915
            aString := CharacterEncoder encodeString:aString from:characterEncoding into:fontsEncoding.
6626
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1916
        ] on:CharacterEncoderError do:[:ex|
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1917
            "substitute a default value for codes that cannot be represented
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1918
             in the new character set"
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1919
            ex proceedWith:ex defaultValue.
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1920
        ].
4026
882de378f763 no longer as string for its encoding;
Claus Gittinger <cg@exept.de>
parents: 3943
diff changeset
  1921
    ].
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1922
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1923
    fontUsed := font.
6472
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1924
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1925
    transformation notNil ifTrue:[
1797
2cb44d740a7e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1742
diff changeset
  1926
        pX := transformation applyToX:x.
2cb44d740a7e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1742
diff changeset
  1927
        pY := transformation applyToY:y.
2cb44d740a7e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1742
diff changeset
  1928
        transformation noScale ifFalse:[
6472
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1929
            |sz|
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1930
6626
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1931
            sz := font size.
6472
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1932
            sz notNil ifTrue:[
6626
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1933
                fontUsed := font asSize:(transformation applyScaleY:sz) rounded.
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1934
            ]
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1935
        ]
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1936
    ] ifFalse:[
6626
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1937
        pX := x.
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1938
        pY := y.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1939
    ].
6472
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1940
7063
2be1214a5dcf #BUGFIX
Stefan Vogel <sv@exept.de>
parents: 7062
diff changeset
  1941
    fontUsed isAlienFont ifTrue:[
2be1214a5dcf #BUGFIX
Stefan Vogel <sv@exept.de>
parents: 7062
diff changeset
  1942
        "
2be1214a5dcf #BUGFIX
Stefan Vogel <sv@exept.de>
parents: 7062
diff changeset
  1943
         hook for alien fonts
2be1214a5dcf #BUGFIX
Stefan Vogel <sv@exept.de>
parents: 7062
diff changeset
  1944
         that 'font' should know how to display the string...
2be1214a5dcf #BUGFIX
Stefan Vogel <sv@exept.de>
parents: 7062
diff changeset
  1945
        "
6472
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1946
        fontUsed displayString:aString from:index1 to:index2 x:x rounded y:y rounded in:self opaque:opaque maxWidth:maxWidth.
7063
2be1214a5dcf #BUGFIX
Stefan Vogel <sv@exept.de>
parents: 7062
diff changeset
  1947
        ^ self
2be1214a5dcf #BUGFIX
Stefan Vogel <sv@exept.de>
parents: 7062
diff changeset
  1948
    ].
2be1214a5dcf #BUGFIX
Stefan Vogel <sv@exept.de>
parents: 7062
diff changeset
  1949
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1950
    pX := pX rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1951
    pY := pY rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1952
5360
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1953
    fontUsed := fontUsed onDevice:device.
6108
6ecfb89408d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6107
diff changeset
  1954
    fontId := fontUsed fontId.
6ecfb89408d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6107
diff changeset
  1955
    fontId isNil ifTrue:[
6626
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1956
        "this should not happen, since #onDevice tries replacement fonts"
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1957
        'STX[DeviceGraphicsContext] no font: ' errorPrint. fontUsed errorPrintCR.
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1958
        ^ self
5360
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1959
    ].
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1960
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1961
    "
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1962
     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
  1963
    "
6472
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1964
    paint isColor ifTrue:[
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1965
        easy := true.
6626
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1966
        fgId := paint colorId.
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1967
        fgId isNil ifTrue:[
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1968
            easy := false
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1969
        ]
6472
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1970
    ] ifFalse:[
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1971
        easy := false
5360
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1972
    ].
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1973
    opaque ifTrue:[
6472
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1974
        bgPaint isColor ifTrue:[
6626
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1975
            bgId := bgPaint colorId.
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1976
            bgId isNil ifTrue:[
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1977
                easy := false
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1978
            ]
6472
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1979
        ] ifFalse:[
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1980
            easy := false
6626
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1981
        ].
5360
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1982
    ].
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1983
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1984
    deviceFont ~~ fontUsed ifTrue:[
6626
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1985
        device setFont:fontId in:gcId.
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1986
        deviceFont := fontUsed
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1987
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1988
5360
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1989
    "/ 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
  1990
    "/ 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
  1991
    "/ which are drawn longer than 32k pixels.
6491
bbc6f0fef5c5 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6485
diff changeset
  1992
    nChars := 500.
bbc6f0fef5c5 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6485
diff changeset
  1993
    (maxWidth notNil and:[(index2 - index1) > nChars]) ifTrue:[
6626
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1994
        nSkipLeft := wSkipLeft := 0.
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1995
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1996
        "/ if the draw starts to the left of the window start,
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1997
        "/ skip some characters at the beginning...
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1998
        pX < 0 ifTrue:[
6472
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1999
"/ ('x=%d wMax=%d l=%d i1=%d i2=%d' printfWith:x with:maxWidth with:aString size with:index1 with:index2) printCR.
6626
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  2000
            nSkipLeft := (pX negated // font width) min:index2.                         "/ estimate
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  2001
            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
  2002
            [ ((pX+wSkipLeft) > 0) and:[nSkipLeft > 0]] whileTrue:[                      "/ too many
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  2003
                nSkipLeft := (nSkipLeft * 0.9) rounded.
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  2004
                wSkipLeft := fontUsed widthOf:aString from:index1 to:index1+nSkipLeft-1.
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  2005
            ].
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  2006
            index1 := index1 + nSkipLeft.
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  2007
            pX := pX + wSkipLeft.
5360
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  2008
"/ ('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
  2009
        ].
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  2010
5360
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  2011
"/ ('n=%d w=%d' printfWith:nChars with:wString) printCR.
6491
bbc6f0fef5c5 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6485
diff changeset
  2012
        [ 
6626
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  2013
            index2Guess := (index1+nChars-1) min:index2.
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  2014
            wString := fontUsed widthOf:aString from:index1 to:index2Guess.
6491
bbc6f0fef5c5 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6485
diff changeset
  2015
            ((pX+wString) < maxWidth) and:[ index2Guess < index2] 
bbc6f0fef5c5 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6485
diff changeset
  2016
        ] whileTrue:[  "/ not enough...
bbc6f0fef5c5 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6485
diff changeset
  2017
            nChars := (nChars * 1.1) rounded.
6626
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  2018
        ].
5360
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  2019
"/ ('n=%d w=%d' printfWith:nChars with:wString) printCR.
6626
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  2020
        index2 := index2Guess.
5360
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  2021
    ].
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  2022
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  2023
    easy ifTrue:[
6626
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  2024
        opaque ifTrue:[
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  2025
            device setForeground:fgId background:bgId in:gcId.
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  2026
            background := bgPaint.
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  2027
        ] ifFalse:[
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  2028
            device setForeground:fgId in:gcId.
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  2029
        ].
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  2030
        foreground := paint.
6472
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  2031
        device displayString:aString from:index1 to:index2 x:pX y:pY in:drawableId with:gcId opaque:opaque.
6626
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  2032
        ^ self
5360
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  2033
    ].
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  2034
6472
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  2035
    "/
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  2036
    "/ do it the hard way - either forground or background is not a plain color,
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  2037
    "/ but dithered or a pattern
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  2038
    "/
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  2039
    w := fontUsed widthOf:aString from:index1 to:index2.
5360
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  2040
    h := fontUsed height.
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  2041
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  2042
    (fgId notNil and:[function == #copy]) ifTrue:[
6626
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  2043
        "
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  2044
         only bg is dithered or a pattern; fill with bg first ...
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  2045
        "
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  2046
        savedPaint := paint.
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  2047
        self paint:bgPaint.
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  2048
        self fillDeviceRectangleX:pX y:(pY - fontUsed ascent) width:w height:h.
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  2049
        self paint:savedPaint.
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  2050
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  2051
        "
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  2052
         then draw using fgPaint (which is a real color)
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  2053
        "
6472
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  2054
        device displayString:aString from:index1 to:index2 x:pX y:pY in:drawableId with:gcId opaque:false.
6626
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  2055
        ^ self
5360
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  2056
    ].
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  2057
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  2058
    "/ the very hard case (fg-dither)
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  2059
6472
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  2060
    self displayDeviceOpaqueString:aString from:index1 to:index2 in:fontUsed x:pX y:pY.
5360
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  2061
5742
3edcdffa74ec changed: #displayString:from:to:x:y:opaque:
Stefan Vogel <sv@exept.de>
parents: 5406
diff changeset
  2062
    "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
  2063
    "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
  2064
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2065
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2066
displayString:aString x:x y:y
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2067
    "draw a string at the coordinate x/y -
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2068
     draw foreground-pixels only (in current paint-color),
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2069
     leaving background as-is. If the transformation involves scaling,
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2070
     the fonts point-size is scaled as appropriate."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2071
6472
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  2072
    self displayString:aString from:1 to:aString size x:x y:y opaque:false maxWidth:nil
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2073
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2074
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2075
displayUnscaledForm:formToDraw x:x y:y
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2076
    "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
  2077
     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
  2078
     current paint-color, leaving pixels with 0-bits unchanged
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2079
     (i.e. only 1-bits are drawn from the form).
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2080
     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
  2081
     settings are ignored and the form is drawn as-is.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2082
     Care must be taken, that the paint color is correctly allocated
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2083
     (by sending #on: to the color) before doing so.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2084
     Using functions other than #copy only makes sense if you are
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2085
     certain, that the colors are real colors (actually, only for
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2086
     noColor or allColor).
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2087
     The origins coordinate is transformed, but the image itself is unscaled."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2088
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  2089
    |pX pY pO|
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2090
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2091
    transformation notNil ifTrue:[
6711
2b50385f7257 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
  2092
        pO := transformation transformPoint:(x@y).
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  2093
        pX := pO x.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  2094
        pY := pO y.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2095
    ] ifFalse:[
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  2096
        pX := x.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  2097
        pY := y.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2098
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2099
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2100
    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
  2101
7ec770f2047a faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents: 1517
diff changeset
  2102
    "Modified: 12.4.1997 / 12:48:04 / cg"
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2103
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2104
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2105
displayUnscaledOpaqueForm:formToDraw x:x y:y
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2106
    "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
  2107
     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
  2108
     current paint-color, 0 bits in background color.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2109
     If its a deep form (i.e. a pixmap) the current paint
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2110
     settings are ignored and the form is drawn as-is (opaque).
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2111
     The origins coordinate is transformed, but the image itself is unscaled."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2112
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  2113
    |pX pY pO|
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2114
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2115
    transformation notNil ifTrue:[
6711
2b50385f7257 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
  2116
        pO := transformation transformPoint:(x@y).
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  2117
        pX := pO x.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  2118
        pY := pO y.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2119
    ] ifFalse:[
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  2120
        pX := x.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  2121
        pY := y.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2122
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2123
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2124
    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
  2125
7ec770f2047a faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents: 1517
diff changeset
  2126
    "Modified: 12.4.1997 / 12:49:21 / cg"
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
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2129
displayUnscaledOpaqueString:aString from:index1 to:index2 x:x y:y
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2130
    "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
  2131
     Draw foreground pixels in paint-color, background pixels in bgPaint color."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2132
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  2133
    |pX pY pO|
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2134
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2135
    transformation notNil ifTrue:[
6711
2b50385f7257 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
  2136
        pO := transformation transformPoint:(x@y).
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  2137
        pX := pO x.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  2138
        pY := pO y.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2139
    ] ifFalse:[
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  2140
        pX := x.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  2141
        pY := y.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2142
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2143
    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
  2144
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2145
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2146
displayUnscaledOpaqueString:aString x:x y:y
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2147
    "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
  2148
     Draw foreground pixels in paint-color, background pixels in bgPaint color."
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
    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
  2161
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2162
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2163
displayUnscaledString:aString from:index1 to:index2 x:x y:y
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2164
    "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
  2165
     draw foreground-pixels only (in current paint-color), leaving background as-is."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2166
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  2167
    |pX pY pO|
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2168
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2169
    transformation notNil ifTrue:[
6711
2b50385f7257 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
  2170
        pO := transformation transformPoint:(x@y).
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  2171
        pX := pO x.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  2172
        pY := pO y.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2173
    ] ifFalse:[
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  2174
        pX := x.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  2175
        pY := y.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2176
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2177
    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
  2178
!
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
displayUnscaledString:aString x:x y:y
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2181
    "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
  2182
     draw foreground-pixels only (in current paint-color), leaving background as-is."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2183
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  2184
    |pX pY pO|
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2185
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2186
    transformation notNil ifTrue:[
6711
2b50385f7257 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
  2187
        pO := transformation transformPoint:(x@y).
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  2188
        pX := pO x.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  2189
        pY := pO y.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2190
    ] ifFalse:[
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  2191
        pX := x.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  2192
        pY := y.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2193
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2194
    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
  2195
! !
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
!DeviceGraphicsContext methodsFor:'drawing in device coordinates'!
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
displayDeviceForm:aForm x:x y:y
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2200
    "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
  2201
     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
  2202
     current paint-color, leaving pixels with 0-bits unchanged
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2203
     (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
  2204
     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
  2205
     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
  2206
     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
  2207
7ec770f2047a faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents: 1517
diff changeset
  2208
     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
  2209
     otherwise its converted here, which slows down the draw.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2210
     No transformation or scaling is done.
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2211
     Care must be taken, that the paint color is correctly allocated
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2212
     (by sending #on: to the color) before doing so.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2213
     Using functions other than #copy only makes sense if you are
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2214
     certain, that the colors are real colors (actually, only for
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2215
     noColor or allColor)."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2216
6472
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  2217
    |id w h easy paintDither tmpForm tmpId tmpGCId
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2218
     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
  2219
     mask maskId deviceForm deviceFormGCId deviceMask colorMap|
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2220
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2221
    w := aForm width.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2222
    h := aForm height.
6612
5c05ccaf6275 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6514
diff changeset
  2223
    (w = 0 or:[h = 0]) ifTrue:[^ self].
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2224
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2225
    pX := x rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2226
    pY := y rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2227
1034
5f6f417dcb12 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1033
diff changeset
  2228
    deviceForm := aForm asFormOn:device.
2192
01f76f23f03f handle case when no deviceForms can be created,
Claus Gittinger <cg@exept.de>
parents: 2065
diff changeset
  2229
    deviceForm isNil ifTrue:[
6484
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2230
        'DeviceGraphicsContext [warning]: cannot create device-form' errorPrintCR.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2231
        ^self
2192
01f76f23f03f handle case when no deviceForms can be created,
Claus Gittinger <cg@exept.de>
parents: 2065
diff changeset
  2232
    ].
976
807b42b00353 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 975
diff changeset
  2233
    id := deviceForm id.
807b42b00353 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 975
diff changeset
  2234
807b42b00353 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 975
diff changeset
  2235
    id isNil ifTrue:[
6484
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2236
        'DeviceGraphicsContext [warning]: invalid form draw - ignored' errorPrintCR.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2237
        ^ self
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2238
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2239
    gcId isNil ifTrue:[
6484
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2240
        self initGC
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2241
    ].
6491
bbc6f0fef5c5 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6485
diff changeset
  2242
    "/ device needGCForBitmapSource  - i.e. WIN32
6836
7c4adc740f7b Fixed delegated GC suppprt on windows
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 6819
diff changeset
  2243
    device isWindowsPlatform ifTrue:[
6491
bbc6f0fef5c5 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6485
diff changeset
  2244
        (deviceFormGCId := deviceForm gcId) isNil ifTrue:[
6484
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2245
            deviceForm initGC.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2246
            deviceFormGCId := deviceForm gcId.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2247
        ]
2865
a97dc9f1e21a no need to create a GC for source bitmap under X
Claus Gittinger <cg@exept.de>
parents: 2835
diff changeset
  2248
    ].
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2249
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2250
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2251
     a deep form ignores paint/bgPaint settings
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2252
    "
1085
3513a4cae87b handle depth1-images with a mask
Claus Gittinger <cg@exept.de>
parents: 1064
diff changeset
  2253
    mask := aForm mask.
3513a4cae87b handle depth1-images with a mask
Claus Gittinger <cg@exept.de>
parents: 1064
diff changeset
  2254
6485
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2255
    ((aForm depth ~~ 1) or:[mask notNil]) ifTrue:[
6484
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2256
        mask notNil ifTrue:[
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2257
            mask depth ~~ 1 ifTrue:[
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2258
                'DEVGC: alpha channel not yet supported' errorPrintCR.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2259
            ] ifFalse:[
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2260
                deviceMask := mask asFormOn:device.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2261
                deviceMask isNil ifTrue:[
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2262
                    'DeviceGraphicsContext [warning]: cannot create device-mask' errorPrintCR.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2263
                    ^self
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2264
                ].
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2265
                maskId := deviceMask id.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2266
                maskId notNil ifTrue:[
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2267
                    deviceMask gcId isNil ifTrue:[deviceMask initGC].
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2268
                    allColor := Color allColor.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2269
                    allBits := allColor colorId.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2270
6485
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2271
                    (deviceForm depth == device depth
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2272
                     and:[aForm maskedPixelsAre0]) ifTrue:[
6484
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2273
                        "/ can do it without a temporary pixmap:
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2274
                        "/   or-in the form into the inverse stamped-out area
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2275
                        "/   of the destination.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2276
                        "/   Oring is of course only possible if we know that
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2277
                        "/   masked pixels are already zero in the form.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2278
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2279
                        "/ stamp out using mask
6485
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2280
                        device setForeground:0 background:allBits in:gcId.
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2281
                        device setFunction:#and in:gcId.
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2282
                        device
6484
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2283
                            copyPlaneFromPixmapId:maskId
6485
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2284
                            x:0
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2285
                            y:0
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2286
                            gc:(deviceMask gcId)
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2287
                            to:drawableId
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2288
                            x:pX
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2289
                            y:pY
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2290
                            gc:gcId
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2291
                            width:w
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2292
                            height:h.
6484
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2293
                        "/ or-in the form
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2294
                        device setFunction:#or in:gcId.
6485
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2295
                        device
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2296
                            copyFromPixmapId:id
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2297
                            x:0
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2298
                            y:0
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2299
                            gc:deviceFormGCId
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2300
                            to:drawableId
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2301
                            x:pX
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2302
                            y:pY
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2303
                            gc:gcId
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2304
                            width:w
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2305
                            height:h.
6484
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2306
                    ] ifFalse:[
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2307
                        "/ must do it slow, using a temporary form ..
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2308
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2309
                        "
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2310
                         create temp-form;
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2311
                        "
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2312
                        tmpForm := Form width:w height:h depth:device depth onDevice:device.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2313
                        tmpForm isNil ifTrue:[
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2314
                            'DeviceGraphicsContext [warning]: cannot create temp form' errorPrintCR.
6485
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2315
                            ^self
6484
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
                        tmpForm initGC.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2318
                        tmpId := tmpForm id.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2319
                        tmpGCId := tmpForm gcId.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2320
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2321
                        "
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2322
                         fill tempform with image
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2323
                        "
6485
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2324
                        aForm depth == 1 ifTrue:[
6484
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2325
                            (colorMap := deviceForm colorMap) notNil ifTrue:[
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2326
                                colorMap size < 2 ifTrue:[
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2327
                                    device
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2328
                                        setForegroundColor:(colorMap at:1)
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2329
                                        in:tmpGCId.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2330
                                ] ifFalse:[
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2331
                                    device
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2332
                                        setForegroundColor:(colorMap at:2)
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2333
                                        backgroundColor:(colorMap at:1)
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2334
                                        in:tmpGCId.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2335
                                ]
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2336
                            ].
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2337
                            device
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2338
                                copyPlaneFromPixmapId:id
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2339
                                x:0
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2340
                                y:0
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2341
                                gc:deviceFormGCId
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2342
                                to:tmpId
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2343
                                x:0
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2344
                                y:0
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2345
                                gc:tmpGCId
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2346
                                width:w
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2347
                                height:h.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2348
                        ] ifFalse:[
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2349
                            device
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2350
                                copyFromPixmapId:id
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2351
                                x:0
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2352
                                y:0
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2353
                                gc:deviceFormGCId
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2354
                                to:tmpId
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2355
                                x:0
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2356
                                y:0
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2357
                                gc:tmpGCId
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2358
                                width:w
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2359
                                height:h.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2360
                        ].
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2361
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2362
                        "
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2363
                         stamp out mask in temp form
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2364
                        "
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2365
                        device 
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2366
                            setForeground:allBits background:0 in:tmpGCId;
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2367
                            setFunction:#and in:tmpGCId;
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2368
                            copyPlaneFromPixmapId:maskId
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2369
                                x:0
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2370
                                y:0
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2371
                                gc:(deviceMask gcId)
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2372
                                to:tmpId
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2373
                                x:0
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2374
                                y:0
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2375
                                gc:tmpGCId
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2376
                                width:w
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2377
                                height:h.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2378
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2379
                        "
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2380
                         stamp out mask in destination
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2381
                        "
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2382
                        device 
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2383
                            setForeground:0 background:allBits in:gcId;
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2384
                            setFunction:#and in:gcId;
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2385
                            copyPlaneFromPixmapId:maskId
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2386
                                x:0
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2387
                                y:0
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2388
                                gc:(deviceMask gcId)
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2389
                                to:drawableId
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2390
                                x:pX
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2391
                                y:pY
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2392
                                gc:gcId
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2393
                                width:w
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2394
                                height:h.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2395
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2396
                        "
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2397
                         or-in tempform-bits ...
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2398
                        "
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2399
                        device 
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2400
                            setFunction:#or in:gcId;
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2401
                            copyFromPixmapId:tmpId
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2402
                                x:0
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2403
                                y:0
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2404
                                gc:tmpGCId
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2405
                                to:drawableId
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2406
                                x:pX
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2407
                                y:pY
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2408
                                gc:gcId
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2409
                                width:w
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2410
                                height:h.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2411
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2412
                        "
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2413
                         release tempForm immediately
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2414
                         (although GC will eventually do it,
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2415
                          this creates less stress to the Xserver in the meanwhile ...)
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2416
                        "
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2417
                        tmpForm destroy.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2418
                    ].
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2419
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2420
                    "/ restore GC
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2421
                    foreground notNil ifTrue:[
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2422
                        device setForegroundColor:foreground in:gcId.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2423
                    ].
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2424
                    background notNil ifTrue:[
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2425
                        device setBackgroundColor:background in:gcId
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
                    device setFunction:function in:gcId.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2428
                    ^ self
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2429
                ]
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
        ].
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2432
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2433
        device
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2434
            copyFromPixmapId:id
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:deviceForm gcId
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2438
            to:drawableId
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2439
            x:pX
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2440
            y:pY
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2441
            gc:gcId
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
        ^ self
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2445
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2446
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2447
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2448
     the following code is somewhat complicated, since it has to deal
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2449
     with dithered paint colors, which cannot be done directly on most
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2450
     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
  2451
     (just assume drawing a bitmap with dithered paint color ... sigh)
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2452
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2453
1507
358603f58138 faster drawing in or-mode.
Claus Gittinger <cg@exept.de>
parents: 1453
diff changeset
  2454
    easy := (function == #copy).
358603f58138 faster drawing in or-mode.
Claus Gittinger <cg@exept.de>
parents: 1453
diff changeset
  2455
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2456
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2457
     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
  2458
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2459
    easy ifTrue:[
6484
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2460
        paint isColor ifTrue:[
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2461
            paintDither := paint ditherForm.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2462
            paintDither notNil ifTrue:[
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2463
                easy := false.
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
        ] ifFalse:[
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2466
            paintDither := paint.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2467
            easy := false
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2468
        ].
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2469
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2470
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2471
    allColor := Color allColor.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2472
    allBits := allColor colorId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2473
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2474
    easy ifTrue:[
6484
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2475
        "
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2476
         paint is a real color
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
        "
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2480
         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
  2481
         operation ...
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
        fgId := paint colorId.
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
        ((fgId ~~ ((1 bitShift:device depth)-1))
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2486
        and:[fgId ~~ allBits]) ifTrue:[
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2487
            "
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2488
             clear fg-bits ...
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
            device setForeground:0 background:allBits in:gcId.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2491
            device setFunction:#and in:gcId.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2492
            device
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2493
                copyPlaneFromPixmapId:id
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2494
                x:0
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2495
                y:0
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2496
                gc:deviceFormGCId
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2497
                to:drawableId
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2498
                x:pX
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2499
                y:pY
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2500
                gc:gcId
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2501
                width:w
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2502
                height:h.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2503
        ].
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2504
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2505
        fgId ~~ 0 ifTrue:[
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2506
            "
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2507
             or-in fg-bits ...
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2508
            "
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2509
            device setForeground:fgId background:0 in:gcId.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2510
            device setFunction:#or in:gcId.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2511
            device
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2512
                copyPlaneFromPixmapId:id
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2513
                x:0
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2514
                y:0
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2515
                gc:deviceFormGCId
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2516
                to:drawableId
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2517
                x:pX
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2518
                y:pY
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2519
                gc:gcId
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2520
                width:w
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2521
                height:h
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2522
        ].
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2523
        "
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2524
         flush foreground/background cache
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2525
        "
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2526
        foreground := nil.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2527
        background := nil.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2528
        device setFunction:function in:gcId.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2529
        ^ self
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2530
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2531
1507
358603f58138 faster drawing in or-mode.
Claus Gittinger <cg@exept.de>
parents: 1453
diff changeset
  2532
    function == #or ifTrue:[
6484
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2533
        easy := paint notNil
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2534
                and:[paint isColor
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2535
                and:[paint ditherForm isNil]].
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2536
        easy ifTrue:[
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2537
            easy := bgPaint isNil
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2538
                        or:[bgPaint isColor
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2539
                            and:[bgPaint colorId == 0]]
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2540
        ].
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2541
        easy ifTrue:[
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2542
            fgId := paint colorId.
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
            fgId ~~ 0 ifTrue:[
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
                 or-in fg-bits ...
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2547
                "
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2548
                device setForeground:fgId background:0 in:gcId.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2549
                device
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2550
                    copyPlaneFromPixmapId:id
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2551
                    x:0
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2552
                    y:0
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2553
                    gc:deviceFormGCId
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2554
                    to:drawableId
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2555
                    x:pX
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2556
                    y:pY
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2557
                    gc:gcId
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2558
                    width:w
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2559
                    height:h
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2560
            ].
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2561
            "
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2562
             flush foreground/background cache
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2563
            "
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2564
            foreground := nil.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2565
            background := nil.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2566
            ^ self
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2567
        ].
1507
358603f58138 faster drawing in or-mode.
Claus Gittinger <cg@exept.de>
parents: 1453
diff changeset
  2568
    ].
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2569
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2570
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2571
     hard case; paint is a dithered color
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2572
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2573
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2574
    noColor := Color noColor.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2575
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2576
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2577
     create temp-form;
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2578
    "
4756
dd597f8839cb changed #displayDeviceForm:x:y:
Claus Gittinger <cg@exept.de>
parents: 4752
diff changeset
  2579
    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
  2580
    tmpForm isNil ifTrue:[
6484
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2581
        'DeviceGraphicsContext [warning]: cannot create temp form' errorPrintCR.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2582
        ^self
2192
01f76f23f03f handle case when no deviceForms can be created,
Claus Gittinger <cg@exept.de>
parents: 2065
diff changeset
  2583
    ].
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2584
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2585
     fill tempform
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2586
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2587
    tmpForm paint:paint.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2588
    tmpForm fillRectangleX:0 y:0 width:w height:h.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2589
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2590
     stamp out background
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2591
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2592
    tmpForm paint:allColor on:noColor.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2593
    tmpForm function:#and.
976
807b42b00353 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 975
diff changeset
  2594
    tmpForm displayOpaqueForm:deviceForm x:0 y:0.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2595
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2596
     stamp out foreground from destination
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2597
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2598
    device setForeground:0 background:allBits in:gcId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2599
    device setFunction:#and in:gcId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2600
    device
6484
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2601
        copyPlaneFromPixmapId:id
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2602
        x:0
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2603
        y:0
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2604
        gc:deviceFormGCId
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2605
        to:drawableId
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2606
        x:pX
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2607
        y:pY
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2608
        gc:gcId
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2609
        width:w
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2610
        height:h.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2611
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2612
     or-in temp into destination
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2613
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2614
    device setForeground:allBits background:0 in:gcId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2615
    device setFunction:#or in:gcId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2616
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2617
    device
6484
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2618
        copyFromPixmapId:tmpForm id
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2619
        x:0
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2620
        y:0
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2621
        gc:tmpForm gcId
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2622
        to:drawableId
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2623
        x:pX
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2624
        y:pY
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2625
        gc:gcId
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2626
        width:w
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2627
        height:h.
1637
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  2628
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  2629
    "
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  2630
     release tempForm immediately
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2631
     (although GC will eventually do it,
1637
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  2632
      this creates less stress to the Xserver in the meanwhile ...)
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  2633
    "
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  2634
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  2635
    tmpForm destroy.
732
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
     flush foreground/background cache
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
    foreground := nil.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2640
    background := nil.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2641
    device setFunction:function in:gcId.
768
77e4f9d30a22 fixes for b&w screens
Claus Gittinger <cg@exept.de>
parents: 745
diff changeset
  2642
4756
dd597f8839cb changed #displayDeviceForm:x:y:
Claus Gittinger <cg@exept.de>
parents: 4752
diff changeset
  2643
    "Modified: / 27-05-2007 / 12:45:10 / cg"
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2644
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2645
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2646
displayDeviceLineFromX:x0 y:y0 toX:x1 y:y1
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2647
    "draw a line (with current paint-color) in device coordinate space.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2648
     This ignores any transformations. The coordinates must be integers."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2649
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2650
    gcId isNil ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2651
	self initGC
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
    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
  2654
!
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
displayDeviceOpaqueForm:aForm x:x y:y
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2657
    "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
  2658
     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
  2659
     current paint-color and 0-bits in the bgPaint color.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2660
     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
  2661
     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
  2662
     Any mask is ignored.
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2663
     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
  2664
     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
  2665
     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
  2666
     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
  2667
     its converted here, which slows down the draw.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2668
     Drawing is in device coordinates; no scaling is done."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2669
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2670
    |id w h easy savedPaint bgForm fgForm tmpForm
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2671
     fgId bgId noColor allColor allBits dx dy
6485
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2672
     pX pY deviceDepth deviceForm map|
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2673
1033
b5cd84ed805f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1029
diff changeset
  2674
    deviceForm := aForm asFormOn:device.
976
807b42b00353 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 975
diff changeset
  2675
    id := deviceForm id.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2676
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2677
    "temporary ..."
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2678
    (id isNil
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2679
    or:[aForm graphicsDevice ~~ device]) ifTrue:[
6485
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2680
        deviceForm := deviceForm asFormOn:device.
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2681
        id := deviceForm id.
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2682
        id isNil ifTrue:[
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2683
            'DeviceGraphicsContext [warning]: invalid form draw - ignored' errorPrintCR.
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2684
            ^ self
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2685
        ].
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2686
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2687
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2688
    gcId isNil ifTrue:[
6485
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2689
        self initGC
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2690
    ].
2065
27bf0cf42e45 changes for WIN32
Claus Gittinger <cg@exept.de>
parents: 2049
diff changeset
  2691
    deviceForm gcId isNil ifTrue:[deviceForm initGC].
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2692
1592
7ec770f2047a faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents: 1517
diff changeset
  2693
    w := aForm width.
7ec770f2047a faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents: 1517
diff changeset
  2694
    h := aForm height.
7ec770f2047a faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents: 1517
diff changeset
  2695
7ec770f2047a faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents: 1517
diff changeset
  2696
    pX := x rounded.
7ec770f2047a faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents: 1517
diff changeset
  2697
    pY := y rounded.
7ec770f2047a faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents: 1517
diff changeset
  2698
902
7f5d81d377de opaque image display fix
Claus Gittinger <cg@exept.de>
parents: 895
diff changeset
  2699
    "
7f5d81d377de opaque image display fix
Claus Gittinger <cg@exept.de>
parents: 895
diff changeset
  2700
     a deep form ignores paint/bgPaint settings
7f5d81d377de opaque image display fix
Claus Gittinger <cg@exept.de>
parents: 895
diff changeset
  2701
     and is always drawn opaque.
7f5d81d377de opaque image display fix
Claus Gittinger <cg@exept.de>
parents: 895
diff changeset
  2702
    "
7f5d81d377de opaque image display fix
Claus Gittinger <cg@exept.de>
parents: 895
diff changeset
  2703
    (aForm depth ~~ 1) ifTrue:[
6485
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2704
        device
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2705
            copyFromPixmapId:id
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2706
            x:0
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2707
            y:0
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2708
            gc:deviceForm gcId
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2709
            to:drawableId
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2710
            x:pX
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2711
            y:pY
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2712
            gc:gcId
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2713
            width:w
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2714
            height:h.
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2715
        ^ self
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2716
    ].
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2717
    map := aForm colorMap.
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2718
    map notNil ifTrue:[
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2719
        paint := map at:2.
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2720
        bgPaint := map at:1.
902
7f5d81d377de opaque image display fix
Claus Gittinger <cg@exept.de>
parents: 895
diff changeset
  2721
    ].
7f5d81d377de opaque image display fix
Claus Gittinger <cg@exept.de>
parents: 895
diff changeset
  2722
7f5d81d377de opaque image display fix
Claus Gittinger <cg@exept.de>
parents: 895
diff changeset
  2723
    "/ 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
  2724
7f5d81d377de opaque image display fix
Claus Gittinger <cg@exept.de>
parents: 895
diff changeset
  2725
    bgPaint isNil ifTrue:[
6485
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2726
        self displayDeviceForm:aForm x:x y:y.
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2727
        ^ self
902
7f5d81d377de opaque image display fix
Claus Gittinger <cg@exept.de>
parents: 895
diff changeset
  2728
    ].
7f5d81d377de opaque image display fix
Claus Gittinger <cg@exept.de>
parents: 895
diff changeset
  2729
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2730
    "the following code is somewhat complicated, since it has to deal
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2731
     with dithered fg/bg colors, which cannot be done directly on most
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2732
     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
  2733
     (just assume drawing a bitmap with dithered fg/bg colors ... sigh)
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2734
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2735
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2736
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2737
     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
  2738
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2739
    easy := true.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2740
    paint isColor ifFalse:[
6485
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2741
        easy := false
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2742
    ] ifTrue:[
6485
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2743
        fgId := paint colorId.
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2744
        fgId isNil ifTrue:[
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2745
            easy := false
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2746
        ]
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2747
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2748
    bgPaint isColor ifFalse:[
6485
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2749
        easy := false
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2750
    ] ifTrue:[
6485
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2751
        bgId := bgPaint colorId.
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2752
        bgId isNil ifTrue:[
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2753
            easy := false
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2754
        ]
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2755
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2756
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2757
    easy ifTrue:[
6485
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2758
        "
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2759
         easy: both paint and bgPaint are real colors
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2760
        "
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2761
        ((foreground ~~ paint) or:[background ~~ bgPaint]) ifTrue:[
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2762
            device setForeground:fgId background:bgId in:gcId.
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2763
            foreground := paint.
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2764
            background := bgPaint.
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2765
        ].
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2766
        device
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2767
            copyPlaneFromPixmapId:id
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2768
            x:0
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2769
            y:0
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2770
            gc:(deviceForm gcId)
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2771
            to:drawableId
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2772
            x:pX
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2773
            y:pY
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2774
            gc:gcId
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2775
            width:w
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2776
            height:h.
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2777
        ^ self
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2778
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2779
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2780
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2781
     hard case: paint and/or bgPaint are dithered or patterns
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2782
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2783
    allColor := Color allColor.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2784
    allBits := allColor colorId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2785
    deviceDepth := device depth.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2786
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2787
    (fgId notNil and:[function == #copy]) ifTrue:[
6485
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2788
        "
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2789
         only bg is dithered; fill with bg first ...
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2790
        "
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2791
        savedPaint := paint.
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2792
        self paint:bgPaint.
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2793
        self fillDeviceRectangleX:pX y:pY width:w height:h.
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2794
        self paint:savedPaint.
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2795
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2796
        "
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2797
         if paint color is all-0 or all-1's, we can do it in one
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2798
         operation ...
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2799
        "
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2800
        ((fgId ~~ ((1 bitShift:deviceDepth)-1))
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2801
        and:[fgId ~~ allBits]) ifTrue:[
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2802
            "
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2803
             clear fg-bits ...
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2804
            "
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2805
            device setForeground:0 background:allBits in:gcId.
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2806
            device setFunction:#and in:gcId.
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2807
            device
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2808
                copyPlaneFromPixmapId:id
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2809
                x:0
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2810
                y:0
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2811
                gc:(deviceForm gcId)
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2812
                to:drawableId
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2813
                x:pX
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2814
                y:pY
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2815
                gc:gcId
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2816
                width:w
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2817
                height:h
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2818
        ].
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2819
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2820
        fgId ~~ 0 ifTrue:[
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2821
            "
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2822
             or-in fg-bits ...
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2823
            "
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2824
            device setForeground:fgId background:0 in:gcId.
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2825
            device setFunction:#or in:gcId.
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2826
            device
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2827
                copyPlaneFromPixmapId:id
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2828
                x:0
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2829
                y:0
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2830
                gc:(deviceForm gcId)
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2831
                to:drawableId
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2832
                x:pX
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2833
                y:pY
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2834
                gc:gcId
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2835
                width:w
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2836
                height:h
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2837
        ].
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2838
        "
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2839
         flush foreground/background cache
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2840
        "
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2841
        foreground := nil.
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2842
        background := nil.
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2843
        device setFunction:function in:gcId.
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2844
        ^ self
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2845
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2846
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2847
    (bgId notNil and:[function == #copy]) ifTrue:[
6485
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2848
        "
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2849
         only fg is dithered; fill with fg first ...
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2850
        "
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2851
        self fillDeviceRectangleX:pX y:pY width:w height:h.
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2852
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2853
        "
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2854
         if paint color is all-0 or all-1's, we can do it in one
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2855
         operation ...
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2856
        "
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2857
        ((bgId ~~ ((1 bitShift:deviceDepth)-1))
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2858
        and:[bgId ~~ allBits]) ifTrue:[
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2859
            "
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2860
             clear bg-bits ...
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2861
            "
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2862
            device setForeground:allBits background:0 in:gcId.
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2863
            device setFunction:#and in:gcId.
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2864
            device
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2865
                copyPlaneFromPixmapId:id
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2866
                x:0
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2867
                y:0
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2868
                gc:(deviceForm gcId)
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2869
                to:drawableId
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2870
                x:pX
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2871
                y:pY
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2872
                gc:gcId
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2873
                width:w
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2874
                height:h
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2875
        ].
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2876
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2877
        "
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2878
         or-in bg-bits ...
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2879
        "
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2880
        bgId ~~ 0 ifTrue:[
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2881
            device setForeground:0 background:bgId in:gcId.
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2882
            device setFunction:#or in:gcId.
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2883
            device
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2884
                copyPlaneFromPixmapId:id
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2885
                x:0
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2886
                y:0
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2887
                gc:(deviceForm gcId)
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2888
                to:drawableId
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2889
                x:pX
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2890
                y:pY
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2891
                gc:gcId
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2892
                width:w
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2893
                height:h
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2894
        ].
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2895
        "
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2896
         flush foreground/background cache
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2897
        "
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2898
        foreground := nil.
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2899
        background := nil.
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2900
        device setFunction:function in:gcId.
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2901
        ^ self
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2902
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2903
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2904
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2905
     very hard case; both fg and bg are dithered colors
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
    noColor := Color noColor.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2908
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2909
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2910
     create temp-forms;
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2911
    "
4781
7f2473db5652 Change senders of obsolete messages Form>>...on: to ...onDevice:
Stefan Vogel <sv@exept.de>
parents: 4756
diff changeset
  2912
    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
  2913
    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
  2914
    tmpForm := Form width:w height:h depth:deviceDepth onDevice:device.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2915
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2916
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2917
     fill
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2918
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2919
    dx := dy := 0.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2920
    maskOrigin notNil ifTrue:[
6485
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2921
        dx := maskOrigin x.
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2922
        dy := maskOrigin y
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2923
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2924
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2925
    bgForm paint:bgPaint.
4983
14c28ec55880 Replace usage of obsolete methods
Stefan Vogel <sv@exept.de>
parents: 4914
diff changeset
  2926
    bgForm maskOriginX:(x negated + dx) y:(y negated + dy).
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2927
    bgForm fillRectangleX:0 y:0 width:w height:h.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2928
    fgForm paint:paint.
4983
14c28ec55880 Replace usage of obsolete methods
Stefan Vogel <sv@exept.de>
parents: 4914
diff changeset
  2929
    fgForm maskOriginX:(x negated + dx) y:(y negated + dy).
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2930
    fgForm fillRectangleX:0 y:0 width:w height:h.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2931
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2932
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2933
     stamp-out background
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2934
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2935
    bgForm paint:noColor on:allColor.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2936
    bgForm function:#and.
976
807b42b00353 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 975
diff changeset
  2937
    bgForm displayOpaqueForm:deviceForm x:0 y:0.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2938
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2939
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2940
     stamp-out foreground
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2941
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2942
    fgForm paint:allColor on:noColor.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2943
    fgForm function:#and.
976
807b42b00353 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 975
diff changeset
  2944
    fgForm displayOpaqueForm:deviceForm x:0 y:0.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2945
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2946
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2947
     clear tempform
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2948
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2949
    tmpForm paint:noColor.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2950
    tmpForm fillRectangleX:0 y:0 width:w height:h.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2951
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2952
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2953
     merge fg-temp and bg-temp into tmp
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2954
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2955
    tmpForm function:#or.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2956
    tmpForm paint:noColor on:allColor.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2957
    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
  2958
    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
  2959
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2960
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2961
     finally, draw it
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2962
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2963
    device setForeground:0 background:allBits in:gcId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2964
    device
6485
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2965
        copyFromPixmapId:tmpForm id
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2966
        x:0
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2967
        y:0
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2968
        gc:tmpForm gcId
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2969
        to:drawableId
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2970
        x:pX
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2971
        y:pY
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2972
        gc:gcId
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2973
        width:w
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2974
        height:h.
1637
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  2975
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  2976
    "
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  2977
     release tempForms immediately
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2978
     (although GC will eventually do it,
1637
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  2979
      this creates less stress to the Xserver in the meanwhile ...)
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  2980
    "
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  2981
    fgForm destroy.
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  2982
    bgForm destroy.
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  2983
    tmpForm destroy.
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  2984
732
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
     flush foreground/background cache
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2987
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2988
    foreground := nil.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2989
    background := nil.
868
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
  2990
1637
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  2991
    "Modified: 22.4.1997 / 21:44:10 / cg"
732
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
displayDeviceOpaqueString:aString from:index1 to:index2 in:font x:x y:y
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2995
    "draw a substring at the coordinate x/y - draw foreground pixels in
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2996
     paint-color and background pixels in bgPaint-color.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2997
     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
  2998
     the case where paint and/or bgPaint are dithered colors.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2999
     No translation or scaling is done."
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
    |easy w h savedPaint fgId bgId allColor allBits noColor
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3002
     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
  3003
     deviceDepth fontsEncoding ascent|
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3004
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3005
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3006
     if backgroundPaint color is nil, we assume
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3007
     this is a non-opaque draw
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3008
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3009
    bgPaint isNil ifTrue:[
7064
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3010
        self displayDeviceString:aString from:index1 to:index2 x:x y:y.
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3011
        ^ self
732
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
7064
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3014
    aString isPlainString ifFalse:[
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3015
        "
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3016
         hook for non-strings (i.e. attributed text)
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3017
         that 'thing' should know how to display itself ...
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3018
        "
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3019
        aString displayOpaqueOn:self x:x y:y from:index1 to:index2.
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3020
        ^ self
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3021
    ].
6210
af0bf039ec07 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6108
diff changeset
  3022
af0bf039ec07 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6108
diff changeset
  3023
    pX := x rounded.
af0bf039ec07 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6108
diff changeset
  3024
    pY := y rounded.
af0bf039ec07 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6108
diff changeset
  3025
6108
6ecfb89408d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6107
diff changeset
  3026
    font isAlienFont ifTrue:[
7064
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3027
        "
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3028
         hook for alien fonts
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3029
         that 'font' should know how to display the string ...
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3030
        "
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3031
        font displayOpaqueString:aString from:index1 to:index2 x:pX y:pY in:self.
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3032
        ^ self
6108
6ecfb89408d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6107
diff changeset
  3033
    ].
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3034
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3035
    gcId isNil ifTrue:[
7064
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3036
        self initGC
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3037
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3038
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3039
4026
882de378f763 no longer as string for its encoding;
Claus Gittinger <cg@exept.de>
parents: 3943
diff changeset
  3040
    s := aString.
4172
0d5bc2a70b83 Do not refer to uninitialized variable fontUsed
Stefan Vogel <sv@exept.de>
parents: 4146
diff changeset
  3041
    fontUsed := font onDevice:device.
4026
882de378f763 no longer as string for its encoding;
Claus Gittinger <cg@exept.de>
parents: 3943
diff changeset
  3042
    fontsEncoding := fontUsed encoding.
7288
fec0c6c1087b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7257
diff changeset
  3043
fec0c6c1087b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7257
diff changeset
  3044
    "/ This is now obsolete, as we are always using unicode internally.
fec0c6c1087b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7257
diff changeset
  3045
    "/ so the next line should be changed to fontsEncoding ~~ #unicode
4056
67c4686afbc6 characterEncoding stuff
Claus Gittinger <cg@exept.de>
parents: 4031
diff changeset
  3046
    (characterEncoding ~~ fontsEncoding) ifTrue:[
7064
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3047
        [
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3048
            s := CharacterEncoder encodeString:s from:characterEncoding into:fontsEncoding.
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3049
        ] on:CharacterEncoderError do:[:ex|
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3050
            "substitute a default value for codes that cannot be represented
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3051
             in the new character set"
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3052
            ex proceedWith:ex defaultValue.
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3053
        ].
4026
882de378f763 no longer as string for its encoding;
Claus Gittinger <cg@exept.de>
parents: 3943
diff changeset
  3054
    ].
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3055
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3056
    id := fontUsed fontId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3057
    id isNil ifTrue:[
7064
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3058
        "this should not happen, since #onDevice tries replacement fonts"
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3059
        'STX[DeviceGraphicsContext] no font: ' errorPrint. fontUsed errorPrintCR.
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3060
        ^ self
732
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
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3063
    deviceFont ~~ fontUsed ifTrue:[
7064
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3064
        device setFont:id in:gcId.
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3065
        deviceFont := fontUsed
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3066
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3067
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3068
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3069
     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
  3070
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3071
    easy := true.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3072
    paint isColor ifFalse:[
7064
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3073
        easy := false
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3074
    ] ifTrue:[
7064
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3075
        fgId := paint colorId.
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3076
        fgId isNil ifTrue:[
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3077
            easy := false
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3078
        ]
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3079
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3080
    bgPaint isColor ifFalse:[
7064
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3081
        easy := false
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3082
    ] ifTrue:[
7064
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3083
        bgId := bgPaint colorId.
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3084
        bgId isNil ifTrue:[
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3085
            easy := false
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3086
        ]
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3087
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3088
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3089
    easy ifTrue:[
7064
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3090
        device setForeground:fgId background:bgId in:gcId.
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3091
        foreground := paint.
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3092
        background := bgPaint.
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3093
        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
  3094
        ^ self
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3095
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3096
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3097
    w := fontUsed widthOf:s from:index1 to:index2.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3098
    h := fontUsed height.
3666
01d7bf1d2333 fixed Text drawing in displayString
Michael Beyl <mb@exept.de>
parents: 3630
diff changeset
  3099
    ascent := fontUsed ascent.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3100
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3101
    (fgId notNil and:[function == #copy]) ifTrue:[
7064
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3102
        "
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3103
         only bg is dithered; fill with bg first ...
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3104
        "
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3105
        savedPaint := paint.
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3106
        self paint:bgPaint.
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3107
        self fillRectangleX:pX y:(pY - ascent) width:w height:h.
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3108
        self paint:savedPaint.
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3109
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3110
        "
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3111
         then draw using fgPaint (which is a real color)
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3112
        "
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3113
        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
  3114
        ^ self
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3115
    ].
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
    allColor := Color allColor.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3118
    allBits := allColor colorId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3119
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3120
    deviceDepth := device depth.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3121
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
     the code below is correct, but some (all?) implementations of the
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3124
     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
  3125
     Therefore we use the slower code below.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3126
    "
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
"/    (bgId notNil and:[function == #copy]) ifTrue:[
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
"/       only fg is dithered; fill with fg first ...
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
"/      self fillRectangleX:pX y:(pY - fontUsed ascent) width:w height:h.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3133
"/
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3134
"/      "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3135
"/       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
  3136
"/       operation ...
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3137
"/      "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3138
"/      ((bgId ~~ ((1 bitShift:deviceDepth)-1))
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3139
"/      and:[bgId ~~ allBits]) ifTrue:[
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
"/           clear bg bits ...
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3142
"/          "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3143
"/          device setForeground:allBits background:0 in:gcId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3144
"/          device setFunction:#and in:gcId.
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3145
"/          device displayOpaqueString:s
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3146
"/                                from:index1 to:index2
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3147
"/                                   x:pX y:pY
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3148
"/                                  in:drawableId with:gcId.
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
"/
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3151
"/      "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3152
"/       or-in bg bits ...
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3153
"/      "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3154
"/      bgId ~~ 0 ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3155
"/          device setForeground:0 background:bgId in:gcId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3156
"/          device setFunction:#or in:gcId.
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3157
"/          device displayOpaqueString:s
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3158
"/                                from:index1 to:index2
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3159
"/                                   x:pX y:pY
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3160
"/                                  in:drawableId with:gcId.
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
"/      "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3163
"/       flush foreground/background cache
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3164
"/      "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3165
"/      foreground := nil.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3166
"/      background := nil.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3167
"/      device setFunction:function in:gcId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3168
"/      ^ self
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3169
"/  ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3170
768
77e4f9d30a22 fixes for b&w screens
Claus Gittinger <cg@exept.de>
parents: 745
diff changeset
  3171
    (bgId notNil and:[function == #copy]) ifTrue:[
7064
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3172
        "
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3173
         only fg is dithered; fill with bg first ...
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3174
        "
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3175
        device setForeground:bgId in:gcId.
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3176
        device setFunction:#copy in:gcId.
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3177
        device setBitmapMask:nil in:gcId.
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3178
        self fillRectangleX:pX y:(pY - ascent) width:w height:h.
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3179
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3180
        mask notNil ifTrue:[
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3181
            "/ draw fg dithered
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3182
            (mask depth == 1) ifTrue:[
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3183
                device setBitmapMask:mask id in:gcId.
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3184
                device setForegroundColor:foreground backgroundColor:background in:gcId.
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3185
            ] ifFalse:[
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3186
                device setPixmapMask:mask id in:gcId
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3187
            ].
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3188
        ].
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3189
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3190
        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
  3191
        ^ self.
832
064890dcfabd fixed opaque string draw with deep-dither
Claus Gittinger <cg@exept.de>
parents: 786
diff changeset
  3192
    ].
064890dcfabd fixed opaque string draw with deep-dither
Claus Gittinger <cg@exept.de>
parents: 786
diff changeset
  3193
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3194
    "
832
064890dcfabd fixed opaque string draw with deep-dither
Claus Gittinger <cg@exept.de>
parents: 786
diff changeset
  3195
     very hard case, both fg and bg are dithered colors/images
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3196
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3197
    noColor := Color noColor.
4026
882de378f763 no longer as string for its encoding;
Claus Gittinger <cg@exept.de>
parents: 3943
diff changeset
  3198
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3199
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3200
     create temp-forms;
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3201
    "
4781
7f2473db5652 Change senders of obsolete messages Form>>...on: to ...onDevice:
Stefan Vogel <sv@exept.de>
parents: 4756
diff changeset
  3202
    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
  3203
    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
  3204
    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
  3205
    maskForm := Form width:w height:h depth:deviceDepth onDevice:device.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3206
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3207
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3208
     fill
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3209
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3210
    dx := 0.
3666
01d7bf1d2333 fixed Text drawing in displayString
Michael Beyl <mb@exept.de>
parents: 3630
diff changeset
  3211
    dy := ascent.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3212
    maskOrigin notNil ifTrue:[
7064
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3213
        dx := maskOrigin x.
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3214
        dy := dy + maskOrigin y
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3215
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3216
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3217
    bgForm paint:bgPaint.
4983
14c28ec55880 Replace usage of obsolete methods
Stefan Vogel <sv@exept.de>
parents: 4914
diff changeset
  3218
    bgForm maskOriginX:(pX negated + dx) y:(pY negated + dy).
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3219
    bgForm fillRectangleX:0 y:0 width:w height:h.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3220
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3221
    fgForm paint:paint.
4983
14c28ec55880 Replace usage of obsolete methods
Stefan Vogel <sv@exept.de>
parents: 4914
diff changeset
  3222
    fgForm maskOriginX:(pX negated + dx) y:(pY negated + dy).
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3223
    fgForm fillRectangleX:0 y:0 width:w height:h.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3224
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
     stamp-out background (have now bg-bits with fg=0 in bgForm)
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3227
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3228
    bgForm font:fontUsed.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3229
    bgForm paint:noColor on:allColor.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3230
    bgForm function:#and.
4026
882de378f763 no longer as string for its encoding;
Claus Gittinger <cg@exept.de>
parents: 3943
diff changeset
  3231
    bgForm displayString:s from:index1 to:index2 x:0 y:ascent.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3232
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3233
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3234
     stamp-out foreground
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3235
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3236
    maskForm font:fontUsed.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3237
    maskForm paint:allColor on:noColor.
4026
882de378f763 no longer as string for its encoding;
Claus Gittinger <cg@exept.de>
parents: 3943
diff changeset
  3238
    maskForm displayOpaqueString:s from:index1 to:index2 x:0 y:ascent.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3239
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3240
    fgForm function:#and.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3241
    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
  3242
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3243
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3244
     clear tempform
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3245
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3246
    tmpForm paint:noColor.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3247
    tmpForm fillRectangleX:0 y:0 width:w height:h.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3248
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3249
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3250
     merge fg-temp and bg-temp into tmp
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3251
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3252
    tmpForm function:#or.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3253
    tmpForm paint:noColor on:allColor.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3254
    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
  3255
    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
  3256
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3257
     finally, draw it
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3258
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3259
    device setForeground:0 background:allBits in:gcId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3260
    device
7064
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3261
        copyFromId:tmpForm id
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3262
        x:0 y:0 gc:tmpForm gcId
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3263
        to:drawableId
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3264
        x:pX y:(pY-ascent) gc:gcId
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3265
        width:w height:h.
1637
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  3266
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  3267
    "
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  3268
     release tempForms immediately
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3269
     (although GC will eventually do it,
1637
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  3270
      this creates less stress to the Xserver in the meanwhile ...)
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  3271
    "
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  3272
    tmpForm destroy.
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  3273
    fgForm destroy.
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  3274
    bgForm destroy.
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  3275
    maskForm destroy.
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  3276
732
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
     flush foreground/background cache
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3279
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3280
    foreground := nil.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3281
    background := nil.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3282
1805
532a11ba8458 tuned-out another send if encoding is wrong in display-string
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  3283
    "Modified: 1.7.1997 / 17:08:46 / cg"
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3284
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3285
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3286
displayDeviceOpaqueString:aString from:index1 to:index2 x:x y:y
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3287
    "draw a substring at the coordinate x/y - draw foreground pixels in
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3288
     paint-color and background pixels in bgPaint-color.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3289
     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
  3290
     the case where paint and/or bgPaint are dithered colors.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3291
     No translation or scaling is done."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3292
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3293
    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
  3294
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3295
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3296
displayDeviceOpaqueString:aString x:x y:y
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3297
    "draw a string at the coordinate x/y - draw foreground pixels in
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3298
     paint-color and background pixels in bgPaint-color.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3299
     No translation or scaling is done"
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
    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
  3302
!
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
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
  3305
    "draw a substring at the coordinate x/y -
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3306
     draw foreground-pixels only (in current paint-color), leaving background as-is.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3307
     No translation or scaling is done"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3308
4026
882de378f763 no longer as string for its encoding;
Claus Gittinger <cg@exept.de>
parents: 3943
diff changeset
  3309
    |id pX pY fontUsed s fontsEncoding|
732
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
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3312
     hook for non-strings (i.e. attributed text)
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3313
    "
7064
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3314
    aString isPlainString ifFalse:[
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3315
        ^ aString displayOn:self x:x y:y from:index1 to:index2
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3316
    ].
6210
af0bf039ec07 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6108
diff changeset
  3317
af0bf039ec07 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6108
diff changeset
  3318
    pX := x rounded.
af0bf039ec07 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6108
diff changeset
  3319
    pY := y rounded.
af0bf039ec07 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6108
diff changeset
  3320
6108
6ecfb89408d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6107
diff changeset
  3321
    font isAlienFont ifTrue:[
7064
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3322
        "
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3323
         hook for alien fonts
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3324
         that 'font' should know how to display the string ...
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3325
        "
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3326
        font displayOpaqueString:aString from:index1 to:index2 x:pX y:pY in:self.
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3327
        ^ self
6108
6ecfb89408d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6107
diff changeset
  3328
    ].
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3329
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3330
    gcId isNil ifTrue:[
7064
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3331
        self initGC
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3332
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3333
4026
882de378f763 no longer as string for its encoding;
Claus Gittinger <cg@exept.de>
parents: 3943
diff changeset
  3334
    s := aString.
4172
0d5bc2a70b83 Do not refer to uninitialized variable fontUsed
Stefan Vogel <sv@exept.de>
parents: 4146
diff changeset
  3335
    fontUsed := font onDevice:device.
4026
882de378f763 no longer as string for its encoding;
Claus Gittinger <cg@exept.de>
parents: 3943
diff changeset
  3336
    fontsEncoding := fontUsed encoding.
7288
fec0c6c1087b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7257
diff changeset
  3337
fec0c6c1087b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7257
diff changeset
  3338
    "/ This is now obsolete, as we are always using unicode internally.
fec0c6c1087b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7257
diff changeset
  3339
    "/ so the next line should be changed to fontsEncoding ~~ #unicode
4056
67c4686afbc6 characterEncoding stuff
Claus Gittinger <cg@exept.de>
parents: 4031
diff changeset
  3340
    (characterEncoding ~~ fontsEncoding) ifTrue:[
7064
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3341
        [
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3342
            s := CharacterEncoder encodeString:s from:characterEncoding into:fontsEncoding.
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3343
        ] on:CharacterEncoderError do:[:ex|
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3344
            "substitute a default value for codes that cannot be represented
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3345
             in the new character set"
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3346
            ex proceedWith:ex defaultValue.
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3347
        ].
4026
882de378f763 no longer as string for its encoding;
Claus Gittinger <cg@exept.de>
parents: 3943
diff changeset
  3348
    ].
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3349
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3350
    id := fontUsed fontId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3351
    id isNil ifTrue:[
7064
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3352
        "this should not happen, since #onDevice tries replacement fonts"
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3353
        'STX[DeviceGraphicsContext] no font: ' errorPrint. fontUsed errorPrintCR.
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3354
        ^ self
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3355
    ] ifFalse:[
7064
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3356
        deviceFont ~~ fontUsed ifTrue:[
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3357
            device setFont:id in:gcId.
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3358
            deviceFont := fontUsed
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3359
        ].
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3360
        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
  3361
    ]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3362
1805
532a11ba8458 tuned-out another send if encoding is wrong in display-string
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  3363
    "Modified: 1.7.1997 / 17:08:48 / cg"
732
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
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3366
displayDeviceString:aString from:index1 to:index2 x:x y:y
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3367
    "draw a substring at the coordinate x/y -
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3368
     draw foreground-pixels only (in current paint-color), leaving background as-is.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3369
     No translation or scaling is done"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3370
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3371
    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
  3372
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3373
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3374
displayDeviceString:aString x:x y:y
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3375
    "draw a string at the coordinate x/y -
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3376
     draw foreground-pixels only (in current paint-color), leaving background as-is.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3377
     No translation or scaling is done"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3378
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3379
    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
  3380
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3381
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3382
fillDeviceRectangleX:x y:y width:w height:h
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3383
    "draw a filled rectangle in device coordinate space.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3384
     This ignores any transformations. The coordinates must be integers."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3385
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3386
    gcId isNil ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3387
	self initGC
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3388
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3389
    device
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3390
	fillRectangleX:x
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3391
		     y:y
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3392
		 width:w
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3393
		height:h
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3394
		    in:drawableId with:gcId
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3395
! !
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3396
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3397
!DeviceGraphicsContext methodsFor:'evaluating in another context'!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3398
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3399
reverseDo:aBlock
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3400
    "evaluate aBlock with foreground and background interchanged.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3401
     This can be reimplemented here in a faster way."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3402
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3403
    |oldFg oldBg|
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3404
2835
963425946ff3 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 2714
diff changeset
  3405
    oldFg := foreground.
963425946ff3 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 2714
diff changeset
  3406
    oldBg := background.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3407
    self foreground:background background:foreground.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3408
    aBlock value.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3409
    self foreground:oldFg background:oldBg
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
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3412
withBackground:fgColor do:aBlock
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3413
    "evaluate aBlock with changed background."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3414
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3415
    |oldBg|
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3416
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3417
    oldBg := background.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3418
    self background:fgColor.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3419
    aBlock value.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3420
    self background:oldBg
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3421
!
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
withForeground:fgColor background:bgColor do:aBlock
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3424
    "evaluate aBlock with changed foreground and background."
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
    |oldFg oldBg|
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3427
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3428
    oldFg := foreground.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3429
    oldBg := background.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3430
    self foreground:fgColor background:bgColor.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3431
    aBlock value.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3432
    self foreground:oldFg background:oldBg
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
withForeground:fgColor background:bgColor function:aFunction do:aBlock
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3436
    "evaluate aBlock with foreground, background and function"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3437
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3438
    |oldFg oldBg oldFun|
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
    oldFg := foreground.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3441
    oldBg := background.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3442
    oldFun := function.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3443
    self foreground:fgColor background:bgColor function:aFunction.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3444
    aBlock value.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3445
    self foreground:oldFg background:oldBg function:oldFun
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
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3448
withForeground:fgColor background:bgColor mask:aMask do:aBlock
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3449
    "evaluate aBlock with foreground, background and mask"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3450
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3451
    |oldFg oldBg oldMask|
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3452
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3453
    oldFg := foreground.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3454
    oldBg := background.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3455
    oldMask := mask.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3456
    self foreground:fgColor background:bgColor.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3457
    self mask:aMask.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3458
    aBlock value.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3459
    self foreground:oldFg background:oldBg.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3460
    self mask:oldMask
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3461
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3462
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3463
withForeground:fgColor do:aBlock
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3464
    "evaluate aBlock with changed foreground."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3465
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3466
    |oldFg|
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3467
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3468
    oldFg := foreground.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3469
    self foreground:fgColor.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3470
    aBlock value.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3471
    self foreground:oldFg
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
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3474
withForeground:fgColor function:aFunction do:aBlock
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3475
    "evaluate aBlock with changed foreground and function."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3476
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3477
    |oldFg oldFun|
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3478
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3479
    oldFg := foreground.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3480
    oldFun := function.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3481
    self foreground:fgColor background:background function:aFunction.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3482
    aBlock value.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3483
    self foreground:oldFg background:background function:oldFun
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3484
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3485
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3486
xoring:aBlock
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3487
    "evaluate aBlock with function xoring"
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
    |fgPixel bgPixel oldFunction|
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3490
2322
6c42f2e0213c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2271
diff changeset
  3491
    fgPixel := device blackpixel.
6c42f2e0213c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2271
diff changeset
  3492
    bgPixel := device whitepixel.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3493
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3494
    gcId isNil ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3495
	self initGC
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3496
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3497
    oldFunction := function.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3498
    device setForeground:(fgPixel bitXor:bgPixel)
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3499
	      background:bgPixel
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3500
		      in:gcId.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3501
    device setFunction:#xor in:gcId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3502
    aBlock value.
2322
6c42f2e0213c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2271
diff changeset
  3503
2879
f1e9b8310d4e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2865
diff changeset
  3504
    paint := bgPaint := nil.        "invalidate"
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3505
    foreground := device blackColor.
1199
f113f6a4c04a use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents: 1177
diff changeset
  3506
    background := device whiteColor.
2322
6c42f2e0213c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2271
diff changeset
  3507
    device setForeground:fgPixel background:bgPixel in:gcId.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3508
    device setFunction:oldFunction in:gcId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3509
    function := oldFunction
1199
f113f6a4c04a use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents: 1177
diff changeset
  3510
2322
6c42f2e0213c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2271
diff changeset
  3511
    "Modified: / 10.9.1998 / 12:17:39 / cg"
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3512
! !
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
!DeviceGraphicsContext methodsFor:'filling'!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3515
5837
28301409379c added: #clearDeviceRectangleX:y:width:height:
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3516
clearDeviceRectangleX:x y:y width:w height:h
28301409379c added: #clearDeviceRectangleX:y:width:height:
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3517
    "clear a rectangular area to viewBackground -
28301409379c added: #clearDeviceRectangleX:y:width:height:
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3518
     redefined since GraphicsMedium fills with background
28301409379c added: #clearDeviceRectangleX:y:width:height:
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3519
     - not viewBackground as we want here."
28301409379c added: #clearDeviceRectangleX:y:width:height:
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3520
7301
153311545645 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 7288
diff changeset
  3521
    |oldPaint viewBackground|
153311545645 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 7288
diff changeset
  3522
153311545645 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 7288
diff changeset
  3523
    viewBackground := self viewBackground.
153311545645 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 7288
diff changeset
  3524
    viewBackground isNil ifTrue:[^ self]. "/ how can this happen?
153311545645 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 7288
diff changeset
  3525
    
5837
28301409379c added: #clearDeviceRectangleX:y:width:height:
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3526
    "
28301409379c added: #clearDeviceRectangleX:y:width:height:
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3527
     fill in device coordinates - not logical coordinates
28301409379c added: #clearDeviceRectangleX:y:width:height:
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3528
    "
28301409379c added: #clearDeviceRectangleX:y:width:height:
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3529
    oldPaint := paint.
7301
153311545645 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 7288
diff changeset
  3530
    self paint:viewBackground.
5837
28301409379c added: #clearDeviceRectangleX:y:width:height:
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3531
    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
  3532
    self paint:oldPaint
28301409379c added: #clearDeviceRectangleX:y:width:height:
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3533
28301409379c added: #clearDeviceRectangleX:y:width:height:
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3534
    "Modified: / 04-05-1999 / 13:00:34 / cg"
28301409379c added: #clearDeviceRectangleX:y:width:height:
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3535
    "Created: / 30-12-2011 / 14:32:14 / cg"
28301409379c added: #clearDeviceRectangleX:y:width:height:
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3536
!
28301409379c added: #clearDeviceRectangleX:y:width:height:
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3537
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3538
fillArcX:x y:y width:w height:h from:startAngle angle:angle
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3539
    "draw a filled arc; apply transformation if nonNil"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3540
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  3541
    |pX pY nW nH sA a pO pC|
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3542
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3543
    gcId isNil ifTrue:[
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  3544
        self initGC
732
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
    transformation notNil ifTrue:[
6711
2b50385f7257 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
  3547
        pO := transformation transformPoint:x@y.
2b50385f7257 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
  3548
        pC := transformation transformPoint:(x+w-1)@(y+h-1).
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  3549
        pX := pO x.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  3550
        pY := pO y.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  3551
        nW := pC x - pX + 1.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  3552
        nH := pC y - pY + 1.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  3553
        nW < 0 ifTrue:[
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  3554
              nW := nW abs.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  3555
              pX := pX - nW.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  3556
        ].
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  3557
        nH < 0 ifTrue:[
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  3558
              nH := nH abs.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  3559
              pY := pY - nH.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  3560
        ].
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3561
    ] ifFalse:[
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  3562
        pX := x.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  3563
        pY := y.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  3564
        nW := w.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  3565
        nH := h.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3566
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3567
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3568
    pX := pX rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3569
    pY := pY rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3570
    nW := nW rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3571
    nH := nH rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3572
2268
1a774fc02c83 fixed non-float (i.e. fraction) args to fillArc/ displayArc
Claus Gittinger <cg@exept.de>
parents: 2259
diff changeset
  3573
    sA := startAngle.
1a774fc02c83 fixed non-float (i.e. fraction) args to fillArc/ displayArc
Claus Gittinger <cg@exept.de>
parents: 2259
diff changeset
  3574
    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
  3575
    a := angle.
1a774fc02c83 fixed non-float (i.e. fraction) args to fillArc/ displayArc
Claus Gittinger <cg@exept.de>
parents: 2259
diff changeset
  3576
    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
  3577
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3578
    device
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  3579
          fillArcX:pX
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  3580
                 y:pY
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  3581
             width:nW
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  3582
            height:nH
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  3583
              from:sA
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  3584
             angle:a
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  3585
                in:drawableId
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  3586
              with:gcId
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3587
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3588
    "Created: 8.5.1996 / 08:29:45 / cg"
784
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
  3589
    "Modified: 4.6.1996 / 17:58:21 / cg"
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3590
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3591
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3592
fillPolygon:aPolygon
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3593
    "draw a filled polygon; apply transformation if nonNil"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3594
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3595
    |newPolygon|
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3596
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3597
    gcId isNil ifTrue:[
6711
2b50385f7257 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
  3598
        self initGC
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3599
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3600
    transformation notNil ifTrue:[
6711
2b50385f7257 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
  3601
        newPolygon := aPolygon collect:[:point | transformation transformPoint:point].
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3602
    ] ifFalse:[
6711
2b50385f7257 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
  3603
        newPolygon := aPolygon
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3604
    ].
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3605
    (newPolygon contains:[:p |
6711
2b50385f7257 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
  3606
        (p isPoint not
2b50385f7257 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
  3607
        or:[(p x class ~~ SmallInteger)
2b50385f7257 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
  3608
        or:[(p y class ~~ SmallInteger)]])
4521
6f065906e740 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4477
diff changeset
  3609
     ]) ifTrue:[
6711
2b50385f7257 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
  3610
        newPolygon := newPolygon collect:[:p | p asPoint rounded]
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3611
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3612
    device
6711
2b50385f7257 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
  3613
        fillPolygon:newPolygon
2b50385f7257 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
  3614
                 in:drawableId
2b50385f7257 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
  3615
               with:gcId
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3616
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3617
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3618
fillRectangleX:x y:y width:w height:h
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3619
    "draw a filled rectangle; apply transformation if nonNil"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3620
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  3621
    |pX pY nW nH pO pC|
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3622
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3623
    gcId isNil ifTrue:[
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  3624
        self initGC
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3625
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3626
    transformation notNil ifTrue:[
6711
2b50385f7257 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
  3627
        pO := transformation transformPoint:x@y.
2b50385f7257 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
  3628
        pC := transformation transformPoint:(x+w-1)@(y+h-1).
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  3629
        pX := pO x.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  3630
        pY := pO y.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  3631
        nW := pC x - pX + 1.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  3632
        nH := pC y - pY + 1.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  3633
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  3634
        nW < 0 ifTrue:[
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  3635
              nW := nW abs.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  3636
              pX := pX - nW.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  3637
        ].
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  3638
        nH < 0 ifTrue:[
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  3639
              nH := nH abs.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  3640
              pY := pY - nH.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  3641
        ].
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3642
    ] ifFalse:[
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  3643
        pX := x.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  3644
        pY := y.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  3645
        nW := w.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  3646
        nH := h.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3647
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3648
    pX := pX rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3649
    pY := pY rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3650
    nW := nW rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3651
    nH := nH rounded.
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
    device
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  3654
        fillRectangleX:pX
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  3655
                     y:pY
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  3656
                 width:nW
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  3657
                height:nH
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  3658
                    in:drawableId with:gcId
784
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
  3659
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
  3660
    "Modified: 4.6.1996 / 17:58:49 / cg"
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3661
! !
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3662
6472
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  3663
!DeviceGraphicsContext methodsFor:'finalization'!
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  3664
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  3665
executor
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  3666
    drawableType == #window ifTrue:[
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  3667
        ^ DeviceWindowGCHandle basicNew
7287
1e2a3258dd8a Replace all `self graphicsDevice` with `device`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 7286
diff changeset
  3668
            setDevice:device id:self drawableId gcId:self gcId parentId:parentId.
6472
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  3669
    ] ifFalse:[
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  3670
        ^ DevicePixmapGCHandle basicNew
7287
1e2a3258dd8a Replace all `self graphicsDevice` with `device`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 7286
diff changeset
  3671
            setDevice:device id:self drawableId gcId:self gcId.
6472
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  3672
    ].
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  3673
!
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  3674
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  3675
finalizationLobby
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  3676
    "answer the registry used for finalization.
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  3677
     DeviceGraphicContexts have their own Registry"
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  3678
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  3679
    ^ Lobby
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  3680
!
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  3681
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  3682
registerChange
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  3683
    "register a change with the finalizationLobby"
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  3684
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  3685
    Lobby registerChange:self.
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  3686
! !
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  3687
3883
4e01a59afccb method category rename
Claus Gittinger <cg@exept.de>
parents: 3880
diff changeset
  3688
!DeviceGraphicsContext methodsFor:'initialization & release'!
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3689
1517
ac751bb3dfdf no need for registration here;
Claus Gittinger <cg@exept.de>
parents: 1514
diff changeset
  3690
close
ac751bb3dfdf no need for registration here;
Claus Gittinger <cg@exept.de>
parents: 1514
diff changeset
  3691
    "same as destroy - for ST-80 compatibility"
ac751bb3dfdf no need for registration here;
Claus Gittinger <cg@exept.de>
parents: 1514
diff changeset
  3692
ac751bb3dfdf no need for registration here;
Claus Gittinger <cg@exept.de>
parents: 1514
diff changeset
  3693
    self destroy
ac751bb3dfdf no need for registration here;
Claus Gittinger <cg@exept.de>
parents: 1514
diff changeset
  3694
ac751bb3dfdf no need for registration here;
Claus Gittinger <cg@exept.de>
parents: 1514
diff changeset
  3695
    "Created: 2.4.1997 / 19:31:27 / cg"
ac751bb3dfdf no need for registration here;
Claus Gittinger <cg@exept.de>
parents: 1514
diff changeset
  3696
!
ac751bb3dfdf no need for registration here;
Claus Gittinger <cg@exept.de>
parents: 1514
diff changeset
  3697
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3698
createGC
1453
e93293618275 only fetch id's once in displayForm.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  3699
    "physically create a device GC.
e93293618275 only fetch id's once in displayForm.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  3700
     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
  3701
     really drawn, none is created up to the first draw.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3702
     This method is sent, when the first drawing happens"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3703
7165
730622084e88 DeviceGraphicsContext: Use test `drawableType == #window` consistenly,
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 7153
diff changeset
  3704
    drawableType == #window ifTrue:[
730622084e88 DeviceGraphicsContext: Use test `drawableType == #window` consistenly,
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 7153
diff changeset
  3705
        gcId := device gcFor:drawableId.
730622084e88 DeviceGraphicsContext: Use test `drawableType == #window` consistenly,
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 7153
diff changeset
  3706
    ] ifFalse:[
6472
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  3707
        gcId := device gcForBitmap:drawableId.
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  3708
    ].
1138
4a2b3b407cae need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents: 1094
diff changeset
  3709
    Lobby registerChange:self.
1453
e93293618275 only fetch id's once in displayForm.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  3710
7165
730622084e88 DeviceGraphicsContext: Use test `drawableType == #window` consistenly,
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 7153
diff changeset
  3711
    "Modified: / 19-03-1997 / 11:07:52 / cg"
730622084e88 DeviceGraphicsContext: Use test `drawableType == #window` consistenly,
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 7153
diff changeset
  3712
    "Modified: / 25-02-2016 / 10:12:09 / Jan Vrany <jan.vrany@fit.cvut.cz>"
6234
404d91662d49 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6225
diff changeset
  3713
!
404d91662d49 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6225
diff changeset
  3714
1138
4a2b3b407cae need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents: 1094
diff changeset
  3715
destroy
6472
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  3716
    |id|
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  3717
7033
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 6933
diff changeset
  3718
    
6472
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  3719
    self destroyGC .
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  3720
    id := drawableId.
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  3721
    id notNil ifTrue:[
7033
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 6933
diff changeset
  3722
        self changed:#aboutToDestroy.
6472
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  3723
        drawableId := nil.
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  3724
        drawableType == #window ifTrue:[
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  3725
            device destroyView:nil withId:id.
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  3726
        ] ifFalse:[
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  3727
            device destroyPixmap:id.
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  3728
        ].
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  3729
    ].
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  3730
    Lobby unregister:self.
1138
4a2b3b407cae need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents: 1094
diff changeset
  3731
!
4a2b3b407cae need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents: 1094
diff changeset
  3732
6222
2d670d3bcfd5 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6215
diff changeset
  3733
destroyGC
2d670d3bcfd5 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6215
diff changeset
  3734
    |id|
2d670d3bcfd5 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6215
diff changeset
  3735
2d670d3bcfd5 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6215
diff changeset
  3736
    id := gcId.
2d670d3bcfd5 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6215
diff changeset
  3737
    id notNil ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3738
	gcId := nil.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3739
	device destroyGC:id.
6222
2d670d3bcfd5 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6215
diff changeset
  3740
    ].
6266
1503c5e038d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  3741
!
1503c5e038d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  3742
1138
4a2b3b407cae need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents: 1094
diff changeset
  3743
initGC
4a2b3b407cae need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents: 1094
diff changeset
  3744
    "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
  3745
     really drawn, none is created.
4a2b3b407cae need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents: 1094
diff changeset
  3746
     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
  3747
4135
a47337e09c40 preset font if already ok for device
werner
parents: 4070
diff changeset
  3748
    |fgId bgId p fontId|
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3749
1453
e93293618275 only fetch id's once in displayForm.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  3750
    gcId notNil ifTrue:[^ self].
1514
7c2a921ae46b better error report when drawing on closed view.
Claus Gittinger <cg@exept.de>
parents: 1507
diff changeset
  3751
    drawableId isNil ifTrue:[
2031
d369d38213cf dont use #error when drawing on a closed drawable;
Claus Gittinger <cg@exept.de>
parents: 2024
diff changeset
  3752
        "/
d369d38213cf dont use #error when drawing on a closed drawable;
Claus Gittinger <cg@exept.de>
parents: 2024
diff changeset
  3753
        "/ the drawable has been closed (or was never open)
d369d38213cf dont use #error when drawing on a closed drawable;
Claus Gittinger <cg@exept.de>
parents: 2024
diff changeset
  3754
        "/ no drawing is possible.
d369d38213cf dont use #error when drawing on a closed drawable;
Claus Gittinger <cg@exept.de>
parents: 2024
diff changeset
  3755
        "/
d369d38213cf dont use #error when drawing on a closed drawable;
Claus Gittinger <cg@exept.de>
parents: 2024
diff changeset
  3756
        ^ DrawingOnClosedDrawableSignal raiseRequest
1514
7c2a921ae46b better error report when drawing on closed view.
Claus Gittinger <cg@exept.de>
parents: 1507
diff changeset
  3757
    ].
1138
4a2b3b407cae need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents: 1094
diff changeset
  3758
    self createGC.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3759
1199
f113f6a4c04a use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents: 1177
diff changeset
  3760
    foreground isNil ifTrue:[foreground := device blackColor].
f113f6a4c04a use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents: 1177
diff changeset
  3761
    background isNil ifTrue:[background := device whiteColor].
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3762
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3763
    foreground isColor ifTrue:[
1199
f113f6a4c04a use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents: 1177
diff changeset
  3764
        "get device colors from the device indep. colors"
2835
963425946ff3 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 2714
diff changeset
  3765
        foreground := foreground onDevice:device.
1199
f113f6a4c04a use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents: 1177
diff changeset
  3766
        fgId := foreground colorId.
f113f6a4c04a use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents: 1177
diff changeset
  3767
        fgId isNil ifTrue:[
f113f6a4c04a use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents: 1177
diff changeset
  3768
            (foreground grayIntensity >= 50) ifTrue:[
f113f6a4c04a use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents: 1177
diff changeset
  3769
                fgId := device whitepixel
f113f6a4c04a use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents: 1177
diff changeset
  3770
            ] ifFalse:[
f113f6a4c04a use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents: 1177
diff changeset
  3771
                fgId := device blackpixel
f113f6a4c04a use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents: 1177
diff changeset
  3772
            ]
f113f6a4c04a use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents: 1177
diff changeset
  3773
        ].
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3774
    ] ifFalse:[
1199
f113f6a4c04a use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents: 1177
diff changeset
  3775
        fgId := device blackpixel.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3776
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3777
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3778
    background isColor ifTrue:[
2835
963425946ff3 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 2714
diff changeset
  3779
        background := background onDevice:device.
1199
f113f6a4c04a use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents: 1177
diff changeset
  3780
        bgId := background colorId.
f113f6a4c04a use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents: 1177
diff changeset
  3781
        bgId isNil ifTrue:[
f113f6a4c04a use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents: 1177
diff changeset
  3782
            (background grayIntensity >= 50) ifTrue:[
f113f6a4c04a use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents: 1177
diff changeset
  3783
                bgId := device whitepixel
f113f6a4c04a use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents: 1177
diff changeset
  3784
            ] ifFalse:[
f113f6a4c04a use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents: 1177
diff changeset
  3785
                bgId := device blackpixel
f113f6a4c04a use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents: 1177
diff changeset
  3786
            ]
f113f6a4c04a use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents: 1177
diff changeset
  3787
        ].
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3788
    ] ifFalse:[
1199
f113f6a4c04a use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents: 1177
diff changeset
  3789
        bgId := device whitepixel
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3790
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3791
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3792
    "now, this is something the device can work with ..."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3793
    device setForeground:fgId background:bgId in:gcId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3794
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3795
    "switch to paint"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3796
    p := paint.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3797
    paint := nil.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3798
    self paint:p.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3799
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3800
    ((lineWidth ~~ 0)
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3801
    or:[(lineStyle ~~ #solid)
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3802
    or:[(capStyle ~~ #butt)
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3803
    or:[joinStyle ~~ #miter]]]) ifTrue:[
6472
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  3804
        device setLineWidth:lineWidth
1199
f113f6a4c04a use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents: 1177
diff changeset
  3805
                      style:lineStyle
f113f6a4c04a use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents: 1177
diff changeset
  3806
                        cap:capStyle
f113f6a4c04a use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents: 1177
diff changeset
  3807
                       join:joinStyle
f113f6a4c04a use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents: 1177
diff changeset
  3808
                         in:gcId
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3809
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3810
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3811
    mask notNil ifTrue:[
1199
f113f6a4c04a use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents: 1177
diff changeset
  3812
        (mask depth == 1) ifTrue:[
f113f6a4c04a use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents: 1177
diff changeset
  3813
            device setBitmapMask:(mask id) in:gcId
f113f6a4c04a use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents: 1177
diff changeset
  3814
        ] ifFalse:[
f113f6a4c04a use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents: 1177
diff changeset
  3815
            device setPixmapMask:(mask id) in:gcId
f113f6a4c04a use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents: 1177
diff changeset
  3816
        ].
f113f6a4c04a use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents: 1177
diff changeset
  3817
        maskOrigin notNil ifTrue:[
f113f6a4c04a use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents: 1177
diff changeset
  3818
            device setMaskOriginX:maskOrigin x y:maskOrigin y in:gcId
f113f6a4c04a use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents: 1177
diff changeset
  3819
        ]
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3820
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3821
    (function ~~ #copy) ifTrue:[device setFunction:function in:gcId].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3822
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3823
    "defer the getting of a device font
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3824
     - this is now done when the first drawstring occurs,
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3825
     since many views (layout-views) will never draw strings and
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3826
     therefore, the overhead of aquiring a font can be avoided.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3827
    "
1138
4a2b3b407cae need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents: 1094
diff changeset
  3828
"/    font := font on:device.
4a2b3b407cae need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents: 1094
diff changeset
  3829
"/    id := font fontId.
4a2b3b407cae need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents: 1094
diff changeset
  3830
"/    id notNil ifTrue:[
4a2b3b407cae need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents: 1094
diff changeset
  3831
"/        device setFont:id in:gcId
4a2b3b407cae need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents: 1094
diff changeset
  3832
"/    ]
1199
f113f6a4c04a use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents: 1177
diff changeset
  3833
4135
a47337e09c40 preset font if already ok for device
werner
parents: 4070
diff changeset
  3834
    font notNil ifTrue:[
4146
4c46ae30bd64 Use #graphicsDevice
Stefan Vogel <sv@exept.de>
parents: 4135
diff changeset
  3835
        font graphicsDevice == device ifTrue:[
4135
a47337e09c40 preset font if already ok for device
werner
parents: 4070
diff changeset
  3836
            (fontId := font fontId) notNil ifTrue:[
4664
02d160974029 fix remembering deviceFont everywhere.
Claus Gittinger <cg@exept.de>
parents: 4657
diff changeset
  3837
                deviceFont := font.
4135
a47337e09c40 preset font if already ok for device
werner
parents: 4070
diff changeset
  3838
                device setFont:fontId in:gcId
a47337e09c40 preset font if already ok for device
werner
parents: 4070
diff changeset
  3839
            ]
a47337e09c40 preset font if already ok for device
werner
parents: 4070
diff changeset
  3840
        ]
a47337e09c40 preset font if already ok for device
werner
parents: 4070
diff changeset
  3841
    ]
4664
02d160974029 fix remembering deviceFont everywhere.
Claus Gittinger <cg@exept.de>
parents: 4657
diff changeset
  3842
02d160974029 fix remembering deviceFont everywhere.
Claus Gittinger <cg@exept.de>
parents: 4657
diff changeset
  3843
    "Modified: / 22-10-2006 / 14:10:53 / cg"
4291
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3844
!
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3845
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3846
initialize
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3847
    "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
  3848
     initColors and initFont, which are usually redefined."
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3849
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3850
    super initialize.
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3851
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3852
    "/ just in case, someone redefined new without setting device
6234
404d91662d49 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6225
diff changeset
  3853
    (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
  3854
6273
d1000b29b5b2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6271
diff changeset
  3855
    foreground isNil ifTrue:[foreground := self blackColor].
d1000b29b5b2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6271
diff changeset
  3856
    background isNil ifTrue:[background := self whiteColor].
4291
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3857
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3858
    "Modified: 10.1.1997 / 17:46:51 / cg"
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3859
!
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3860
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3861
prepareForReinit
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3862
    "kludge - clear drawableId and gcId
4291
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3863
     needed after snapin"
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3864
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3865
    gcId := nil.
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3866
    drawableId := nil.
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3867
    deviceFont := nil
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3868
!
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3869
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3870
recreate
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3871
    "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
  3872
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3873
    gcId := nil.
6472
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  3874
    drawableId := nil.
4291
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3875
    foreground notNil ifTrue:[
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3876
        foreground := foreground onDevice:device
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3877
    ].
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3878
    background notNil ifTrue:[
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3879
        background := background onDevice:device
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3880
    ].
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3881
    paint notNil ifTrue:[
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3882
        paint := paint onDevice:device
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3883
    ].
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3884
    bgPaint notNil ifTrue:[
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3885
        bgPaint := bgPaint onDevice:device
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3886
    ].
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3887
    font notNil ifTrue:[
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3888
        font := font onDevice:device
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3889
    ]
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3890
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3891
    "Modified: 28.10.1996 / 13:25:02 / cg"
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3892
!
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3893
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3894
releaseGC
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3895
    "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
  3896
     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
  3897
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3898
    |id|
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3899
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3900
    foreground := background := paint := bgPaint := nil.
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3901
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3902
    id := gcId.
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3903
    id notNil ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3904
	gcId := nil.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3905
	device destroyGC:id.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3906
	Lobby registerChange:self.
4291
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3907
    ].
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3908
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3909
    "Created: 11.6.1996 / 22:07:30 / cg"
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3910
    "Modified: 2.4.1997 / 19:36:30 / cg"
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3911
! !
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3912
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3913
!DeviceGraphicsContext methodsFor:'private'!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3914
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3915
setDevice:aDevice id:aDrawbleId gcId:aGCId
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3916
    "private"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3917
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3918
    device := aDevice.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3919
    gcId := aGCId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3920
    drawableId := aDrawbleId
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3921
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3922
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3923
setGCForPaint
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3924
    "private; given a complex color (i.e. a pixmap or dithered color,
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3925
     setup the GC to draw in this color.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3926
     A helper for paint and paint:on:"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3927
832
064890dcfabd fixed opaque string draw with deep-dither
Claus Gittinger <cg@exept.de>
parents: 786
diff changeset
  3928
    |dither map pixelId p fg bg vOrg ditherDepth deviceDepth|
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3929
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3930
    gcId notNil ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3931
	paint isSymbol ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3932
	    "map symbols to colors"
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3933
	    paint := Color perform:paint ifNotUnderstood:[Color yellow].
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3934
	].
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3935
	p := paint.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3936
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3937
	p isColor ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3938
	    paint := p := p onDevice:device.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3939
	    pixelId := p colorId.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3940
	    pixelId notNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3941
		"
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3942
		 a real (undithered) color
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3943
		"
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3944
		mask notNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3945
		    mask := nil.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3946
		    device setBitmapMask:nil in:gcId
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3947
		].
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3948
		(p ~~ foreground) ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3949
		    foreground := paint.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3950
		    device setForeground:pixelId in:gcId
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3951
		].
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3952
		^ self
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3953
	    ].
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3954
	    "a dithered color"
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3955
	    dither := paint ditherForm.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3956
	] ifFalse:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3957
	    "mhmh - seems to be some kind of form ..."
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3958
	    paint := paint onDevice:device.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3959
	    dither := paint.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3960
	].
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3961
	"
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3962
	 a dithered color or image
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3963
	"
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3964
	(ditherDepth := dither depth) == 1 ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3965
	    "a simple 0/1 bitmap"
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3966
	    map := dither colorMap.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3967
	    "temporary (kludgy) fix for destroyed paint"
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3968
	    p := paint.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3969
	    map isNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3970
		fg := Color black.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3971
		bg := Color white.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3972
	    ] ifFalse:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3973
		fg := map at:2.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3974
		bg := map at:1.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3975
	    ].
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3976
	    self foreground:fg background:bg.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3977
	    paint := p
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3978
	] ifFalse:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3979
	    deviceDepth := device depth.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3980
	    (ditherDepth ~~ deviceDepth) ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3981
		dither := dither asFormOn:device.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3982
		ditherDepth := dither depth.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3983
		(dither isNil or:[ditherDepth ~~ deviceDepth]) ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3984
		    self error:'bad dither'.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3985
		    ^ self
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3986
		]
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3987
	    ]
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3988
	].
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3989
	self mask:dither.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3990
	vOrg := self viewOrigin.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3991
	self maskOriginX:vOrg x negated y:vOrg y negated.
732
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
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3994
    "Created: 16.5.1996 / 15:35:51 / cg"
1742
ca904d85a84c #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1741
diff changeset
  3995
    "Modified: 6.6.1997 / 12:55:38 / cg"
2049
1ceec8ef240e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2031
diff changeset
  3996
!
1ceec8ef240e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2031
diff changeset
  3997
1ceec8ef240e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2031
diff changeset
  3998
setId:aDrawbleId
1ceec8ef240e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2031
diff changeset
  3999
    "private"
1ceec8ef240e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2031
diff changeset
  4000
1ceec8ef240e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2031
diff changeset
  4001
    drawableId := aDrawbleId
1ceec8ef240e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2031
diff changeset
  4002
1ceec8ef240e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2031
diff changeset
  4003
    "Created: / 6.2.1998 / 12:44:45 / cg"
7253
1b427e95d77c Inform GC (DeviceGraphicsContext) when it's size or children's size or origin changes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 7244
diff changeset
  4004
!
1b427e95d77c Inform GC (DeviceGraphicsContext) when it's size or children's size or origin changes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 7244
diff changeset
  4005
1b427e95d77c Inform GC (DeviceGraphicsContext) when it's size or children's size or origin changes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 7244
diff changeset
  4006
subViewChangedSizeOrOrigin
1b427e95d77c Inform GC (DeviceGraphicsContext) when it's size or children's size or origin changes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 7244
diff changeset
  4007
    "Internal. Called whenever one of the owner's
1b427e95d77c Inform GC (DeviceGraphicsContext) when it's size or children's size or origin changes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 7244
diff changeset
  4008
     subview changes size or origin (i.e., when moved)    
1b427e95d77c Inform GC (DeviceGraphicsContext) when it's size or children's size or origin changes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 7244
diff changeset
  4009
     See SimpleView>>pixelOrigin:extent:.
1b427e95d77c Inform GC (DeviceGraphicsContext) when it's size or children's size or origin changes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 7244
diff changeset
  4010
     Can be used to adjust internal state."
1b427e95d77c Inform GC (DeviceGraphicsContext) when it's size or children's size or origin changes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 7244
diff changeset
  4011
1b427e95d77c Inform GC (DeviceGraphicsContext) when it's size or children's size or origin changes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 7244
diff changeset
  4012
    "/ Nothing by default
1b427e95d77c Inform GC (DeviceGraphicsContext) when it's size or children's size or origin changes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 7244
diff changeset
  4013
1b427e95d77c Inform GC (DeviceGraphicsContext) when it's size or children's size or origin changes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 7244
diff changeset
  4014
    "Created: / 02-04-2016 / 15:35:52 / Jan Vrany <jan.vrany@fit.cvut.cz>"
1b427e95d77c Inform GC (DeviceGraphicsContext) when it's size or children's size or origin changes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 7244
diff changeset
  4015
!
1b427e95d77c Inform GC (DeviceGraphicsContext) when it's size or children's size or origin changes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 7244
diff changeset
  4016
1b427e95d77c Inform GC (DeviceGraphicsContext) when it's size or children's size or origin changes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 7244
diff changeset
  4017
width: width height: height
1b427e95d77c Inform GC (DeviceGraphicsContext) when it's size or children's size or origin changes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 7244
diff changeset
  4018
    "Internal. Called by SimpleView when resized. 
1b427e95d77c Inform GC (DeviceGraphicsContext) when it's size or children's size or origin changes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 7244
diff changeset
  4019
     See SimpleView>>pixelOrigin:extent:.
1b427e95d77c Inform GC (DeviceGraphicsContext) when it's size or children's size or origin changes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 7244
diff changeset
  4020
     Can be used to adjust internal state."
1b427e95d77c Inform GC (DeviceGraphicsContext) when it's size or children's size or origin changes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 7244
diff changeset
  4021
1b427e95d77c Inform GC (DeviceGraphicsContext) when it's size or children's size or origin changes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 7244
diff changeset
  4022
    "/ Nothing by default
1b427e95d77c Inform GC (DeviceGraphicsContext) when it's size or children's size or origin changes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 7244
diff changeset
  4023
1b427e95d77c Inform GC (DeviceGraphicsContext) when it's size or children's size or origin changes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 7244
diff changeset
  4024
    "Created: / 02-04-2016 / 14:34:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4025
! !
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4026
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4027
!DeviceGraphicsContext methodsFor:'queries'!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4028
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4029
horizontalIntegerPixelPerMillimeter
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4030
    "return the (rounded) number of pixels per millimeter"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4031
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4032
    ^ device horizontalPixelPerMillimeter rounded
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4033
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4034
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4035
horizontalPixelPerInch
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4036
    "return the number of horizontal pixels per inch of the display"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4037
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4038
    ^ device horizontalPixelPerMillimeter * 25.4
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4039
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4040
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4041
horizontalPixelPerMillimeter
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4042
    "return the number of pixels per millimeter (not rounded)"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4043
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4044
    ^ device horizontalPixelPerMillimeter
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4045
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4046
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4047
horizontalPixelPerMillimeter:millis
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4048
    "return the number of pixels (not rounded) for millis millimeter"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4049
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4050
    ^ device horizontalPixelPerMillimeter * millis
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4051
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4052
784
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
  4053
resolution
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
  4054
    "return a point consisting of pixel-per-inch horizontally and vertically."
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
  4055
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
  4056
    ^ device resolution
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
  4057
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
  4058
    "Created: 4.6.1996 / 15:23:55 / cg"
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
  4059
!
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
  4060
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4061
verticalIntegerPixelPerMillimeter
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4062
    "return the (rounded) number of pixels per millimeter"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4063
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4064
    ^ device verticalPixelPerMillimeter rounded
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4065
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4066
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4067
verticalPixelPerInch
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4068
    "return the number of vertical pixels per inch of the display"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4069
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4070
    ^ device verticalPixelPerMillimeter * 25.4
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
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4073
verticalPixelPerMillimeter
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4074
    "return the number of pixels per millimeter (not rounded)"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4075
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4076
    ^ device verticalPixelPerMillimeter
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4077
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4078
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4079
verticalPixelPerMillimeter:millis
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4080
    "return the number of pixels (not rounded) for millis millimeter"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4081
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4082
    ^ device verticalPixelPerMillimeter * millis
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
6225
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4085
!DeviceGraphicsContext methodsFor:'view creation'!
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4086
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4087
createBitmapFromArray:data width:width height:height
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4088
    "create a bitmap from data and set the drawableId"
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  4089
6225
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4090
    drawableId := device createBitmapFromArray:data width:width height:height.
6472
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4091
    drawableType := #pixmap.
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4092
    Lobby registerChange:self.
6225
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4093
!
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4094
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4095
createPixmapWidth:w height:h depth:d
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4096
    "create a pixmap and set the drawableId"
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  4097
6225
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4098
    drawableId := device createPixmapWidth:w height:h depth:d.
6472
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4099
    drawableType := #pixmap.
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4100
    Lobby registerChange:self.
6225
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4101
!
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4102
6472
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4103
createRootWindowFor:aView
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4104
    drawableId := device rootWindowFor:aView.
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4105
    drawableType := #window.
6234
404d91662d49 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6225
diff changeset
  4106
!
404d91662d49 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6225
diff changeset
  4107
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  4108
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
  4109
    "create a window and set the drawableId"
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  4110
6472
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4111
    |container|
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4112
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  4113
    drawableId := device
6225
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4114
            createWindowFor:aView
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4115
            type:typeSymbol
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4116
            origin:org
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4117
            extent:ext
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4118
            minExtent:minE
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4119
            maxExtent:maxE
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4120
            borderWidth:bw
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4121
            subViewOf:sv
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4122
            style:styleSymbol
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4123
            inputOnly:inp
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4124
            label:label
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4125
            owner:owner
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4126
            icon:icn
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4127
            iconMask:icnM
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4128
            iconView:icnV.
6472
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4129
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4130
    drawableType := #window.
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4131
    container := aView container.
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4132
    container notNil ifTrue:[ parentId := container id ].
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4133
    Lobby registerChange:self.
6225
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4134
! !
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4135
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4136
!DeviceGraphicsContext methodsFor:'view properties'!
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4137
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4138
backingStore:how
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4139
    "turn on/off backingStore (saving my pixels)
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4140
     how may true/false, but also #always, #whenMapped or #never."
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4141
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4142
    drawableId notNil ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  4143
	device setBackingStore:how in:drawableId
6225
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4144
    ]
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4145
!
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4146
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4147
bitGravity:gravity
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4148
    "set the bitGravity - thats the direction where the contents will move
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4149
     when the view is resized."
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4150
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4151
    drawableId notNil ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  4152
	device setBitGravity:gravity in:drawableId
6225
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4153
    ]
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
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4156
saveUnder:aBoolean
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4157
    "turn on/off saveUnder (saving pixels under myself)
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4158
     - used for temporary views (i.e. PopUps and ModalBoxes)"
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4159
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4160
    drawableId notNil ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  4161
	device setSaveUnder:aBoolean in:drawableId
6225
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4162
    ]
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4163
!
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4164
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4165
setCursorId:id
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4166
    drawableId notNil ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  4167
	device setCursor:id in:drawableId.
6225
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4168
    ]
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4169
!
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4170
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4171
setWindowPid: pid
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4172
    "Sets the _NET_WM_PID property for the window.
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4173
     This may be used by the window manager to group windows.
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4174
     If anIntegerOrNil is nil, then PID of currently running
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4175
     Smalltalk is used"
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4176
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4177
    drawableId notNil ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  4178
	device setWindowPid:pid in:drawableId.
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
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4182
viewGravity:gravity
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4183
    "set the viewGravity - thats the direction where the view will move
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4184
     when the superView is resized."
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4185
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4186
    drawableId notNil ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  4187
	device setWindowGravity:gravity in:drawableId
6225
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4188
    ].
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
windowBorderShape:aForm
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4192
    "set the windows border shape"
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4193
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4194
    drawableId notNil ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  4195
	device setWindowBorderShape:(aForm id) in:drawableId
6225
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4196
    ].
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4197
!
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
windowClass:windowClassNameString name:nameString
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4200
    "define class and name of a window.
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4201
     This may be used by the window manager to
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4202
     select client specific resources."
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4203
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4204
    drawableId notNil ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  4205
	device setWindowClass:windowClassNameString name:nameString in:drawableId.
6225
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4206
    ].
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
windowName:aString
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4210
    "define the views name in the windows title area."
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4211
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4212
    drawableId notNil ifTrue: [
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  4213
	device setWindowName:aString in:drawableId.
6225
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
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4217
windowShape:aForm
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4218
    "set the windows shape.
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4219
     Returns false, if the display does not support the
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4220
     X shape extension."
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 setWindowShape:(aForm id) 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
    ^ false.
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
6472
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4228
!DeviceGraphicsContext::DevicePixmapGCHandle methodsFor:'accessing'!
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4229
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4230
parentId
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4231
    "pixmaps do not have a parent"
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4232
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4233
    ^ nil
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4234
! !
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4235
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4236
!DeviceGraphicsContext::DevicePixmapGCHandle methodsFor:'finalization'!
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4237
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4238
finalize
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4239
    "the Form for which I am a handle has been collected - tell it to the x-server"
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4240
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4241
    |id|
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4242
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4243
    drawableId notNil ifTrue:[
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4244
	(id := gcId) notNil ifTrue:[
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4245
	    gcId := nil.
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4246
	    device destroyGC:id.
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4247
	].
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4248
	id := drawableId.
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4249
	drawableId := nil.
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4250
	device destroyPixmap:id.
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4251
    ]
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4252
! !
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4253
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4254
!DeviceGraphicsContext::DeviceWindowGCHandle methodsFor:'accessing'!
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4255
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4256
parentId
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4257
    ^ parentId
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4258
! !
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4259
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4260
!DeviceGraphicsContext::DeviceWindowGCHandle methodsFor:'finalization'!
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4261
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4262
finalize
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4263
    "the view for which I am a handle was collected
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4264
     - release system resources"
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4265
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4266
    drawableId notNil ifTrue:[
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4267
	[
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4268
	    (device viewIdKnown:drawableId) ifTrue:[
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4269
"/ 'Display [info]: recycled view (' infoPrint. v infoPrint. ') not destroyed: ' infoPrint.
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4270
"/ drawableId displayString infoPrintCR.
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4271
		drawableId := nil.
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4272
	    ] ifFalse:[
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4273
		|id|
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4274
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4275
		(id := gcId) notNil ifTrue:[
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4276
		    gcId := nil.
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4277
		    device deviceIOErrorSignal handle:[:ex |
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4278
		    ] do:[
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4279
			device destroyGC:id.
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4280
		    ]
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4281
		].
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4282
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4283
		id := drawableId.
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4284
		drawableId := nil.
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4285
		device deviceIOErrorSignal handle:[:ex |
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4286
		] do:[
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4287
		    device destroyView:nil withId:id.
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4288
		].
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4289
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4290
		"When a window ist destroyed, all its subwindows are also destroyed.
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4291
		 Unregister all the subwindows, to avoid destroying of reused windoeIds
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4292
		 later."
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4293
		DeviceGraphicsContext cleanupLobbyForChildrenOfViewWithDevice:device id:id.
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4294
	    ]
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4295
	] valueUninterruptably.
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4296
    ].
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4297
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4298
    "Created: / 25.9.1997 / 10:01:46 / stefan"
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4299
    "Modified: / 15.11.2001 / 14:17:12 / cg"
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4300
! !
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4301
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4302
!DeviceGraphicsContext::DeviceWindowGCHandle methodsFor:'private-accessing'!
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4303
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4304
setDevice:aDevice id:aDrawableId gcId:aGCId parentId:parentIdArg
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4305
    "set the handles contents"
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4306
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4307
    device := aDevice.
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4308
    drawableId := aDrawableId.
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4309
    gcId := aGCId.
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4310
    parentId := parentIdArg.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4311
! !
3880
c4c8268a2d9f method category rename
Claus Gittinger <cg@exept.de>
parents: 3666
diff changeset
  4312
1085
3513a4cae87b handle depth1-images with a mask
Claus Gittinger <cg@exept.de>
parents: 1064
diff changeset
  4313
!DeviceGraphicsContext class methodsFor:'documentation'!
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4314
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4315
version
6926
d04d6d93b921 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6765
diff changeset
  4316
    ^ '$Header$'
5360
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  4317
!
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  4318
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  4319
version_CVS
6926
d04d6d93b921 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6765
diff changeset
  4320
    ^ '$Header$'
7165
730622084e88 DeviceGraphicsContext: Use test `drawableType == #window` consistenly,
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 7153
diff changeset
  4321
!
730622084e88 DeviceGraphicsContext: Use test `drawableType == #window` consistenly,
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 7153
diff changeset
  4322
730622084e88 DeviceGraphicsContext: Use test `drawableType == #window` consistenly,
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 7153
diff changeset
  4323
version_HG
730622084e88 DeviceGraphicsContext: Use test `drawableType == #window` consistenly,
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 7153
diff changeset
  4324
730622084e88 DeviceGraphicsContext: Use test `drawableType == #window` consistenly,
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 7153
diff changeset
  4325
    ^ '$Changeset: <not expanded> $'
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4326
! !
3880
c4c8268a2d9f method category rename
Claus Gittinger <cg@exept.de>
parents: 3666
diff changeset
  4327
6107
afaac69e9310 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 5837
diff changeset
  4328
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4329
DeviceGraphicsContext initialize!