DeviceGraphicsContext.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Thu, 27 Nov 2014 11:15:56 +0000
branchdelegated_gc_jv
changeset 6636 2603da69ccf0
parent 6616 9dad6d1245cc
parent 6626 4afe1d3883b4
child 6655 c600b219bb9e
permissions -rw-r--r--
Merged 9dad6d1245cc and 69f2878eaacb (branch default)
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
"
6485
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
    12
'From Smalltalk/X, Version:6.2.3.0 on 23-05-2014 at 17:22:04'                   !
6472
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
    13
3275
b40f47ec5661 comment
Claus Gittinger <cg@exept.de>
parents: 3188
diff changeset
    14
"{ Package: 'stx:libview' }"
b40f47ec5661 comment
Claus Gittinger <cg@exept.de>
parents: 3188
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:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   120
	device := Display.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   121
	device isNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   122
	    (self class name,' [warning]: no Display') infoPrintCR.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   123
	    Smalltalk openDisplay.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   124
	].
6290
b6886e346ae9 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6273
diff changeset
   125
    ].
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   126
    ^ self onDevice:Screen current "Display"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   127
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   128
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   129
on:aDevice
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   130
    "create a new drawable on aDevice"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   131
3429
7f87cd2ae010 Use <resource:#obsolete>
Stefan Vogel <sv@exept.de>
parents: 3300
diff changeset
   132
    <resource:#obsolete>
7f87cd2ae010 Use <resource:#obsolete>
Stefan Vogel <sv@exept.de>
parents: 3300
diff changeset
   133
1741
b84a2f4317e9 warn #on: vs. #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1722
diff changeset
   134
    "/ 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
   135
    "/ operating on a model.
b84a2f4317e9 warn #on: vs. #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1722
diff changeset
   136
    "/ Please use #onDevice: to avoid confusion.
b84a2f4317e9 warn #on: vs. #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1722
diff changeset
   137
1255
bdf4cbcae668 on: -> onDevice:
Claus Gittinger <cg@exept.de>
parents: 1249
diff changeset
   138
    self obsoleteMethodWarning:'use #onDevice:'.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   139
    ^ self onDevice:aDevice
1255
bdf4cbcae668 on: -> onDevice:
Claus Gittinger <cg@exept.de>
parents: 1249
diff changeset
   140
1741
b84a2f4317e9 warn #on: vs. #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1722
diff changeset
   141
    "Modified: 5.6.1997 / 21:04:16 / cg"
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   142
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   143
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   144
onDevice:aDevice
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   145
    "create a new drawable on aDevice"
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
    |newDrawable|
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   148
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   149
    newDrawable := self basicNew.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   150
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   151
    "
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   152
     set display before its initialized
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   153
     - 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
   154
     intitialize method(s)
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   155
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   156
    newDrawable device:aDevice.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   157
    newDrawable initialize.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   158
    ^ newDrawable
1517
ac751bb3dfdf no need for registration here;
Claus Gittinger <cg@exept.de>
parents: 1514
diff changeset
   159
ac751bb3dfdf no need for registration here;
Claus Gittinger <cg@exept.de>
parents: 1514
diff changeset
   160
    "Modified: 2.4.1997 / 19:19:35 / cg"
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   161
! !
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   162
1085
3513a4cae87b handle depth1-images with a mask
Claus Gittinger <cg@exept.de>
parents: 1064
diff changeset
   163
!DeviceGraphicsContext class methodsFor:'cleanup'!
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   164
4436
05eadeb4b603 In #cleanUpLobbyForChildrenOfView...
Stefan Vogel <sv@exept.de>
parents: 4434
diff changeset
   165
cleanupLobbyForChildrenOfViewWithDevice:aDevice id:anId
6472
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   166
    "recursively clean all the subcomponents of the handle with id anId.
4436
05eadeb4b603 In #cleanUpLobbyForChildrenOfView...
Stefan Vogel <sv@exept.de>
parents: 4434
diff changeset
   167
     This must be done on finalization, because descendent handles
05eadeb4b603 In #cleanUpLobbyForChildrenOfView...
Stefan Vogel <sv@exept.de>
parents: 4434
diff changeset
   168
     are destroyed implicitly when a parent handle is destroyed."
05eadeb4b603 In #cleanUpLobbyForChildrenOfView...
Stefan Vogel <sv@exept.de>
parents: 4434
diff changeset
   169
05eadeb4b603 In #cleanUpLobbyForChildrenOfView...
Stefan Vogel <sv@exept.de>
parents: 4434
diff changeset
   170
    |parents newChildren|
05eadeb4b603 In #cleanUpLobbyForChildrenOfView...
Stefan Vogel <sv@exept.de>
parents: 4434
diff changeset
   171
05eadeb4b603 In #cleanUpLobbyForChildrenOfView...
Stefan Vogel <sv@exept.de>
parents: 4434
diff changeset
   172
    parents := Array with:anId address.
05eadeb4b603 In #cleanUpLobbyForChildrenOfView...
Stefan Vogel <sv@exept.de>
parents: 4434
diff changeset
   173
05eadeb4b603 In #cleanUpLobbyForChildrenOfView...
Stefan Vogel <sv@exept.de>
parents: 4434
diff changeset
   174
    [
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   175
	newChildren := Set new.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   176
	Lobby unregisterAllForWhichHandle:[:handle |
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   177
	    |parentId|
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   178
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   179
	    (handle notNil
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   180
		and:[handle device == aDevice
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   181
		and:[(parentId := handle parentId) notNil
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   182
		and:[parents includes:parentId]]]
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   183
	    ) ifTrue:[newChildren add:handle id. true] ifFalse:[false]
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   184
	].
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   185
	parents := newChildren.
4436
05eadeb4b603 In #cleanUpLobbyForChildrenOfView...
Stefan Vogel <sv@exept.de>
parents: 4434
diff changeset
   186
    ] doWhile:[parents notEmpty].
4434
cbbb56b8d851 addons and fixes for X11-deviceHandle fix
Claus Gittinger <cg@exept.de>
parents: 4403
diff changeset
   187
!
cbbb56b8d851 addons and fixes for X11-deviceHandle fix
Claus Gittinger <cg@exept.de>
parents: 4403
diff changeset
   188
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   189
lowSpaceCleanup
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   190
    CachedScaledForms := CachedScales := nil
1224
2a2270ec4236 added #releaseResourcesOnDevice:, to allow cleanup when
Claus Gittinger <cg@exept.de>
parents: 1199
diff changeset
   191
!
2a2270ec4236 added #releaseResourcesOnDevice:, to allow cleanup when
Claus Gittinger <cg@exept.de>
parents: 1199
diff changeset
   192
2a2270ec4236 added #releaseResourcesOnDevice:, to allow cleanup when
Claus Gittinger <cg@exept.de>
parents: 1199
diff changeset
   193
releaseResourcesOnDevice:aDevice
2a2270ec4236 added #releaseResourcesOnDevice:, to allow cleanup when
Claus Gittinger <cg@exept.de>
parents: 1199
diff changeset
   194
    "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
   195
     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
   196
2a2270ec4236 added #releaseResourcesOnDevice:, to allow cleanup when
Claus Gittinger <cg@exept.de>
parents: 1199
diff changeset
   197
    Lobby unregisterAllForWhich:[:aDrawable | aDrawable graphicsDevice == aDevice]
2a2270ec4236 added #releaseResourcesOnDevice:, to allow cleanup when
Claus Gittinger <cg@exept.de>
parents: 1199
diff changeset
   198
2a2270ec4236 added #releaseResourcesOnDevice:, to allow cleanup when
Claus Gittinger <cg@exept.de>
parents: 1199
diff changeset
   199
    "Created: 16.1.1997 / 16:43:52 / cg"
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   200
! !
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   201
3880
c4c8268a2d9f method category rename
Claus Gittinger <cg@exept.de>
parents: 3666
diff changeset
   202
!DeviceGraphicsContext methodsFor:'Compatibility-ST80'!
3188
67ce53b6b843 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3160
diff changeset
   203
67ce53b6b843 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3160
diff changeset
   204
key
67ce53b6b843 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3160
diff changeset
   205
    ^ self id
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
3942
ee09c1391e61 some more dummies for VW widgets
Claus Gittinger <cg@exept.de>
parents: 3938
diff changeset
   208
!DeviceGraphicsContext methodsFor:'Compatibility-VW'!
ee09c1391e61 some more dummies for VW widgets
Claus Gittinger <cg@exept.de>
parents: 3938
diff changeset
   209
ee09c1391e61 some more dummies for VW widgets
Claus Gittinger <cg@exept.de>
parents: 3938
diff changeset
   210
displayBackgroundIfNeededOn: aGraphicsContext
4070
efd0ffb52d43 clear -> clearView
Claus Gittinger <cg@exept.de>
parents: 4056
diff changeset
   211
    aGraphicsContext clearView.
3942
ee09c1391e61 some more dummies for VW widgets
Claus Gittinger <cg@exept.de>
parents: 3938
diff changeset
   212
!
ee09c1391e61 some more dummies for VW widgets
Claus Gittinger <cg@exept.de>
parents: 3938
diff changeset
   213
ee09c1391e61 some more dummies for VW widgets
Claus Gittinger <cg@exept.de>
parents: 3938
diff changeset
   214
inactiveForegroundColor
3943
2d4dbd3f9aa6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3942
diff changeset
   215
    "a dummy method to support VW widgets"
2d4dbd3f9aa6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3942
diff changeset
   216
3942
ee09c1391e61 some more dummies for VW widgets
Claus Gittinger <cg@exept.de>
parents: 3938
diff changeset
   217
    ^ self foregroundColor
ee09c1391e61 some more dummies for VW widgets
Claus Gittinger <cg@exept.de>
parents: 3938
diff changeset
   218
!
ee09c1391e61 some more dummies for VW widgets
Claus Gittinger <cg@exept.de>
parents: 3938
diff changeset
   219
ee09c1391e61 some more dummies for VW widgets
Claus Gittinger <cg@exept.de>
parents: 3938
diff changeset
   220
selectionBackgroundColor
3943
2d4dbd3f9aa6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3942
diff changeset
   221
    "a dummy method to support VW widgets"
2d4dbd3f9aa6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3942
diff changeset
   222
3942
ee09c1391e61 some more dummies for VW widgets
Claus Gittinger <cg@exept.de>
parents: 3938
diff changeset
   223
    ^ self foregroundColor
ee09c1391e61 some more dummies for VW widgets
Claus Gittinger <cg@exept.de>
parents: 3938
diff changeset
   224
!
ee09c1391e61 some more dummies for VW widgets
Claus Gittinger <cg@exept.de>
parents: 3938
diff changeset
   225
ee09c1391e61 some more dummies for VW widgets
Claus Gittinger <cg@exept.de>
parents: 3938
diff changeset
   226
selectionForegroundColor
3943
2d4dbd3f9aa6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3942
diff changeset
   227
    "a dummy method to support VW widgets"
2d4dbd3f9aa6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3942
diff changeset
   228
3942
ee09c1391e61 some more dummies for VW widgets
Claus Gittinger <cg@exept.de>
parents: 3938
diff changeset
   229
    ^ self backgroundColor
ee09c1391e61 some more dummies for VW widgets
Claus Gittinger <cg@exept.de>
parents: 3938
diff changeset
   230
!
ee09c1391e61 some more dummies for VW widgets
Claus Gittinger <cg@exept.de>
parents: 3938
diff changeset
   231
ee09c1391e61 some more dummies for VW widgets
Claus Gittinger <cg@exept.de>
parents: 3938
diff changeset
   232
separatorColor
3943
2d4dbd3f9aa6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3942
diff changeset
   233
    "a dummy method to support VW widgets"
2d4dbd3f9aa6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3942
diff changeset
   234
3942
ee09c1391e61 some more dummies for VW widgets
Claus Gittinger <cg@exept.de>
parents: 3938
diff changeset
   235
    ^ self foregroundColor
ee09c1391e61 some more dummies for VW widgets
Claus Gittinger <cg@exept.de>
parents: 3938
diff changeset
   236
! !
ee09c1391e61 some more dummies for VW widgets
Claus Gittinger <cg@exept.de>
parents: 3938
diff changeset
   237
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   238
!DeviceGraphicsContext methodsFor:'accessing'!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   239
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   240
at:aPoint
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   241
    "return the pixel at the coordinate given by aPoint"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   242
3160
89905f311a09 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3137
diff changeset
   243
    ^ self atX:aPoint x y:aPoint y
89905f311a09 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3137
diff changeset
   244
89905f311a09 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3137
diff changeset
   245
    "Modified: / 29.1.2000 / 12:17:42 / cg"
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   246
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   247
4204
947a5a5620d3 comments
Claus Gittinger <cg@exept.de>
parents: 4199
diff changeset
   248
at:aPoint put:aPixelColor
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   249
    "set a pixel"
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
    ^ self atX:aPoint x y:aPoint y put:aPixelColor
947a5a5620d3 comments
Claus Gittinger <cg@exept.de>
parents: 4199
diff changeset
   252
947a5a5620d3 comments
Claus Gittinger <cg@exept.de>
parents: 4199
diff changeset
   253
    "
947a5a5620d3 comments
Claus Gittinger <cg@exept.de>
parents: 4199
diff changeset
   254
     Display rootView at:(0@0) put:(Color red).
947a5a5620d3 comments
Claus Gittinger <cg@exept.de>
parents: 4199
diff changeset
   255
     Display rootView at:(1@1) put:(Color red).
947a5a5620d3 comments
Claus Gittinger <cg@exept.de>
parents: 4199
diff changeset
   256
     Display rootView at:(2@2) put:(Color red).
947a5a5620d3 comments
Claus Gittinger <cg@exept.de>
parents: 4199
diff changeset
   257
     Display rootView at:(3@3) put:(Color red).
947a5a5620d3 comments
Claus Gittinger <cg@exept.de>
parents: 4199
diff changeset
   258
     Display rootView at:(4@4) put:(Color red).
947a5a5620d3 comments
Claus Gittinger <cg@exept.de>
parents: 4199
diff changeset
   259
     Display rootView at:(5@5) put:(Color red).
947a5a5620d3 comments
Claus Gittinger <cg@exept.de>
parents: 4199
diff changeset
   260
    "
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   261
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   262
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   263
atX:x y:y
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   264
    "return the pixel at the coordinate given by x/y"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   265
2714
e5d16e41cbab need gcId-argument in getPixel
Claus Gittinger <cg@exept.de>
parents: 2680
diff changeset
   266
    ^ device getPixelX:x y:y from:drawableId with:gcId
e5d16e41cbab need gcId-argument in getPixel
Claus Gittinger <cg@exept.de>
parents: 2680
diff changeset
   267
e5d16e41cbab need gcId-argument in getPixel
Claus Gittinger <cg@exept.de>
parents: 2680
diff changeset
   268
    "Modified: / 22.5.1999 / 01:40:23 / cg"
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   269
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   270
4204
947a5a5620d3 comments
Claus Gittinger <cg@exept.de>
parents: 4199
diff changeset
   271
atX:x y:y put:aPixelColor
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   272
    "set a pixel"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   273
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   274
    |oldFg|
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   275
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   276
    oldFg := foreground.
4204
947a5a5620d3 comments
Claus Gittinger <cg@exept.de>
parents: 4199
diff changeset
   277
    self foreground:aPixelColor.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   278
    self displayPointX:x y:y.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   279
    self foreground:oldFg
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   280
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   281
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   282
backgroundPaint:aColor
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   283
    "set the background-paint color; this is used in opaque-draw
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   284
     operations"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   285
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   286
    (aColor ~~ bgPaint) ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   287
	aColor notNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   288
	    bgPaint := aColor.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   289
	    gcId notNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   290
		bgPaint isColor ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   291
		    bgPaint := aColor onDevice:device.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   292
		    bgPaint colorId notNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   293
			background := bgPaint.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   294
			gcId notNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   295
			    device setBackground:(bgPaint colorId) in:gcId.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   296
			].
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   297
			^ self
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   298
		    ]
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 paint:paint on:aColor
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
	]
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   303
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   304
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   305
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   306
basicFont
2918
1e777dc8588a #font answers device font if possible (cg)
Stefan Vogel <sv@exept.de>
parents: 2913
diff changeset
   307
    "return the font for drawing"
732
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
    ^ font
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   310
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   311
    "Created: 12.5.1996 / 11:17:59 / cg"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   312
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   313
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   314
basicFont:aFont
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   315
    "set the font for drawing if it has changed.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   316
     This is a low level entry, which is not to be redefined
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   317
     (i.e. it must not imply a redraw operation)"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   318
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   319
    |id|
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   320
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   321
    (aFont ~~ font) ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   322
	aFont notNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   323
	    font := aFont.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   324
	    device notNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   325
		font := font onDevice:device.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   326
		gcId notNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   327
		    id := font fontId.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   328
		    id notNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   329
			deviceFont := font.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   330
			device setFont:id in:gcId
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   331
		    ]
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   332
		]
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   333
	    ]
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   334
	]
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   335
    ]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   336
4664
02d160974029 fix remembering deviceFont everywhere.
Claus Gittinger <cg@exept.de>
parents: 4657
diff changeset
   337
    "Created: / 23-02-1996 / 17:16:51 / cg"
02d160974029 fix remembering deviceFont everywhere.
Claus Gittinger <cg@exept.de>
parents: 4657
diff changeset
   338
    "Modified: / 22-10-2006 / 14:11:37 / cg"
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   339
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   340
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   341
capStyle:aSymbol
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   342
    "set the style in which the endpoints of lines
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   343
     are drawn - aSymbol may be #notLast, #butt, #round, #projecting"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   344
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   345
    |s|
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   346
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   347
    (s := aSymbol) isNil ifTrue:[
1029
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
   348
	s := #butt.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   349
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   350
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   351
    (s ~~ capStyle) ifTrue:[
1029
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
   352
	capStyle := s.
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
   353
	gcId notNil ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   354
	    device setLineWidth:lineWidth
1029
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
   355
			  style:lineStyle
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
   356
			    cap:s
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
   357
			   join:joinStyle
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
   358
			     in:gcId
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
   359
	]
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   360
    ]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   361
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   362
    "Modified: 12.5.1996 / 22:23:03 / cg"
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
950
d4d907fc7d78 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 927
diff changeset
   365
clipByChildren
d4d907fc7d78 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 927
diff changeset
   366
    "drawing shall be done into my view only (default)"
d4d907fc7d78 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 927
diff changeset
   367
3429
7f87cd2ae010 Use <resource:#obsolete>
Stefan Vogel <sv@exept.de>
parents: 3300
diff changeset
   368
    <resource:#obsolete>
7f87cd2ae010 Use <resource:#obsolete>
Stefan Vogel <sv@exept.de>
parents: 3300
diff changeset
   369
1722
4ceaeda95cc3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1715
diff changeset
   370
    self obsoleteMethodWarning:'use #clippedByChildren:true'.
950
d4d907fc7d78 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 927
diff changeset
   371
    ^ self clippedByChildren:true
d4d907fc7d78 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 927
diff changeset
   372
d4d907fc7d78 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 927
diff changeset
   373
    "Created: 17.7.1996 / 13:25:55 / cg"
d4d907fc7d78 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 927
diff changeset
   374
!
d4d907fc7d78 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 927
diff changeset
   375
6222
2d670d3bcfd5 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6215
diff changeset
   376
clipRect
2d670d3bcfd5 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6215
diff changeset
   377
    "return the clipping rectangle for drawing. If there is currently no clipRect,
2d670d3bcfd5 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6215
diff changeset
   378
     a dummy is created."
2d670d3bcfd5 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6215
diff changeset
   379
2d670d3bcfd5 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6215
diff changeset
   380
    |rect|
2d670d3bcfd5 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6215
diff changeset
   381
2d670d3bcfd5 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6215
diff changeset
   382
    (rect := clipRect) isNil ifTrue:[
6472
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   383
	rect := 0@0 extent:(self extent).
6222
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
"/ nope - it is already kept in logical coordinates
2d670d3bcfd5 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6215
diff changeset
   386
"/    transformation notNil ifTrue:[
2d670d3bcfd5 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6215
diff changeset
   387
"/        rect := transformation applyInverseTo:rect.
2d670d3bcfd5 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6215
diff changeset
   388
"/    ].
2d670d3bcfd5 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6215
diff changeset
   389
    ^ rect
2d670d3bcfd5 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6215
diff changeset
   390
2d670d3bcfd5 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6215
diff changeset
   391
    "Modified: / 20-10-2006 / 13:24:21 / cg"
2d670d3bcfd5 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6215
diff changeset
   392
!
2d670d3bcfd5 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6215
diff changeset
   393
950
d4d907fc7d78 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 927
diff changeset
   394
clippedByChildren:aBoolean
d4d907fc7d78 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 927
diff changeset
   395
    "turn on/off drawing over children.
d4d907fc7d78 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 927
diff changeset
   396
     If on, a superview may draw 'over' its children.
d4d907fc7d78 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 927
diff changeset
   397
     If off (the default), drawing is 'under' its children.
d4d907fc7d78 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 927
diff changeset
   398
     Only useful for the rootView, to draw over any visible views.
d4d907fc7d78 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 927
diff changeset
   399
     (for example, when dragging a rubber-line)"
d4d907fc7d78 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 927
diff changeset
   400
d4d907fc7d78 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 927
diff changeset
   401
    gcId isNil ifTrue:[
1680
f47862c358fb pass both drawableId & gcID to setClipByChildren
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   402
        self initGC
950
d4d907fc7d78 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 927
diff changeset
   403
    ].
1715
c70e31496f91 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1714
diff changeset
   404
    device noClipIn:drawableId gc:gcId.
c70e31496f91 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1714
diff changeset
   405
    device setClipByChildren:aBoolean in:drawableId gc:gcId.
950
d4d907fc7d78 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 927
diff changeset
   406
d4d907fc7d78 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 927
diff changeset
   407
    "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
   408
    "Modified: 29.4.1997 / 15:33:55 / dq"
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
6215
701d3f1f91f7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6210
diff changeset
   411
clippingBounds:aRectangleOrNil
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   412
    "set the clipping rectangle for drawing (in logical coordinates);
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   413
     a nil argument turn off clipping (i.e. whole view is drawable)"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   414
6472
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   415
    |x y w h newBounds|
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   416
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   417
    aRectangleOrNil isNil ifTrue:[
2680
78abc6171873 always remember the deviceClipRect internally;
Claus Gittinger <cg@exept.de>
parents: 2572
diff changeset
   418
        clipRect isNil ifTrue:[^ self].
78abc6171873 always remember the deviceClipRect internally;
Claus Gittinger <cg@exept.de>
parents: 2572
diff changeset
   419
        gcId notNil ifTrue:[
78abc6171873 always remember the deviceClipRect internally;
Claus Gittinger <cg@exept.de>
parents: 2572
diff changeset
   420
            device noClipIn:drawableId gc:gcId
78abc6171873 always remember the deviceClipRect internally;
Claus Gittinger <cg@exept.de>
parents: 2572
diff changeset
   421
        ].
6472
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   422
        clipRect := nil.
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   423
        ^ self.
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   424
    ].
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   425
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   426
    x := aRectangleOrNil left.
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   427
    y := aRectangleOrNil top.
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   428
    w := aRectangleOrNil width.
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   429
    h := aRectangleOrNil height.
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   430
    transformation notNil ifTrue:[
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   431
        x := transformation applyToX:x.
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   432
        y := transformation applyToY:y.
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   433
        w := transformation applyScaleX:w.
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   434
        h := transformation applyScaleY:h.
6222
2d670d3bcfd5 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6215
diff changeset
   435
    ].
6472
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   436
    (x class == SmallInteger) ifFalse:[
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   437
        w := w + (x - x truncated).
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   438
        x := x truncated
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   439
    ].
6472
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   440
    (y class == SmallInteger) ifFalse:[
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   441
        h := h + (y - y truncated).
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   442
        y := y truncated
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   443
    ].
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   444
    (w class == SmallInteger) ifFalse:[
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   445
        w := w truncated + 1
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
    (h class == SmallInteger) ifFalse:[
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   448
        h := h truncated + 1
6222
2d670d3bcfd5 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6215
diff changeset
   449
    ].
6472
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   450
    w := w max:0.
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   451
    h := h max:0.
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   452
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   453
    newBounds := Rectangle left:x top:y width:w height:h.
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   454
    (clipRect notNil and:[clipRect = newBounds]) ifTrue:[
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   455
        ^ self
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   456
    ].
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   457
    clipRect := newBounds.
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   458
    gcId notNil ifTrue:[
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   459
        device setClipX:x y:y width:w height:h in:drawableId gc:gcId.
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   460
    ].
6222
2d670d3bcfd5 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6215
diff changeset
   461
2d670d3bcfd5 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6215
diff changeset
   462
    "Created: / 28.5.1996 / 19:40:20 / cg"
2d670d3bcfd5 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6215
diff changeset
   463
    "Modified: / 16.5.1999 / 19:40:37 / cg"
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
1842
502aa16b146e added #colorAt:
Claus Gittinger <cg@exept.de>
parents: 1805
diff changeset
   466
colorAt:aPoint
502aa16b146e added #colorAt:
Claus Gittinger <cg@exept.de>
parents: 1805
diff changeset
   467
    "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
   468
502aa16b146e added #colorAt:
Claus Gittinger <cg@exept.de>
parents: 1805
diff changeset
   469
    ^ self colorAtX:(aPoint x) y:(aPoint y)
502aa16b146e added #colorAt:
Claus Gittinger <cg@exept.de>
parents: 1805
diff changeset
   470
502aa16b146e added #colorAt:
Claus Gittinger <cg@exept.de>
parents: 1805
diff changeset
   471
    "Modified: 1.8.1997 / 20:01:58 / cg"
502aa16b146e added #colorAt:
Claus Gittinger <cg@exept.de>
parents: 1805
diff changeset
   472
!
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
colorAtX:x y:y
502aa16b146e added #colorAt:
Claus Gittinger <cg@exept.de>
parents: 1805
diff changeset
   475
    "return the color of the pixel at the coordinate given by aPoint"
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
    |pixel|
502aa16b146e added #colorAt:
Claus Gittinger <cg@exept.de>
parents: 1805
diff changeset
   478
502aa16b146e added #colorAt:
Claus Gittinger <cg@exept.de>
parents: 1805
diff changeset
   479
    pixel := self atX:x y:y.
502aa16b146e added #colorAt:
Claus Gittinger <cg@exept.de>
parents: 1805
diff changeset
   480
    device getScaledRGBFrom:pixel into:[:r :g :b |
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   481
	^ Color scaledRed:r scaledGreen:g scaledBlue:b
1842
502aa16b146e added #colorAt:
Claus Gittinger <cg@exept.de>
parents: 1805
diff changeset
   482
    ].
502aa16b146e added #colorAt:
Claus Gittinger <cg@exept.de>
parents: 1805
diff changeset
   483
502aa16b146e added #colorAt:
Claus Gittinger <cg@exept.de>
parents: 1805
diff changeset
   484
    "Created: 1.8.1997 / 20:01:32 / cg"
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
4199
c01c62e8c7a5 dummy container
Claus Gittinger <cg@exept.de>
parents: 4172
diff changeset
   487
container
c01c62e8c7a5 dummy container
Claus Gittinger <cg@exept.de>
parents: 4172
diff changeset
   488
    "return my container - for protocol compatibility"
c01c62e8c7a5 dummy container
Claus Gittinger <cg@exept.de>
parents: 4172
diff changeset
   489
c01c62e8c7a5 dummy container
Claus Gittinger <cg@exept.de>
parents: 4172
diff changeset
   490
    ^ nil
c01c62e8c7a5 dummy container
Claus Gittinger <cg@exept.de>
parents: 4172
diff changeset
   491
!
c01c62e8c7a5 dummy container
Claus Gittinger <cg@exept.de>
parents: 4172
diff changeset
   492
786
af5fecf93126 added dashStyle: ...
Claus Gittinger <cg@exept.de>
parents: 784
diff changeset
   493
dashStyle:aDashList offset:dashOffset
af5fecf93126 added dashStyle: ...
Claus Gittinger <cg@exept.de>
parents: 784
diff changeset
   494
    "define dashes. Each element of the dashList specifies the length
af5fecf93126 added dashStyle: ...
Claus Gittinger <cg@exept.de>
parents: 784
diff changeset
   495
     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
   496
     defines 4on-4off dashing;
786
af5fecf93126 added dashStyle: ...
Claus Gittinger <cg@exept.de>
parents: 784
diff changeset
   497
     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
   498
     The dashOffset specifies where in the dashList the dashing starts.
af5fecf93126 added dashStyle: ...
Claus Gittinger <cg@exept.de>
parents: 784
diff changeset
   499
     This may not be supported by all graphics devices."
af5fecf93126 added dashStyle: ...
Claus Gittinger <cg@exept.de>
parents: 784
diff changeset
   500
af5fecf93126 added dashStyle: ...
Claus Gittinger <cg@exept.de>
parents: 784
diff changeset
   501
    gcId notNil ifTrue:[
1029
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
   502
	device setDashes:(ByteArray withAll:aDashList)
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
   503
	      dashOffset:dashOffset
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
   504
		      in:gcId
786
af5fecf93126 added dashStyle: ...
Claus Gittinger <cg@exept.de>
parents: 784
diff changeset
   505
    ]
af5fecf93126 added dashStyle: ...
Claus Gittinger <cg@exept.de>
parents: 784
diff changeset
   506
af5fecf93126 added dashStyle: ...
Claus Gittinger <cg@exept.de>
parents: 784
diff changeset
   507
    "Modified: 4.6.1996 / 19:03:06 / cg"
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
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   510
device
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   511
    "return the device, the receiver is associated with"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   512
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
!
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:aDevice
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   517
    "set the device"
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
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   521
6472
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   522
deviceClippingBounds:aRectangleOrNil
2343
9e8d62561418 added #deviceClippingRectangle:
Claus Gittinger <cg@exept.de>
parents: 2322
diff changeset
   523
    "set the clipping rectangle for drawing (in device coordinates);
3275
b40f47ec5661 comment
Claus Gittinger <cg@exept.de>
parents: 3188
diff changeset
   524
     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
   525
6472
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   526
    clipRect = aRectangleOrNil ifTrue:[
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   527
        ^ self
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   528
    ].
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   529
    clipRect := aRectangleOrNil.
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   530
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   531
    gcId isNil ifTrue:[
6501
ef63b2302cba class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6497
diff changeset
   532
        ^ self.
ef63b2302cba class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6497
diff changeset
   533
    ].
ef63b2302cba class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6497
diff changeset
   534
2343
9e8d62561418 added #deviceClippingRectangle:
Claus Gittinger <cg@exept.de>
parents: 2322
diff changeset
   535
    aRectangleOrNil isNil ifTrue:[
6472
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   536
        device noClipIn:drawableId gc:gcId
2343
9e8d62561418 added #deviceClippingRectangle:
Claus Gittinger <cg@exept.de>
parents: 2322
diff changeset
   537
    ] ifFalse:[
6472
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   538
        device setClipX:aRectangleOrNil left 
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   539
                    y:aRectangleOrNil top 
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   540
                    width:aRectangleOrNil width 
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   541
                    height:aRectangleOrNil height 
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   542
                    in:drawableId
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   543
                    gc:gcId
6501
ef63b2302cba class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6497
diff changeset
   544
    ].
ef63b2302cba class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6497
diff changeset
   545
2343
9e8d62561418 added #deviceClippingRectangle:
Claus Gittinger <cg@exept.de>
parents: 2322
diff changeset
   546
    "Modified: / 22.5.1996 / 13:12:07 / cg"
9e8d62561418 added #deviceClippingRectangle:
Claus Gittinger <cg@exept.de>
parents: 2322
diff changeset
   547
    "Created: / 14.9.1998 / 18:50:31 / cg"
9e8d62561418 added #deviceClippingRectangle:
Claus Gittinger <cg@exept.de>
parents: 2322
diff changeset
   548
!
9e8d62561418 added #deviceClippingRectangle:
Claus Gittinger <cg@exept.de>
parents: 2322
diff changeset
   549
6472
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   550
deviceClippingBoundsOrNil
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   551
    "get the clipping rectangle for drawing (in device coordinates);
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   552
     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
   553
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   554
    ^ clipRect
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   555
!
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
deviceClippingRectangle
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   558
    <resource: #obsolete>
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   559
    "get the clipping rectangle for drawing (in device coordinates);
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   560
     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
   561
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   562
    ^ clipRect
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   563
!
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   564
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   565
deviceClippingRectangle:aRectangleOrNil
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   566
    <resource: #obsolete>
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   567
    self deviceClippingBounds:aRectangleOrNil
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   568
!
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   569
6222
2d670d3bcfd5 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6215
diff changeset
   570
drawableId
2d670d3bcfd5 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6215
diff changeset
   571
    "return the id of the drawable on the device"
2d670d3bcfd5 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6215
diff changeset
   572
2d670d3bcfd5 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6215
diff changeset
   573
    ^ drawableId
2d670d3bcfd5 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6215
diff changeset
   574
!
2d670d3bcfd5 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6215
diff changeset
   575
2918
1e777dc8588a #font answers device font if possible (cg)
Stefan Vogel <sv@exept.de>
parents: 2913
diff changeset
   576
font
1e777dc8588a #font answers device font if possible (cg)
Stefan Vogel <sv@exept.de>
parents: 2913
diff changeset
   577
    "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
   578
     the GC is realized."
1e777dc8588a #font answers device font if possible (cg)
Stefan Vogel <sv@exept.de>
parents: 2913
diff changeset
   579
1e777dc8588a #font answers device font if possible (cg)
Stefan Vogel <sv@exept.de>
parents: 2913
diff changeset
   580
    device notNil ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   581
	font := font onDevice:device
2918
1e777dc8588a #font answers device font if possible (cg)
Stefan Vogel <sv@exept.de>
parents: 2913
diff changeset
   582
    ].
1e777dc8588a #font answers device font if possible (cg)
Stefan Vogel <sv@exept.de>
parents: 2913
diff changeset
   583
    ^ font
1e777dc8588a #font answers device font if possible (cg)
Stefan Vogel <sv@exept.de>
parents: 2913
diff changeset
   584
!
1e777dc8588a #font answers device font if possible (cg)
Stefan Vogel <sv@exept.de>
parents: 2913
diff changeset
   585
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   586
font:aFont
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   587
    "set the font for drawing if it has changed.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   588
     This should be redefined in some widget to perform an automatic
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   589
     redraw. See also: #basicFont:"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   590
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   591
    (aFont ~~ font) ifTrue:[
4031
31728329be82 font-change sends a change notification
Claus Gittinger <cg@exept.de>
parents: 4026
diff changeset
   592
        self basicFont:aFont.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   593
    ]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   594
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   595
    "Modified: 6.3.1996 / 18:17:40 / cg"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   596
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   597
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   598
function:aSymbol
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   599
    "set the drawing function if it has changed"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   600
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   601
    (aSymbol ~~ function) ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   602
	function := aSymbol.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   603
	gcId notNil ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   604
	    device setFunction:aSymbol in:gcId
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   605
	]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   606
    ]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   607
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   608
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   609
gcId
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   610
    "return the receivers graphic context id on the device"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   611
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   612
    ^ gcId
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   613
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   614
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   615
graphicsDevice
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   616
    "return the device, the receiver is associated with.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   617
     Same as #device, for ST-80 compatibility."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   618
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   619
    ^ device
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   620
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   621
    "Created: 9.5.1996 / 01:37:58 / cg"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   622
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   623
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   624
id
6222
2d670d3bcfd5 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6215
diff changeset
   625
    "return the id of the drawable on the device"
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   626
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   627
    ^ drawableId
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   628
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   629
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   630
joinStyle:aSymbol
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   631
    "set the style in which 2 lines are connected in polygons -
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   632
     aSymbol may be #miter, #bevel, #round"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   633
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   634
    |s|
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   635
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   636
    (s := aSymbol) isNil ifTrue:[
1029
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
   637
	s := #miter
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   638
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   639
    (s ~~ joinStyle) ifTrue:[
1029
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
   640
	joinStyle := s.
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   641
1029
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
   642
	gcId notNil ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   643
	    device setLineWidth:lineWidth
1029
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
   644
			  style:lineStyle
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
   645
			    cap:capStyle
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
   646
			   join:s
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
   647
			     in:gcId
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
   648
	]
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: 12.5.1996 / 22:20:43 / 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
lineStyle:aSymbol
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   655
    "set the style in which lines are drawn -
2360
c7ca5d55d8ce comment
Claus Gittinger <cg@exept.de>
parents: 2343
diff changeset
   656
     aSymbol may be #solid, #dashed, #doubleDashed,
c7ca5d55d8ce comment
Claus Gittinger <cg@exept.de>
parents: 2343
diff changeset
   657
     #dotted, #dashDot or #dashDotDot."
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   658
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   659
    |s|
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   660
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   661
    (s := aSymbol) isNil ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   662
	s := #solid
732
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
    (s ~~ lineStyle) ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   665
	lineStyle := s.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   666
	gcId notNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   667
	    device setLineWidth:lineWidth
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   668
			  style:s
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   669
			    cap:capStyle
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   670
			   join:joinStyle
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   671
			     in:gcId
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   672
	]
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   673
    ]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   674
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   675
    "Modified: 12.5.1996 / 22:21:25 / cg"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   676
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   677
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   678
lineWidth:aNumber
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   679
    "set the line width for drawing if it has changed"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   680
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   681
    |n|
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
    (aNumber ~~ lineWidth) ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   684
	lineWidth := aNumber.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   685
	transformation isNil ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   686
	    n := aNumber.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   687
	] ifFalse:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   688
	    n := transformation applyScaleX:aNumber.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   689
	    n := n rounded
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   690
	].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   691
	gcId notNil ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   692
	    device setLineWidth:n
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   693
			  style:lineStyle
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   694
			    cap:capStyle
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   695
			   join:joinStyle
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   696
			     in:gcId
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   697
	]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   698
    ]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   699
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   700
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   701
mask:aForm
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   702
    "set the mask form for drawing"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   703
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   704
    |id|
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
    (aForm ~~ mask) ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   707
	mask := aForm.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   708
	gcId notNil ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   709
	    (mask == nil) ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   710
		device setBitmapMask:nil in:gcId
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   711
	    ] ifFalse:[
1033
b5cd84ed805f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1029
diff changeset
   712
		mask := mask asFormOn:device.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   713
		id := mask id.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   714
		(mask depth == 1) ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   715
		    device setBitmapMask:id in:gcId
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   716
		] ifFalse:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   717
		    device setPixmapMask:id in:gcId
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   718
		]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   719
	    ]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   720
	]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   721
    ]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   722
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   723
2018
1ad552e97c67 maskOrigin
Claus Gittinger <cg@exept.de>
parents: 2016
diff changeset
   724
maskOrigin:aPoint
1ad552e97c67 maskOrigin
Claus Gittinger <cg@exept.de>
parents: 2016
diff changeset
   725
    "set the origin of the mask-pattern"
1ad552e97c67 maskOrigin
Claus Gittinger <cg@exept.de>
parents: 2016
diff changeset
   726
1ad552e97c67 maskOrigin
Claus Gittinger <cg@exept.de>
parents: 2016
diff changeset
   727
    |x y|
1ad552e97c67 maskOrigin
Claus Gittinger <cg@exept.de>
parents: 2016
diff changeset
   728
1ad552e97c67 maskOrigin
Claus Gittinger <cg@exept.de>
parents: 2016
diff changeset
   729
    x := aPoint x.
1ad552e97c67 maskOrigin
Claus Gittinger <cg@exept.de>
parents: 2016
diff changeset
   730
    y := aPoint y.
1ad552e97c67 maskOrigin
Claus Gittinger <cg@exept.de>
parents: 2016
diff changeset
   731
1ad552e97c67 maskOrigin
Claus Gittinger <cg@exept.de>
parents: 2016
diff changeset
   732
    (maskOrigin isNil or:[
1ad552e97c67 maskOrigin
Claus Gittinger <cg@exept.de>
parents: 2016
diff changeset
   733
     ((x ~= maskOrigin x) or:[y ~= maskOrigin y]) ]) ifTrue:[
1ad552e97c67 maskOrigin
Claus Gittinger <cg@exept.de>
parents: 2016
diff changeset
   734
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   735
	maskOrigin := aPoint.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   736
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   737
	transformation notNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   738
	    x := transformation applyToX:x.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   739
	    y := transformation applyToY:y.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   740
	].
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   741
	x := x rounded.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   742
	y := y rounded.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   743
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   744
	gcId notNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   745
	    device setMaskOriginX:x y:y in:gcId
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   746
	]
2018
1ad552e97c67 maskOrigin
Claus Gittinger <cg@exept.de>
parents: 2016
diff changeset
   747
    ]
1ad552e97c67 maskOrigin
Claus Gittinger <cg@exept.de>
parents: 2016
diff changeset
   748
1ad552e97c67 maskOrigin
Claus Gittinger <cg@exept.de>
parents: 2016
diff changeset
   749
    "Created: / 26.1.1998 / 19:03:02 / cg"
1ad552e97c67 maskOrigin
Claus Gittinger <cg@exept.de>
parents: 2016
diff changeset
   750
!
1ad552e97c67 maskOrigin
Claus Gittinger <cg@exept.de>
parents: 2016
diff changeset
   751
2016
bef5fe2ec2ca checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2013
diff changeset
   752
maskOriginX:orgX y:orgY
bef5fe2ec2ca checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2013
diff changeset
   753
    "set the origin of the pattern"
bef5fe2ec2ca checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2013
diff changeset
   754
bef5fe2ec2ca checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2013
diff changeset
   755
    |x y|
bef5fe2ec2ca checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2013
diff changeset
   756
bef5fe2ec2ca checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2013
diff changeset
   757
    transformation notNil ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   758
	x := transformation applyToX:orgX.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   759
	y := transformation applyToY:orgY.
2016
bef5fe2ec2ca checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2013
diff changeset
   760
    ] ifFalse:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   761
	x := orgX.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   762
	y := orgY
2016
bef5fe2ec2ca checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2013
diff changeset
   763
    ].
bef5fe2ec2ca checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2013
diff changeset
   764
    x := x rounded.
bef5fe2ec2ca checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2013
diff changeset
   765
    y := y rounded.
bef5fe2ec2ca checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2013
diff changeset
   766
bef5fe2ec2ca checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2013
diff changeset
   767
    (maskOrigin isNil or:[
bef5fe2ec2ca checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2013
diff changeset
   768
     ((x ~~ maskOrigin x) or:[y ~~ maskOrigin y]) ]) ifTrue:[
bef5fe2ec2ca checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2013
diff changeset
   769
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   770
	maskOrigin := x @ y.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   771
	gcId notNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   772
	    device setMaskOriginX:x y:y in:gcId
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   773
	]
2016
bef5fe2ec2ca checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2013
diff changeset
   774
    ]
bef5fe2ec2ca checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2013
diff changeset
   775
bef5fe2ec2ca checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2013
diff changeset
   776
    "Created: / 26.1.1998 / 18:51:18 / cg"
bef5fe2ec2ca checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2013
diff changeset
   777
!
bef5fe2ec2ca checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2013
diff changeset
   778
950
d4d907fc7d78 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 927
diff changeset
   779
noClipByChildren
d4d907fc7d78 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 927
diff changeset
   780
    "drawing shall also be done into subviews"
d4d907fc7d78 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 927
diff changeset
   781
3429
7f87cd2ae010 Use <resource:#obsolete>
Stefan Vogel <sv@exept.de>
parents: 3300
diff changeset
   782
    <resource:#obsolete>
7f87cd2ae010 Use <resource:#obsolete>
Stefan Vogel <sv@exept.de>
parents: 3300
diff changeset
   783
1722
4ceaeda95cc3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1715
diff changeset
   784
    self obsoleteMethodWarning:'use #clippedByChildren:false'.
950
d4d907fc7d78 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 927
diff changeset
   785
    ^ self clippedByChildren:false
d4d907fc7d78 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 927
diff changeset
   786
d4d907fc7d78 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 927
diff changeset
   787
    "Created: 17.7.1996 / 14:15:54 / cg"
d4d907fc7d78 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 927
diff changeset
   788
!
d4d907fc7d78 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 927
diff changeset
   789
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   790
paint:aColor
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   791
    "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
   792
     or even an image."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   793
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   794
    (aColor ~~ paint) ifTrue:[
1029
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
   795
	aColor notNil ifTrue:[
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
   796
	    paint := aColor.
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
   797
	    self setGCForPaint.
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
   798
	]
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   799
    ]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   800
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   801
    "Modified: 16.5.1996 / 15:35:57 / cg"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   802
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   803
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   804
paint:fgColor on:bgColor
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   805
    "set the paint and background-paint color.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   806
     The bg-paint is used in opaque-draw operations"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   807
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   808
    |fgId bgId|
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   809
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   810
    ((fgColor ~~ paint) or:[bgColor ~~ bgPaint]) ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   811
	fgColor notNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   812
	    paint := fgColor
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   813
	].
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   814
	bgColor notNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   815
	    bgPaint := bgColor
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   816
	].
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   817
	gcId notNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   818
	    paint isColor ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   819
		paint := paint onDevice:device.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   820
	    ].
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   821
	    paint isColor ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   822
		fgId := paint colorId.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   823
		fgId notNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   824
		    mask notNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   825
			mask := nil.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   826
			device setBitmapMask:nil in:gcId
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   827
		    ].
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   828
		    bgPaint isColor ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   829
			bgPaint := bgPaint onDevice:device.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   830
		    ].
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   831
		    bgPaint isColor ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   832
			bgId := bgPaint colorId.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   833
			bgId notNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   834
			    "the common case, both are real colors"
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   835
			    (paint ~~ foreground) ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   836
				foreground := paint.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   837
				(bgPaint ~~ background) ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   838
				    background := bgPaint.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   839
				    device setForeground:fgId background:bgId in:gcId.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   840
				    ^ self
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   841
				].
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   842
				device setForeground:fgId in:gcId.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   843
				^ self
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   844
			    ].
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   845
			    (bgPaint ~~ background) ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   846
				background := bgPaint.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   847
				device setBackground:bgId in:gcId.
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
			    ^ self
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   850
			].
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   851
			"bgPaint is dithered, setup paint here, leave bgPaint
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   852
			 till next opaque draw comes around."
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   853
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   854
			(paint ~~ foreground) ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   855
			    foreground := paint.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   856
			    device setForeground:fgId in:gcId
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   857
			].
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   858
			^ self
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
		]
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   861
	    ].
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   862
	    "either paint or bgPaint (or both) are dithered colors,
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   863
	     setup for paint, leave bg-problem till next opaque draw
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   864
	     comes around.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   865
	    "
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   866
	    self setGCForPaint.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   867
	]
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   868
    ]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   869
4797
91ee43d3acf5 changed #paint:on:
Claus Gittinger <cg@exept.de>
parents: 4781
diff changeset
   870
    "Modified: / 31-08-2007 / 10:56:49 / cg"
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   871
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   872
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   873
paint:fgColor on:bgColor function:f
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   874
    "set paint, background-paint and function"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   875
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   876
    self paint:fgColor on:bgColor.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   877
    self function:f
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   878
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   879
    "Modified: 16.5.1996 / 15:36:35 / cg"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   880
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   881
6266
1503c5e038d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   882
setClippingBounds:aRectangleOrNil
6472
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   883
    "set the clipping rectangle for drawing (in physical coordinates.
6266
1503c5e038d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   884
     Only set the variable, do not change the gc"
1503c5e038d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   885
1503c5e038d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   886
    clipRect := aRectangleOrNil
1503c5e038d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   887
!
1503c5e038d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   888
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   889
setGraphicsExposures:aBoolean
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   890
    "want to if aBoolean is true - or dont want to be notified
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   891
     of graphics exposures"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   892
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   893
    gcId notNil ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   894
	device setGraphicsExposures:aBoolean in:gcId
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   895
    ]
6266
1503c5e038d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   896
!
1503c5e038d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   897
1503c5e038d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   898
setPaint:fgColor on:bgColor
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   899
    "set the paint and background-paint color.
6266
1503c5e038d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   900
     The bg-paint is used in opaque-draw operations.
1503c5e038d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   901
     Only set the variables, but do not send it to the device,
1503c5e038d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   902
     Used on initialization."
1503c5e038d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   903
1503c5e038d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   904
    fgColor notNil ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   905
	foreground := paint := fgColor
6266
1503c5e038d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   906
    ].
1503c5e038d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   907
    bgColor notNil ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   908
	background := bgPaint := bgColor
6266
1503c5e038d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   909
    ].
732
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
1092
1b6391f333de category rename
Claus Gittinger <cg@exept.de>
parents: 1085
diff changeset
   912
!DeviceGraphicsContext methodsFor:'accessing-internals'!
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   913
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   914
background
6266
1503c5e038d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   915
    <resource: #obsolete>
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   916
    "return the current background drawing color.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   917
     OBSOLETE: use #paint: / #backgroundPaint: / #paint:on:"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   918
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   919
    ^ background
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   920
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   921
    "Modified: 12.5.1996 / 22:28:09 / cg"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   922
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   923
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   924
background:aColor
6266
1503c5e038d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   925
    <resource: #obsolete>
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   926
    "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
   927
     OBSOLETE: this method will vanish; use #paint: / #backgroundPaint: / #paint:on:"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   928
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   929
    |bgId|
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   930
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   931
    (aColor ~~ background) ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   932
	aColor notNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   933
	    background := aColor.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   934
	    gcId notNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   935
		background := background onDevice:device.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   936
		bgId := background colorId.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   937
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   938
		"
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   939
		 mhmh the following is a kludge ....
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   940
		"
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   941
		bgId isNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   942
		    (background grayIntensity >= 50) ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   943
			bgId := device whitepixel
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   944
		    ] ifFalse:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   945
			bgId := device blackpixel
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   946
		    ]
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   947
		].
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   948
		device setBackground:bgId in:gcId
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   949
	    ]
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   950
	]
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   951
    ]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   952
745
d4465098f2c0 gray vs. grey
Claus Gittinger <cg@exept.de>
parents: 735
diff changeset
   953
    "Modified: 28.5.1996 / 20:44:55 / cg"
732
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
foreground
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
    "return the current foreground drawing color.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   959
     OBSOLETE: use #paint: / #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
    ^ foreground
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
    "Modified: 12.5.1996 / 22:28:03 / cg"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   964
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   965
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   966
foreground:aColor
6266
1503c5e038d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   967
    <resource: #obsolete>
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   968
    "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
   969
     OBSOLETE: this method will vanish; use #paint: / #paint:on:"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   970
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   971
    |fgId|
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   972
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   973
    (aColor ~~ foreground) ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   974
	aColor notNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   975
	    foreground := aColor.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   976
	    gcId notNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   977
		(foreground class == SmallInteger) ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   978
		    fgId := foreground
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   979
		] ifFalse:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   980
		    foreground := foreground onDevice:device.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   981
		    fgId := foreground colorId.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   982
		].
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   983
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   984
		"mhmh the following is a kludge ...."
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   985
		fgId isNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   986
		    (foreground grayIntensity >= 50) ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   987
			fgId := device whitepixel
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   988
		    ] ifFalse:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   989
			fgId := device blackpixel
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   990
		    ]
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   991
		].
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   992
		device setForeground:fgId in:gcId.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   993
		paint := foreground
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   994
	    ]
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   995
	]
732
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
745
d4465098f2c0 gray vs. grey
Claus Gittinger <cg@exept.de>
parents: 735
diff changeset
   998
    "Modified: 28.5.1996 / 20:45:02 / cg"
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   999
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1000
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1001
foreground:fgColor background:bgColor
6266
1503c5e038d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1002
    <resource: #obsolete>
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1003
    "set both internal foreground and internal background colors
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1004
     - these must be real colors.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1005
     OBSOLETE: this method will vanish; use #paint: / #paint:on:"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1006
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1007
    |fgPixel bgPixel|
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1008
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1009
    ((fgColor ~~ foreground) or:[bgColor ~~ background]) ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1010
	fgColor notNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1011
	    foreground := fgColor
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1012
	].
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1013
	bgColor notNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1014
	    background := bgColor
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
	gcId notNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1017
	    foreground := foreground onDevice:device.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1018
	    background := background onDevice:device.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1019
	    fgPixel := foreground colorId.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1020
	    bgPixel := background colorId.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1021
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1022
	    "mhmh the following is a kludge ...."
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1023
	    fgPixel isNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1024
		(foreground grayIntensity >= 50) ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1025
		    fgPixel := device whitepixel
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1026
		] ifFalse:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1027
		    fgPixel := device blackpixel
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1028
		]
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1029
	    ].
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1030
	    bgPixel isNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1031
		(background grayIntensity >= 50) ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1032
		    bgPixel := device whitepixel
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1033
		] ifFalse:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1034
		    bgPixel := device blackpixel
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1035
		]
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1036
	    ].
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1037
	    device setForeground:fgPixel background:bgPixel in:gcId.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1038
	    paint := foreground
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1039
	]
732
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
745
d4465098f2c0 gray vs. grey
Claus Gittinger <cg@exept.de>
parents: 735
diff changeset
  1042
    "Modified: 28.5.1996 / 20:45:27 / cg"
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1043
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1044
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1045
foreground:fgColor background:bgColor function:fun
6266
1503c5e038d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1046
    <resource: #obsolete>
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1047
    "set foreground, background colors and function.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1048
     OBSOLETE: this method will vanish; use #paint: / #paint:on:"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1049
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1050
    self foreground:fgColor background:bgColor.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1051
    self function:fun
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1052
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1053
    "Modified: 12.5.1996 / 22:28:34 / cg"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1054
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1055
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1056
foreground:aColor function:fun
6266
1503c5e038d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1057
    <resource: #obsolete>
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1058
    "set the foreground color and function for drawing.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1059
     OBSOLETE: this method will vanish; use #paint: / #paint:on:"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1060
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1061
    |fgPixel|
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1062
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1063
    ((aColor ~~ foreground) or:[fun ~~ function]) ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1064
	foreground := aColor.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1065
	function := fun.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1066
	gcId notNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1067
	    foreground := foreground onDevice:device.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1068
	    fgPixel := foreground colorId.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1069
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1070
	    "mhmh the following is a kludge ...."
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1071
	    fgPixel isNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1072
		(foreground grayIntensity >= 50) ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1073
		    fgPixel := device whitepixel
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1074
		] ifFalse:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1075
		    fgPixel := device blackpixel
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1076
		]
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1077
	    ].
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1078
	    device setForeground:fgPixel in:gcId.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1079
	    device setFunction:fun in:gcId.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1080
	    paint := foreground
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1081
	]
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1082
    ]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1083
745
d4465098f2c0 gray vs. grey
Claus Gittinger <cg@exept.de>
parents: 735
diff changeset
  1084
    "Modified: 28.5.1996 / 20:45:09 / cg"
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1085
! !
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
!DeviceGraphicsContext methodsFor:'bit blitting'!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1088
2016
bef5fe2ec2ca checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2013
diff changeset
  1089
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
  1090
    "copy bits from a smalltalk byteArray.
bef5fe2ec2ca checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2013
diff changeset
  1091
     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
  1092
     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
  1093
     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
  1094
     method to whatever the device needs."
bef5fe2ec2ca checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2013
diff changeset
  1095
bef5fe2ec2ca checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2013
diff changeset
  1096
    device
bef5fe2ec2ca checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2013
diff changeset
  1097
        drawBits:aByteArray
6472
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1098
        bitsPerPixel:bpp
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1099
        depth:depth
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1100
        padding:pad
2016
bef5fe2ec2ca checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2013
diff changeset
  1101
        width:srcW height:srcH
bef5fe2ec2ca checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2013
diff changeset
  1102
        x:srcX y:srcY
bef5fe2ec2ca checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2013
diff changeset
  1103
        into:drawableId
6472
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1104
        x:dstX y:dstY
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1105
        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
  1106
        with:gcId.
bef5fe2ec2ca checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2013
diff changeset
  1107
!
bef5fe2ec2ca checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2013
diff changeset
  1108
6472
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1109
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
  1110
    "copy bits from a smalltalk byteArray.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1111
     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
  1112
     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
  1113
     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
  1114
     method to whatever the device needs.
d8b8149ab79d added interface to specify padding in drawBits method
Claus Gittinger <cg@exept.de>
parents: 1842
diff changeset
  1115
     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
  1116
    
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1117
    self 
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1118
        copyBitsFrom:aByteArray
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1119
        bitsPerPixel:bpp
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1120
        depth:depth
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1121
        padding:8
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1122
        width:srcW
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1123
        height:srcH
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1124
        x:srcX
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1125
        y:srcY
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1126
        toX:dstX
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1127
        y:dstY
1996
d8b8149ab79d added interface to specify padding in drawBits method
Claus Gittinger <cg@exept.de>
parents: 1842
diff changeset
  1128
!
d8b8149ab79d added interface to specify padding in drawBits method
Claus Gittinger <cg@exept.de>
parents: 1842
diff changeset
  1129
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1130
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
  1131
    "copy from aDrawable into the receiver;
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1132
     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
  1133
     All coordinates are in device coordinates."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1134
1291
1480f8aae3bb explicit sync/async bitBlt.
Claus Gittinger <cg@exept.de>
parents: 1255
diff changeset
  1135
    ^ self
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1136
	copyFrom:aDrawable
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1137
	x:srcX y:srcY
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1138
	toX:dstX y:dstY
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1139
	width:w height:h
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1140
	async:false
1291
1480f8aae3bb explicit sync/async bitBlt.
Claus Gittinger <cg@exept.de>
parents: 1255
diff changeset
  1141
1480f8aae3bb explicit sync/async bitBlt.
Claus Gittinger <cg@exept.de>
parents: 1255
diff changeset
  1142
    "Modified: 29.1.1997 / 13:12:36 / cg"
1480f8aae3bb explicit sync/async bitBlt.
Claus Gittinger <cg@exept.de>
parents: 1255
diff changeset
  1143
!
1480f8aae3bb explicit sync/async bitBlt.
Claus Gittinger <cg@exept.de>
parents: 1255
diff changeset
  1144
1480f8aae3bb explicit sync/async bitBlt.
Claus Gittinger <cg@exept.de>
parents: 1255
diff changeset
  1145
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
  1146
    "copy from aDrawable into the receiver;
1480f8aae3bb explicit sync/async bitBlt.
Claus Gittinger <cg@exept.de>
parents: 1255
diff changeset
  1147
     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
  1148
     All coordinates are in device coordinates.
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1149
     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
  1150
     - otherwise, it returns when the scroll operation is finished.
1480f8aae3bb explicit sync/async bitBlt.
Claus Gittinger <cg@exept.de>
parents: 1255
diff changeset
  1151
     (not all devices care for this).
1480f8aae3bb explicit sync/async bitBlt.
Claus Gittinger <cg@exept.de>
parents: 1255
diff changeset
  1152
     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
  1153
6472
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1154
    |deviceDrawable id srcGCId|
976
807b42b00353 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 975
diff changeset
  1155
2210
18d4e83d08ad care for images being passed to #copyFrom: as source.
Claus Gittinger <cg@exept.de>
parents: 2192
diff changeset
  1156
    ((aDrawable graphicsDevice ~~ device)
6472
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1157
     or:[aDrawable isImage]) ifTrue:[
1177
e89408c15bb5 newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 1138
diff changeset
  1158
        deviceDrawable := aDrawable asFormOn:device.
976
807b42b00353 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 975
diff changeset
  1159
    ] ifFalse:[
1177
e89408c15bb5 newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 1138
diff changeset
  1160
        deviceDrawable := aDrawable
976
807b42b00353 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 975
diff changeset
  1161
    ].
807b42b00353 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 975
diff changeset
  1162
807b42b00353 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 975
diff changeset
  1163
    id := deviceDrawable id.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1164
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1165
    "temporary ...
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1166
     this fixes a problem after restart on another display,
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1167
     when a file-bitmap was not found.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1168
     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
  1169
     This will be fixed soon (no longer use device>>bitmapFromFile:).
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1170
    "
976
807b42b00353 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 975
diff changeset
  1171
    id isNil ifTrue:[
1177
e89408c15bb5 newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 1138
diff changeset
  1172
        'DeviceGraphicsContext [warning]: invalid bitmap copy - ignored' errorPrintCR.
e89408c15bb5 newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 1138
diff changeset
  1173
        ^ self
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1174
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1175
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1176
    gcId isNil ifTrue:[
1177
e89408c15bb5 newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 1138
diff changeset
  1177
        self initGC
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1178
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1179
2065
27bf0cf42e45 changes for WIN32
Claus Gittinger <cg@exept.de>
parents: 2049
diff changeset
  1180
    deviceDrawable gcId isNil ifTrue:[deviceDrawable initGC].
976
807b42b00353 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 975
diff changeset
  1181
    srcGCId := deviceDrawable gcId.
807b42b00353 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 975
diff changeset
  1182
807b42b00353 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 975
diff changeset
  1183
    ((deviceDrawable depth == 1) and:[device depth ~~ 1]) ifTrue:[
1249
5224bb7a97bf use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  1184
        deviceDrawable isForm ifTrue:[
5224bb7a97bf use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  1185
            device
5224bb7a97bf use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  1186
                copyPlaneFromPixmapId:id
6472
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1187
                x:srcX
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1188
                y:srcY
1249
5224bb7a97bf use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  1189
                gc:srcGCId
5224bb7a97bf use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  1190
                to:drawableId
6472
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1191
                x:dstX
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1192
                y:dstY
1249
5224bb7a97bf use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  1193
                gc:gcId
6472
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1194
                width:w
1249
5224bb7a97bf use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  1195
                height:h
5224bb7a97bf use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  1196
        ] ifFalse:[
5224bb7a97bf use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  1197
            device
5224bb7a97bf use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  1198
                copyPlaneFromId:id
6472
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1199
                x:srcX
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1200
                y:srcY
1249
5224bb7a97bf use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  1201
                gc:srcGCId
5224bb7a97bf use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  1202
                to:drawableId
6472
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1203
                x:dstX
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1204
                y:dstY
1249
5224bb7a97bf use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  1205
                gc:gcId
6472
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1206
                width:w
1249
5224bb7a97bf use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  1207
                height:h
5224bb7a97bf use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  1208
        ]
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1209
    ] ifFalse:[
1249
5224bb7a97bf use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  1210
        deviceDrawable isForm ifTrue:[
5224bb7a97bf use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  1211
            device
5224bb7a97bf use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  1212
                copyFromPixmapId:id
6472
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1213
                x:srcX
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1214
                y:srcY
1249
5224bb7a97bf use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  1215
                gc:srcGCId
5224bb7a97bf use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  1216
                to:drawableId
6472
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1217
                x:dstX
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1218
                y:dstY
1249
5224bb7a97bf use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  1219
                gc:gcId
6472
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1220
                width:w
1249
5224bb7a97bf use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  1221
                height:h
5224bb7a97bf use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  1222
        ] ifFalse:[
5224bb7a97bf use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  1223
            device
5224bb7a97bf use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  1224
                copyFromId:id
6472
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1225
                x:srcX
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1226
                y:srcY
1249
5224bb7a97bf use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  1227
                gc:srcGCId
5224bb7a97bf use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  1228
                to:drawableId
6472
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1229
                x:dstX
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1230
                y:dstY
1249
5224bb7a97bf use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  1231
                gc:gcId
6472
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1232
                width:w
1291
1480f8aae3bb explicit sync/async bitBlt.
Claus Gittinger <cg@exept.de>
parents: 1255
diff changeset
  1233
                height:h.
1249
5224bb7a97bf use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  1234
        ]
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1235
    ]
868
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
  1236
2210
18d4e83d08ad care for images being passed to #copyFrom: as source.
Claus Gittinger <cg@exept.de>
parents: 2192
diff changeset
  1237
    "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
  1238
    "Modified: / 31.7.1998 / 17:23:43 / cg"
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1239
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1240
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1241
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
  1242
    "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
  1243
     background, while 1's are drawn with foreground color.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1244
     The depth of aDrawable must (should) be 1.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1245
     The drawable must have been allocated on the same device.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1246
     All coordinates are in device coordinates."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1247
1064
2d0783c97f32 removed unused vars
Claus Gittinger <cg@exept.de>
parents: 1034
diff changeset
  1248
    |deviceDrawable id|
976
807b42b00353 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 975
diff changeset
  1249
2210
18d4e83d08ad care for images being passed to #copyFrom: as source.
Claus Gittinger <cg@exept.de>
parents: 2192
diff changeset
  1250
    ((aDrawable graphicsDevice ~~ device)
18d4e83d08ad care for images being passed to #copyFrom: as source.
Claus Gittinger <cg@exept.de>
parents: 2192
diff changeset
  1251
    or:[aDrawable isImage]) ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1252
	deviceDrawable := aDrawable asFormOn:device.
976
807b42b00353 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 975
diff changeset
  1253
    ] ifFalse:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1254
	deviceDrawable := aDrawable
976
807b42b00353 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 975
diff changeset
  1255
    ].
807b42b00353 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 975
diff changeset
  1256
807b42b00353 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 975
diff changeset
  1257
    id := deviceDrawable id.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1258
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1259
    "temporary ...
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1260
     this fixes a problem after restart on another display,
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1261
     when a file-bitmap was not found.
976
807b42b00353 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 975
diff changeset
  1262
     In this case, the id of the bitmap will be nil.
807b42b00353 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 975
diff changeset
  1263
     This will be fixed soon (no longer use device>>bitmapFromFile:).
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1264
    "
976
807b42b00353 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 975
diff changeset
  1265
    id isNil ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1266
	'DeviceGraphicsContext [warning]: invalid copyPlane - ignored' errorPrintCR.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1267
	^ self
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1268
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1269
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1270
    gcId isNil ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1271
	self initGC
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1272
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1273
1249
5224bb7a97bf use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  1274
    deviceDrawable isForm ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1275
	deviceDrawable gcId isNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1276
	    deviceDrawable initGC
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1277
	].
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1278
	device
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1279
	    copyPlaneFromPixmapId:id
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1280
	    x:srcX
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1281
	    y:srcY
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1282
	    gc:(deviceDrawable gcId)
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1283
	    to:drawableId
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1284
	    x:dstX
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1285
	    y:dstY
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1286
	    gc:gcId
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1287
	    width:w
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1288
	    height:h
1249
5224bb7a97bf use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  1289
    ] ifFalse:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1290
	device
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1291
	    copyPlaneFromId:id
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1292
	    x:srcX
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1293
	    y:srcY
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1294
	    gc:(deviceDrawable gcId)
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1295
	    to:drawableId
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1296
	    x:dstX
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1297
	    y:dstY
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1298
	    gc:gcId
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1299
	    width:w
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1300
	    height:h
1249
5224bb7a97bf use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  1301
    ]
5224bb7a97bf use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  1302
2271
46b68ae54cbc win32 needs source-gc to be initialized in a bitBlt.
Claus Gittinger <cg@exept.de>
parents: 2268
diff changeset
  1303
    "Modified: / 22.8.1998 / 15:15:52 / cg"
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1304
! !
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1305
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1306
!DeviceGraphicsContext methodsFor:'copying'!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1307
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1308
postCopy
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1309
    "this may not be enough to allow copying of views ..."
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
    super postCopy.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1312
    device := drawableId := gcId := nil.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1313
    self recreate
4403
3342601d3fed +postDeepCopy
Claus Gittinger <cg@exept.de>
parents: 4389
diff changeset
  1314
!
3342601d3fed +postDeepCopy
Claus Gittinger <cg@exept.de>
parents: 4389
diff changeset
  1315
3342601d3fed +postDeepCopy
Claus Gittinger <cg@exept.de>
parents: 4389
diff changeset
  1316
postDeepCopy
3342601d3fed +postDeepCopy
Claus Gittinger <cg@exept.de>
parents: 4389
diff changeset
  1317
    device := drawableId := gcId := nil.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1318
! !
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1319
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1320
!DeviceGraphicsContext methodsFor:'drawing'!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1321
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1322
displayArcX:x y:y width:w height:h from:startAngle angle:angle
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1323
    "draw an arc; apply transformation if nonNil"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1324
2268
1a774fc02c83 fixed non-float (i.e. fraction) args to fillArc/ displayArc
Claus Gittinger <cg@exept.de>
parents: 2259
diff changeset
  1325
    |pX pY nW nH sA a|
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1326
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1327
    gcId isNil ifTrue:[
1029
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
  1328
	self initGC
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1329
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1330
    transformation notNil ifTrue:[
1029
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
  1331
	pX := transformation applyToX:x.
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
  1332
	pY := transformation applyToY:y.
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
  1333
	nW := transformation applyScaleX:w.
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
  1334
	nH := transformation applyScaleY:h.
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
  1335
	nW < 0 ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1336
	      nW := nW abs.
1029
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
  1337
	      pX := pX - nW.
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
  1338
	].
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
  1339
	nH < 0 ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1340
	      nH := nH abs.
1029
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
  1341
	      pY := pY - nH.
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
  1342
	].
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1343
    ] ifFalse:[
1029
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
  1344
	pX := x.
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
  1345
	pY := y.
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
  1346
	nW := w.
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
  1347
	nH := h.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1348
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1349
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1350
    pX := pX rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1351
    pY := pY rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1352
    nW := nW rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1353
    nH := nH rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1354
2268
1a774fc02c83 fixed non-float (i.e. fraction) args to fillArc/ displayArc
Claus Gittinger <cg@exept.de>
parents: 2259
diff changeset
  1355
    sA := startAngle.
1a774fc02c83 fixed non-float (i.e. fraction) args to fillArc/ displayArc
Claus Gittinger <cg@exept.de>
parents: 2259
diff changeset
  1356
    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
  1357
    a := angle.
1a774fc02c83 fixed non-float (i.e. fraction) args to fillArc/ displayArc
Claus Gittinger <cg@exept.de>
parents: 2259
diff changeset
  1358
    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
  1359
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1360
    device
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1361
	  displayArcX:pX
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1362
		    y:pY
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1363
		width:nW
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1364
	       height:nH
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1365
		 from:sA
2268
1a774fc02c83 fixed non-float (i.e. fraction) args to fillArc/ displayArc
Claus Gittinger <cg@exept.de>
parents: 2259
diff changeset
  1366
		angle:a
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1367
		   in:drawableId
1029
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
  1368
		 with:gcId
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
    "Created: 8.5.1996 / 08:31:30 / cg"
784
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
  1371
    "Modified: 4.6.1996 / 17:59:28 / cg"
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
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1374
displayForm:formToDraw x:x y:y
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1375
    "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
  1376
     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
  1377
     current paint-color, leaving pixels with 0-bits unchanged
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1378
     (i.e. only 1-bits are drawn from the form).
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1379
     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
  1380
     settings are ignored and the form is drawn as-is.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1381
     Care must be taken, that the paint color is correctly allocated
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1382
     (by sending #on: to the color) before doing so.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1383
     Using functions other than #copy only makes sense if you are
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1384
     certain, that the colors are real colors (actually, only for
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1385
     noColor or allColor)."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1386
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1387
    |realForm pX pY w h nW nH|
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1388
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1389
    realForm := formToDraw.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1390
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1391
    transformation notNil ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1392
	pX := transformation applyToX:x.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1393
	pY := transformation applyToY:y.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1394
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1395
	transformation noScale ifFalse:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1396
	    w := formToDraw width.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1397
	    h := formToDraw height.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1398
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1399
	    nW := (transformation applyScaleX:w) rounded.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1400
	    nH := (transformation applyScaleY:h) rounded.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1401
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1402
	    ((nW ~= w) or:[nH ~= h]) ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1403
		"/
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1404
		"/ hard case - someone is drawing forms with scaling in effect
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1405
		"/ look if we have a scaled version in our pocket ...
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1406
		"/
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1407
		realForm := nil.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1408
		CachedScaledForms notNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1409
		    (CachedScales at:formToDraw ifAbsent:nil) = transformation scale ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1410
			realForm := CachedScaledForms at:formToDraw ifAbsent:nil.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1411
		    ]
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1412
		].
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1413
		realForm isNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1414
		    "/
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1415
		    "/ nope - must do the work ...
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1416
		    "/
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1417
		    realForm := formToDraw magnifiedBy:(nW / w) @ (nH / h).
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1418
		    CachedScaledForms isNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1419
			CachedScaledForms := WeakIdentityDictionary new.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1420
			CachedScales := WeakIdentityDictionary new.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1421
		    ].
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1422
		    CachedScaledForms at:formToDraw put:realForm.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1423
		    CachedScales at:formToDraw put:transformation scale.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1424
		]
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1425
	    ]
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1426
	]
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1427
    ] ifFalse:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1428
	pX := x.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1429
	pY := y.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1430
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1431
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1432
    self displayDeviceForm:realForm x:pX y:pY
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1433
1592
7ec770f2047a faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents: 1517
diff changeset
  1434
    "Modified: 12.4.1997 / 12:47:29 / cg"
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1435
!
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
displayLineFromX:x0 y:y0 toX:x1 y:y1
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1438
    "draw a line (with current paint-color); apply transformation if nonNil"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1439
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1440
    |pX0 pY0 pX1 pY1 easy fgId bgId|
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1441
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1442
    gcId isNil ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1443
	self initGC
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1444
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1445
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1446
    lineStyle == #doubleDashed ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1447
	"
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1448
	 if bgPaint or paint is not a real color, we have to do it the hard way ...
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1449
	"
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1450
	easy := true.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1451
	paint isColor ifFalse:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1452
	    easy := false
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1453
	] ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1454
	    fgId := paint colorId.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1455
	    fgId isNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1456
		easy := false
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1457
	    ]
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1458
	].
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1459
	bgPaint isColor ifFalse:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1460
	    easy := false
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1461
	] ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1462
	    bgId := bgPaint colorId.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1463
	    bgId isNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1464
		easy := false
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1465
	    ]
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1466
	].
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1467
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1468
	easy ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1469
	    ((foreground ~~ paint) or:[background ~~ bgPaint]) ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1470
		device setForeground:fgId background:bgId in:gcId.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1471
		foreground := paint.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1472
		background := bgPaint.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1473
	    ].
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1474
	] ifFalse:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1475
	    'DeviceGraphicsContext [warning]: cannot draw dashes with dithered colors' errorPrintCR
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1476
	].
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1477
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1478
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1479
    transformation notNil ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1480
	pX0 := transformation applyToX:x0.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1481
	pY0 := transformation applyToY:y0.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1482
	pX1 := transformation applyToX:x1.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1483
	pY1 := transformation applyToY:y1.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1484
    ] ifFalse:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1485
	pX0 := x0.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1486
	pY0 := y0.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1487
	pX1 := x1.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1488
	pY1 := y1
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1489
    ].
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
    pX0 := pX0 rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1492
    pY0 := pY0 rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1493
    pX1 := pX1 rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1494
    pY1 := pY1 rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1495
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1496
    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
  1497
1177
e89408c15bb5 newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 1138
diff changeset
  1498
    "Modified: 10.1.1997 / 17:46:32 / cg"
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1499
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1500
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1501
displayOpaqueForm:formToDraw x:x y:y
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1502
    "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
  1503
     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
  1504
     current paint-color and 0-bits in the bgPaint color.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1505
     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
  1506
     settings are ignored and the form drawn as-is.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1507
     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
  1508
     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
  1509
     (by sending #on: to the colors) before doing so.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1510
     If there is a transformation, the image is scaled as appropiate."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1511
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1512
    |w h realForm pX pY nW nH|
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1513
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1514
    bgPaint isNil ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1515
	"/
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1516
	"/ actually not an opaque draw
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1517
	"/
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1518
	self displayForm:formToDraw x:x y:y.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1519
	^ self
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1520
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1521
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1522
    realForm := formToDraw.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1523
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1524
    transformation notNil ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1525
	pX := transformation applyToX:x.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1526
	pY := transformation applyToY:y.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1527
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1528
	transformation noScale ifFalse:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1529
	    w := formToDraw width.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1530
	    h := formToDraw height.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1531
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1532
	    nW := (transformation applyScaleX:w) rounded.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1533
	    nH := (transformation applyScaleY:h) rounded.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1534
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1535
	    ((nW ~= w) or:[nH ~= h]) ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1536
		"/
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1537
		"/ hard case - someone is drawing forms with scaling in effect
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1538
		"/ look if we have a scaled version in our pocket ...
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1539
		"/
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1540
		realForm := nil.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1541
		CachedScaledForms notNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1542
		    (CachedScales at:formToDraw ifAbsent:nil) = transformation scale ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1543
			realForm := CachedScaledForms at:formToDraw ifAbsent:nil.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1544
		    ]
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1545
		].
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1546
		realForm isNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1547
		    "/
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1548
		    "/ nope - must do the work ...
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1549
		    "/
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1550
		    realForm := formToDraw magnifiedBy:(nW / w) @ (nH / h).
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1551
		    CachedScaledForms isNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1552
			CachedScaledForms := WeakIdentityDictionary new.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1553
			CachedScales := WeakIdentityDictionary new.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1554
		    ].
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1555
		    CachedScaledForms at:formToDraw put:realForm.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1556
		    CachedScales at:formToDraw put:transformation scale.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1557
		]
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1558
	    ]
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1559
	]
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1560
    ] ifFalse:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1561
	pX := x.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1562
	pY := y.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1563
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1564
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1565
    self displayDeviceOpaqueForm:realForm x:pX y:pY
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1566
1592
7ec770f2047a faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents: 1517
diff changeset
  1567
    "Modified: 12.4.1997 / 12:49:02 / cg"
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1568
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1569
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1570
displayOpaqueString:aString from:index1 to:index2 x:x y:y
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1571
    "draw a substring at the coordinate x/y - draw foreground pixels in
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1572
     paint-color and background pixels in bgPaint-color.
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1573
     If the transformation involves scaling,
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1574
     the fonts point-size is scaled as appropriate.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1575
     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
  1576
     the case where paint and/or bgPaint are dithered colors"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1577
6472
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1578
    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
  1579
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1580
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1581
displayOpaqueString:aString x:x y:y
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1582
    "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
  1583
     background pixels in bgPaint color. If the transformation involves scaling,
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1584
     the fonts point-size is scaled as appropriate.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1585
     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
  1586
     the case where paint and/or bgPaint are dithered colors or images."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1587
5360
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1588
    (aString isString not or:[aString isText]) ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1589
	"
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1590
	 hook for non-strings (i.e. attributed text)
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1591
	 that 'thing' should know how to display itself ...
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1592
	"
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1593
	aString displayOpaqueOn:self x:x y:y.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1594
	^ self
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1595
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1596
5360
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1597
    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
  1598
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1599
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1600
displayPointX:x y:y
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1601
    "draw a point (with current paint-color); apply transformation if nonNil"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1602
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1603
    |pX pY|
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
    gcId isNil ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1606
	self initGC
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1607
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1608
    transformation notNil ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1609
	pX := transformation applyToX:x.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1610
	pY := transformation applyToY:y.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1611
    ] ifFalse:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1612
	pX := x.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1613
	pY := y
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
    pX := pX rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1616
    pY := pY rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1617
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1618
    device displayPointX:pX y:pY in:drawableId with:gcId
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1619
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1620
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1621
displayPolygon:aPolygon
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1622
    "draw (the outline of) a polygon (with current paint-color).
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1623
     Apply transformation if nonNil"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1624
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1625
    |newPolygon|
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1626
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1627
    gcId isNil ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1628
	self initGC
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1629
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1630
    transformation notNil ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1631
	newPolygon := aPolygon collect:[:point | transformation applyTo:point].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1632
    ] ifFalse:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1633
	newPolygon := aPolygon
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1634
    ].
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1635
    (newPolygon findFirst:[:p |
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1636
	(p isPoint not
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1637
	or:[(p x class ~~ SmallInteger)
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1638
	or:[(p y class ~~ SmallInteger)]])
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1639
     ]) ~~ 0 ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1640
	newPolygon := newPolygon collect:[:p | p asPoint rounded]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1641
    ].
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1642
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1643
    device displayPolygon:newPolygon in:drawableId with:gcId
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1644
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1645
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1646
displayRectangleX:x y:y width:w height:h
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1647
    "draw a rectangle (with current paint-color).
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1648
     If transformation is nonNil, drawing is in logical coordinates."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1649
1064
2d0783c97f32 removed unused vars
Claus Gittinger <cg@exept.de>
parents: 1034
diff changeset
  1650
    |pX pY nW nH easy fgId bgId|
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1651
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1652
    gcId isNil ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1653
	self initGC
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1654
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1655
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1656
    lineStyle == #doubleDashed ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1657
	"
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1658
	 if bgPaint or paint is not a real color, we have to do it the hard way ...
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1659
	"
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1660
	easy := true.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1661
	paint isColor ifFalse:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1662
	    easy := false
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1663
	] ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1664
	    fgId := paint colorId.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1665
	    fgId isNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1666
		easy := false
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1667
	    ]
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1668
	].
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1669
	bgPaint isColor ifFalse:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1670
	    easy := false
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1671
	] ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1672
	    bgId := bgPaint colorId.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1673
	    bgId isNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1674
		easy := false
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1675
	    ]
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1676
	].
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1677
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1678
	easy ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1679
	    ((foreground ~~ paint) or:[background ~~ bgPaint]) ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1680
		device setForeground:fgId background:bgId in:gcId.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1681
		foreground := paint.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1682
		background := bgPaint.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1683
	    ].
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1684
	] ifFalse:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1685
	    'DeviceGraphicsContext [warning]: cannot draw dashes with dithered colors' errorPrintCR
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1686
	].
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1687
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1688
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1689
    transformation notNil ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1690
	pX := transformation applyToX:x.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1691
	pY := transformation applyToY:y.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1692
	nW := transformation applyScaleX:w.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1693
	nH := transformation applyScaleY:h.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1694
	nW < 0 ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1695
	      nW := nW abs.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1696
	      pX := pX - nW.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1697
	].
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1698
	nH < 0 ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1699
	      nH := nH abs.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1700
	      pY := pY - nH.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1701
	].
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1702
    ] ifFalse:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1703
	pX := x.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1704
	pY := y.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1705
	nW := w.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1706
	nH := h
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1707
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1708
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1709
    pX := pX rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1710
    pY := pY rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1711
    nW := nW rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1712
    nH := nH rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1713
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1714
    "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
  1715
     this one seems mathematically incorrect but allows to draw and fill
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1716
     a rectangle using the same extents.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1717
     I'm not certain if is the right thing to do ...
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1718
    "
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1719
    device displayRectangleX:pX
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1720
			   y:pY
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1721
		       width:(nW - 1)
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1722
		      height:(nH - 1)
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1723
			  in:drawableId with:gcId
1177
e89408c15bb5 newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 1138
diff changeset
  1724
e89408c15bb5 newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 1138
diff changeset
  1725
    "Modified: 10.1.1997 / 17:46:41 / cg"
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1726
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1727
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1728
displayString:aString from:index1 to:index2 x:x y:y
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1729
    "draw a substring at the coordinate x/y -
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1730
     draw foreground-pixels only (in current paint-color),
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1731
     leaving background as-is. If the transformation involves scaling,
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1732
     the fonts point-size is scaled as appropriate."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1733
6472
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1734
    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
  1735
!
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1736
6472
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1737
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
  1738
    "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
  1739
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1740
    ^ 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
  1741
!
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1742
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1743
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
  1744
    "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
  1745
     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
  1746
     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
  1747
     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
  1748
     the case where paint and/or bgPaint are dithered colors.
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1749
     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
  1750
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1751
    |opaque index1 index2 easy w h savedPaint fgId bgId
6472
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1752
     fontId pX pY fontUsed fontsEncoding aString
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1753
     nSkipLeft nChars wString wSkipLeft index2Guess|
5360
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1754
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1755
    index1 := index1Arg.
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1756
    index2 := index2Arg.
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1757
    opaque := opaqueArg.
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1758
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1759
    "
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1760
     if backgroundPaint color is nil, we assume
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1761
     this is a non-opaque draw
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1762
    "
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1763
    bgPaint isNil ifTrue:[
6626
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1764
        opaque := false.
5360
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1765
    ].
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1766
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1767
    gcId isNil ifTrue:[
6472
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1768
        self initGC
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1769
    ].
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1770
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1771
    (aStringArg isString not or:[aStringArg isText]) ifTrue:[
6626
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1772
        "
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1773
         hook for non-strings (i.e. attributed text)
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1774
         that 'thing' should know how to display itself ...
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1775
        "
6472
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1776
        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
  1777
        ^ self
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1778
    ].
6472
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1779
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1780
    "/ transcode the string into the fonts encoding...
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1781
    aString := aStringArg.
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1782
    fontsEncoding := font encoding.
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1783
    (characterEncoding ~~ fontsEncoding) ifTrue:[
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1784
        [
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1785
            aString := CharacterEncoder encodeString:aString from:characterEncoding into:fontsEncoding.
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1786
        ] on:CharacterEncoderError do:[:ex|
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1787
            "substitute a default value for codes that cannot be represented
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1788
             in the new character set"
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1789
            ex proceedWith:ex defaultValue.
6626
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1790
        ].
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1791
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1792
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1793
    fontUsed := font.
6472
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1794
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1795
    transformation notNil ifTrue:[
6626
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1796
        pX := transformation applyToX:x.
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1797
        pY := transformation applyToY:y.
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1798
        transformation noScale ifFalse:[
6472
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1799
            |sz|
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1800
6626
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1801
            sz := font size.
6472
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1802
            sz notNil ifTrue:[
6626
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1803
                fontUsed := font asSize:(transformation applyScaleY:sz) rounded.
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1804
            ]
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1805
        ]
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1806
    ] ifFalse:[
6626
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1807
        pX := x.
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1808
        pY := y.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1809
    ].
6472
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1810
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1811
    fontUsed isAlienFont ifTrue:[
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1812
        "
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1813
         hook for alien fonts
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1814
         that 'font' should know how to display the string...
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1815
        "
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1816
        fontUsed displayString:aString from:index1 to:index2 x:x rounded y:y rounded in:self opaque:opaque maxWidth:maxWidth.
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1817
        ^ self
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1818
    ].
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1819
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1820
    pX := pX rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1821
    pY := pY rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1822
5360
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1823
    fontUsed := fontUsed onDevice:device.
6108
6ecfb89408d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6107
diff changeset
  1824
    fontId := fontUsed fontId.
6ecfb89408d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6107
diff changeset
  1825
    fontId isNil ifTrue:[
6626
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1826
        "this should not happen, since #onDevice tries replacement fonts"
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1827
        'STX[DeviceGraphicsContext] no font: ' errorPrint. fontUsed errorPrintCR.
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1828
        ^ self
5360
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1829
    ].
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1830
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1831
    "
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1832
     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
  1833
    "
6472
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1834
    paint isColor ifTrue:[
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1835
        easy := true.
6626
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1836
        fgId := paint colorId.
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1837
        fgId isNil ifTrue:[
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1838
            easy := false
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1839
        ]
6472
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1840
    ] ifFalse:[
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1841
        easy := false
5360
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1842
    ].
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1843
    opaque ifTrue:[
6472
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1844
        bgPaint isColor ifTrue:[
6626
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1845
            bgId := bgPaint colorId.
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1846
            bgId isNil ifTrue:[
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1847
                easy := false
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1848
            ]
6472
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1849
        ] ifFalse:[
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1850
            easy := false
6626
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1851
        ].
5360
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1852
    ].
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1853
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1854
    deviceFont ~~ fontUsed ifTrue:[
6626
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1855
        device setFont:fontId in:gcId.
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1856
        deviceFont := fontUsed
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1857
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1858
5360
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1859
    "/ 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
  1860
    "/ 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
  1861
    "/ which are drawn longer than 32k pixels.
6472
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1862
    (maxWidth notNil and:[(index2 - index1) > 500]) ifTrue:[
6626
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1863
        nSkipLeft := wSkipLeft := 0.
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1864
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1865
        "/ if the draw starts to the left of the window start,
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1866
        "/ skip some characters at the beginning...
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1867
        pX < 0 ifTrue:[
6472
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1868
"/ ('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
  1869
            nSkipLeft := (pX negated // font width) min:index2.                         "/ estimate
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1870
            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
  1871
            [ ((pX+wSkipLeft) > 0) and:[nSkipLeft > 0]] whileTrue:[                      "/ too many
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1872
                nSkipLeft := (nSkipLeft * 0.9) rounded.
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1873
                wSkipLeft := fontUsed widthOf:aString from:index1 to:index1+nSkipLeft-1.
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1874
            ].
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1875
            index1 := index1 + nSkipLeft.
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1876
            pX := pX + wSkipLeft.
5360
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1877
"/ ('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
  1878
        ].
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1879
5360
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1880
"/ ('n=%d w=%d' printfWith:nChars with:wString) printCR.
6472
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1881
        [ ((pX+wString) < maxWidth) and:[ index2Guess < index2] ] whileTrue:[  "/ not enough...
6626
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1882
            nChars := (nChars * 1.1) rounded.
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1883
            index2Guess := (index1+nChars-1) min:index2.
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1884
            wString := fontUsed widthOf:aString from:index1 to:index2Guess.
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1885
        ].
5360
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1886
"/ ('n=%d w=%d' printfWith:nChars with:wString) printCR.
6626
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1887
        index2 := index2Guess.
5360
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1888
    ].
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1889
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1890
    easy ifTrue:[
6626
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1891
        opaque ifTrue:[
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1892
            device setForeground:fgId background:bgId in:gcId.
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1893
            background := bgPaint.
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1894
        ] ifFalse:[
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1895
            device setForeground:fgId in:gcId.
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1896
        ].
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1897
        foreground := paint.
6472
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1898
        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
  1899
        ^ self
5360
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1900
    ].
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1901
6472
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1902
    "/
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1903
    "/ 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
  1904
    "/ but dithered or a pattern
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1905
    "/
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1906
    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
  1907
    h := fontUsed height.
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1908
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1909
    (fgId notNil and:[function == #copy]) ifTrue:[
6626
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1910
        "
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1911
         only bg is dithered or a pattern; fill with bg first ...
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1912
        "
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1913
        savedPaint := paint.
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1914
        self paint:bgPaint.
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1915
        self fillDeviceRectangleX:pX y:(pY - fontUsed ascent) width:w height:h.
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1916
        self paint:savedPaint.
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1917
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1918
        "
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1919
         then draw using fgPaint (which is a real color)
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1920
        "
6472
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1921
        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
  1922
        ^ self
5360
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1923
    ].
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1924
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1925
    "/ the very hard case (fg-dither)
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1926
6472
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1927
    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
  1928
5742
3edcdffa74ec changed: #displayString:from:to:x:y:opaque:
Stefan Vogel <sv@exept.de>
parents: 5406
diff changeset
  1929
    "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
  1930
    "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
  1931
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1932
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1933
displayString:aString x:x y:y
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1934
    "draw a string at the coordinate x/y -
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1935
     draw foreground-pixels only (in current paint-color),
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1936
     leaving background as-is. If the transformation involves scaling,
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1937
     the fonts point-size is scaled as appropriate."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1938
6472
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  1939
    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
  1940
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1941
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1942
displayUnscaledForm:formToDraw x:x y:y
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1943
    "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
  1944
     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
  1945
     current paint-color, leaving pixels with 0-bits unchanged
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1946
     (i.e. only 1-bits are drawn from the form).
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1947
     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
  1948
     settings are ignored and the form is drawn as-is.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1949
     Care must be taken, that the paint color is correctly allocated
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1950
     (by sending #on: to the color) before doing so.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1951
     Using functions other than #copy only makes sense if you are
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1952
     certain, that the colors are real colors (actually, only for
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1953
     noColor or allColor).
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1954
     The origins coordinate is transformed, but the image itself is unscaled."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1955
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1956
    |pX pY|
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1957
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1958
    transformation notNil ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1959
	pX := transformation applyToX:x.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1960
	pY := transformation applyToY:y.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1961
    ] ifFalse:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1962
	pX := x.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1963
	pY := y.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1964
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1965
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1966
    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
  1967
7ec770f2047a faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents: 1517
diff changeset
  1968
    "Modified: 12.4.1997 / 12:48:04 / cg"
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1969
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1970
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1971
displayUnscaledOpaqueForm:formToDraw x:x y:y
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1972
    "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
  1973
     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
  1974
     current paint-color, 0 bits in background color.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1975
     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
  1976
     settings are ignored and the form is drawn as-is (opaque).
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1977
     The origins coordinate is transformed, but the image itself is unscaled."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1978
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1979
    |pX pY|
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1980
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1981
    transformation notNil ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1982
	pX := transformation applyToX:x.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1983
	pY := transformation applyToY:y.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1984
    ] ifFalse:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1985
	pX := x.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1986
	pY := y.
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
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1989
    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
  1990
7ec770f2047a faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents: 1517
diff changeset
  1991
    "Modified: 12.4.1997 / 12:49:21 / cg"
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1992
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1993
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1994
displayUnscaledOpaqueString:aString from:index1 to:index2 x:x y:y
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1995
    "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
  1996
     Draw foreground pixels in paint-color, background pixels in bgPaint color."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1997
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1998
    |pX pY|
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1999
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2000
    transformation notNil ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2001
	pX := transformation applyToX:x.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2002
	pY := transformation applyToY:y.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2003
    ] ifFalse:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2004
	pX := x.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2005
	pY := y.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2006
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2007
    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
  2008
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2009
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2010
displayUnscaledOpaqueString:aString x:x y:y
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2011
    "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
  2012
     Draw foreground pixels in paint-color, background pixels in bgPaint color."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2013
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2014
    |pX pY|
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2015
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2016
    transformation notNil ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2017
	pX := transformation applyToX:x.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2018
	pY := transformation applyToY:y.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2019
    ] ifFalse:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2020
	pX := x.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2021
	pY := y.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2022
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2023
    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
  2024
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2025
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2026
displayUnscaledString:aString from:index1 to:index2 x:x y:y
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2027
    "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
  2028
     draw foreground-pixels only (in current paint-color), leaving background as-is."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2029
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2030
    |pX pY|
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2031
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2032
    transformation notNil ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2033
	pX := transformation applyToX:x.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2034
	pY := transformation applyToY:y.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2035
    ] ifFalse:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2036
	pX := x.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2037
	pY := y.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2038
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2039
    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
  2040
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2041
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2042
displayUnscaledString:aString x:x y:y
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2043
    "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
  2044
     draw foreground-pixels only (in current paint-color), leaving background as-is."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2045
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2046
    |pX pY|
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2047
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2048
    transformation notNil ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2049
	pX := transformation applyToX:x.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2050
	pY := transformation applyToY:y.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2051
    ] ifFalse:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2052
	pX := x.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2053
	pY := y.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2054
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2055
    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
  2056
! !
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2057
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2058
!DeviceGraphicsContext methodsFor:'drawing in device coordinates'!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2059
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2060
displayDeviceForm:aForm x:x y:y
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2061
    "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
  2062
     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
  2063
     current paint-color, leaving pixels with 0-bits unchanged
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2064
     (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
  2065
     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
  2066
     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
  2067
     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
  2068
7ec770f2047a faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents: 1517
diff changeset
  2069
     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
  2070
     otherwise its converted here, which slows down the draw.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2071
     No transformation or scaling is done.
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2072
     Care must be taken, that the paint color is correctly allocated
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2073
     (by sending #on: to the color) before doing so.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2074
     Using functions other than #copy only makes sense if you are
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2075
     certain, that the colors are real colors (actually, only for
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2076
     noColor or allColor)."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2077
6472
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  2078
    |id w h easy paintDither tmpForm tmpId tmpGCId
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2079
     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
  2080
     mask maskId deviceForm deviceFormGCId deviceMask colorMap|
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2081
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2082
    w := aForm width.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2083
    h := aForm height.
6612
5c05ccaf6275 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6514
diff changeset
  2084
    (w = 0 or:[h = 0]) ifTrue:[^ self].
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2085
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2086
    pX := x rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2087
    pY := y rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2088
1034
5f6f417dcb12 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1033
diff changeset
  2089
    deviceForm := aForm asFormOn:device.
2192
01f76f23f03f handle case when no deviceForms can be created,
Claus Gittinger <cg@exept.de>
parents: 2065
diff changeset
  2090
    deviceForm isNil ifTrue:[
6484
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2091
        'DeviceGraphicsContext [warning]: cannot create device-form' errorPrintCR.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2092
        ^self
2192
01f76f23f03f handle case when no deviceForms can be created,
Claus Gittinger <cg@exept.de>
parents: 2065
diff changeset
  2093
    ].
976
807b42b00353 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 975
diff changeset
  2094
    id := deviceForm id.
807b42b00353 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 975
diff changeset
  2095
807b42b00353 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 975
diff changeset
  2096
    id isNil ifTrue:[
6484
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2097
        'DeviceGraphicsContext [warning]: invalid form draw - ignored' errorPrintCR.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2098
        ^ self
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2099
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2100
    gcId isNil ifTrue:[
6484
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2101
        self initGC
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2102
    ].
2865
a97dc9f1e21a no need to create a GC for source bitmap under X
Claus Gittinger <cg@exept.de>
parents: 2835
diff changeset
  2103
    (deviceFormGCId := deviceForm gcId) isNil ifTrue:[
6484
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2104
        "/ device needGCForBitmapSource  - i.e. WIN32
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2105
        device platformName ~= 'X11' ifTrue:[
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2106
            deviceForm initGC.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2107
            deviceFormGCId := deviceForm gcId.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2108
        ]
2865
a97dc9f1e21a no need to create a GC for source bitmap under X
Claus Gittinger <cg@exept.de>
parents: 2835
diff changeset
  2109
    ].
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2110
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2111
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2112
     a deep form ignores paint/bgPaint settings
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2113
    "
1085
3513a4cae87b handle depth1-images with a mask
Claus Gittinger <cg@exept.de>
parents: 1064
diff changeset
  2114
    mask := aForm mask.
3513a4cae87b handle depth1-images with a mask
Claus Gittinger <cg@exept.de>
parents: 1064
diff changeset
  2115
6485
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2116
    ((aForm depth ~~ 1) or:[mask notNil]) ifTrue:[
6484
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2117
        mask notNil ifTrue:[
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2118
            mask depth ~~ 1 ifTrue:[
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2119
                'DEVGC: alpha channel not yet supported' errorPrintCR.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2120
            ] ifFalse:[
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2121
                deviceMask := mask asFormOn:device.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2122
                deviceMask isNil ifTrue:[
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2123
                    'DeviceGraphicsContext [warning]: cannot create device-mask' errorPrintCR.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2124
                    ^self
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2125
                ].
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2126
                maskId := deviceMask id.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2127
                maskId notNil ifTrue:[
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2128
                    deviceMask gcId isNil ifTrue:[deviceMask initGC].
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2129
                    allColor := Color allColor.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2130
                    allBits := allColor colorId.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2131
6485
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2132
                    (deviceForm depth == device depth
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2133
                     and:[aForm maskedPixelsAre0]) ifTrue:[
6484
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2134
                        "/ can do it without a temporary pixmap:
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2135
                        "/   or-in the form into the inverse stamped-out area
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2136
                        "/   of the destination.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2137
                        "/   Oring is of course only possible if we know that
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2138
                        "/   masked pixels are already zero in the form.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2139
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2140
                        "/ stamp out using mask
6485
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2141
                        device setForeground:0 background:allBits in:gcId.
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2142
                        device setFunction:#and in:gcId.
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2143
                        device
6484
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2144
                            copyPlaneFromPixmapId:maskId
6485
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2145
                            x:0
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2146
                            y:0
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2147
                            gc:(deviceMask gcId)
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2148
                            to:drawableId
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2149
                            x:pX
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2150
                            y:pY
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2151
                            gc:gcId
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2152
                            width:w
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2153
                            height:h.
6484
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2154
                        "/ or-in the form
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2155
                        device setFunction:#or in:gcId.
6485
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2156
                        device
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2157
                            copyFromPixmapId:id
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2158
                            x:0
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2159
                            y:0
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2160
                            gc:deviceFormGCId
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2161
                            to:drawableId
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2162
                            x:pX
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2163
                            y:pY
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2164
                            gc:gcId
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2165
                            width:w
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2166
                            height:h.
6484
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2167
                    ] ifFalse:[
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2168
                        "/ must do it slow, using a temporary form ..
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2169
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2170
                        "
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2171
                         create temp-form;
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2172
                        "
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2173
                        tmpForm := Form width:w height:h depth:device depth onDevice:device.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2174
                        tmpForm isNil ifTrue:[
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2175
                            'DeviceGraphicsContext [warning]: cannot create temp form' errorPrintCR.
6485
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2176
                            ^self
6484
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2177
                        ].
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2178
                        tmpForm initGC.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2179
                        tmpId := tmpForm id.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2180
                        tmpGCId := tmpForm gcId.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2181
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2182
                        "
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2183
                         fill tempform with image
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2184
                        "
6485
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2185
                        aForm depth == 1 ifTrue:[
6484
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2186
                            (colorMap := deviceForm colorMap) notNil ifTrue:[
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2187
                                colorMap size < 2 ifTrue:[
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2188
                                    device
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2189
                                        setForegroundColor:(colorMap at:1)
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2190
                                        in:tmpGCId.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2191
                                ] ifFalse:[
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2192
                                    device
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2193
                                        setForegroundColor:(colorMap at:2)
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2194
                                        backgroundColor:(colorMap at:1)
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2195
                                        in:tmpGCId.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2196
                                ]
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2197
                            ].
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2198
                            device
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2199
                                copyPlaneFromPixmapId:id
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2200
                                x:0
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2201
                                y:0
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2202
                                gc:deviceFormGCId
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2203
                                to:tmpId
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2204
                                x:0
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2205
                                y:0
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2206
                                gc:tmpGCId
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2207
                                width:w
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2208
                                height:h.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2209
                        ] ifFalse:[
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2210
                            device
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2211
                                copyFromPixmapId:id
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2212
                                x:0
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2213
                                y:0
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2214
                                gc:deviceFormGCId
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2215
                                to:tmpId
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2216
                                x:0
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2217
                                y:0
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2218
                                gc:tmpGCId
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2219
                                width:w
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2220
                                height:h.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2221
                        ].
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2222
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2223
                        "
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2224
                         stamp out mask in temp form
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2225
                        "
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2226
                        device 
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2227
                            setForeground:allBits background:0 in:tmpGCId;
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2228
                            setFunction:#and in:tmpGCId;
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2229
                            copyPlaneFromPixmapId:maskId
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2230
                                x:0
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2231
                                y:0
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2232
                                gc:(deviceMask gcId)
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2233
                                to:tmpId
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2234
                                x:0
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2235
                                y:0
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2236
                                gc:tmpGCId
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2237
                                width:w
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2238
                                height:h.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2239
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2240
                        "
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2241
                         stamp out mask in destination
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2242
                        "
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2243
                        device 
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2244
                            setForeground:0 background:allBits in:gcId;
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2245
                            setFunction:#and in:gcId;
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2246
                            copyPlaneFromPixmapId:maskId
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2247
                                x:0
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2248
                                y:0
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2249
                                gc:(deviceMask gcId)
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2250
                                to:drawableId
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2251
                                x:pX
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2252
                                y:pY
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2253
                                gc:gcId
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2254
                                width:w
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2255
                                height:h.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2256
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2257
                        "
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2258
                         or-in tempform-bits ...
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2259
                        "
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2260
                        device 
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2261
                            setFunction:#or in:gcId;
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2262
                            copyFromPixmapId:tmpId
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2263
                                x:0
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2264
                                y:0
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2265
                                gc:tmpGCId
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2266
                                to:drawableId
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2267
                                x:pX
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2268
                                y:pY
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2269
                                gc:gcId
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2270
                                width:w
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2271
                                height:h.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2272
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2273
                        "
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2274
                         release tempForm immediately
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2275
                         (although GC will eventually do it,
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2276
                          this creates less stress to the Xserver in the meanwhile ...)
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2277
                        "
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2278
                        tmpForm destroy.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2279
                    ].
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2280
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2281
                    "/ restore GC
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2282
                    foreground notNil ifTrue:[
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2283
                        device setForegroundColor:foreground in:gcId.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2284
                    ].
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2285
                    background notNil ifTrue:[
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2286
                        device setBackgroundColor:background in:gcId
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2287
                    ].
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2288
                    device setFunction:function in:gcId.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2289
                    ^ self
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2290
                ]
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2291
            ]
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2292
        ].
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2293
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2294
        device
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2295
            copyFromPixmapId:id
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2296
            x:0
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2297
            y:0
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2298
            gc:deviceForm gcId
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2299
            to:drawableId
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2300
            x:pX
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2301
            y:pY
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2302
            gc:gcId
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2303
            width:w
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2304
            height:h.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2305
        ^ self
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2306
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2307
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2308
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2309
     the following code is somewhat complicated, since it has to deal
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2310
     with dithered paint colors, which cannot be done directly on most
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2311
     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
  2312
     (just assume drawing a bitmap with dithered paint color ... sigh)
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2313
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2314
1507
358603f58138 faster drawing in or-mode.
Claus Gittinger <cg@exept.de>
parents: 1453
diff changeset
  2315
    easy := (function == #copy).
358603f58138 faster drawing in or-mode.
Claus Gittinger <cg@exept.de>
parents: 1453
diff changeset
  2316
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2317
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2318
     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
  2319
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2320
    easy ifTrue:[
6484
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2321
        paint isColor ifTrue:[
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2322
            paintDither := paint ditherForm.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2323
            paintDither notNil ifTrue:[
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2324
                easy := false.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2325
            ]
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2326
        ] ifFalse:[
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2327
            paintDither := paint.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2328
            easy := false
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2329
        ].
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2330
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2331
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2332
    allColor := Color allColor.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2333
    allBits := allColor colorId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2334
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2335
    easy ifTrue:[
6484
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
         paint is a real color
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2338
        "
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2339
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2340
        "
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2341
         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
  2342
         operation ...
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2343
        "
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2344
        fgId := paint colorId.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2345
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2346
        ((fgId ~~ ((1 bitShift:device depth)-1))
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2347
        and:[fgId ~~ allBits]) ifTrue:[
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2348
            "
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2349
             clear fg-bits ...
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2350
            "
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2351
            device setForeground:0 background:allBits in:gcId.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2352
            device setFunction:#and in:gcId.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2353
            device
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2354
                copyPlaneFromPixmapId:id
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:deviceFormGCId
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2358
                to:drawableId
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2359
                x:pX
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2360
                y:pY
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2361
                gc:gcId
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2362
                width:w
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2363
                height:h.
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
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2366
        fgId ~~ 0 ifTrue:[
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2367
            "
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2368
             or-in fg-bits ...
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2369
            "
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2370
            device setForeground:fgId background:0 in:gcId.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2371
            device setFunction:#or in:gcId.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2372
            device
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2373
                copyPlaneFromPixmapId:id
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2374
                x:0
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2375
                y:0
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2376
                gc:deviceFormGCId
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2377
                to:drawableId
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2378
                x:pX
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2379
                y:pY
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2380
                gc:gcId
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2381
                width:w
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2382
                height:h
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2383
        ].
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2384
        "
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2385
         flush foreground/background cache
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2386
        "
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2387
        foreground := nil.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2388
        background := nil.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2389
        device setFunction:function in:gcId.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2390
        ^ self
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2391
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2392
1507
358603f58138 faster drawing in or-mode.
Claus Gittinger <cg@exept.de>
parents: 1453
diff changeset
  2393
    function == #or ifTrue:[
6484
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2394
        easy := paint notNil
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2395
                and:[paint isColor
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2396
                and:[paint ditherForm isNil]].
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2397
        easy ifTrue:[
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2398
            easy := bgPaint isNil
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2399
                        or:[bgPaint isColor
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2400
                            and:[bgPaint colorId == 0]]
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2401
        ].
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2402
        easy ifTrue:[
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2403
            fgId := paint colorId.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2404
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2405
            fgId ~~ 0 ifTrue:[
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2406
                "
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2407
                 or-in fg-bits ...
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2408
                "
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2409
                device setForeground:fgId background:0 in:gcId.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2410
                device
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2411
                    copyPlaneFromPixmapId:id
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2412
                    x:0
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2413
                    y:0
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2414
                    gc:deviceFormGCId
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2415
                    to:drawableId
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2416
                    x:pX
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2417
                    y:pY
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2418
                    gc:gcId
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2419
                    width:w
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2420
                    height:h
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2421
            ].
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2422
            "
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2423
             flush foreground/background cache
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2424
            "
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2425
            foreground := nil.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2426
            background := nil.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2427
            ^ self
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2428
        ].
1507
358603f58138 faster drawing in or-mode.
Claus Gittinger <cg@exept.de>
parents: 1453
diff changeset
  2429
    ].
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2430
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2431
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2432
     hard case; paint is a dithered color
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2433
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2434
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2435
    noColor := Color noColor.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2436
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2437
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2438
     create temp-form;
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2439
    "
4756
dd597f8839cb changed #displayDeviceForm:x:y:
Claus Gittinger <cg@exept.de>
parents: 4752
diff changeset
  2440
    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
  2441
    tmpForm isNil ifTrue:[
6484
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2442
        'DeviceGraphicsContext [warning]: cannot create temp form' errorPrintCR.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2443
        ^self
2192
01f76f23f03f handle case when no deviceForms can be created,
Claus Gittinger <cg@exept.de>
parents: 2065
diff changeset
  2444
    ].
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
     fill tempform
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
    tmpForm paint:paint.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2449
    tmpForm fillRectangleX:0 y:0 width:w height:h.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2450
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2451
     stamp out background
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
    tmpForm paint:allColor on:noColor.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2454
    tmpForm function:#and.
976
807b42b00353 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 975
diff changeset
  2455
    tmpForm displayOpaqueForm:deviceForm x:0 y:0.
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
     stamp out foreground from destination
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
    device setForeground:0 background:allBits in:gcId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2460
    device setFunction:#and in:gcId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2461
    device
6484
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2462
        copyPlaneFromPixmapId:id
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2463
        x:0
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2464
        y:0
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2465
        gc:deviceFormGCId
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2466
        to:drawableId
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2467
        x:pX
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2468
        y:pY
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2469
        gc:gcId
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2470
        width:w
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2471
        height:h.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2472
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2473
     or-in temp into destination
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2474
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2475
    device setForeground:allBits background:0 in:gcId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2476
    device setFunction:#or in:gcId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2477
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2478
    device
6484
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2479
        copyFromPixmapId:tmpForm id
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2480
        x:0
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2481
        y:0
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2482
        gc:tmpForm gcId
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2483
        to:drawableId
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2484
        x:pX
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2485
        y:pY
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2486
        gc:gcId
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2487
        width:w
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2488
        height:h.
1637
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  2489
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  2490
    "
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  2491
     release tempForm immediately
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2492
     (although GC will eventually do it,
1637
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  2493
      this creates less stress to the Xserver in the meanwhile ...)
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  2494
    "
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  2495
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  2496
    tmpForm destroy.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2497
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2498
     flush foreground/background cache
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2499
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2500
    foreground := nil.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2501
    background := nil.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2502
    device setFunction:function in:gcId.
768
77e4f9d30a22 fixes for b&w screens
Claus Gittinger <cg@exept.de>
parents: 745
diff changeset
  2503
4756
dd597f8839cb changed #displayDeviceForm:x:y:
Claus Gittinger <cg@exept.de>
parents: 4752
diff changeset
  2504
    "Modified: / 27-05-2007 / 12:45:10 / cg"
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2505
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2506
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2507
displayDeviceLineFromX:x0 y:y0 toX:x1 y:y1
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2508
    "draw a line (with current paint-color) in device coordinate space.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2509
     This ignores any transformations. The coordinates must be integers."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2510
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2511
    gcId isNil ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2512
	self initGC
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2513
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2514
    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
  2515
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2516
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2517
displayDeviceOpaqueForm:aForm x:x y:y
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2518
    "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
  2519
     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
  2520
     current paint-color and 0-bits in the bgPaint color.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2521
     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
  2522
     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
  2523
     Any mask is ignored.
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2524
     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
  2525
     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
  2526
     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
  2527
     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
  2528
     its converted here, which slows down the draw.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2529
     Drawing is in device coordinates; no scaling is done."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2530
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2531
    |id w h easy savedPaint bgForm fgForm tmpForm
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2532
     fgId bgId noColor allColor allBits dx dy
6485
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2533
     pX pY deviceDepth deviceForm map|
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2534
1033
b5cd84ed805f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1029
diff changeset
  2535
    deviceForm := aForm asFormOn:device.
976
807b42b00353 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 975
diff changeset
  2536
    id := deviceForm id.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2537
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2538
    "temporary ..."
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2539
    (id isNil
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2540
    or:[aForm graphicsDevice ~~ device]) ifTrue:[
6485
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2541
        deviceForm := deviceForm asFormOn:device.
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2542
        id := deviceForm id.
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2543
        id isNil ifTrue:[
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2544
            'DeviceGraphicsContext [warning]: invalid form draw - ignored' errorPrintCR.
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2545
            ^ self
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2546
        ].
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2547
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2548
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2549
    gcId isNil ifTrue:[
6485
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2550
        self initGC
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2551
    ].
2065
27bf0cf42e45 changes for WIN32
Claus Gittinger <cg@exept.de>
parents: 2049
diff changeset
  2552
    deviceForm gcId isNil ifTrue:[deviceForm initGC].
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2553
1592
7ec770f2047a faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents: 1517
diff changeset
  2554
    w := aForm width.
7ec770f2047a faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents: 1517
diff changeset
  2555
    h := aForm height.
7ec770f2047a faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents: 1517
diff changeset
  2556
7ec770f2047a faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents: 1517
diff changeset
  2557
    pX := x rounded.
7ec770f2047a faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents: 1517
diff changeset
  2558
    pY := y rounded.
7ec770f2047a faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents: 1517
diff changeset
  2559
902
7f5d81d377de opaque image display fix
Claus Gittinger <cg@exept.de>
parents: 895
diff changeset
  2560
    "
7f5d81d377de opaque image display fix
Claus Gittinger <cg@exept.de>
parents: 895
diff changeset
  2561
     a deep form ignores paint/bgPaint settings
7f5d81d377de opaque image display fix
Claus Gittinger <cg@exept.de>
parents: 895
diff changeset
  2562
     and is always drawn opaque.
7f5d81d377de opaque image display fix
Claus Gittinger <cg@exept.de>
parents: 895
diff changeset
  2563
    "
7f5d81d377de opaque image display fix
Claus Gittinger <cg@exept.de>
parents: 895
diff changeset
  2564
    (aForm depth ~~ 1) ifTrue:[
6485
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2565
        device
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2566
            copyFromPixmapId:id
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2567
            x:0
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2568
            y:0
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2569
            gc:deviceForm gcId
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2570
            to:drawableId
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2571
            x:pX
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2572
            y:pY
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2573
            gc:gcId
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2574
            width:w
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2575
            height:h.
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2576
        ^ self
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2577
    ].
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2578
    map := aForm colorMap.
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2579
    map notNil ifTrue:[
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2580
        paint := map at:2.
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2581
        bgPaint := map at:1.
902
7f5d81d377de opaque image display fix
Claus Gittinger <cg@exept.de>
parents: 895
diff changeset
  2582
    ].
7f5d81d377de opaque image display fix
Claus Gittinger <cg@exept.de>
parents: 895
diff changeset
  2583
7f5d81d377de opaque image display fix
Claus Gittinger <cg@exept.de>
parents: 895
diff changeset
  2584
    "/ 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
  2585
7f5d81d377de opaque image display fix
Claus Gittinger <cg@exept.de>
parents: 895
diff changeset
  2586
    bgPaint isNil ifTrue:[
6485
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2587
        self displayDeviceForm:aForm x:x y:y.
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2588
        ^ self
902
7f5d81d377de opaque image display fix
Claus Gittinger <cg@exept.de>
parents: 895
diff changeset
  2589
    ].
7f5d81d377de opaque image display fix
Claus Gittinger <cg@exept.de>
parents: 895
diff changeset
  2590
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2591
    "the following code is somewhat complicated, since it has to deal
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2592
     with dithered fg/bg colors, which cannot be done directly on most
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2593
     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
  2594
     (just assume drawing a bitmap with dithered fg/bg colors ... sigh)
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
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
     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
  2599
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2600
    easy := true.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2601
    paint isColor ifFalse:[
6485
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2602
        easy := false
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2603
    ] ifTrue:[
6485
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2604
        fgId := paint colorId.
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2605
        fgId isNil ifTrue:[
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2606
            easy := false
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2607
        ]
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2608
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2609
    bgPaint isColor ifFalse:[
6485
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2610
        easy := false
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2611
    ] ifTrue:[
6485
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2612
        bgId := bgPaint colorId.
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2613
        bgId isNil ifTrue:[
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2614
            easy := false
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2615
        ]
732
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
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2618
    easy ifTrue:[
6485
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2619
        "
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2620
         easy: both paint and bgPaint are real colors
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2621
        "
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2622
        ((foreground ~~ paint) or:[background ~~ bgPaint]) ifTrue:[
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2623
            device setForeground:fgId background:bgId in:gcId.
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2624
            foreground := paint.
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2625
            background := bgPaint.
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2626
        ].
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2627
        device
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2628
            copyPlaneFromPixmapId:id
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2629
            x:0
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2630
            y:0
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2631
            gc:(deviceForm gcId)
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2632
            to:drawableId
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2633
            x:pX
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2634
            y:pY
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2635
            gc:gcId
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2636
            width:w
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2637
            height:h.
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2638
        ^ self
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2639
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2640
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2641
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2642
     hard case: paint and/or bgPaint are dithered or patterns
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2643
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2644
    allColor := Color allColor.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2645
    allBits := allColor colorId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2646
    deviceDepth := device depth.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2647
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2648
    (fgId notNil and:[function == #copy]) ifTrue:[
6485
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2649
        "
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2650
         only bg is dithered; fill with bg first ...
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2651
        "
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2652
        savedPaint := paint.
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2653
        self paint:bgPaint.
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2654
        self fillDeviceRectangleX:pX y:pY width:w height:h.
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2655
        self paint:savedPaint.
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2656
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2657
        "
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2658
         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
  2659
         operation ...
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2660
        "
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2661
        ((fgId ~~ ((1 bitShift:deviceDepth)-1))
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2662
        and:[fgId ~~ allBits]) ifTrue:[
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2663
            "
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2664
             clear fg-bits ...
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2665
            "
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2666
            device setForeground:0 background:allBits in:gcId.
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2667
            device setFunction:#and in:gcId.
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2668
            device
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2669
                copyPlaneFromPixmapId:id
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2670
                x:0
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2671
                y:0
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2672
                gc:(deviceForm gcId)
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2673
                to:drawableId
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2674
                x:pX
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2675
                y:pY
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2676
                gc:gcId
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2677
                width:w
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2678
                height:h
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2679
        ].
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2680
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2681
        fgId ~~ 0 ifTrue:[
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2682
            "
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2683
             or-in fg-bits ...
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2684
            "
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2685
            device setForeground:fgId background:0 in:gcId.
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2686
            device setFunction:#or in:gcId.
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2687
            device
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2688
                copyPlaneFromPixmapId:id
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2689
                x:0
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2690
                y:0
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2691
                gc:(deviceForm gcId)
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2692
                to:drawableId
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2693
                x:pX
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2694
                y:pY
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2695
                gc:gcId
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2696
                width:w
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2697
                height:h
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2698
        ].
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2699
        "
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2700
         flush foreground/background cache
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2701
        "
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2702
        foreground := nil.
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2703
        background := nil.
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2704
        device setFunction:function in:gcId.
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2705
        ^ self
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2706
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2707
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2708
    (bgId notNil and:[function == #copy]) ifTrue:[
6485
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2709
        "
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2710
         only fg is dithered; fill with fg first ...
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2711
        "
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2712
        self fillDeviceRectangleX:pX y:pY width:w height:h.
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2713
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2714
        "
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2715
         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
  2716
         operation ...
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2717
        "
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2718
        ((bgId ~~ ((1 bitShift:deviceDepth)-1))
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2719
        and:[bgId ~~ allBits]) ifTrue:[
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2720
            "
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2721
             clear bg-bits ...
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2722
            "
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2723
            device setForeground:allBits background:0 in:gcId.
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2724
            device setFunction:#and in:gcId.
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2725
            device
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2726
                copyPlaneFromPixmapId:id
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2727
                x:0
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2728
                y:0
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2729
                gc:(deviceForm gcId)
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2730
                to:drawableId
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2731
                x:pX
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2732
                y:pY
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2733
                gc:gcId
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2734
                width:w
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2735
                height:h
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2736
        ].
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2737
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2738
        "
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2739
         or-in bg-bits ...
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2740
        "
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2741
        bgId ~~ 0 ifTrue:[
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2742
            device setForeground:0 background:bgId in:gcId.
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2743
            device setFunction:#or in:gcId.
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2744
            device
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2745
                copyPlaneFromPixmapId:id
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2746
                x:0
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2747
                y:0
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2748
                gc:(deviceForm gcId)
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2749
                to:drawableId
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2750
                x:pX
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2751
                y:pY
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2752
                gc:gcId
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2753
                width:w
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2754
                height:h
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2755
        ].
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2756
        "
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2757
         flush foreground/background cache
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
        foreground := nil.
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2760
        background := nil.
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2761
        device setFunction:function in:gcId.
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2762
        ^ self
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2763
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2764
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2765
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2766
     very hard case; both fg and bg are dithered colors
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2767
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2768
    noColor := Color noColor.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2769
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2770
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2771
     create temp-forms;
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2772
    "
4781
7f2473db5652 Change senders of obsolete messages Form>>...on: to ...onDevice:
Stefan Vogel <sv@exept.de>
parents: 4756
diff changeset
  2773
    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
  2774
    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
  2775
    tmpForm := Form width:w height:h depth:deviceDepth onDevice:device.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2776
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2777
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2778
     fill
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
    dx := dy := 0.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2781
    maskOrigin notNil ifTrue:[
6485
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2782
        dx := maskOrigin x.
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2783
        dy := maskOrigin y
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2784
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2785
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2786
    bgForm paint:bgPaint.
4983
14c28ec55880 Replace usage of obsolete methods
Stefan Vogel <sv@exept.de>
parents: 4914
diff changeset
  2787
    bgForm maskOriginX:(x negated + dx) y:(y negated + dy).
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2788
    bgForm fillRectangleX:0 y:0 width:w height:h.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2789
    fgForm paint:paint.
4983
14c28ec55880 Replace usage of obsolete methods
Stefan Vogel <sv@exept.de>
parents: 4914
diff changeset
  2790
    fgForm maskOriginX:(x negated + dx) y:(y negated + dy).
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2791
    fgForm fillRectangleX:0 y:0 width:w height:h.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2792
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2793
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2794
     stamp-out background
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2795
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2796
    bgForm paint:noColor on:allColor.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2797
    bgForm function:#and.
976
807b42b00353 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 975
diff changeset
  2798
    bgForm displayOpaqueForm:deviceForm x:0 y:0.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2799
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2800
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2801
     stamp-out foreground
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2802
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2803
    fgForm paint:allColor on:noColor.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2804
    fgForm function:#and.
976
807b42b00353 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 975
diff changeset
  2805
    fgForm displayOpaqueForm:deviceForm x:0 y:0.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2806
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2807
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2808
     clear tempform
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2809
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2810
    tmpForm paint:noColor.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2811
    tmpForm fillRectangleX:0 y:0 width:w height:h.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2812
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2813
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2814
     merge fg-temp and bg-temp into tmp
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2815
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2816
    tmpForm function:#or.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2817
    tmpForm paint:noColor on:allColor.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2818
    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
  2819
    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
  2820
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2821
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2822
     finally, draw it
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2823
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2824
    device setForeground:0 background:allBits in:gcId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2825
    device
6485
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2826
        copyFromPixmapId:tmpForm id
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2827
        x:0
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2828
        y:0
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2829
        gc:tmpForm gcId
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2830
        to:drawableId
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2831
        x:pX
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2832
        y:pY
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2833
        gc:gcId
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2834
        width:w
14afc96826c4 Fix Depth1Icons drawn in black.
Stefan Vogel <sv@exept.de>
parents: 6472
diff changeset
  2835
        height:h.
1637
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  2836
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  2837
    "
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  2838
     release tempForms immediately
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2839
     (although GC will eventually do it,
1637
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  2840
      this creates less stress to the Xserver in the meanwhile ...)
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  2841
    "
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  2842
    fgForm destroy.
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  2843
    bgForm destroy.
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  2844
    tmpForm destroy.
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  2845
732
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
     flush foreground/background cache
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2848
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2849
    foreground := nil.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2850
    background := nil.
868
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
  2851
1637
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  2852
    "Modified: 22.4.1997 / 21:44:10 / cg"
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2853
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2854
6472
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  2855
displayDeviceOpaqueString:aStringArg from:index1 to:index2 in:font x:x y:y
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2856
    "draw a substring at the coordinate x/y - draw foreground pixels in
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2857
     paint-color and background pixels in bgPaint-color.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2858
     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
  2859
     the case where paint and/or bgPaint are dithered colors.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2860
     No translation or scaling is done."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2861
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2862
    |easy w h savedPaint fgId bgId allColor allBits noColor
6472
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  2863
     id bgForm fgForm tmpForm maskForm dx dy pX pY fontUsed aString
4026
882de378f763 no longer as string for its encoding;
Claus Gittinger <cg@exept.de>
parents: 3943
diff changeset
  2864
     deviceDepth fontsEncoding ascent|
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2865
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2866
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2867
     if backgroundPaint color is nil, we assume
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2868
     this is a non-opaque draw
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2869
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2870
    bgPaint isNil ifTrue:[
6472
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  2871
        self displayDeviceString:aStringArg from:index1 to:index2 x:x y:y.
1637
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  2872
        ^ self
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2873
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2874
6472
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  2875
    (aStringArg isString not or:[aStringArg isText]) ifTrue:[
1637
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  2876
        "
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  2877
         hook for non-strings (i.e. attributed text)
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  2878
         that 'thing' should know how to display itself ...
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  2879
        "
6472
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  2880
        aStringArg displayOpaqueOn:self x:x y:y from:index1 to:index2.
1637
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  2881
        ^ self
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2882
    ].
6210
af0bf039ec07 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6108
diff changeset
  2883
af0bf039ec07 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6108
diff changeset
  2884
    pX := x rounded.
af0bf039ec07 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6108
diff changeset
  2885
    pY := y rounded.
af0bf039ec07 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6108
diff changeset
  2886
6472
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  2887
    aString := aStringArg.
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  2888
    fontsEncoding := font encoding.
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  2889
    (characterEncoding ~~ fontsEncoding) ifTrue:[
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  2890
        [
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  2891
            aString := CharacterEncoder encodeString:aString from:characterEncoding into:fontsEncoding.
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  2892
        ] on:CharacterEncoderError do:[:ex|
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  2893
            "substitute a default value for codes that cannot be represented
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  2894
             in the new character set"
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  2895
            ex proceedWith:ex defaultValue.
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  2896
        ].
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  2897
    ].
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  2898
6108
6ecfb89408d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6107
diff changeset
  2899
    font isAlienFont ifTrue:[
6ecfb89408d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6107
diff changeset
  2900
        "
6ecfb89408d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6107
diff changeset
  2901
         hook for alien fonts
6ecfb89408d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6107
diff changeset
  2902
         that 'font' should know how to display the string ...
6ecfb89408d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6107
diff changeset
  2903
        "
6210
af0bf039ec07 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6108
diff changeset
  2904
        font displayOpaqueString:aString from:index1 to:index2 x:pX y:pY in:self.
6108
6ecfb89408d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6107
diff changeset
  2905
        ^ self
6ecfb89408d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6107
diff changeset
  2906
    ].
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2907
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2908
    gcId isNil ifTrue:[
1637
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  2909
        self initGC
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2910
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2911
4172
0d5bc2a70b83 Do not refer to uninitialized variable fontUsed
Stefan Vogel <sv@exept.de>
parents: 4146
diff changeset
  2912
    fontUsed := font onDevice:device.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2913
    id := fontUsed fontId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2914
    id isNil ifTrue:[
6108
6ecfb89408d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6107
diff changeset
  2915
        "this should not happen, since #onDevice tries replacement fonts"
6ecfb89408d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6107
diff changeset
  2916
        'STX[DeviceGraphicsContext] no font: ' errorPrint. fontUsed errorPrintCR.
1637
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  2917
        ^ self
732
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
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2920
    deviceFont ~~ fontUsed ifTrue:[
1637
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  2921
        device setFont:id in:gcId.
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  2922
        deviceFont := fontUsed
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
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2926
     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
  2927
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2928
    easy := true.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2929
    paint isColor ifFalse:[
1637
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  2930
        easy := false
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2931
    ] ifTrue:[
1637
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  2932
        fgId := paint colorId.
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  2933
        fgId isNil ifTrue:[
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  2934
            easy := false
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  2935
        ]
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2936
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2937
    bgPaint isColor ifFalse:[
1637
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  2938
        easy := false
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2939
    ] ifTrue:[
1637
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  2940
        bgId := bgPaint colorId.
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  2941
        bgId isNil ifTrue:[
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  2942
            easy := false
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  2943
        ]
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2944
    ].
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
    easy ifTrue:[
1637
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  2947
        device setForeground:fgId background:bgId in:gcId.
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  2948
        foreground := paint.
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  2949
        background := bgPaint.
6472
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  2950
        device displayOpaqueString:aString from:index1 to:index2 x:pX y:pY in:drawableId with:gcId.
1637
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  2951
        ^ self
732
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
6472
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  2954
    w := fontUsed widthOf:aString from:index1 to:index2.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2955
    h := fontUsed height.
3666
01d7bf1d2333 fixed Text drawing in displayString
Michael Beyl <mb@exept.de>
parents: 3630
diff changeset
  2956
    ascent := fontUsed ascent.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2957
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2958
    (fgId notNil and:[function == #copy]) ifTrue:[
1637
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  2959
        "
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  2960
         only bg is dithered; fill with bg first ...
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  2961
        "
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  2962
        savedPaint := paint.
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  2963
        self paint:bgPaint.
3666
01d7bf1d2333 fixed Text drawing in displayString
Michael Beyl <mb@exept.de>
parents: 3630
diff changeset
  2964
        self fillRectangleX:pX y:(pY - ascent) width:w height:h.
1637
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  2965
        self paint:savedPaint.
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  2966
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  2967
        "
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  2968
         then draw using fgPaint (which is a real color)
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  2969
        "
6472
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  2970
        device displayString:aString from:index1 to:index2 x:pX y:pY in:drawableId with:gcId.
1637
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  2971
        ^ self
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2972
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2973
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2974
    allColor := Color allColor.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2975
    allBits := allColor colorId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2976
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2977
    deviceDepth := device depth.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2978
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2979
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2980
     the code below is correct, but some (all?) implementations of the
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2981
     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
  2982
     Therefore we use the slower code below.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2983
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2984
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2985
"/    (bgId notNil and:[function == #copy]) ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2986
"/      "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2987
"/       only fg is dithered; fill with fg first ...
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2988
"/      "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2989
"/      self fillRectangleX:pX y:(pY - fontUsed ascent) width:w height:h.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2990
"/
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2991
"/      "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2992
"/       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
  2993
"/       operation ...
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2994
"/      "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2995
"/      ((bgId ~~ ((1 bitShift:deviceDepth)-1))
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2996
"/      and:[bgId ~~ allBits]) ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2997
"/          "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2998
"/           clear bg bits ...
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2999
"/          "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3000
"/          device setForeground:allBits background:0 in:gcId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3001
"/          device setFunction:#and in:gcId.
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3002
"/          device displayOpaqueString:s
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3003
"/                                from:index1 to:index2
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3004
"/                                   x:pX y:pY
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3005
"/                                  in:drawableId with:gcId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3006
"/      ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3007
"/
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3008
"/      "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3009
"/       or-in bg bits ...
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3010
"/      "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3011
"/      bgId ~~ 0 ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3012
"/          device setForeground:0 background:bgId in:gcId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3013
"/          device setFunction:#or in:gcId.
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3014
"/          device displayOpaqueString:s
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3015
"/                                from:index1 to:index2
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3016
"/                                   x:pX y:pY
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3017
"/                                  in:drawableId with:gcId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3018
"/      ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3019
"/      "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3020
"/       flush foreground/background cache
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3021
"/      "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3022
"/      foreground := nil.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3023
"/      background := nil.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3024
"/      device setFunction:function in:gcId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3025
"/      ^ self
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3026
"/  ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3027
768
77e4f9d30a22 fixes for b&w screens
Claus Gittinger <cg@exept.de>
parents: 745
diff changeset
  3028
    (bgId notNil and:[function == #copy]) ifTrue:[
1637
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  3029
        "
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  3030
         only fg is dithered; fill with bg first ...
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  3031
        "
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  3032
        device setForeground:bgId in:gcId.
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  3033
        device setFunction:#copy in:gcId.
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  3034
        device setBitmapMask:nil in:gcId.
3666
01d7bf1d2333 fixed Text drawing in displayString
Michael Beyl <mb@exept.de>
parents: 3630
diff changeset
  3035
        self fillRectangleX:pX y:(pY - ascent) width:w height:h.
1637
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  3036
2024
4ab032384c63 checkin from browser
tz
parents: 2018
diff changeset
  3037
        mask notNil ifTrue:[
4ab032384c63 checkin from browser
tz
parents: 2018
diff changeset
  3038
            "/ draw fg dithered
4ab032384c63 checkin from browser
tz
parents: 2018
diff changeset
  3039
            (mask depth == 1) ifTrue:[
4ab032384c63 checkin from browser
tz
parents: 2018
diff changeset
  3040
                device setBitmapMask:mask id in:gcId.
3530
d90974c7d477 setForegroundColor/setBackgroundColor
james
parents: 3429
diff changeset
  3041
                device setForegroundColor:foreground backgroundColor:background in:gcId.
2024
4ab032384c63 checkin from browser
tz
parents: 2018
diff changeset
  3042
            ] ifFalse:[
4ab032384c63 checkin from browser
tz
parents: 2018
diff changeset
  3043
                device setPixmapMask:mask id in:gcId
4ab032384c63 checkin from browser
tz
parents: 2018
diff changeset
  3044
            ].
1637
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  3045
        ].
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  3046
6472
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  3047
        device displayString:aString from:index1 to:index2 x:pX y:pY in:drawableId with:gcId.
1637
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  3048
        ^ self.
832
064890dcfabd fixed opaque string draw with deep-dither
Claus Gittinger <cg@exept.de>
parents: 786
diff changeset
  3049
    ].
064890dcfabd fixed opaque string draw with deep-dither
Claus Gittinger <cg@exept.de>
parents: 786
diff changeset
  3050
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3051
    "
832
064890dcfabd fixed opaque string draw with deep-dither
Claus Gittinger <cg@exept.de>
parents: 786
diff changeset
  3052
     very hard case, both fg and bg are dithered colors/images
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3053
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3054
    noColor := Color noColor.
4026
882de378f763 no longer as string for its encoding;
Claus Gittinger <cg@exept.de>
parents: 3943
diff changeset
  3055
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3056
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3057
     create temp-forms;
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3058
    "
4781
7f2473db5652 Change senders of obsolete messages Form>>...on: to ...onDevice:
Stefan Vogel <sv@exept.de>
parents: 4756
diff changeset
  3059
    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
  3060
    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
  3061
    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
  3062
    maskForm := Form width:w height:h depth:deviceDepth onDevice:device.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3063
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3064
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3065
     fill
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
    dx := 0.
3666
01d7bf1d2333 fixed Text drawing in displayString
Michael Beyl <mb@exept.de>
parents: 3630
diff changeset
  3068
    dy := ascent.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3069
    maskOrigin notNil ifTrue:[
1637
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  3070
        dx := maskOrigin x.
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  3071
        dy := dy + maskOrigin y
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3072
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3073
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3074
    bgForm paint:bgPaint.
4983
14c28ec55880 Replace usage of obsolete methods
Stefan Vogel <sv@exept.de>
parents: 4914
diff changeset
  3075
    bgForm maskOriginX:(pX negated + dx) y:(pY negated + dy).
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3076
    bgForm fillRectangleX:0 y:0 width:w height:h.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3077
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3078
    fgForm paint:paint.
4983
14c28ec55880 Replace usage of obsolete methods
Stefan Vogel <sv@exept.de>
parents: 4914
diff changeset
  3079
    fgForm maskOriginX:(pX negated + dx) y:(pY negated + dy).
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3080
    fgForm fillRectangleX:0 y:0 width:w height:h.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3081
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3082
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3083
     stamp-out background (have now bg-bits with fg=0 in bgForm)
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3084
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3085
    bgForm font:fontUsed.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3086
    bgForm paint:noColor on:allColor.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3087
    bgForm function:#and.
6472
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  3088
    bgForm displayString:aString from:index1 to:index2 x:0 y:ascent.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3089
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3090
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3091
     stamp-out foreground
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3092
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3093
    maskForm font:fontUsed.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3094
    maskForm paint:allColor on:noColor.
6472
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  3095
    maskForm displayOpaqueString:aString from:index1 to:index2 x:0 y:ascent.
732
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
    fgForm function:#and.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3098
    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
  3099
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
     clear tempform
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3102
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3103
    tmpForm paint:noColor.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3104
    tmpForm fillRectangleX:0 y:0 width:w height:h.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3105
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3106
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3107
     merge fg-temp and bg-temp into tmp
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3108
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3109
    tmpForm function:#or.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3110
    tmpForm paint:noColor on:allColor.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3111
    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
  3112
    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
  3113
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3114
     finally, draw it
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
    device setForeground:0 background:allBits in:gcId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3117
    device
1637
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  3118
        copyFromId:tmpForm id
4026
882de378f763 no longer as string for its encoding;
Claus Gittinger <cg@exept.de>
parents: 3943
diff changeset
  3119
        x:0 y:0 gc:tmpForm gcId
882de378f763 no longer as string for its encoding;
Claus Gittinger <cg@exept.de>
parents: 3943
diff changeset
  3120
        to:drawableId
882de378f763 no longer as string for its encoding;
Claus Gittinger <cg@exept.de>
parents: 3943
diff changeset
  3121
        x:pX y:(pY-ascent) gc:gcId
882de378f763 no longer as string for its encoding;
Claus Gittinger <cg@exept.de>
parents: 3943
diff changeset
  3122
        width:w height:h.
1637
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  3123
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  3124
    "
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  3125
     release tempForms immediately
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3126
     (although GC will eventually do it,
1637
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  3127
      this creates less stress to the Xserver in the meanwhile ...)
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  3128
    "
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  3129
    tmpForm destroy.
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  3130
    fgForm destroy.
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  3131
    bgForm destroy.
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  3132
    maskForm destroy.
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  3133
732
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
     flush foreground/background cache
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3136
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3137
    foreground := nil.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3138
    background := nil.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3139
1805
532a11ba8458 tuned-out another send if encoding is wrong in display-string
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  3140
    "Modified: 1.7.1997 / 17:08:46 / cg"
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3141
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3142
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3143
displayDeviceOpaqueString:aString from:index1 to:index2 x:x y:y
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3144
    "draw a substring at the coordinate x/y - draw foreground pixels in
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3145
     paint-color and background pixels in bgPaint-color.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3146
     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
  3147
     the case where paint and/or bgPaint are dithered colors.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3148
     No translation or scaling is done."
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
    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
  3151
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3152
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3153
displayDeviceOpaqueString:aString x:x y:y
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3154
    "draw a string at the coordinate x/y - draw foreground pixels in
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3155
     paint-color and background pixels in bgPaint-color.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3156
     No translation or scaling is done"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3157
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3158
    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
  3159
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3160
6472
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  3161
displayDeviceString:aStringArg from:index1 to:index2 in:font x:x y:y
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3162
    "draw a substring at the coordinate x/y -
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3163
     draw foreground-pixels only (in current paint-color), leaving background as-is.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3164
     No translation or scaling is done"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3165
6472
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  3166
    |id pX pY fontUsed aString fontsEncoding|
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3167
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3168
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3169
     hook for non-strings (i.e. attributed text)
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3170
    "
6472
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  3171
    (aStringArg isString not or:[aStringArg isText]) ifTrue:[
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  3172
        ^ aStringArg displayOn:self x:x y:y from:index1 to:index2
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3173
    ].
6210
af0bf039ec07 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6108
diff changeset
  3174
af0bf039ec07 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6108
diff changeset
  3175
    pX := x rounded.
af0bf039ec07 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6108
diff changeset
  3176
    pY := y rounded.
af0bf039ec07 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6108
diff changeset
  3177
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3178
    gcId isNil ifTrue:[
6472
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  3179
        self initGC
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3180
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3181
6472
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  3182
    aString := aStringArg.
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  3183
    fontsEncoding := font encoding.
4056
67c4686afbc6 characterEncoding stuff
Claus Gittinger <cg@exept.de>
parents: 4031
diff changeset
  3184
    (characterEncoding ~~ fontsEncoding) ifTrue:[
6472
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  3185
        [
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  3186
            aString := CharacterEncoder encodeString:aString from:characterEncoding into:fontsEncoding.
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  3187
        ] on:CharacterEncoderError do:[:ex|
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  3188
            "substitute a default value for codes that cannot be represented
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  3189
             in the new character set"
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  3190
            ex proceedWith:ex defaultValue.
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  3191
        ].
4026
882de378f763 no longer as string for its encoding;
Claus Gittinger <cg@exept.de>
parents: 3943
diff changeset
  3192
    ].
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3193
6108
6ecfb89408d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6107
diff changeset
  3194
    font isAlienFont ifTrue:[
6ecfb89408d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6107
diff changeset
  3195
        "
6ecfb89408d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6107
diff changeset
  3196
         hook for alien fonts
6ecfb89408d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6107
diff changeset
  3197
         that 'font' should know how to display the string ...
6ecfb89408d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6107
diff changeset
  3198
        "
6472
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  3199
        font displayString:aString from:index1 to:index2 x:pX y:pY in:self.
6108
6ecfb89408d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6107
diff changeset
  3200
        ^ self
6ecfb89408d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6107
diff changeset
  3201
    ].
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3202
4172
0d5bc2a70b83 Do not refer to uninitialized variable fontUsed
Stefan Vogel <sv@exept.de>
parents: 4146
diff changeset
  3203
    fontUsed := font onDevice:device.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3204
    id := fontUsed fontId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3205
    id isNil ifTrue:[
6108
6ecfb89408d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6107
diff changeset
  3206
        "this should not happen, since #onDevice tries replacement fonts"
6ecfb89408d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6107
diff changeset
  3207
        'STX[DeviceGraphicsContext] no font: ' errorPrint. fontUsed errorPrintCR.
6ecfb89408d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6107
diff changeset
  3208
        ^ self
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3209
    ] ifFalse:[
1797
2cb44d740a7e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1742
diff changeset
  3210
        deviceFont ~~ fontUsed ifTrue:[
2cb44d740a7e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1742
diff changeset
  3211
            device setFont:id in:gcId.
2cb44d740a7e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1742
diff changeset
  3212
            deviceFont := fontUsed
2cb44d740a7e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1742
diff changeset
  3213
        ].
6472
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  3214
        device displayString:aString 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
  3215
    ]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3216
1805
532a11ba8458 tuned-out another send if encoding is wrong in display-string
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  3217
    "Modified: 1.7.1997 / 17:08:48 / cg"
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3218
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3219
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3220
displayDeviceString:aString from:index1 to:index2 x:x y:y
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3221
    "draw a substring at the coordinate x/y -
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3222
     draw foreground-pixels only (in current paint-color), leaving background as-is.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3223
     No translation or scaling is done"
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
    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
  3226
!
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
displayDeviceString:aString x:x y:y
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3229
    "draw a string at the coordinate x/y -
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3230
     draw foreground-pixels only (in current paint-color), leaving background as-is.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3231
     No translation or scaling is done"
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
    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
  3234
!
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
fillDeviceRectangleX:x y:y width:w height:h
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3237
    "draw a filled rectangle in device coordinate space.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3238
     This ignores any transformations. The coordinates must be integers."
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
    gcId isNil ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3241
	self initGC
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
    device
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3244
	fillRectangleX:x
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3245
		     y:y
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3246
		 width:w
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3247
		height:h
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3248
		    in:drawableId with:gcId
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
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3251
!DeviceGraphicsContext methodsFor:'evaluating in another context'!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3252
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3253
reverseDo:aBlock
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3254
    "evaluate aBlock with foreground and background interchanged.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3255
     This can be reimplemented here in a faster way."
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
    |oldFg oldBg|
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3258
2835
963425946ff3 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 2714
diff changeset
  3259
    oldFg := foreground.
963425946ff3 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 2714
diff changeset
  3260
    oldBg := background.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3261
    self foreground:background background:foreground.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3262
    aBlock value.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3263
    self foreground:oldFg background:oldBg
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3264
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3265
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3266
withBackground:fgColor do:aBlock
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3267
    "evaluate aBlock with changed background."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3268
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3269
    |oldBg|
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3270
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3271
    oldBg := background.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3272
    self background:fgColor.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3273
    aBlock value.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3274
    self background:oldBg
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3275
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3276
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3277
withForeground:fgColor background:bgColor do:aBlock
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3278
    "evaluate aBlock with changed foreground and background."
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
    |oldFg oldBg|
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3281
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3282
    oldFg := foreground.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3283
    oldBg := background.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3284
    self foreground:fgColor background:bgColor.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3285
    aBlock value.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3286
    self foreground:oldFg background:oldBg
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3287
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3288
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3289
withForeground:fgColor background:bgColor function:aFunction do:aBlock
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3290
    "evaluate aBlock with foreground, background and function"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3291
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3292
    |oldFg oldBg oldFun|
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3293
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3294
    oldFg := foreground.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3295
    oldBg := background.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3296
    oldFun := function.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3297
    self foreground:fgColor background:bgColor function:aFunction.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3298
    aBlock value.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3299
    self foreground:oldFg background:oldBg function:oldFun
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
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3302
withForeground:fgColor background:bgColor mask:aMask do:aBlock
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3303
    "evaluate aBlock with foreground, background and mask"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3304
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3305
    |oldFg oldBg oldMask|
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3306
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3307
    oldFg := foreground.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3308
    oldBg := background.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3309
    oldMask := mask.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3310
    self foreground:fgColor background:bgColor.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3311
    self mask:aMask.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3312
    aBlock value.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3313
    self foreground:oldFg background:oldBg.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3314
    self mask:oldMask
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3315
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3316
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3317
withForeground:fgColor do:aBlock
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3318
    "evaluate aBlock with changed foreground."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3319
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3320
    |oldFg|
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3321
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3322
    oldFg := foreground.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3323
    self foreground:fgColor.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3324
    aBlock value.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3325
    self foreground:oldFg
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3326
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3327
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3328
withForeground:fgColor function:aFunction do:aBlock
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3329
    "evaluate aBlock with changed foreground and function."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3330
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3331
    |oldFg oldFun|
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
    oldFg := foreground.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3334
    oldFun := function.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3335
    self foreground:fgColor background:background function:aFunction.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3336
    aBlock value.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3337
    self foreground:oldFg background:background function:oldFun
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3338
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3339
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3340
xoring:aBlock
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3341
    "evaluate aBlock with function xoring"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3342
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3343
    |fgPixel bgPixel oldFunction|
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3344
2322
6c42f2e0213c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2271
diff changeset
  3345
    fgPixel := device blackpixel.
6c42f2e0213c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2271
diff changeset
  3346
    bgPixel := device whitepixel.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3347
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3348
    gcId isNil ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3349
	self initGC
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3350
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3351
    oldFunction := function.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3352
    device setForeground:(fgPixel bitXor:bgPixel)
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3353
	      background:bgPixel
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3354
		      in:gcId.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3355
    device setFunction:#xor in:gcId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3356
    aBlock value.
2322
6c42f2e0213c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2271
diff changeset
  3357
2879
f1e9b8310d4e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2865
diff changeset
  3358
    paint := bgPaint := nil.        "invalidate"
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3359
    foreground := device blackColor.
1199
f113f6a4c04a use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents: 1177
diff changeset
  3360
    background := device whiteColor.
2322
6c42f2e0213c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2271
diff changeset
  3361
    device setForeground:fgPixel background:bgPixel in:gcId.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3362
    device setFunction:oldFunction in:gcId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3363
    function := oldFunction
1199
f113f6a4c04a use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents: 1177
diff changeset
  3364
2322
6c42f2e0213c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2271
diff changeset
  3365
    "Modified: / 10.9.1998 / 12:17:39 / cg"
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3366
! !
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3367
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3368
!DeviceGraphicsContext methodsFor:'filling'!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3369
5837
28301409379c added: #clearDeviceRectangleX:y:width:height:
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3370
clearDeviceRectangleX:x y:y width:w height:h
28301409379c added: #clearDeviceRectangleX:y:width:height:
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3371
    "clear a rectangular area to viewBackground -
28301409379c added: #clearDeviceRectangleX:y:width:height:
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3372
     redefined since GraphicsMedium fills with background
28301409379c added: #clearDeviceRectangleX:y:width:height:
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3373
     - not viewBackground as we want here."
28301409379c added: #clearDeviceRectangleX:y:width:height:
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3374
28301409379c added: #clearDeviceRectangleX:y:width:height:
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3375
    |oldPaint|
28301409379c added: #clearDeviceRectangleX:y:width:height:
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3376
28301409379c added: #clearDeviceRectangleX:y:width:height:
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3377
    "
28301409379c added: #clearDeviceRectangleX:y:width:height:
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3378
     fill in device coordinates - not logical coordinates
28301409379c added: #clearDeviceRectangleX:y:width:height:
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3379
    "
28301409379c added: #clearDeviceRectangleX:y:width:height:
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3380
    oldPaint := paint.
28301409379c added: #clearDeviceRectangleX:y:width:height:
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3381
    self paint:self viewBackground.
28301409379c added: #clearDeviceRectangleX:y:width:height:
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3382
    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
  3383
    self paint:oldPaint
28301409379c added: #clearDeviceRectangleX:y:width:height:
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3384
28301409379c added: #clearDeviceRectangleX:y:width:height:
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3385
    "Modified: / 04-05-1999 / 13:00:34 / cg"
28301409379c added: #clearDeviceRectangleX:y:width:height:
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3386
    "Created: / 30-12-2011 / 14:32:14 / cg"
28301409379c added: #clearDeviceRectangleX:y:width:height:
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3387
!
28301409379c added: #clearDeviceRectangleX:y:width:height:
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3388
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3389
fillArcX:x y:y width:w height:h from:startAngle angle:angle
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3390
    "draw a filled arc; apply transformation if nonNil"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3391
2268
1a774fc02c83 fixed non-float (i.e. fraction) args to fillArc/ displayArc
Claus Gittinger <cg@exept.de>
parents: 2259
diff changeset
  3392
    |pX pY nW nH sA a|
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3393
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3394
    gcId isNil ifTrue:[
1029
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
  3395
	self initGC
732
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
    transformation notNil ifTrue:[
1029
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
  3398
	pX := transformation applyToX:x.
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
  3399
	pY := transformation applyToY:y.
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
  3400
	nW := transformation applyScaleX:w.
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
  3401
	nH := transformation applyScaleY:h.
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
  3402
	nW < 0 ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3403
	      nW := nW abs.
1029
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
  3404
	      pX := pX - nW.
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
  3405
	].
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
  3406
	nH < 0 ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3407
	      nH := nH abs.
1029
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
  3408
	      pY := pY - nH.
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
  3409
	].
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3410
    ] ifFalse:[
1029
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
  3411
	pX := x.
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
  3412
	pY := y.
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
  3413
	nW := w.
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
  3414
	nH := h.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3415
    ].
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
    pX := pX rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3418
    pY := pY rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3419
    nW := nW rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3420
    nH := nH rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3421
2268
1a774fc02c83 fixed non-float (i.e. fraction) args to fillArc/ displayArc
Claus Gittinger <cg@exept.de>
parents: 2259
diff changeset
  3422
    sA := startAngle.
1a774fc02c83 fixed non-float (i.e. fraction) args to fillArc/ displayArc
Claus Gittinger <cg@exept.de>
parents: 2259
diff changeset
  3423
    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
  3424
    a := angle.
1a774fc02c83 fixed non-float (i.e. fraction) args to fillArc/ displayArc
Claus Gittinger <cg@exept.de>
parents: 2259
diff changeset
  3425
    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
  3426
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3427
    device
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3428
	  fillArcX:pX
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3429
		 y:pY
1029
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
  3430
	     width:nW
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3431
	    height:nH
2268
1a774fc02c83 fixed non-float (i.e. fraction) args to fillArc/ displayArc
Claus Gittinger <cg@exept.de>
parents: 2259
diff changeset
  3432
	      from:sA
1a774fc02c83 fixed non-float (i.e. fraction) args to fillArc/ displayArc
Claus Gittinger <cg@exept.de>
parents: 2259
diff changeset
  3433
	     angle:a
1029
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
  3434
		in:drawableId
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
  3435
	      with:gcId
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3436
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3437
    "Created: 8.5.1996 / 08:29:45 / cg"
784
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
  3438
    "Modified: 4.6.1996 / 17:58:21 / cg"
732
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
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3441
fillPolygon:aPolygon
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3442
    "draw a filled polygon; apply transformation if nonNil"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3443
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3444
    |newPolygon|
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3445
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3446
    gcId isNil ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3447
	self initGC
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3448
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3449
    transformation notNil ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3450
	newPolygon := aPolygon collect:[:point | transformation applyTo:point].
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3451
    ] ifFalse:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3452
	newPolygon := aPolygon
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3453
    ].
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3454
    (newPolygon contains:[:p |
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3455
	(p isPoint not
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3456
	or:[(p x class ~~ SmallInteger)
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3457
	or:[(p y class ~~ SmallInteger)]])
4521
6f065906e740 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4477
diff changeset
  3458
     ]) ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3459
	newPolygon := newPolygon collect:[:p | p asPoint rounded]
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3460
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3461
    device
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3462
	fillPolygon:newPolygon
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3463
		 in:drawableId
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3464
	       with:gcId
732
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
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3467
fillRectangleX:x y:y width:w height:h
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3468
    "draw a filled rectangle; apply transformation if nonNil"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3469
1064
2d0783c97f32 removed unused vars
Claus Gittinger <cg@exept.de>
parents: 1034
diff changeset
  3470
    |pX pY nW nH|
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3471
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3472
    gcId isNil ifTrue:[
1029
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
  3473
	self initGC
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3474
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3475
    transformation notNil ifTrue:[
1029
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
  3476
	pX := transformation applyToX:x.
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
  3477
	pY := transformation applyToY:y.
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
  3478
	nW := transformation applyScaleX:w.
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
  3479
	nH := transformation applyScaleY:h.
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
  3480
	nW < 0 ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3481
	      nW := nW abs.
1029
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
  3482
	      pX := pX - nW.
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
  3483
	].
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
  3484
	nH < 0 ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3485
	      nH := nH abs.
1029
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
  3486
	      pY := pY - nH.
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
  3487
	].
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3488
    ] ifFalse:[
1029
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
  3489
	pX := x.
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
  3490
	pY := y.
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
  3491
	nW := w.
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
  3492
	nH := h.
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
    pX := pX rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3495
    pY := pY rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3496
    nW := nW rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3497
    nH := nH rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3498
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3499
    device
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3500
	fillRectangleX:pX
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3501
		     y:pY
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3502
		 width:nW
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3503
		height:nH
1029
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
  3504
		    in:drawableId with:gcId
784
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
  3505
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
  3506
    "Modified: 4.6.1996 / 17:58:49 / cg"
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3507
! !
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3508
6472
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  3509
!DeviceGraphicsContext methodsFor:'finalization'!
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  3510
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  3511
executor
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  3512
    drawableType == #window ifTrue:[
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  3513
        ^ DeviceWindowGCHandle basicNew
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  3514
            setDevice:self graphicsDevice id:self drawableId gcId:self gcId parentId:parentId.
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  3515
    ] ifFalse:[
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  3516
        ^ DevicePixmapGCHandle basicNew
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  3517
            setDevice:self graphicsDevice id:self drawableId gcId:self gcId.
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  3518
    ].
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  3519
!
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  3520
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  3521
finalizationLobby
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  3522
    "answer the registry used for finalization.
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  3523
     DeviceGraphicContexts have their own Registry"
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  3524
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  3525
    ^ Lobby
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  3526
!
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  3527
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  3528
registerChange
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  3529
    "register a change with the finalizationLobby"
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  3530
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  3531
    Lobby registerChange:self.
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  3532
! !
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  3533
3883
4e01a59afccb method category rename
Claus Gittinger <cg@exept.de>
parents: 3880
diff changeset
  3534
!DeviceGraphicsContext methodsFor:'initialization & release'!
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3535
1517
ac751bb3dfdf no need for registration here;
Claus Gittinger <cg@exept.de>
parents: 1514
diff changeset
  3536
close
ac751bb3dfdf no need for registration here;
Claus Gittinger <cg@exept.de>
parents: 1514
diff changeset
  3537
    "same as destroy - for ST-80 compatibility"
ac751bb3dfdf no need for registration here;
Claus Gittinger <cg@exept.de>
parents: 1514
diff changeset
  3538
ac751bb3dfdf no need for registration here;
Claus Gittinger <cg@exept.de>
parents: 1514
diff changeset
  3539
    self destroy
ac751bb3dfdf no need for registration here;
Claus Gittinger <cg@exept.de>
parents: 1514
diff changeset
  3540
ac751bb3dfdf no need for registration here;
Claus Gittinger <cg@exept.de>
parents: 1514
diff changeset
  3541
    "Created: 2.4.1997 / 19:31:27 / cg"
ac751bb3dfdf no need for registration here;
Claus Gittinger <cg@exept.de>
parents: 1514
diff changeset
  3542
!
ac751bb3dfdf no need for registration here;
Claus Gittinger <cg@exept.de>
parents: 1514
diff changeset
  3543
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3544
createGC
1453
e93293618275 only fetch id's once in displayForm.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  3545
    "physically create a device GC.
e93293618275 only fetch id's once in displayForm.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  3546
     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
  3547
     really drawn, none is created up to the first draw.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3548
     This method is sent, when the first drawing happens"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3549
6472
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  3550
    drawableType == #pixmap ifTrue:[
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  3551
        gcId := device gcForBitmap:drawableId.
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  3552
    ] ifFalse:[
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  3553
        gcId := device gcFor:drawableId.
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  3554
    ].
1138
4a2b3b407cae need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents: 1094
diff changeset
  3555
    Lobby registerChange:self.
1453
e93293618275 only fetch id's once in displayForm.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  3556
e93293618275 only fetch id's once in displayForm.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  3557
    "Modified: 19.3.1997 / 11:07:52 / cg"
1138
4a2b3b407cae need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents: 1094
diff changeset
  3558
!
4a2b3b407cae need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents: 1094
diff changeset
  3559
4a2b3b407cae need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents: 1094
diff changeset
  3560
destroy
6472
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  3561
    |id|
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  3562
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  3563
    self destroyGC .
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  3564
    id := drawableId.
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  3565
    id notNil ifTrue:[
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  3566
        drawableId := nil.
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  3567
        drawableType == #window ifTrue:[
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  3568
            device destroyView:nil withId:id.
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  3569
        ] ifFalse:[
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  3570
            device destroyPixmap:id.
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  3571
        ].
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  3572
    ].
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  3573
    Lobby unregister:self.
1138
4a2b3b407cae need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents: 1094
diff changeset
  3574
!
4a2b3b407cae need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents: 1094
diff changeset
  3575
6222
2d670d3bcfd5 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6215
diff changeset
  3576
destroyGC
2d670d3bcfd5 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6215
diff changeset
  3577
    |id|
2d670d3bcfd5 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6215
diff changeset
  3578
2d670d3bcfd5 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6215
diff changeset
  3579
    id := gcId.
2d670d3bcfd5 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6215
diff changeset
  3580
    id notNil ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3581
	gcId := nil.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3582
	device destroyGC:id.
6222
2d670d3bcfd5 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6215
diff changeset
  3583
    ].
6266
1503c5e038d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  3584
!
1503c5e038d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  3585
1138
4a2b3b407cae need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents: 1094
diff changeset
  3586
initGC
4a2b3b407cae need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents: 1094
diff changeset
  3587
    "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
  3588
     really drawn, none is created.
4a2b3b407cae need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents: 1094
diff changeset
  3589
     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
  3590
4135
a47337e09c40 preset font if already ok for device
werner
parents: 4070
diff changeset
  3591
    |fgId bgId p fontId|
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3592
1453
e93293618275 only fetch id's once in displayForm.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  3593
    gcId notNil ifTrue:[^ self].
1514
7c2a921ae46b better error report when drawing on closed view.
Claus Gittinger <cg@exept.de>
parents: 1507
diff changeset
  3594
    drawableId isNil ifTrue:[
2031
d369d38213cf dont use #error when drawing on a closed drawable;
Claus Gittinger <cg@exept.de>
parents: 2024
diff changeset
  3595
        "/
d369d38213cf dont use #error when drawing on a closed drawable;
Claus Gittinger <cg@exept.de>
parents: 2024
diff changeset
  3596
        "/ 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
  3597
        "/ no drawing is possible.
d369d38213cf dont use #error when drawing on a closed drawable;
Claus Gittinger <cg@exept.de>
parents: 2024
diff changeset
  3598
        "/
d369d38213cf dont use #error when drawing on a closed drawable;
Claus Gittinger <cg@exept.de>
parents: 2024
diff changeset
  3599
        ^ DrawingOnClosedDrawableSignal raiseRequest
1514
7c2a921ae46b better error report when drawing on closed view.
Claus Gittinger <cg@exept.de>
parents: 1507
diff changeset
  3600
    ].
1138
4a2b3b407cae need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents: 1094
diff changeset
  3601
    self createGC.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3602
1199
f113f6a4c04a use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents: 1177
diff changeset
  3603
    foreground isNil ifTrue:[foreground := device blackColor].
f113f6a4c04a use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents: 1177
diff changeset
  3604
    background isNil ifTrue:[background := device whiteColor].
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3605
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3606
    foreground isColor ifTrue:[
1199
f113f6a4c04a use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents: 1177
diff changeset
  3607
        "get device colors from the device indep. colors"
2835
963425946ff3 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 2714
diff changeset
  3608
        foreground := foreground onDevice:device.
1199
f113f6a4c04a use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents: 1177
diff changeset
  3609
        fgId := foreground colorId.
f113f6a4c04a use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents: 1177
diff changeset
  3610
        fgId isNil ifTrue:[
f113f6a4c04a use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents: 1177
diff changeset
  3611
            (foreground grayIntensity >= 50) ifTrue:[
f113f6a4c04a use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents: 1177
diff changeset
  3612
                fgId := device whitepixel
f113f6a4c04a use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents: 1177
diff changeset
  3613
            ] ifFalse:[
f113f6a4c04a use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents: 1177
diff changeset
  3614
                fgId := device blackpixel
f113f6a4c04a use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents: 1177
diff changeset
  3615
            ]
f113f6a4c04a use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents: 1177
diff changeset
  3616
        ].
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3617
    ] ifFalse:[
1199
f113f6a4c04a use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents: 1177
diff changeset
  3618
        fgId := device blackpixel.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3619
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3620
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3621
    background isColor ifTrue:[
2835
963425946ff3 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 2714
diff changeset
  3622
        background := background onDevice:device.
1199
f113f6a4c04a use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents: 1177
diff changeset
  3623
        bgId := background colorId.
f113f6a4c04a use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents: 1177
diff changeset
  3624
        bgId isNil ifTrue:[
f113f6a4c04a use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents: 1177
diff changeset
  3625
            (background grayIntensity >= 50) ifTrue:[
f113f6a4c04a use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents: 1177
diff changeset
  3626
                bgId := device whitepixel
f113f6a4c04a use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents: 1177
diff changeset
  3627
            ] ifFalse:[
f113f6a4c04a use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents: 1177
diff changeset
  3628
                bgId := device blackpixel
f113f6a4c04a use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents: 1177
diff changeset
  3629
            ]
f113f6a4c04a use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents: 1177
diff changeset
  3630
        ].
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3631
    ] ifFalse:[
1199
f113f6a4c04a use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents: 1177
diff changeset
  3632
        bgId := device whitepixel
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3633
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3634
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3635
    "now, this is something the device can work with ..."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3636
    device setForeground:fgId background:bgId in:gcId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3637
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3638
    "switch to paint"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3639
    p := paint.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3640
    paint := nil.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3641
    self paint:p.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3642
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3643
    ((lineWidth ~~ 0)
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3644
    or:[(lineStyle ~~ #solid)
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3645
    or:[(capStyle ~~ #butt)
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3646
    or:[joinStyle ~~ #miter]]]) ifTrue:[
6472
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  3647
        device setLineWidth:lineWidth
1199
f113f6a4c04a use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents: 1177
diff changeset
  3648
                      style:lineStyle
f113f6a4c04a use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents: 1177
diff changeset
  3649
                        cap:capStyle
f113f6a4c04a use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents: 1177
diff changeset
  3650
                       join:joinStyle
f113f6a4c04a use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents: 1177
diff changeset
  3651
                         in:gcId
732
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
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3654
    mask notNil ifTrue:[
1199
f113f6a4c04a use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents: 1177
diff changeset
  3655
        (mask depth == 1) ifTrue:[
f113f6a4c04a use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents: 1177
diff changeset
  3656
            device setBitmapMask:(mask id) in:gcId
f113f6a4c04a use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents: 1177
diff changeset
  3657
        ] ifFalse:[
f113f6a4c04a use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents: 1177
diff changeset
  3658
            device setPixmapMask:(mask id) in:gcId
f113f6a4c04a use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents: 1177
diff changeset
  3659
        ].
f113f6a4c04a use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents: 1177
diff changeset
  3660
        maskOrigin notNil ifTrue:[
f113f6a4c04a use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents: 1177
diff changeset
  3661
            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
  3662
        ]
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3663
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3664
    (function ~~ #copy) ifTrue:[device setFunction:function in:gcId].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3665
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3666
    "defer the getting of a device font
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3667
     - this is now done when the first drawstring occurs,
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3668
     since many views (layout-views) will never draw strings and
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3669
     therefore, the overhead of aquiring a font can be avoided.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3670
    "
1138
4a2b3b407cae need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents: 1094
diff changeset
  3671
"/    font := font on:device.
4a2b3b407cae need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents: 1094
diff changeset
  3672
"/    id := font fontId.
4a2b3b407cae need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents: 1094
diff changeset
  3673
"/    id notNil ifTrue:[
4a2b3b407cae need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents: 1094
diff changeset
  3674
"/        device setFont:id in:gcId
4a2b3b407cae need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents: 1094
diff changeset
  3675
"/    ]
1199
f113f6a4c04a use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents: 1177
diff changeset
  3676
4135
a47337e09c40 preset font if already ok for device
werner
parents: 4070
diff changeset
  3677
    font notNil ifTrue:[
4146
4c46ae30bd64 Use #graphicsDevice
Stefan Vogel <sv@exept.de>
parents: 4135
diff changeset
  3678
        font graphicsDevice == device ifTrue:[
4135
a47337e09c40 preset font if already ok for device
werner
parents: 4070
diff changeset
  3679
            (fontId := font fontId) notNil ifTrue:[
4664
02d160974029 fix remembering deviceFont everywhere.
Claus Gittinger <cg@exept.de>
parents: 4657
diff changeset
  3680
                deviceFont := font.
4135
a47337e09c40 preset font if already ok for device
werner
parents: 4070
diff changeset
  3681
                device setFont:fontId in:gcId
a47337e09c40 preset font if already ok for device
werner
parents: 4070
diff changeset
  3682
            ]
a47337e09c40 preset font if already ok for device
werner
parents: 4070
diff changeset
  3683
        ]
a47337e09c40 preset font if already ok for device
werner
parents: 4070
diff changeset
  3684
    ]
4664
02d160974029 fix remembering deviceFont everywhere.
Claus Gittinger <cg@exept.de>
parents: 4657
diff changeset
  3685
02d160974029 fix remembering deviceFont everywhere.
Claus Gittinger <cg@exept.de>
parents: 4657
diff changeset
  3686
    "Modified: / 22-10-2006 / 14:10:53 / cg"
4291
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3687
!
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3688
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3689
initialize
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3690
    "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
  3691
     initColors and initFont, which are usually redefined."
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3692
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3693
    super initialize.
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3694
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3695
    "/ just in case, someone redefined new without setting device
6234
404d91662d49 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6225
diff changeset
  3696
    (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
  3697
6273
d1000b29b5b2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6271
diff changeset
  3698
    foreground isNil ifTrue:[foreground := self blackColor].
d1000b29b5b2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6271
diff changeset
  3699
    background isNil ifTrue:[background := self whiteColor].
4291
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3700
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3701
    "Modified: 10.1.1997 / 17:46:51 / cg"
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3702
!
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3703
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3704
prepareForReinit
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3705
    "kludge - clear drawableId and gcId
4291
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3706
     needed after snapin"
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3707
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3708
    gcId := nil.
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3709
    drawableId := nil.
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3710
    deviceFont := nil
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3711
!
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3712
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3713
recreate
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3714
    "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
  3715
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3716
    gcId := nil.
6472
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  3717
    drawableId := nil.
4291
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3718
    foreground notNil ifTrue:[
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3719
        foreground := foreground onDevice:device
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3720
    ].
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3721
    background notNil ifTrue:[
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3722
        background := background onDevice:device
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3723
    ].
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3724
    paint notNil ifTrue:[
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3725
        paint := paint onDevice:device
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3726
    ].
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3727
    bgPaint notNil ifTrue:[
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3728
        bgPaint := bgPaint onDevice:device
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3729
    ].
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3730
    font notNil ifTrue:[
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3731
        font := font onDevice:device
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3732
    ]
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3733
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3734
    "Modified: 28.10.1996 / 13:25:02 / cg"
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3735
!
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3736
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3737
releaseGC
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3738
    "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
  3739
     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
  3740
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3741
    |id|
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3742
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3743
    foreground := background := paint := bgPaint := nil.
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3744
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3745
    id := gcId.
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3746
    id notNil ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3747
	gcId := nil.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3748
	device destroyGC:id.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3749
	Lobby registerChange:self.
4291
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3750
    ].
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3751
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3752
    "Created: 11.6.1996 / 22:07:30 / cg"
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3753
    "Modified: 2.4.1997 / 19:36:30 / cg"
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3754
! !
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3755
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3756
!DeviceGraphicsContext methodsFor:'private'!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3757
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3758
setDevice:aDevice id:aDrawbleId gcId:aGCId
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3759
    "private"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3760
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3761
    device := aDevice.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3762
    gcId := aGCId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3763
    drawableId := aDrawbleId
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3764
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3765
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3766
setGCForPaint
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3767
    "private; given a complex color (i.e. a pixmap or dithered color,
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3768
     setup the GC to draw in this color.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3769
     A helper for paint and paint:on:"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3770
832
064890dcfabd fixed opaque string draw with deep-dither
Claus Gittinger <cg@exept.de>
parents: 786
diff changeset
  3771
    |dither map pixelId p fg bg vOrg ditherDepth deviceDepth|
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3772
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3773
    gcId notNil ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3774
	paint isSymbol ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3775
	    "map symbols to colors"
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3776
	    paint := Color perform:paint ifNotUnderstood:[Color yellow].
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3777
	].
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3778
	p := paint.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3779
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3780
	p isColor ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3781
	    paint := p := p onDevice:device.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3782
	    pixelId := p colorId.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3783
	    pixelId notNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3784
		"
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3785
		 a real (undithered) color
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3786
		"
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3787
		mask notNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3788
		    mask := nil.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3789
		    device setBitmapMask:nil in:gcId
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3790
		].
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3791
		(p ~~ foreground) ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3792
		    foreground := paint.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3793
		    device setForeground:pixelId in:gcId
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3794
		].
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3795
		^ self
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3796
	    ].
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3797
	    "a dithered color"
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3798
	    dither := paint ditherForm.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3799
	] ifFalse:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3800
	    "mhmh - seems to be some kind of form ..."
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3801
	    paint := paint onDevice:device.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3802
	    dither := paint.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3803
	].
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3804
	"
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3805
	 a dithered color or image
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3806
	"
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3807
	(ditherDepth := dither depth) == 1 ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3808
	    "a simple 0/1 bitmap"
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3809
	    map := dither colorMap.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3810
	    "temporary (kludgy) fix for destroyed paint"
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3811
	    p := paint.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3812
	    map isNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3813
		fg := Color black.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3814
		bg := Color white.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3815
	    ] ifFalse:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3816
		fg := map at:2.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3817
		bg := map at:1.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3818
	    ].
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3819
	    self foreground:fg background:bg.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3820
	    paint := p
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3821
	] ifFalse:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3822
	    deviceDepth := device depth.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3823
	    (ditherDepth ~~ deviceDepth) ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3824
		dither := dither asFormOn:device.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3825
		ditherDepth := dither depth.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3826
		(dither isNil or:[ditherDepth ~~ deviceDepth]) ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3827
		    self error:'bad dither'.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3828
		    ^ self
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3829
		]
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3830
	    ]
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3831
	].
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3832
	self mask:dither.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3833
	vOrg := self viewOrigin.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3834
	self maskOriginX:vOrg x negated y:vOrg y negated.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3835
    ]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3836
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3837
    "Created: 16.5.1996 / 15:35:51 / cg"
1742
ca904d85a84c #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1741
diff changeset
  3838
    "Modified: 6.6.1997 / 12:55:38 / cg"
2049
1ceec8ef240e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2031
diff changeset
  3839
!
1ceec8ef240e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2031
diff changeset
  3840
1ceec8ef240e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2031
diff changeset
  3841
setId:aDrawbleId
1ceec8ef240e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2031
diff changeset
  3842
    "private"
1ceec8ef240e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2031
diff changeset
  3843
1ceec8ef240e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2031
diff changeset
  3844
    drawableId := aDrawbleId
1ceec8ef240e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2031
diff changeset
  3845
1ceec8ef240e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2031
diff changeset
  3846
    "Created: / 6.2.1998 / 12:44:45 / cg"
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3847
! !
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3848
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3849
!DeviceGraphicsContext methodsFor:'queries'!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3850
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3851
horizontalIntegerPixelPerMillimeter
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3852
    "return the (rounded) number of pixels per millimeter"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3853
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3854
    ^ device horizontalPixelPerMillimeter rounded
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3855
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3856
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3857
horizontalPixelPerInch
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3858
    "return the number of horizontal pixels per inch of the display"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3859
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3860
    ^ device horizontalPixelPerMillimeter * 25.4
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3861
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3862
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3863
horizontalPixelPerMillimeter
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3864
    "return the number of pixels per millimeter (not rounded)"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3865
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3866
    ^ device horizontalPixelPerMillimeter
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3867
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3868
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3869
horizontalPixelPerMillimeter:millis
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3870
    "return the number of pixels (not rounded) for millis millimeter"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3871
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3872
    ^ device horizontalPixelPerMillimeter * millis
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3873
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3874
784
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
  3875
resolution
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
  3876
    "return a point consisting of pixel-per-inch horizontally and vertically."
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
  3877
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
  3878
    ^ device resolution
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
  3879
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
  3880
    "Created: 4.6.1996 / 15:23:55 / cg"
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
  3881
!
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
  3882
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3883
verticalIntegerPixelPerMillimeter
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3884
    "return the (rounded) number of pixels per millimeter"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3885
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3886
    ^ device verticalPixelPerMillimeter rounded
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3887
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3888
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3889
verticalPixelPerInch
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3890
    "return the number of vertical pixels per inch of the display"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3891
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3892
    ^ device verticalPixelPerMillimeter * 25.4
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3893
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3894
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3895
verticalPixelPerMillimeter
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3896
    "return the number of pixels per millimeter (not rounded)"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3897
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3898
    ^ device verticalPixelPerMillimeter
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3899
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3900
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3901
verticalPixelPerMillimeter:millis
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3902
    "return the number of pixels (not rounded) for millis millimeter"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3903
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3904
    ^ device verticalPixelPerMillimeter * millis
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3905
! !
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3906
6225
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  3907
!DeviceGraphicsContext methodsFor:'view creation'!
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  3908
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  3909
createBitmapFromArray:data width:width height:height
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  3910
    "create a bitmap from data and set the drawableId"
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3911
6225
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  3912
    drawableId := device createBitmapFromArray:data width:width height:height.
6472
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  3913
    drawableType := #pixmap.
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  3914
    Lobby registerChange:self.
6225
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  3915
!
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  3916
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  3917
createPixmapWidth:w height:h depth:d
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  3918
    "create a pixmap and set the drawableId"
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3919
6225
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  3920
    drawableId := device createPixmapWidth:w height:h depth:d.
6472
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  3921
    drawableType := #pixmap.
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  3922
    Lobby registerChange:self.
6225
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  3923
!
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  3924
6472
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  3925
createRootWindowFor:aView
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  3926
    drawableId := device rootWindowFor:aView.
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  3927
    drawableType := #window.
6234
404d91662d49 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6225
diff changeset
  3928
!
404d91662d49 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6225
diff changeset
  3929
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3930
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
  3931
    "create a window and set the drawableId"
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3932
6472
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  3933
    |container|
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  3934
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3935
    drawableId := device
6225
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  3936
            createWindowFor:aView
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  3937
            type:typeSymbol
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  3938
            origin:org
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  3939
            extent:ext
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  3940
            minExtent:minE
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  3941
            maxExtent:maxE
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  3942
            borderWidth:bw
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  3943
            subViewOf:sv
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  3944
            style:styleSymbol
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  3945
            inputOnly:inp
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  3946
            label:label
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  3947
            owner:owner
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  3948
            icon:icn
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  3949
            iconMask:icnM
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  3950
            iconView:icnV.
6472
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  3951
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  3952
    drawableType := #window.
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  3953
    container := aView container.
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  3954
    container notNil ifTrue:[ parentId := container id ].
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  3955
    Lobby registerChange:self.
6225
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  3956
! !
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  3957
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  3958
!DeviceGraphicsContext methodsFor:'view properties'!
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  3959
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  3960
backingStore:how
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  3961
    "turn on/off backingStore (saving my pixels)
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  3962
     how may true/false, but also #always, #whenMapped or #never."
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  3963
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  3964
    drawableId notNil ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3965
	device setBackingStore:how in:drawableId
6225
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  3966
    ]
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  3967
!
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  3968
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  3969
bitGravity:gravity
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  3970
    "set the bitGravity - thats the direction where the contents will move
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  3971
     when the view is resized."
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  3972
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  3973
    drawableId notNil ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3974
	device setBitGravity:gravity in:drawableId
6225
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  3975
    ]
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  3976
!
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  3977
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  3978
saveUnder:aBoolean
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  3979
    "turn on/off saveUnder (saving pixels under myself)
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  3980
     - used for temporary views (i.e. PopUps and ModalBoxes)"
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  3981
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  3982
    drawableId notNil ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3983
	device setSaveUnder:aBoolean in:drawableId
6225
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  3984
    ]
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  3985
!
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  3986
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  3987
setCursorId:id
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  3988
    drawableId notNil ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3989
	device setCursor:id in:drawableId.
6225
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  3990
    ]
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  3991
!
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  3992
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  3993
setWindowPid: pid
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  3994
    "Sets the _NET_WM_PID property for the window.
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  3995
     This may be used by the window manager to group windows.
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  3996
     If anIntegerOrNil is nil, then PID of currently running
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  3997
     Smalltalk is used"
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  3998
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  3999
    drawableId notNil ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  4000
	device setWindowPid:pid in:drawableId.
6225
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4001
    ].
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4002
!
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4003
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4004
viewGravity:gravity
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4005
    "set the viewGravity - thats the direction where the view will move
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4006
     when the superView is resized."
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4007
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4008
    drawableId notNil ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  4009
	device setWindowGravity:gravity in:drawableId
6225
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4010
    ].
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4011
!
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4012
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4013
windowBorderShape:aForm
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4014
    "set the windows border shape"
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4015
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4016
    drawableId notNil ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  4017
	device setWindowBorderShape:(aForm id) in:drawableId
6225
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4018
    ].
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4019
!
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4020
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4021
windowClass:windowClassNameString name:nameString
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4022
    "define class and name of a window.
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4023
     This may be used by the window manager to
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4024
     select client specific resources."
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4025
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4026
    drawableId notNil ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  4027
	device setWindowClass:windowClassNameString name:nameString in:drawableId.
6225
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4028
    ].
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4029
!
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4030
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4031
windowName:aString
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4032
    "define the views name in the windows title area."
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4033
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4034
    drawableId notNil ifTrue: [
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  4035
	device setWindowName:aString in:drawableId.
6225
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4036
    ]
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4037
!
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4038
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4039
windowShape:aForm
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4040
    "set the windows shape.
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4041
     Returns false, if the display does not support the
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4042
     X shape extension."
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4043
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4044
    drawableId notNil ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  4045
	^ device setWindowShape:(aForm id) in:drawableId
6225
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4046
    ].
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4047
    ^ false.
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4048
! !
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4049
6472
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4050
!DeviceGraphicsContext::DevicePixmapGCHandle methodsFor:'accessing'!
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4051
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4052
parentId
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4053
    "pixmaps do not have a parent"
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4054
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4055
    ^ nil
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4056
! !
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4057
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4058
!DeviceGraphicsContext::DevicePixmapGCHandle methodsFor:'finalization'!
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4059
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4060
finalize
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4061
    "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
  4062
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4063
    |id|
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4064
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4065
    drawableId notNil ifTrue:[
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4066
	(id := gcId) notNil ifTrue:[
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4067
	    gcId := nil.
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4068
	    device destroyGC:id.
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4069
	].
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4070
	id := drawableId.
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4071
	drawableId := nil.
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4072
	device destroyPixmap:id.
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4073
    ]
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4074
! !
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4075
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4076
!DeviceGraphicsContext::DeviceWindowGCHandle methodsFor:'accessing'!
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4077
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4078
parentId
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4079
    ^ parentId
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4080
! !
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4081
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4082
!DeviceGraphicsContext::DeviceWindowGCHandle methodsFor:'finalization'!
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4083
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4084
finalize
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4085
    "the view for which I am a handle was collected
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4086
     - release system resources"
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4087
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4088
    drawableId notNil ifTrue:[
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4089
	[
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4090
	    (device viewIdKnown:drawableId) ifTrue:[
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4091
"/ 'Display [info]: recycled view (' infoPrint. v infoPrint. ') not destroyed: ' infoPrint.
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4092
"/ drawableId displayString infoPrintCR.
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4093
		drawableId := nil.
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4094
	    ] ifFalse:[
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4095
		|id|
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4096
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4097
		(id := gcId) notNil ifTrue:[
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4098
		    gcId := nil.
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4099
		    device deviceIOErrorSignal handle:[:ex |
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4100
		    ] do:[
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4101
			device destroyGC:id.
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4102
		    ]
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4103
		].
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4104
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4105
		id := drawableId.
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4106
		drawableId := nil.
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4107
		device deviceIOErrorSignal handle:[:ex |
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4108
		] do:[
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4109
		    device destroyView:nil withId:id.
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4110
		].
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4111
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4112
		"When a window ist destroyed, all its subwindows are also destroyed.
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4113
		 Unregister all the subwindows, to avoid destroying of reused windoeIds
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4114
		 later."
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4115
		DeviceGraphicsContext cleanupLobbyForChildrenOfViewWithDevice:device id:id.
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4116
	    ]
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4117
	] valueUninterruptably.
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4118
    ].
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4119
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4120
    "Created: / 25.9.1997 / 10:01:46 / stefan"
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4121
    "Modified: / 15.11.2001 / 14:17:12 / cg"
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4122
! !
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4123
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4124
!DeviceGraphicsContext::DeviceWindowGCHandle methodsFor:'private-accessing'!
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4125
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4126
setDevice:aDevice id:aDrawableId gcId:aGCId parentId:parentIdArg
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4127
    "set the handles contents"
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4128
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4129
    device := aDevice.
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4130
    drawableId := aDrawableId.
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4131
    gcId := aGCId.
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4132
    parentId := parentIdArg.
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4133
! !
5b21ff383a12 Delegated gc stuff
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  4134
1085
3513a4cae87b handle depth1-images with a mask
Claus Gittinger <cg@exept.de>
parents: 1064
diff changeset
  4135
!DeviceGraphicsContext class methodsFor:'documentation'!
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4136
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4137
version
6612
5c05ccaf6275 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6514
diff changeset
  4138
    ^ '$Header: /cvs/stx/stx/libview/DeviceGraphicsContext.st,v 1.143 2014-11-23 15:53:27 cg Exp $'
5360
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  4139
!
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  4140
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  4141
version_CVS
6612
5c05ccaf6275 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6514
diff changeset
  4142
    ^ '$Header: /cvs/stx/stx/libview/DeviceGraphicsContext.st,v 1.143 2014-11-23 15:53:27 cg Exp $'
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4143
! !
3880
c4c8268a2d9f method category rename
Claus Gittinger <cg@exept.de>
parents: 3666
diff changeset
  4144
6107
afaac69e9310 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 5837
diff changeset
  4145
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4146
DeviceGraphicsContext initialize!