DeviceGraphicsContext.st
author Claus Gittinger <cg@exept.de>
Sat, 24 Dec 2016 14:53:12 +0100
changeset 7759 45386945d6d7
parent 7752 81c84fab0aac
child 7767 7ba26d21c628
child 7799 68deff7c0fd9
permissions -rw-r--r--
#FEATURE by cg class: DeviceGraphicsContext added: #withPaint:do:
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     1
"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     2
 COPYRIGHT (c) 1992 by Claus Gittinger
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     3
	      All Rights Reserved
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     4
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     5
 This software is furnished under a license and may be used
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     6
 only in accordance with the terms of that license and with the
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     8
 be provided or otherwise made available to, or used by, any
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     9
 other person.  No title to or ownership of the software is
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    10
 hereby transferred.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    11
"
3275
b40f47ec5661 comment
Claus Gittinger <cg@exept.de>
parents: 3188
diff changeset
    12
"{ Package: 'stx:libview' }"
b40f47ec5661 comment
Claus Gittinger <cg@exept.de>
parents: 3188
diff changeset
    13
6746
e63784ff3863 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6711
diff changeset
    14
"{ NameSpace: Smalltalk }"
e63784ff3863 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6711
diff changeset
    15
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    16
GraphicsContext subclass:#DeviceGraphicsContext
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
    17
	instanceVariableNames:'drawableId gcId deviceFont foreground background drawableType
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
    18
		parentId'
7443
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
    19
	classVariableNames:'CachedScaledForms CachedScales'
732
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
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
    24
DeviceHandle subclass:#DevicePixmapGCHandle
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
    25
	instanceVariableNames:''
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
    26
	classVariableNames:''
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
    27
	poolDictionaries:''
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
    28
	privateIn:DeviceGraphicsContext
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
    29
!
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
    30
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
    31
DeviceHandle subclass:#DeviceWindowGCHandle
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
    32
	instanceVariableNames:'parentId'
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
    33
	classVariableNames:''
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
    34
	poolDictionaries:''
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
    35
	privateIn:DeviceGraphicsContext
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
    36
!
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
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)
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
    61
    to avoid needless message traffic. 
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    62
    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
    63
    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
    64
    drawing functions (see GraphicsContext drawing vs. basic drawing category).
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    65
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
    66
    The added variables foreground/background are the drawing colors actually
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    67
    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
    68
    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
    69
    totally replaced by paint/bgPaint
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
    70
    (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
    71
     fg/bg makes sense)
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    72
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    73
    [Instance variables:]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    74
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
    75
        drawableId      <SmallInteger>  my drawableId on the device (a device handle)
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
    76
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
    77
        gcId            <SmallInteger>  my gc's ID on the device (a device handle)
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
    78
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
    79
        deviceFont      <Font>          the actual font, currently set in the device
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
    80
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
    81
        foreground      <Color>         the device foreground color used for drawing
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
    82
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
    83
        background      <Color>         the device background color used for drawing
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    84
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    85
    [see also:]
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
    86
        DeviceWorkstation
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
    87
        Color Font Cursor
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    88
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    89
    [author:]
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
    90
        Claus Gittinger
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    91
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
1085
3513a4cae87b handle depth1-images with a mask
Claus Gittinger <cg@exept.de>
parents: 1064
diff changeset
    95
!DeviceGraphicsContext class methodsFor:'instance creation'!
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    96
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    97
new
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    98
    "create a new drawable - take the current display as
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    99
     its device (for now, this may be changed until the view is
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   100
     physically created)"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   101
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   102
"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   103
    '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
   104
"
6290
b6886e346ae9 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6273
diff changeset
   105
    |device|
b6886e346ae9 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6273
diff changeset
   106
b6886e346ae9 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6273
diff changeset
   107
    device := Screen current.
b6886e346ae9 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6273
diff changeset
   108
    device isNil ifTrue:[
7645
1090560bf547 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7629
diff changeset
   109
        device := Display.
1090560bf547 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7629
diff changeset
   110
        device isNil ifTrue:[
1090560bf547 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7629
diff changeset
   111
            (self class name,' [warning]: no Display') infoPrintCR.
7647
5625fcecbb2d #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7646
diff changeset
   112
            Smalltalk lateOpenDisplay.
7645
1090560bf547 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7629
diff changeset
   113
1090560bf547 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7629
diff changeset
   114
            device := Screen current ? Display.
1090560bf547 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7629
diff changeset
   115
            device isNil ifTrue:[ self error:'no screen device' ]
1090560bf547 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7629
diff changeset
   116
        ].
6290
b6886e346ae9 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6273
diff changeset
   117
    ].
6926
d04d6d93b921 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6765
diff changeset
   118
    ^ self onDevice:device
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   119
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   120
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   121
on:aDevice
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   122
    "create a new drawable on aDevice"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   123
3429
7f87cd2ae010 Use <resource:#obsolete>
Stefan Vogel <sv@exept.de>
parents: 3300
diff changeset
   124
    <resource:#obsolete>
7f87cd2ae010 Use <resource:#obsolete>
Stefan Vogel <sv@exept.de>
parents: 3300
diff changeset
   125
1741
b84a2f4317e9 warn #on: vs. #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1722
diff changeset
   126
    "/ 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
   127
    "/ operating on a model.
b84a2f4317e9 warn #on: vs. #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1722
diff changeset
   128
    "/ Please use #onDevice: to avoid confusion.
b84a2f4317e9 warn #on: vs. #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1722
diff changeset
   129
1255
bdf4cbcae668 on: -> onDevice:
Claus Gittinger <cg@exept.de>
parents: 1249
diff changeset
   130
    self obsoleteMethodWarning:'use #onDevice:'.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   131
    ^ self onDevice:aDevice
1255
bdf4cbcae668 on: -> onDevice:
Claus Gittinger <cg@exept.de>
parents: 1249
diff changeset
   132
1741
b84a2f4317e9 warn #on: vs. #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1722
diff changeset
   133
    "Modified: 5.6.1997 / 21:04:16 / cg"
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   134
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   135
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   136
onDevice:aDevice
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   137
    "create a new drawable on aDevice"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   138
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   139
    |newDrawable|
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   140
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   141
    newDrawable := self basicNew.
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
    "
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   144
     set display before its initialized
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   145
     - 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
   146
     intitialize method(s)
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   147
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   148
    newDrawable device:aDevice.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   149
    newDrawable initialize.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   150
    ^ newDrawable
1517
ac751bb3dfdf no need for registration here;
Claus Gittinger <cg@exept.de>
parents: 1514
diff changeset
   151
ac751bb3dfdf no need for registration here;
Claus Gittinger <cg@exept.de>
parents: 1514
diff changeset
   152
    "Modified: 2.4.1997 / 19:19:35 / cg"
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   153
! !
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   154
1085
3513a4cae87b handle depth1-images with a mask
Claus Gittinger <cg@exept.de>
parents: 1064
diff changeset
   155
!DeviceGraphicsContext class methodsFor:'cleanup'!
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   156
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   157
lowSpaceCleanup
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   158
    CachedScaledForms := CachedScales := nil
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   159
! !
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   160
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   161
!DeviceGraphicsContext methodsFor:'accessing'!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   162
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   163
at:aPoint
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   164
    "return the pixel at the coordinate given by aPoint"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   165
3160
89905f311a09 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3137
diff changeset
   166
    ^ self atX:aPoint x y:aPoint y
89905f311a09 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3137
diff changeset
   167
89905f311a09 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3137
diff changeset
   168
    "Modified: / 29.1.2000 / 12:17:42 / cg"
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   169
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   170
4204
947a5a5620d3 comments
Claus Gittinger <cg@exept.de>
parents: 4199
diff changeset
   171
at:aPoint put:aPixelColor
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   172
    "set a pixel"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   173
4204
947a5a5620d3 comments
Claus Gittinger <cg@exept.de>
parents: 4199
diff changeset
   174
    ^ self atX:aPoint x y:aPoint y put:aPixelColor
947a5a5620d3 comments
Claus Gittinger <cg@exept.de>
parents: 4199
diff changeset
   175
947a5a5620d3 comments
Claus Gittinger <cg@exept.de>
parents: 4199
diff changeset
   176
    "
947a5a5620d3 comments
Claus Gittinger <cg@exept.de>
parents: 4199
diff changeset
   177
     Display rootView at:(0@0) put:(Color red).
947a5a5620d3 comments
Claus Gittinger <cg@exept.de>
parents: 4199
diff changeset
   178
     Display rootView at:(1@1) put:(Color red).
947a5a5620d3 comments
Claus Gittinger <cg@exept.de>
parents: 4199
diff changeset
   179
     Display rootView at:(2@2) put:(Color red).
947a5a5620d3 comments
Claus Gittinger <cg@exept.de>
parents: 4199
diff changeset
   180
     Display rootView at:(3@3) put:(Color red).
947a5a5620d3 comments
Claus Gittinger <cg@exept.de>
parents: 4199
diff changeset
   181
     Display rootView at:(4@4) put:(Color red).
947a5a5620d3 comments
Claus Gittinger <cg@exept.de>
parents: 4199
diff changeset
   182
     Display rootView at:(5@5) put:(Color red).
947a5a5620d3 comments
Claus Gittinger <cg@exept.de>
parents: 4199
diff changeset
   183
    "
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   184
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   185
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   186
atX:x y:y
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   187
    "return the pixel at the coordinate given by x/y"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   188
2714
e5d16e41cbab need gcId-argument in getPixel
Claus Gittinger <cg@exept.de>
parents: 2680
diff changeset
   189
    ^ device getPixelX:x y:y from:drawableId with:gcId
e5d16e41cbab need gcId-argument in getPixel
Claus Gittinger <cg@exept.de>
parents: 2680
diff changeset
   190
e5d16e41cbab need gcId-argument in getPixel
Claus Gittinger <cg@exept.de>
parents: 2680
diff changeset
   191
    "Modified: / 22.5.1999 / 01:40:23 / cg"
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   192
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   193
4204
947a5a5620d3 comments
Claus Gittinger <cg@exept.de>
parents: 4199
diff changeset
   194
atX:x y:y put:aPixelColor
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   195
    "set a pixel"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   196
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   197
    |oldFg|
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   198
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   199
    oldFg := foreground.
4204
947a5a5620d3 comments
Claus Gittinger <cg@exept.de>
parents: 4199
diff changeset
   200
    self foreground:aPixelColor.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   201
    self displayPointX:x y:y.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   202
    self foreground:oldFg
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   203
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   204
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   205
backgroundPaint:aColor
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   206
    "set the background-paint color; this is used in opaque-draw
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   207
     operations"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   208
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   209
    (aColor ~~ bgPaint) ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   210
	aColor notNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   211
	    bgPaint := aColor.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   212
	    gcId notNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   213
		bgPaint isColor ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   214
		    bgPaint := aColor onDevice:device.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   215
		    bgPaint colorId notNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   216
			background := bgPaint.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   217
			gcId notNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   218
			    device setBackground:(bgPaint colorId) in:gcId.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   219
			].
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   220
			^ self
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   221
		    ]
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   222
		].
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   223
		self paint:paint on:aColor
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   224
	    ]
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   225
	]
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   226
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   227
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   228
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   229
basicFont:aFont
7560
086e2f28082c #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7510
diff changeset
   230
    "compatibility with GraphicsMedium"
086e2f28082c #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7510
diff changeset
   231
086e2f28082c #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7510
diff changeset
   232
    self font:aFont.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   233
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   234
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   235
capStyle:aSymbol
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   236
    "set the style in which the endpoints of lines
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   237
     are drawn - aSymbol may be #notLast, #butt, #round, #projecting"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   238
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   239
    |s|
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   240
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   241
    (s := aSymbol) isNil ifTrue:[
1029
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
   242
	s := #butt.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   243
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   244
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   245
    (s ~~ capStyle) ifTrue:[
1029
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
   246
	capStyle := s.
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
   247
	gcId notNil ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   248
	    device setLineWidth:lineWidth
1029
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
   249
			  style:lineStyle
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
   250
			    cap:s
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
   251
			   join:joinStyle
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
   252
			     in:gcId
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
   253
	]
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   254
    ]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   255
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   256
    "Modified: 12.5.1996 / 22:23:03 / cg"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   257
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   258
950
d4d907fc7d78 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 927
diff changeset
   259
clippedByChildren:aBoolean
d4d907fc7d78 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 927
diff changeset
   260
    "turn on/off drawing over children.
d4d907fc7d78 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 927
diff changeset
   261
     If on, a superview may draw 'over' its children.
d4d907fc7d78 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 927
diff changeset
   262
     If off (the default), drawing is 'under' its children.
d4d907fc7d78 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 927
diff changeset
   263
     Only useful for the rootView, to draw over any visible views.
d4d907fc7d78 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 927
diff changeset
   264
     (for example, when dragging a rubber-line)"
d4d907fc7d78 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 927
diff changeset
   265
d4d907fc7d78 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 927
diff changeset
   266
    gcId isNil ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   267
	self initGC
950
d4d907fc7d78 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 927
diff changeset
   268
    ].
1715
c70e31496f91 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1714
diff changeset
   269
    device noClipIn:drawableId gc:gcId.
c70e31496f91 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1714
diff changeset
   270
    device setClipByChildren:aBoolean in:drawableId gc:gcId.
950
d4d907fc7d78 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 927
diff changeset
   271
d4d907fc7d78 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 927
diff changeset
   272
    "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
   273
    "Modified: 29.4.1997 / 15:33:55 / dq"
950
d4d907fc7d78 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 927
diff changeset
   274
!
d4d907fc7d78 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 927
diff changeset
   275
6215
701d3f1f91f7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6210
diff changeset
   276
clippingBounds:aRectangleOrNil
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   277
    "set the clipping rectangle for drawing (in logical coordinates);
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   278
     a nil argument turn off clipping (i.e. whole view is drawable)"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   279
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   280
    |x y w h newBounds|
7066
ac2d03dac697 #REFACTORING
Stefan Vogel <sv@exept.de>
parents: 7064
diff changeset
   281
ac2d03dac697 #REFACTORING
Stefan Vogel <sv@exept.de>
parents: 7064
diff changeset
   282
    aRectangleOrNil isNil ifTrue:[
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   283
	clipRect isNil ifTrue:[^ self].
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   284
	gcId notNil ifTrue:[
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   285
	    device noClipIn:drawableId gc:gcId
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   286
	].
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   287
	clipRect := nil.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   288
	^ self.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   289
    ].
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   290
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   291
    x := aRectangleOrNil left.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   292
    y := aRectangleOrNil top.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   293
    w := aRectangleOrNil width.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   294
    h := aRectangleOrNil height.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   295
    transformation notNil ifTrue:[
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   296
	x := transformation applyToX:x.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   297
	y := transformation applyToY:y.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   298
	w := transformation applyScaleX:w.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   299
	h := transformation applyScaleY:h.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   300
    ].
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   301
    (x class == SmallInteger) ifFalse:[
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   302
	w := w + (x - x truncated).
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   303
	x := x truncated
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   304
    ].
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   305
    (y class == SmallInteger) ifFalse:[
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   306
	h := h + (y - y truncated).
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   307
	y := y truncated
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   308
    ].
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   309
    (w class == SmallInteger) ifFalse:[
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   310
	w := w truncated + 1
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   311
    ].
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   312
    (h class == SmallInteger) ifFalse:[
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   313
	h := h truncated + 1
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   314
    ].
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   315
    w := w max:0.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   316
    h := h max:0.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   317
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   318
    newBounds := Rectangle left:x top:y width:w height:h.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   319
    (clipRect notNil and:[clipRect = newBounds]) ifTrue:[
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   320
	^ self
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   321
    ].
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   322
    clipRect := newBounds.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   323
    gcId notNil ifTrue:[
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   324
	device setClipX:x y:y width:w height:h in:drawableId gc:gcId.
6222
2d670d3bcfd5 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6215
diff changeset
   325
    ].
2d670d3bcfd5 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6215
diff changeset
   326
2d670d3bcfd5 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6215
diff changeset
   327
    "Created: / 28.5.1996 / 19:40:20 / cg"
2d670d3bcfd5 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6215
diff changeset
   328
    "Modified: / 16.5.1999 / 19:40:37 / cg"
2d670d3bcfd5 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6215
diff changeset
   329
!
2d670d3bcfd5 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6215
diff changeset
   330
1842
502aa16b146e added #colorAt:
Claus Gittinger <cg@exept.de>
parents: 1805
diff changeset
   331
colorAt:aPoint
502aa16b146e added #colorAt:
Claus Gittinger <cg@exept.de>
parents: 1805
diff changeset
   332
    "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
   333
502aa16b146e added #colorAt:
Claus Gittinger <cg@exept.de>
parents: 1805
diff changeset
   334
    ^ self colorAtX:(aPoint x) y:(aPoint y)
502aa16b146e added #colorAt:
Claus Gittinger <cg@exept.de>
parents: 1805
diff changeset
   335
502aa16b146e added #colorAt:
Claus Gittinger <cg@exept.de>
parents: 1805
diff changeset
   336
    "Modified: 1.8.1997 / 20:01:58 / cg"
502aa16b146e added #colorAt:
Claus Gittinger <cg@exept.de>
parents: 1805
diff changeset
   337
!
502aa16b146e added #colorAt:
Claus Gittinger <cg@exept.de>
parents: 1805
diff changeset
   338
502aa16b146e added #colorAt:
Claus Gittinger <cg@exept.de>
parents: 1805
diff changeset
   339
colorAtX:x y:y
502aa16b146e added #colorAt:
Claus Gittinger <cg@exept.de>
parents: 1805
diff changeset
   340
    "return the color of the pixel at the coordinate given by aPoint"
502aa16b146e added #colorAt:
Claus Gittinger <cg@exept.de>
parents: 1805
diff changeset
   341
502aa16b146e added #colorAt:
Claus Gittinger <cg@exept.de>
parents: 1805
diff changeset
   342
    |pixel|
502aa16b146e added #colorAt:
Claus Gittinger <cg@exept.de>
parents: 1805
diff changeset
   343
502aa16b146e added #colorAt:
Claus Gittinger <cg@exept.de>
parents: 1805
diff changeset
   344
    pixel := self atX:x y:y.
502aa16b146e added #colorAt:
Claus Gittinger <cg@exept.de>
parents: 1805
diff changeset
   345
    device getScaledRGBFrom:pixel into:[:r :g :b |
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   346
	^ Color scaledRed:r scaledGreen:g scaledBlue:b
1842
502aa16b146e added #colorAt:
Claus Gittinger <cg@exept.de>
parents: 1805
diff changeset
   347
    ].
502aa16b146e added #colorAt:
Claus Gittinger <cg@exept.de>
parents: 1805
diff changeset
   348
502aa16b146e added #colorAt:
Claus Gittinger <cg@exept.de>
parents: 1805
diff changeset
   349
    "Created: 1.8.1997 / 20:01:32 / cg"
502aa16b146e added #colorAt:
Claus Gittinger <cg@exept.de>
parents: 1805
diff changeset
   350
!
502aa16b146e added #colorAt:
Claus Gittinger <cg@exept.de>
parents: 1805
diff changeset
   351
4199
c01c62e8c7a5 dummy container
Claus Gittinger <cg@exept.de>
parents: 4172
diff changeset
   352
container
c01c62e8c7a5 dummy container
Claus Gittinger <cg@exept.de>
parents: 4172
diff changeset
   353
    "return my container - for protocol compatibility"
c01c62e8c7a5 dummy container
Claus Gittinger <cg@exept.de>
parents: 4172
diff changeset
   354
c01c62e8c7a5 dummy container
Claus Gittinger <cg@exept.de>
parents: 4172
diff changeset
   355
    ^ nil
c01c62e8c7a5 dummy container
Claus Gittinger <cg@exept.de>
parents: 4172
diff changeset
   356
!
c01c62e8c7a5 dummy container
Claus Gittinger <cg@exept.de>
parents: 4172
diff changeset
   357
786
af5fecf93126 added dashStyle: ...
Claus Gittinger <cg@exept.de>
parents: 784
diff changeset
   358
dashStyle:aDashList offset:dashOffset
af5fecf93126 added dashStyle: ...
Claus Gittinger <cg@exept.de>
parents: 784
diff changeset
   359
    "define dashes. Each element of the dashList specifies the length
af5fecf93126 added dashStyle: ...
Claus Gittinger <cg@exept.de>
parents: 784
diff changeset
   360
     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
   361
     defines 4on-4off dashing;
786
af5fecf93126 added dashStyle: ...
Claus Gittinger <cg@exept.de>
parents: 784
diff changeset
   362
     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
   363
     The dashOffset specifies where in the dashList the dashing starts.
af5fecf93126 added dashStyle: ...
Claus Gittinger <cg@exept.de>
parents: 784
diff changeset
   364
     This may not be supported by all graphics devices."
af5fecf93126 added dashStyle: ...
Claus Gittinger <cg@exept.de>
parents: 784
diff changeset
   365
af5fecf93126 added dashStyle: ...
Claus Gittinger <cg@exept.de>
parents: 784
diff changeset
   366
    gcId notNil ifTrue:[
1029
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
   367
	device setDashes:(ByteArray withAll:aDashList)
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
   368
	      dashOffset:dashOffset
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
   369
		      in:gcId
786
af5fecf93126 added dashStyle: ...
Claus Gittinger <cg@exept.de>
parents: 784
diff changeset
   370
    ]
af5fecf93126 added dashStyle: ...
Claus Gittinger <cg@exept.de>
parents: 784
diff changeset
   371
af5fecf93126 added dashStyle: ...
Claus Gittinger <cg@exept.de>
parents: 784
diff changeset
   372
    "Modified: 4.6.1996 / 19:03:06 / cg"
af5fecf93126 added dashStyle: ...
Claus Gittinger <cg@exept.de>
parents: 784
diff changeset
   373
!
af5fecf93126 added dashStyle: ...
Claus Gittinger <cg@exept.de>
parents: 784
diff changeset
   374
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   375
device
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   376
    "return the device, the receiver is associated with"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   377
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   378
    ^ device
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   379
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   380
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   381
device:aDevice
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   382
    "set the device"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   383
7443
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
   384
    device == aDevice ifTrue:[
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
   385
        ^ self.
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
   386
    ].
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
   387
    device notNil ifTrue:[
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
   388
        "change of device of an already existing GraphicsContext"
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
   389
        drawableId notNil ifTrue:[
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
   390
            device unregisterGraphicsContext:self.
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
   391
        ].
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
   392
        device := aDevice.
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
   393
        self recreate.
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
   394
        ^ self.
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
   395
    ].
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
   396
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
   397
    "set device of a new GraphicsContext"
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   398
    device := aDevice
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   399
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   400
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   401
deviceClippingBounds:aRectangleOrNil
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   402
    "set the clipping rectangle for drawing (in device coordinates);
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   403
     a nil argument turns off clipping (i.e. whole view is drawable - incl. margins)"
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   404
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   405
    clipRect = aRectangleOrNil ifTrue:[
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   406
	^ self
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   407
    ].
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   408
    clipRect := aRectangleOrNil.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   409
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   410
    gcId isNil ifTrue:[
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   411
	^ self.
7060
Stefan Vogel <sv@exept.de>
parents: 6926
diff changeset
   412
    ].
Stefan Vogel <sv@exept.de>
parents: 6926
diff changeset
   413
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   414
    aRectangleOrNil isNil ifTrue:[
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   415
	device noClipIn:drawableId gc:gcId
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   416
    ] ifFalse:[
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   417
	device setClipX:aRectangleOrNil left
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   418
		    y:aRectangleOrNil top
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   419
		    width:aRectangleOrNil width
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   420
		    height:aRectangleOrNil height
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   421
		    in:drawableId
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   422
		    gc:gcId
7060
Stefan Vogel <sv@exept.de>
parents: 6926
diff changeset
   423
    ].
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   424
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   425
    "Modified: / 22.5.1996 / 13:12:07 / cg"
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   426
    "Created: / 14.9.1998 / 18:50:31 / cg"
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   427
!
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   428
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   429
deviceClippingBoundsOrNil
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   430
    "get the clipping rectangle for drawing (in device coordinates);
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   431
     a nil clipping rectangle means: no clipping (i.e. whole view is drawable - incl. margins)"
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   432
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   433
    ^ clipRect
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   434
!
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   435
7502
83e3d1504fc2 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7476
diff changeset
   436
deviceFont
83e3d1504fc2 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7476
diff changeset
   437
    "return the font for drawing - here, a device font is returned if
83e3d1504fc2 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7476
diff changeset
   438
     the GC is realized."
83e3d1504fc2 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7476
diff changeset
   439
83e3d1504fc2 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7476
diff changeset
   440
    (device notNil and:[font notNil]) ifTrue:[
83e3d1504fc2 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7476
diff changeset
   441
        font := font onDevice:device
83e3d1504fc2 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7476
diff changeset
   442
    ].
83e3d1504fc2 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7476
diff changeset
   443
    ^ font
83e3d1504fc2 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7476
diff changeset
   444
!
83e3d1504fc2 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7476
diff changeset
   445
6222
2d670d3bcfd5 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6215
diff changeset
   446
drawableId
2d670d3bcfd5 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6215
diff changeset
   447
    "return the id of the drawable on the device"
2d670d3bcfd5 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6215
diff changeset
   448
2d670d3bcfd5 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6215
diff changeset
   449
    ^ drawableId
2d670d3bcfd5 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6215
diff changeset
   450
!
2d670d3bcfd5 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6215
diff changeset
   451
2918
1e777dc8588a #font answers device font if possible (cg)
Stefan Vogel <sv@exept.de>
parents: 2913
diff changeset
   452
font
1e777dc8588a #font answers device font if possible (cg)
Stefan Vogel <sv@exept.de>
parents: 2913
diff changeset
   453
    "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
   454
     the GC is realized."
1e777dc8588a #font answers device font if possible (cg)
Stefan Vogel <sv@exept.de>
parents: 2913
diff changeset
   455
7218
4c15124a9431 #BUGFIX
Stefan Vogel <sv@exept.de>
parents: 7066
diff changeset
   456
    (device notNil and:[font notNil]) ifTrue:[
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   457
	font := font onDevice:device
2918
1e777dc8588a #font answers device font if possible (cg)
Stefan Vogel <sv@exept.de>
parents: 2913
diff changeset
   458
    ].
1e777dc8588a #font answers device font if possible (cg)
Stefan Vogel <sv@exept.de>
parents: 2913
diff changeset
   459
    ^ font
1e777dc8588a #font answers device font if possible (cg)
Stefan Vogel <sv@exept.de>
parents: 2913
diff changeset
   460
!
1e777dc8588a #font answers device font if possible (cg)
Stefan Vogel <sv@exept.de>
parents: 2913
diff changeset
   461
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   462
font:aFont
7560
086e2f28082c #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7510
diff changeset
   463
    "set the font for drawing if it has changed.
086e2f28082c #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7510
diff changeset
   464
     This is a low level entry, which is not to be redefined
086e2f28082c #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7510
diff changeset
   465
     (i.e. it must not imply a redraw operation)"
086e2f28082c #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7510
diff changeset
   466
086e2f28082c #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7510
diff changeset
   467
    |id|
086e2f28082c #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7510
diff changeset
   468
086e2f28082c #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7510
diff changeset
   469
    (aFont notNil and:[aFont ~~ font]) ifTrue:[
086e2f28082c #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7510
diff changeset
   470
        font := aFont.
086e2f28082c #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7510
diff changeset
   471
        device notNil ifTrue:[
086e2f28082c #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7510
diff changeset
   472
            font := font onDevice:device.
086e2f28082c #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7510
diff changeset
   473
            gcId notNil ifTrue:[
086e2f28082c #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7510
diff changeset
   474
                id := font fontId.
086e2f28082c #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7510
diff changeset
   475
                id notNil ifTrue:[
086e2f28082c #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7510
diff changeset
   476
                    deviceFont := font.
086e2f28082c #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7510
diff changeset
   477
                    device setFont:id in:gcId
086e2f28082c #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7510
diff changeset
   478
                ]
086e2f28082c #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7510
diff changeset
   479
            ]
086e2f28082c #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7510
diff changeset
   480
        ]
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   481
    ]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   482
7560
086e2f28082c #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7510
diff changeset
   483
    "Created: / 23-02-1996 / 17:16:51 / cg"
086e2f28082c #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7510
diff changeset
   484
    "Modified: / 22-10-2006 / 14:11:37 / cg"
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   485
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   486
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   487
function:aSymbol
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   488
    "set the drawing function if it has changed"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   489
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   490
    (aSymbol ~~ function) ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   491
	function := aSymbol.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   492
	gcId notNil ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   493
	    device setFunction:aSymbol in:gcId
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   494
	]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   495
    ]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   496
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   497
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   498
gcId
7237
9482956af0f1 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 7218
diff changeset
   499
    "return the receiver's graphic context id on the device"
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   500
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   501
    ^ gcId
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   502
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   503
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   504
id
6222
2d670d3bcfd5 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6215
diff changeset
   505
    "return the id of the drawable on the device"
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   506
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   507
    ^ drawableId
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   508
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   509
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   510
joinStyle:aSymbol
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   511
    "set the style in which 2 lines are connected in polygons -
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   512
     aSymbol may be #miter, #bevel, #round"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   513
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   514
    |s|
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
    (s := aSymbol) isNil ifTrue:[
1029
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
   517
	s := #miter
732
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
    (s ~~ joinStyle) ifTrue:[
1029
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
   520
	joinStyle := s.
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   521
1029
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
   522
	gcId notNil ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   523
	    device setLineWidth:lineWidth
1029
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
   524
			  style:lineStyle
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
   525
			    cap:capStyle
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
   526
			   join:s
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
   527
			     in:gcId
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
   528
	]
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   529
    ]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   530
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   531
    "Modified: 12.5.1996 / 22:20:43 / cg"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   532
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   533
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   534
lineStyle:aSymbol
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   535
    "set the style in which lines are drawn -
2360
c7ca5d55d8ce comment
Claus Gittinger <cg@exept.de>
parents: 2343
diff changeset
   536
     aSymbol may be #solid, #dashed, #doubleDashed,
c7ca5d55d8ce comment
Claus Gittinger <cg@exept.de>
parents: 2343
diff changeset
   537
     #dotted, #dashDot or #dashDotDot."
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   538
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   539
    |s|
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   540
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   541
    (s := aSymbol) isNil ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   542
	s := #solid
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   543
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   544
    (s ~~ lineStyle) ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   545
	lineStyle := s.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   546
	gcId notNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   547
	    device setLineWidth:lineWidth
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   548
			  style:s
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   549
			    cap:capStyle
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   550
			   join:joinStyle
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   551
			     in:gcId
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   552
	]
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   553
    ]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   554
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   555
    "Modified: 12.5.1996 / 22:21:25 / cg"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   556
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   557
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   558
lineWidth:aNumber
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   559
    "set the line width for drawing if it has changed"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   560
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   561
    |n|
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   562
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   563
    (aNumber ~~ lineWidth) ifTrue:[
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   564
	lineWidth := aNumber.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   565
	transformation isNil ifTrue:[
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   566
	    n := aNumber.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   567
	] ifFalse:[
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   568
	    n := transformation applyScaleX:aNumber.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   569
	    n := n rounded
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   570
	].
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   571
	gcId notNil ifTrue:[
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   572
	    device setLineWidth:n style:lineStyle cap:capStyle join:joinStyle in:gcId
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   573
	]
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   574
    ]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   575
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   576
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   577
mask:aForm
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   578
    "set the mask form for drawing"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   579
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   580
    |id|
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   581
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   582
    (aForm ~~ mask) ifTrue:[
7629
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
   583
        mask := aForm.
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
   584
        gcId notNil ifTrue:[
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
   585
            (mask == nil) ifTrue:[
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
   586
                device setBitmapMask:nil in:gcId
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
   587
            ] ifFalse:[
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
   588
                mask := mask asFormOn:device.
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
   589
                id := mask drawableId.
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
   590
                (mask depth == 1) ifTrue:[
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
   591
                    device setBitmapMask:id in:gcId
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
   592
                ] ifFalse:[
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
   593
                    device setPixmapMask:id in:gcId
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
   594
                ]
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
   595
            ]
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
   596
        ]
732
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
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   599
2018
1ad552e97c67 maskOrigin
Claus Gittinger <cg@exept.de>
parents: 2016
diff changeset
   600
maskOrigin:aPoint
1ad552e97c67 maskOrigin
Claus Gittinger <cg@exept.de>
parents: 2016
diff changeset
   601
    "set the origin of the mask-pattern"
1ad552e97c67 maskOrigin
Claus Gittinger <cg@exept.de>
parents: 2016
diff changeset
   602
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
   603
    |x y pO|
2018
1ad552e97c67 maskOrigin
Claus Gittinger <cg@exept.de>
parents: 2016
diff changeset
   604
1ad552e97c67 maskOrigin
Claus Gittinger <cg@exept.de>
parents: 2016
diff changeset
   605
    x := aPoint x.
1ad552e97c67 maskOrigin
Claus Gittinger <cg@exept.de>
parents: 2016
diff changeset
   606
    y := aPoint y.
1ad552e97c67 maskOrigin
Claus Gittinger <cg@exept.de>
parents: 2016
diff changeset
   607
1ad552e97c67 maskOrigin
Claus Gittinger <cg@exept.de>
parents: 2016
diff changeset
   608
    (maskOrigin isNil or:[
1ad552e97c67 maskOrigin
Claus Gittinger <cg@exept.de>
parents: 2016
diff changeset
   609
     ((x ~= maskOrigin x) or:[y ~= maskOrigin y]) ]) ifTrue:[
1ad552e97c67 maskOrigin
Claus Gittinger <cg@exept.de>
parents: 2016
diff changeset
   610
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
   611
        maskOrigin := aPoint.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
   612
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
   613
        transformation notNil ifTrue:[
6711
2b50385f7257 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
   614
            pO := transformation transformPoint:aPoint.
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
   615
            x:= pO x.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
   616
            y := pO y.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
   617
        ].
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
   618
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
   619
        gcId notNil ifTrue:[
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   620
            device setMaskOriginX:x rounded y:y rounded in:gcId
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
   621
        ]
2018
1ad552e97c67 maskOrigin
Claus Gittinger <cg@exept.de>
parents: 2016
diff changeset
   622
    ]
1ad552e97c67 maskOrigin
Claus Gittinger <cg@exept.de>
parents: 2016
diff changeset
   623
1ad552e97c67 maskOrigin
Claus Gittinger <cg@exept.de>
parents: 2016
diff changeset
   624
    "Created: / 26.1.1998 / 19:03:02 / cg"
1ad552e97c67 maskOrigin
Claus Gittinger <cg@exept.de>
parents: 2016
diff changeset
   625
!
1ad552e97c67 maskOrigin
Claus Gittinger <cg@exept.de>
parents: 2016
diff changeset
   626
2016
bef5fe2ec2ca checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2013
diff changeset
   627
maskOriginX:orgX y:orgY
bef5fe2ec2ca checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2013
diff changeset
   628
    "set the origin of the pattern"
bef5fe2ec2ca checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2013
diff changeset
   629
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
   630
    self maskOrigin:(orgX @ orgY)
2016
bef5fe2ec2ca checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2013
diff changeset
   631
!
bef5fe2ec2ca checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2013
diff changeset
   632
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   633
paint:aColor
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   634
    "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
   635
     or even an image."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   636
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   637
    (aColor ~~ paint) ifTrue:[
1029
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
   638
	aColor notNil ifTrue:[
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
   639
	    paint := aColor.
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
   640
	    self setGCForPaint.
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
   641
	]
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   642
    ]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   643
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   644
    "Modified: 16.5.1996 / 15:35:57 / cg"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   645
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   646
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   647
paint:fgColor on:bgColor
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   648
    "set the paint and background-paint color.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   649
     The bg-paint is used in opaque-draw operations"
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
    |fgId bgId|
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
    ((fgColor ~~ paint) or:[bgColor ~~ bgPaint]) ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   654
	fgColor notNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   655
	    paint := fgColor
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   656
	].
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   657
	bgColor notNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   658
	    bgPaint := bgColor
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   659
	].
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   660
	gcId notNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   661
	    paint isColor ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   662
		paint := paint onDevice:device.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   663
	    ].
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   664
	    paint isColor ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   665
		fgId := paint colorId.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   666
		fgId notNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   667
		    mask notNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   668
			mask := nil.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   669
			device setBitmapMask:nil in:gcId
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   670
		    ].
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   671
		    bgPaint isColor ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   672
			bgPaint := bgPaint onDevice:device.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   673
		    ].
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   674
		    bgPaint isColor ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   675
			bgId := bgPaint colorId.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   676
			bgId notNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   677
			    "the common case, both are real colors"
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   678
			    (paint ~~ foreground) ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   679
				foreground := paint.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   680
				(bgPaint ~~ background) ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   681
				    background := bgPaint.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   682
				    device setForeground:fgId background:bgId in:gcId.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   683
				    ^ self
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   684
				].
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   685
				device setForeground:fgId in:gcId.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   686
				^ self
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   687
			    ].
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   688
			    (bgPaint ~~ background) ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   689
				background := bgPaint.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   690
				device setBackground:bgId in:gcId.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   691
			    ].
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   692
			    ^ self
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   693
			].
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   694
			"bgPaint is dithered, setup paint here, leave bgPaint
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   695
			 till next opaque draw comes around."
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   696
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   697
			(paint ~~ foreground) ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   698
			    foreground := paint.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   699
			    device setForeground:fgId in:gcId
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   700
			].
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   701
			^ self
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   702
		    ]
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   703
		]
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   704
	    ].
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   705
	    "either paint or bgPaint (or both) are dithered colors,
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   706
	     setup for paint, leave bg-problem till next opaque draw
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   707
	     comes around.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   708
	    "
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   709
	    self setGCForPaint.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   710
	]
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   711
    ]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   712
4797
91ee43d3acf5 changed #paint:on:
Claus Gittinger <cg@exept.de>
parents: 4781
diff changeset
   713
    "Modified: / 31-08-2007 / 10:56:49 / cg"
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   714
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   715
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   716
paint:fgColor on:bgColor function:f
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   717
    "set paint, background-paint and function"
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
    self paint:fgColor on:bgColor.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   720
    self function:f
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
    "Modified: 16.5.1996 / 15:36:35 / cg"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   723
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   724
6266
1503c5e038d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   725
setClippingBounds:aRectangleOrNil
6501
ef63b2302cba class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6497
diff changeset
   726
    "set the clipping rectangle for drawing (in logical coordinates).
6266
1503c5e038d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   727
     Only set the variable, do not change the gc"
1503c5e038d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   728
1503c5e038d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   729
    clipRect := aRectangleOrNil
1503c5e038d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   730
!
1503c5e038d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   731
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   732
setDeviceMaskOriginX:x y:y
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   733
    "set the origin of the mask-pattern"
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   734
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   735
    gcId notNil ifTrue:[
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   736
        device setMaskOriginX:x rounded y:y rounded in:gcId
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   737
    ].
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   738
!
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   739
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   740
setGraphicsExposures:aBoolean
7651
ad5c7f222b7c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7647
diff changeset
   741
    "want to if aBoolean is true - or don't want to be notified
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   742
     of graphics exposures"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   743
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   744
    gcId notNil ifTrue:[
7651
ad5c7f222b7c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7647
diff changeset
   745
        device setGraphicsExposures:aBoolean in:gcId
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   746
    ]
6266
1503c5e038d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   747
!
1503c5e038d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   748
1503c5e038d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   749
setPaint:fgColor on:bgColor
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   750
    "set the paint and background-paint color.
6266
1503c5e038d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   751
     The bg-paint is used in opaque-draw operations.
1503c5e038d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   752
     Only set the variables, but do not send it to the device,
1503c5e038d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   753
     Used on initialization."
1503c5e038d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   754
1503c5e038d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   755
    fgColor notNil ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   756
	foreground := paint := fgColor
6266
1503c5e038d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   757
    ].
1503c5e038d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   758
    bgColor notNil ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   759
	background := bgPaint := bgColor
6266
1503c5e038d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   760
    ].
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   761
! !
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   762
1092
1b6391f333de category rename
Claus Gittinger <cg@exept.de>
parents: 1085
diff changeset
   763
!DeviceGraphicsContext methodsFor:'accessing-internals'!
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   764
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   765
background
6266
1503c5e038d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   766
    <resource: #obsolete>
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   767
    "return the current background drawing color.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   768
     OBSOLETE: use #paint: / #backgroundPaint: / #paint:on:"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   769
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   770
    ^ background
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   771
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   772
    "Modified: 12.5.1996 / 22:28:09 / cg"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   773
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   774
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   775
background:aColor
6266
1503c5e038d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   776
    <resource: #obsolete>
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   777
    "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
   778
     OBSOLETE: this method will vanish; use #paint: / #backgroundPaint: / #paint:on:"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   779
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   780
    |bgId|
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   781
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   782
    (aColor ~~ background) ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   783
	aColor notNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   784
	    background := aColor.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   785
	    gcId notNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   786
		background := background onDevice:device.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   787
		bgId := background colorId.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   788
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   789
		"
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   790
		 mhmh the following is a kludge ....
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   791
		"
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   792
		bgId isNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   793
		    (background grayIntensity >= 50) ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   794
			bgId := device whitepixel
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   795
		    ] ifFalse:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   796
			bgId := device blackpixel
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   797
		    ]
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   798
		].
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   799
		device setBackground:bgId in:gcId
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   800
	    ]
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   801
	]
732
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
745
d4465098f2c0 gray vs. grey
Claus Gittinger <cg@exept.de>
parents: 735
diff changeset
   804
    "Modified: 28.5.1996 / 20:44:55 / cg"
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   805
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   806
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   807
foreground
6266
1503c5e038d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   808
    <resource: #obsolete>
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   809
    "return the current foreground drawing color.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   810
     OBSOLETE: use #paint: / #paint:on:"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   811
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   812
    ^ foreground
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   813
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   814
    "Modified: 12.5.1996 / 22:28:03 / cg"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   815
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   816
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   817
foreground:aColor
6266
1503c5e038d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   818
    <resource: #obsolete>
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   819
    "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
   820
     OBSOLETE: this method will vanish; use #paint: / #paint:on:"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   821
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   822
    |fgId|
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   823
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   824
    (aColor ~~ foreground) ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   825
	aColor notNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   826
	    foreground := aColor.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   827
	    gcId notNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   828
		(foreground class == SmallInteger) ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   829
		    fgId := foreground
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   830
		] ifFalse:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   831
		    foreground := foreground onDevice:device.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   832
		    fgId := foreground colorId.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   833
		].
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   834
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   835
		"mhmh the following is a kludge ...."
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   836
		fgId isNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   837
		    (foreground grayIntensity >= 50) ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   838
			fgId := device whitepixel
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   839
		    ] ifFalse:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   840
			fgId := device blackpixel
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
		].
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   843
		device setForeground:fgId in:gcId.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   844
		paint := foreground
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   845
	    ]
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   846
	]
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   847
    ]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   848
745
d4465098f2c0 gray vs. grey
Claus Gittinger <cg@exept.de>
parents: 735
diff changeset
   849
    "Modified: 28.5.1996 / 20:45:02 / cg"
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   850
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   851
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   852
foreground:fgColor background:bgColor
6266
1503c5e038d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   853
    <resource: #obsolete>
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   854
    "set both internal foreground and internal background colors
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   855
     - these must be real colors.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   856
     OBSOLETE: this method will vanish; use #paint: / #paint:on:"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   857
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   858
    |fgPixel bgPixel|
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   859
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   860
    ((fgColor ~~ foreground) or:[bgColor ~~ background]) ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   861
	fgColor notNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   862
	    foreground := fgColor
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   863
	].
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   864
	bgColor notNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   865
	    background := bgColor
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   866
	].
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   867
	gcId notNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   868
	    foreground := foreground onDevice:device.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   869
	    background := background onDevice:device.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   870
	    fgPixel := foreground colorId.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   871
	    bgPixel := background colorId.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   872
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   873
	    "mhmh the following is a kludge ...."
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   874
	    fgPixel isNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   875
		(foreground grayIntensity >= 50) ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   876
		    fgPixel := device whitepixel
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   877
		] ifFalse:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   878
		    fgPixel := device blackpixel
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   879
		]
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   880
	    ].
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   881
	    bgPixel isNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   882
		(background grayIntensity >= 50) ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   883
		    bgPixel := device whitepixel
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   884
		] ifFalse:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   885
		    bgPixel := device blackpixel
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   886
		]
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   887
	    ].
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   888
	    device setForeground:fgPixel background:bgPixel in:gcId.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   889
	    paint := foreground
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   890
	]
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   891
    ]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   892
745
d4465098f2c0 gray vs. grey
Claus Gittinger <cg@exept.de>
parents: 735
diff changeset
   893
    "Modified: 28.5.1996 / 20:45:27 / cg"
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   894
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   895
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   896
foreground:aColor function:fun
6266
1503c5e038d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   897
    <resource: #obsolete>
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   898
    "set the foreground color and function for drawing.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   899
     OBSOLETE: this method will vanish; use #paint: / #paint:on:"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   900
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   901
    |fgPixel|
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   902
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   903
    ((aColor ~~ foreground) or:[fun ~~ function]) ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   904
	foreground := aColor.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   905
	function := fun.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   906
	gcId notNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   907
	    foreground := foreground onDevice:device.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   908
	    fgPixel := foreground colorId.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   909
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   910
	    "mhmh the following is a kludge ...."
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   911
	    fgPixel isNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   912
		(foreground grayIntensity >= 50) ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   913
		    fgPixel := device whitepixel
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   914
		] ifFalse:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   915
		    fgPixel := device blackpixel
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   916
		]
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   917
	    ].
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   918
	    device setForeground:fgPixel in:gcId.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   919
	    device setFunction:fun in:gcId.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   920
	    paint := foreground
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   921
	]
732
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
745
d4465098f2c0 gray vs. grey
Claus Gittinger <cg@exept.de>
parents: 735
diff changeset
   924
    "Modified: 28.5.1996 / 20:45:09 / cg"
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   925
! !
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   926
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   927
!DeviceGraphicsContext methodsFor:'bit blitting'!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   928
2016
bef5fe2ec2ca checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2013
diff changeset
   929
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
   930
    "copy bits from a smalltalk byteArray.
bef5fe2ec2ca checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2013
diff changeset
   931
     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
   932
     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
   933
     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
   934
     method to whatever the device needs."
bef5fe2ec2ca checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2013
diff changeset
   935
bef5fe2ec2ca checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2013
diff changeset
   936
    device
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   937
	drawBits:aByteArray
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   938
	bitsPerPixel:bpp
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   939
	depth:depth
2016
bef5fe2ec2ca checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2013
diff changeset
   940
	padding:pad
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   941
	width:srcW height:srcH
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   942
	x:srcX y:srcY
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   943
	into:drawableId
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   944
	x:dstX y:dstY
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   945
	width:srcW height:srcH       "all senders set srcW/srcH to self width / self height"
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   946
	with:gcId.
2016
bef5fe2ec2ca checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2013
diff changeset
   947
!
bef5fe2ec2ca checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2013
diff changeset
   948
7456
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
   949
copyFrom:aGC x:srcX y:srcY toX:dstX y:dstY width:w height:h depth:depth
1291
1480f8aae3bb explicit sync/async bitBlt.
Claus Gittinger <cg@exept.de>
parents: 1255
diff changeset
   950
    "copy from aDrawable into the receiver;
1480f8aae3bb explicit sync/async bitBlt.
Claus Gittinger <cg@exept.de>
parents: 1255
diff changeset
   951
     the source may be the receiver as well - in this case its a scroll.
7749
f4ad7601ae41 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 7746
diff changeset
   952
     All coordinates are in device coordinates."
1291
1480f8aae3bb explicit sync/async bitBlt.
Claus Gittinger <cg@exept.de>
parents: 1255
diff changeset
   953
7456
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
   954
    |srcGCId srcDrawableId|
732
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
    gcId isNil ifTrue:[
7456
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
   957
        self initGC
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   958
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   959
7749
f4ad7601ae41 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 7746
diff changeset
   960
    srcGCId := aGC initGC.
7456
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
   961
    srcDrawableId := aGC drawableId.
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
   962
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
   963
    ((depth == 1) and:[device depth ~~ 1]) ifTrue:[
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
   964
        aGC isPixmap ifTrue:[
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
   965
            device
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
   966
                copyPlaneFromPixmapId:srcDrawableId
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
   967
                x:srcX
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
   968
                y:srcY
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
   969
                gc:srcGCId
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
   970
                to:drawableId
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
   971
                x:dstX
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
   972
                y:dstY
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
   973
                gc:gcId
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
   974
                width:w
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
   975
                height:h
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
   976
        ] ifFalse:[
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
   977
            device
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
   978
                copyPlaneFromId:srcDrawableId
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
   979
                x:srcX
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
   980
                y:srcY
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
   981
                gc:srcGCId
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
   982
                to:drawableId
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
   983
                x:dstX
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
   984
                y:dstY
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
   985
                gc:gcId
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
   986
                width:w
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
   987
                height:h
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
   988
        ]
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   989
    ] ifFalse:[
7456
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
   990
        aGC isPixmap ifTrue:[
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
   991
            device
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
   992
                copyFromPixmapId:srcDrawableId
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
   993
                x:srcX
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
   994
                y:srcY
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
   995
                gc:srcGCId
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
   996
                to:drawableId
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
   997
                x:dstX
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
   998
                y:dstY
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
   999
                gc:gcId
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
  1000
                width:w
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
  1001
                height:h
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
  1002
        ] ifFalse:[
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
  1003
            device
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
  1004
                copyFromId:srcDrawableId
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
  1005
                x:srcX
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
  1006
                y:srcY
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
  1007
                gc:srcGCId
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
  1008
                to:drawableId
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
  1009
                x:dstX
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
  1010
                y:dstY
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
  1011
                gc:gcId
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
  1012
                width:w
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
  1013
                height:h.
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
  1014
        ]
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
  1015
    ].
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1016
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1017
7456
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
  1018
copyPlaneFrom:aGC x:srcX y:srcY toX:dstX y:dstY width:w height:h
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1019
    "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
  1020
     background, while 1's are drawn with foreground color.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1021
     The depth of aDrawable must (should) be 1.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1022
     The drawable must have been allocated on the same device.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1023
     All coordinates are in device coordinates."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1024
7456
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
  1025
    |srcGCId srcDrawableId|
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1026
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1027
    gcId isNil ifTrue:[
7456
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
  1028
        self initGC
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1029
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1030
7749
f4ad7601ae41 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 7746
diff changeset
  1031
    srcGCId := aGC initGC.
7456
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
  1032
    srcDrawableId := aGC drawableId.
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
  1033
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
  1034
    aGC isPixmap ifTrue:[
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
  1035
        device
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
  1036
            copyPlaneFromPixmapId:srcDrawableId
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
  1037
            x:srcX
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
  1038
            y:srcY
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
  1039
            gc:srcGCId
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
  1040
            to:drawableId
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
  1041
            x:dstX
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
  1042
            y:dstY
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
  1043
            gc:gcId
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
  1044
            width:w
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
  1045
            height:h
1249
5224bb7a97bf use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  1046
    ] ifFalse:[
7456
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
  1047
        device
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
  1048
            copyPlaneFromId:srcDrawableId
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
  1049
            x:srcX
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
  1050
            y:srcY
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
  1051
            gc:srcGCId
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
  1052
            to:drawableId
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
  1053
            x:dstX
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
  1054
            y:dstY
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
  1055
            gc:gcId
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
  1056
            width:w
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
  1057
            height:h
1249
5224bb7a97bf use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  1058
    ]
5224bb7a97bf use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  1059
2271
46b68ae54cbc win32 needs source-gc to be initialized in a bitBlt.
Claus Gittinger <cg@exept.de>
parents: 2268
diff changeset
  1060
    "Modified: / 22.8.1998 / 15:15:52 / cg"
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1061
! !
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1062
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1063
!DeviceGraphicsContext methodsFor:'copying'!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1064
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1065
postCopy
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1066
    "this may not be enough to allow copying of views ..."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1067
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1068
    super postCopy.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1069
    device := drawableId := gcId := nil.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1070
    self recreate
4403
3342601d3fed +postDeepCopy
Claus Gittinger <cg@exept.de>
parents: 4389
diff changeset
  1071
!
3342601d3fed +postDeepCopy
Claus Gittinger <cg@exept.de>
parents: 4389
diff changeset
  1072
3342601d3fed +postDeepCopy
Claus Gittinger <cg@exept.de>
parents: 4389
diff changeset
  1073
postDeepCopy
3342601d3fed +postDeepCopy
Claus Gittinger <cg@exept.de>
parents: 4389
diff changeset
  1074
    device := drawableId := gcId := nil.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1075
! !
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1076
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1077
!DeviceGraphicsContext methodsFor:'drawing'!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1078
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1079
displayArcX:x y:y width:w height:h from:startAngle angle:angle
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1080
    "draw an arc; apply transformation if nonNil"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1081
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1082
    |pX pY nW nH sA a pO pC|
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1083
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1084
    gcId isNil ifTrue:[
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1085
	self initGC
732
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
    transformation notNil ifTrue:[
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1088
	pO := transformation transformPoint:x@y.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1089
	pC := transformation transformPoint:(x+w-1)@(y+h-1).
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1090
	pX := pO x.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1091
	pY := pO y.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1092
	nW := pC x - pX + 1.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1093
	nH := pC y - pY + 1.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1094
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1095
	nW < 0 ifTrue:[
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1096
	      nW := nW abs.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1097
	      pX := pX - nW.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1098
	].
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1099
	nH < 0 ifTrue:[
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1100
	      nH := nH abs.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1101
	      pY := pY - nH.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1102
	].
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1103
    ] ifFalse:[
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1104
	pX := x.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1105
	pY := y.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1106
	nW := w.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1107
	nH := h.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1108
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1109
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1110
    pX := pX rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1111
    pY := pY rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1112
    nW := nW rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1113
    nH := nH rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1114
2268
1a774fc02c83 fixed non-float (i.e. fraction) args to fillArc/ displayArc
Claus Gittinger <cg@exept.de>
parents: 2259
diff changeset
  1115
    sA := startAngle.
1a774fc02c83 fixed non-float (i.e. fraction) args to fillArc/ displayArc
Claus Gittinger <cg@exept.de>
parents: 2259
diff changeset
  1116
    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
  1117
    a := angle.
1a774fc02c83 fixed non-float (i.e. fraction) args to fillArc/ displayArc
Claus Gittinger <cg@exept.de>
parents: 2259
diff changeset
  1118
    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
  1119
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1120
    device
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1121
	  displayArcX:pX
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1122
		    y:pY
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1123
		width:nW
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1124
	       height:nH
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1125
		 from:sA
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1126
		angle:a
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1127
		   in:drawableId
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1128
		 with:gcId
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1129
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1130
    "Created: 8.5.1996 / 08:31:30 / cg"
784
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
  1131
    "Modified: 4.6.1996 / 17:59:28 / cg"
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1132
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1133
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1134
displayForm:formToDraw x:x y:y
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1135
    "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
  1136
     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
  1137
     current paint-color, leaving pixels with 0-bits unchanged
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1138
     (i.e. only 1-bits are drawn from the form).
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1139
     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
  1140
     settings are ignored and the form is drawn as-is.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1141
     Care must be taken, that the paint color is correctly allocated
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1142
     (by sending #on: to the color) before doing so.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1143
     Using functions other than #copy only makes sense if you are
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1144
     certain, that the colors are real colors (actually, only for
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1145
     noColor or allColor)."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1146
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1147
    |realForm pX pY w h nW nH pO pC|
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1148
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1149
    realForm := formToDraw.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1150
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1151
    transformation notNil ifTrue:[
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1152
	pO := transformation transformPoint:x@y.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1153
	pX := pO x.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1154
	pY := pO y.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1155
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1156
	transformation isNoScale ifFalse:[
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1157
	    w := formToDraw width.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1158
	    h := formToDraw height.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1159
	    pC := transformation applyTo:(x+w-1)@(y+h-1).
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1160
	    nW := pC x - pX + 1.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1161
	    nH := pC y - pY + 1.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1162
	    "/ nW := (transformation applyScaleX:w) rounded.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1163
	    "/ nH := (transformation applyScaleY:h) rounded.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1164
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1165
	    ((nW ~= w) or:[nH ~= h]) ifTrue:[
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1166
		"/
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1167
		"/ hard case - someone is drawing forms with scaling in effect
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1168
		"/ look if we have a scaled version in our pocket ...
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1169
		"/
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1170
		realForm := nil.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1171
		CachedScaledForms notNil ifTrue:[
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1172
		    (CachedScales at:formToDraw ifAbsent:nil) = transformation scale ifTrue:[
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1173
			realForm := CachedScaledForms at:formToDraw ifAbsent:nil.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1174
		    ]
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1175
		].
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1176
		realForm isNil ifTrue:[
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1177
		    "/
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1178
		    "/ nope - must do the work ...
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1179
		    "/
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1180
		    realForm := formToDraw magnifiedBy:(nW / w) @ (nH / h).
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1181
		    CachedScaledForms isNil ifTrue:[
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1182
			CachedScaledForms := WeakIdentityDictionary new.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1183
			CachedScales := WeakIdentityDictionary new.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1184
		    ].
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1185
		    CachedScaledForms at:formToDraw put:realForm.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1186
		    CachedScales at:formToDraw put:transformation scale.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1187
		]
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1188
	    ]
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1189
	]
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1190
    ] ifFalse:[
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1191
	pX := x.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1192
	pY := y.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1193
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1194
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1195
    self displayDeviceForm:realForm x:pX y:pY
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1196
1592
7ec770f2047a faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents: 1517
diff changeset
  1197
    "Modified: 12.4.1997 / 12:47:29 / cg"
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1198
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1199
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1200
displayLineFrom:p0 to:p1
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1201
    "draw a line (with current paint-color); apply transformation if nonNil"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1202
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1203
    |pX0 pY0 pX1 pY1 easy fgId bgId tp0 tp1|
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1204
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1205
    gcId isNil ifTrue:[
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1206
	self initGC
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1207
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1208
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1209
    lineStyle == #doubleDashed ifTrue:[
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1210
	"
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1211
	 if bgPaint or paint is not a real color, we have to do it the hard way ...
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1212
	"
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1213
	easy := true.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1214
	paint isColor ifFalse:[
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1215
	    easy := false
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1216
	] ifTrue:[
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1217
	    fgId := paint colorId.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1218
	    fgId isNil ifTrue:[
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1219
		easy := false
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1220
	    ]
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1221
	].
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1222
	bgPaint isColor ifFalse:[
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1223
	    easy := false
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1224
	] ifTrue:[
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1225
	    bgId := bgPaint colorId.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1226
	    bgId isNil ifTrue:[
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1227
		easy := false
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1228
	    ]
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1229
	].
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1230
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1231
	easy ifTrue:[
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1232
	    ((foreground ~~ paint) or:[background ~~ bgPaint]) ifTrue:[
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1233
		device setForeground:fgId background:bgId in:gcId.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1234
		foreground := paint.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1235
		background := bgPaint.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1236
	    ].
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1237
	] ifFalse:[
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1238
	    'DeviceGraphicsContext [warning]: cannot draw dashes with dithered colors' errorPrintCR
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1239
	].
732
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
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1242
    transformation notNil ifTrue:[
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1243
	tp0 := transformation transformPoint:p0.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1244
	tp1 := transformation transformPoint:p1.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1245
	pX0 := tp0 x.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1246
	pY0 := tp0 y.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1247
	pX1 := tp1 x.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1248
	pY1 := tp1 y.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1249
    ] ifFalse:[
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1250
	pX0 := p0 x.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1251
	pY0 := p0 y.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1252
	pX1 := p1 x.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1253
	pY1 := p1 y
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1254
    ].
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1255
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1256
    pX0 := pX0 rounded.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1257
    pY0 := pY0 rounded.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1258
    pX1 := pX1 rounded.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1259
    pY1 := pY1 rounded.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1260
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1261
    device displayLineFromX:pX0 y:pY0 toX:pX1 y:pY1 in:drawableId with:gcId
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1262
!
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1263
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1264
displayLineFromX:x0 y:y0 toX:x1 y:y1
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1265
    "draw a line (with current paint-color); apply transformation if nonNil"
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1266
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1267
    |pX0 pY0 pX1 pY1 easy fgId bgId p0 p1|
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1268
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1269
    gcId isNil ifTrue:[
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1270
	self initGC
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1271
    ].
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1272
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1273
    lineStyle == #doubleDashed ifTrue:[
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1274
	"
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1275
	 if bgPaint or paint is not a real color, we have to do it the hard way ...
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1276
	"
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1277
	easy := true.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1278
	paint isColor ifFalse:[
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1279
	    easy := false
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1280
	] ifTrue:[
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1281
	    fgId := paint colorId.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1282
	    fgId isNil ifTrue:[
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1283
		easy := false
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1284
	    ]
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1285
	].
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1286
	bgPaint isColor ifFalse:[
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1287
	    easy := false
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1288
	] ifTrue:[
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1289
	    bgId := bgPaint colorId.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1290
	    bgId isNil ifTrue:[
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1291
		easy := false
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1292
	    ]
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1293
	].
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1294
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1295
	easy ifTrue:[
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1296
	    ((foreground ~~ paint) or:[background ~~ bgPaint]) ifTrue:[
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1297
		device setForeground:fgId background:bgId in:gcId.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1298
		foreground := paint.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1299
		background := bgPaint.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1300
	    ].
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1301
	] ifFalse:[
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1302
	    'DeviceGraphicsContext [warning]: cannot draw dashes with dithered colors' errorPrintCR
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1303
	].
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1304
    ].
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1305
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1306
    transformation notNil ifTrue:[
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1307
	p0 := transformation transformPoint:x0@y0.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1308
	p1 := transformation transformPoint:x1@y1.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1309
	pX0 := p0 x.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1310
	pY0 := p0 y.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1311
	pX1 := p1 x.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1312
	pY1 := p1 y.
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1313
    ] ifFalse:[
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1314
	pX0 := x0.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1315
	pY0 := y0.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1316
	pX1 := x1.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1317
	pY1 := y1
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
    pX0 := pX0 rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1321
    pY0 := pY0 rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1322
    pX1 := pX1 rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1323
    pY1 := pY1 rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1324
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1325
    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
  1326
1177
e89408c15bb5 newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 1138
diff changeset
  1327
    "Modified: 10.1.1997 / 17:46:32 / cg"
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1328
!
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
displayOpaqueForm:formToDraw x:x y:y
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1331
    "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
  1332
     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
  1333
     current paint-color and 0-bits in the bgPaint color.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1334
     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
  1335
     settings are ignored and the form drawn as-is.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1336
     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
  1337
     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
  1338
     (by sending #on: to the colors) before doing so.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1339
     If there is a transformation, the image is scaled as appropiate."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1340
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1341
    |w h realForm pX pY nW nH pO pC|
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1342
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1343
    bgPaint isNil ifTrue:[
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1344
	"/
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1345
	"/ actually not an opaque draw
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1346
	"/
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1347
	self displayForm:formToDraw x:x y:y.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1348
	^ self
732
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
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1351
    realForm := formToDraw.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1352
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1353
    transformation notNil ifTrue:[
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1354
	pO := transformation transformPoint:x@y.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1355
	pX := pO x.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1356
	pY := pO y.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1357
	"/ pX := transformation applyToX:x.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1358
	"/ pY := transformation applyToY:y.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1359
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1360
	transformation isNoScale ifFalse:[
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1361
	    w := formToDraw width.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1362
	    h := formToDraw height.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1363
	    pC := transformation applyTo:(x+w-1)@(y+h-1).
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1364
	    nW := pX - x + 1.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1365
	    nH := pY - y + 1.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1366
	    "/ nW := (transformation applyScaleX:w) rounded.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1367
	    "/ nH := (transformation applyScaleY:h) rounded.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1368
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1369
	    ((nW ~= w) or:[nH ~= h]) ifTrue:[
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1370
		"/
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1371
		"/ hard case - someone is drawing forms with scaling in effect
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1372
		"/ look if we have a scaled version in our pocket ...
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1373
		"/
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1374
		realForm := nil.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1375
		CachedScaledForms notNil ifTrue:[
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1376
		    (CachedScales at:formToDraw ifAbsent:nil) = transformation scale ifTrue:[
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1377
			realForm := CachedScaledForms at:formToDraw ifAbsent:nil.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1378
		    ]
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1379
		].
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1380
		realForm isNil ifTrue:[
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1381
		    "/
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1382
		    "/ nope - must do the work ...
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1383
		    "/
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1384
		    realForm := formToDraw magnifiedBy:(nW / w) @ (nH / h).
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1385
		    CachedScaledForms isNil ifTrue:[
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1386
			CachedScaledForms := WeakIdentityDictionary new.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1387
			CachedScales := WeakIdentityDictionary new.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1388
		    ].
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1389
		    CachedScaledForms at:formToDraw put:realForm.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1390
		    CachedScales at:formToDraw put:transformation scale.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1391
		]
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1392
	    ]
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1393
	]
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1394
    ] ifFalse:[
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1395
	pX := x.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1396
	pY := y.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1397
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1398
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1399
    self displayDeviceOpaqueForm:realForm x:pX y:pY
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1400
1592
7ec770f2047a faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents: 1517
diff changeset
  1401
    "Modified: 12.4.1997 / 12:49:02 / cg"
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1402
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1403
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1404
displayOpaqueString:aString from:index1 to:index2 x:x y:y
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1405
    "draw a substring at the coordinate x/y - draw foreground pixels in
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1406
     paint-color and background pixels in bgPaint-color.
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1407
     If the transformation involves scaling,
7345
8eea38c33a0b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7301
diff changeset
  1408
     the font's point-size is scaled as appropriate.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1409
     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
  1410
     the case where paint and/or bgPaint are dithered colors"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1411
5360
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1412
    self displayString:aString from:index1 to:index2 x:x y:y opaque:true
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1413
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1414
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1415
displayOpaqueString:aString x:x y:y
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1416
    "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
  1417
     background pixels in bgPaint color. If the transformation involves scaling,
7345
8eea38c33a0b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7301
diff changeset
  1418
     the font's point-size is scaled as appropriate.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1419
     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
  1420
     the case where paint and/or bgPaint are dithered colors or images."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1421
7064
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  1422
    aString isPlainString ifFalse:[
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1423
	"
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1424
	 hook for non-strings (i.e. attributed text)
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1425
	 that 'thing' should know how to display itself ...
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1426
	"
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1427
	aString displayOpaqueOn:self x:x y:y.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1428
	^ self
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1429
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1430
5360
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1431
    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
  1432
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1433
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1434
displayPointX:x y:y
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1435
    "draw a point (with current paint-color); apply transformation if nonNil"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1436
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1437
    |pX pY pO|
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1438
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1439
    gcId isNil ifTrue:[
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1440
	self initGC
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1441
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1442
    transformation notNil ifTrue:[
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1443
	pO := transformation transformPoint:x@y.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1444
	pX := pO x.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1445
	pY := pO y.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1446
    ] ifFalse:[
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1447
	pX := x.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1448
	pY := y
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1449
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1450
    pX := pX rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1451
    pY := pY rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1452
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1453
    device displayPointX:pX y:pY in:drawableId with:gcId
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1454
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1455
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1456
displayPolygon:aPolygon
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1457
    "draw (the outline of) a polygon (with current paint-color).
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1458
     Apply transformation if nonNil"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1459
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1460
    |newPolygon|
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1461
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1462
    gcId isNil ifTrue:[
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1463
	self initGC
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1464
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1465
    transformation notNil ifTrue:[
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1466
	newPolygon := aPolygon collect:[:point | transformation transformPoint:point].
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1467
    ] ifFalse:[
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1468
	newPolygon := aPolygon
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1469
    ].
6645
6066dcf16c20 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6626
diff changeset
  1470
    (newPolygon contains:[:p |
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1471
	(p isPoint not
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1472
	or:[(p x class ~~ SmallInteger)
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1473
	or:[(p y class ~~ SmallInteger)]])
6645
6066dcf16c20 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6626
diff changeset
  1474
     ]) ifTrue:[
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1475
	newPolygon := newPolygon collect:[:p | p asPoint rounded]
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1476
    ].
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1477
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1478
    device displayPolygon:newPolygon in:drawableId with:gcId
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1479
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1480
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1481
displayRectangleX:x y:y width:w height:h
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1482
    "draw a rectangle (with current paint-color).
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1483
     If transformation is nonNil, drawing is in logical coordinates."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1484
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1485
    |pX pY nW nH easy fgId bgId pO pC|
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1486
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1487
    gcId isNil ifTrue:[
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1488
	self initGC
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
    lineStyle == #doubleDashed ifTrue:[
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1492
	"
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1493
	 if bgPaint or paint is not a real color, we have to do it the hard way ...
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1494
	"
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1495
	easy := true.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1496
	paint isColor ifFalse:[
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1497
	    easy := false
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1498
	] ifTrue:[
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1499
	    fgId := paint colorId.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1500
	    fgId isNil ifTrue:[
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1501
		easy := false
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1502
	    ]
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1503
	].
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1504
	bgPaint isColor ifFalse:[
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1505
	    easy := false
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1506
	] ifTrue:[
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1507
	    bgId := bgPaint colorId.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1508
	    bgId isNil ifTrue:[
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1509
		easy := false
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1510
	    ]
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1511
	].
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1512
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1513
	easy ifTrue:[
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1514
	    ((foreground ~~ paint) or:[background ~~ bgPaint]) ifTrue:[
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1515
		device setForeground:fgId background:bgId in:gcId.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1516
		foreground := paint.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1517
		background := bgPaint.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1518
	    ].
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1519
	] ifFalse:[
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1520
	    'DeviceGraphicsContext [warning]: cannot draw dashes with dithered colors' errorPrintCR
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1521
	].
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1522
    ].
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:[
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1525
	pO := transformation transformPoint:x@y.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1526
	pC := transformation transformPoint:(x+w-1)@(y+h-1).
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1527
	pX := pO x.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1528
	pY := pO y.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1529
	nW := pC x - pX + 1.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1530
	nH := pC y - pY + 1.
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1531
"/        pX := transformation applyToX:x.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1532
"/        pY := transformation applyToY:y.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1533
"/        nW := transformation applyScaleX:w.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1534
"/        nH := transformation applyScaleY:h.
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1535
	nW < 0 ifTrue:[
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1536
	      nW := nW abs.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1537
	      pX := pX - nW.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1538
	].
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1539
	nH < 0 ifTrue:[
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1540
	      nH := nH abs.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1541
	      pY := pY - nH.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1542
	].
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1543
    ] ifFalse:[
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1544
	pX := x.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1545
	pY := y.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1546
	nW := w.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1547
	nH := h
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1548
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1549
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1550
    pX := pX rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1551
    pY := pY rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1552
    nW := nW rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1553
    nH := nH rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1554
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1555
    "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
  1556
     this one seems mathematically incorrect but allows to draw and fill
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1557
     a rectangle using the same extents.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1558
     I'm not certain if is the right thing to do ...
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1559
    "
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1560
    device displayRectangleX:pX
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1561
			   y:pY
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1562
		       width:(nW - 1)
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1563
		      height:(nH - 1)
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1564
			  in:drawableId with:gcId
1177
e89408c15bb5 newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 1138
diff changeset
  1565
e89408c15bb5 newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 1138
diff changeset
  1566
    "Modified: 10.1.1997 / 17:46:41 / cg"
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1567
!
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
displayString:aString from:index1 to:index2 x:x y:y
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1570
    "draw a substring at the coordinate x/y -
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1571
     draw foreground-pixels only (in current paint-color),
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1572
     leaving background as-is. If the transformation involves scaling,
7345
8eea38c33a0b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7301
diff changeset
  1573
     the font's point-size is scaled as appropriate."
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1574
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1575
    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
  1576
!
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1577
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1578
displayString:aString from:index1 to:index2 x:x y:y opaque:opaque
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1579
    "draw part of a string with both fg and bg at x/y in current font"
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1580
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1581
    ^ self displayString:aString from:index1 to:index2 x:x y:y opaque:opaque maxWidth:nil
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1582
!
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1583
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1584
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
  1585
    "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
  1586
     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
  1587
     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
  1588
     Assuming that device can only draw in device colors, we have to handle
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1589
     the case where paint and/or bgPaint are dithered colors.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1590
     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
  1591
7443
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  1592
    |opaque index1 index2 easy w h savedPaint fgId bgId pX pY fontUsed fontsEncoding sz aString
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1593
     nSkipLeft nChars wString wSkipLeft index2Guess|
5360
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1594
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1595
    index1 := index1Arg.
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1596
    index2 := index2Arg.
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1597
    opaque := opaqueArg.
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1598
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1599
    "
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1600
     if backgroundPaint color is nil, we assume
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1601
     this is a non-opaque draw
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1602
    "
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1603
    bgPaint isNil ifTrue:[
6626
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1604
        opaque := false.
5360
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1605
    ].
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1606
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1607
    gcId isNil ifTrue:[
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1608
        self initGC
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1609
    ].
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1610
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1611
    aStringArg isPlainString ifFalse:[
6626
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1612
        "
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1613
         hook for non-strings (i.e. attributed text)
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1614
         that 'thing' should know how to display itself ...
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1615
        "
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1616
        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
  1617
        ^ self
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1618
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1619
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1620
    "/ transcode the string into the fonts encoding...
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1621
    aString := aStringArg.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1622
    fontsEncoding := font encoding.
4056
67c4686afbc6 characterEncoding stuff
Claus Gittinger <cg@exept.de>
parents: 4031
diff changeset
  1623
    (characterEncoding ~~ fontsEncoding) ifTrue:[
6626
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1624
        [
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1625
            aString := CharacterEncoder encodeString:aString from:characterEncoding into:fontsEncoding.
6626
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1626
        ] on:CharacterEncoderError do:[:ex|
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1627
            "substitute a default value for codes that cannot be represented
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1628
             in the new character set"
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1629
            ex proceedWith:ex defaultValue.
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1630
        ].
4026
882de378f763 no longer as string for its encoding;
Claus Gittinger <cg@exept.de>
parents: 3943
diff changeset
  1631
    ].
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1632
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1633
    fontUsed := font.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1634
    transformation notNil ifTrue:[
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1635
        pX := transformation applyToX:x.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1636
        pY := transformation applyToY:y.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1637
        transformation noScale ifFalse:[
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1638
            sz := font size.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1639
            sz notNil ifTrue:[
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1640
                fontUsed := font asSize:(transformation applyScaleY:sz) rounded.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1641
            ]
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1642
        ]
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1643
    ] ifFalse:[
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1644
        pX := x.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1645
        pY := y.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1646
    ].
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1647
7063
2be1214a5dcf #BUGFIX
Stefan Vogel <sv@exept.de>
parents: 7062
diff changeset
  1648
    fontUsed isAlienFont ifTrue:[
2be1214a5dcf #BUGFIX
Stefan Vogel <sv@exept.de>
parents: 7062
diff changeset
  1649
        "
2be1214a5dcf #BUGFIX
Stefan Vogel <sv@exept.de>
parents: 7062
diff changeset
  1650
         hook for alien fonts
2be1214a5dcf #BUGFIX
Stefan Vogel <sv@exept.de>
parents: 7062
diff changeset
  1651
         that 'font' should know how to display the string...
2be1214a5dcf #BUGFIX
Stefan Vogel <sv@exept.de>
parents: 7062
diff changeset
  1652
        "
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1653
        fontUsed displayString:aString from:index1 to:index2 x:x rounded y:y rounded in:self opaque:opaque maxWidth:maxWidth.
7063
2be1214a5dcf #BUGFIX
Stefan Vogel <sv@exept.de>
parents: 7062
diff changeset
  1654
        ^ self
2be1214a5dcf #BUGFIX
Stefan Vogel <sv@exept.de>
parents: 7062
diff changeset
  1655
    ].
2be1214a5dcf #BUGFIX
Stefan Vogel <sv@exept.de>
parents: 7062
diff changeset
  1656
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1657
    pX := pX rounded.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1658
    pY := pY rounded.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1659
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1660
    fontUsed := fontUsed onDevice:device.
7443
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  1661
    deviceFont ~~ fontUsed ifTrue:[
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  1662
        (fontUsed installInDeviceForGCId:gcId) isNil ifTrue:[
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  1663
            "error - no such font"
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1664
            ^ self.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1665
        ].
7443
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  1666
        deviceFont := fontUsed.
7064
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  1667
    ].
5360
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1668
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1669
    "
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1670
     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
  1671
    "
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1672
    paint isColor ifTrue:[
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1673
        easy := true.
6626
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1674
        fgId := paint colorId.
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1675
        fgId isNil ifTrue:[
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1676
            easy := false
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1677
        ]
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1678
    ] ifFalse:[
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1679
        easy := false
5360
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1680
    ].
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1681
    opaque ifTrue:[
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1682
        bgPaint isColor ifTrue:[
6626
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1683
            bgId := bgPaint colorId.
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1684
            bgId isNil ifTrue:[
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1685
                easy := false
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1686
            ]
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1687
        ] ifFalse:[
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1688
            easy := false
6626
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1689
        ].
5360
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1690
    ].
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1691
7064
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  1692
    pX := pX rounded.
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  1693
    pY := pY rounded.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1694
5360
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1695
    "/ 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
  1696
    "/ 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
  1697
    "/ which are drawn longer than 32k pixels.
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1698
    nChars := 500.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1699
    (maxWidth notNil and:[(index2 - index1) > nChars]) ifTrue:[
6626
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1700
        nSkipLeft := wSkipLeft := 0.
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1701
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1702
        "/ if the draw starts to the left of the window start,
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1703
        "/ skip some characters at the beginning...
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1704
        pX < 0 ifTrue:[
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1705
"/ ('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
  1706
            nSkipLeft := (pX negated // font width) min:index2.                         "/ estimate
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1707
            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
  1708
            [ ((pX+wSkipLeft) > 0) and:[nSkipLeft > 0]] whileTrue:[                      "/ too many
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1709
                nSkipLeft := (nSkipLeft * 0.9) rounded.
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1710
                wSkipLeft := fontUsed widthOf:aString from:index1 to:index1+nSkipLeft-1.
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1711
            ].
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1712
            index1 := index1 + nSkipLeft.
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1713
            pX := pX + wSkipLeft.
5360
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1714
"/ ('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
  1715
        ].
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1716
5360
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1717
"/ ('n=%d w=%d' printfWith:nChars with:wString) printCR.
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1718
        [
6626
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1719
            index2Guess := (index1+nChars-1) min:index2.
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1720
            wString := fontUsed widthOf:aString from:index1 to:index2Guess.
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1721
            ((pX+wString) < maxWidth) and:[ index2Guess < index2]
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1722
        ] whileTrue:[  "/ not enough...
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1723
            nChars := (nChars * 1.1) rounded.
6626
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1724
        ].
5360
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1725
"/ ('n=%d w=%d' printfWith:nChars with:wString) printCR.
6626
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1726
        index2 := index2Guess.
5360
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1727
    ].
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1728
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1729
    easy ifTrue:[
6626
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1730
        opaque ifTrue:[
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1731
            device setForeground:fgId background:bgId in:gcId.
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1732
            background := bgPaint.
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1733
        ] ifFalse:[
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1734
            device setForeground:fgId in:gcId.
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1735
        ].
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1736
        foreground := paint.
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1737
        self displayDeviceString:aString from:index1 to:index2 x:pX y:pY opaque:opaque.
6626
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1738
        ^ self
5360
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1739
    ].
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1740
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1741
    "/
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1742
    "/ do it the hard way - either forground or background is not a plain color,
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1743
    "/ but dithered or a pattern
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1744
    "/
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1745
    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
  1746
    h := fontUsed height.
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1747
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1748
    (fgId notNil and:[function == #copy]) ifTrue:[
6626
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1749
        "
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1750
         only bg is dithered or a pattern; fill with bg first ...
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1751
        "
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1752
        savedPaint := paint.
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1753
        self paint:bgPaint.
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1754
        self fillDeviceRectangleX:pX y:(pY - fontUsed ascent) width:w height:h.
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1755
        self paint:savedPaint.
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1756
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1757
        "
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1758
         then draw using fgPaint (which is a real color)
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1759
        "
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1760
        self displayDeviceString:aString from:index1 to:index2 x:pX y:pY opaque:false.
6626
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1761
        ^ self
5360
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
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1764
    "/ the very hard case (fg-dither)
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1765
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1766
    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
  1767
5742
3edcdffa74ec changed: #displayString:from:to:x:y:opaque:
Stefan Vogel <sv@exept.de>
parents: 5406
diff changeset
  1768
    "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
  1769
    "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
  1770
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1771
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1772
displayString:aString x:x y:y
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1773
    "draw a string at the coordinate x/y -
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1774
     draw foreground-pixels only (in current paint-color),
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1775
     leaving background as-is. If the transformation involves scaling,
7345
8eea38c33a0b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7301
diff changeset
  1776
     the font's point-size is scaled as appropriate."
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1777
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1778
    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
  1779
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1780
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1781
displayUnscaledForm:formToDraw x:x y:y
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1782
    "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
  1783
     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
  1784
     current paint-color, leaving pixels with 0-bits unchanged
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1785
     (i.e. only 1-bits are drawn from the form).
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1786
     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
  1787
     settings are ignored and the form is drawn as-is.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1788
     Care must be taken, that the paint color is correctly allocated
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1789
     (by sending #on: to the color) before doing so.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1790
     Using functions other than #copy only makes sense if you are
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1791
     certain, that the colors are real colors (actually, only for
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1792
     noColor or allColor).
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1793
     The origins coordinate is transformed, but the image itself is unscaled."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1794
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1795
    |pX pY pO|
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1796
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1797
    transformation notNil ifTrue:[
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1798
	pO := transformation transformPoint:(x@y).
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1799
	pX := pO x.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1800
	pY := pO y.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1801
    ] ifFalse:[
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1802
	pX := x.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1803
	pY := y.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1804
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1805
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1806
    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
  1807
7ec770f2047a faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents: 1517
diff changeset
  1808
    "Modified: 12.4.1997 / 12:48:04 / cg"
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1809
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1810
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1811
displayUnscaledOpaqueForm:formToDraw x:x y:y
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1812
    "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
  1813
     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
  1814
     current paint-color, 0 bits in background color.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1815
     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
  1816
     settings are ignored and the form is drawn as-is (opaque).
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1817
     The origins coordinate is transformed, but the image itself is unscaled."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1818
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1819
    |pX pY pO|
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1820
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1821
    transformation notNil ifTrue:[
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1822
	pO := transformation transformPoint:(x@y).
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1823
	pX := pO x.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1824
	pY := pO y.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1825
    ] ifFalse:[
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1826
	pX := x.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1827
	pY := y.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1828
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1829
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1830
    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
  1831
7ec770f2047a faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents: 1517
diff changeset
  1832
    "Modified: 12.4.1997 / 12:49:21 / cg"
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1833
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1834
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1835
displayUnscaledOpaqueString:aString from:index1 to:index2 x:x y:y
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1836
    "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
  1837
     Draw foreground pixels in paint-color, background pixels in bgPaint color."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1838
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1839
    |pX pY pO|
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1840
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1841
    transformation notNil ifTrue:[
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1842
	pO := transformation transformPoint:(x@y).
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1843
	pX := pO x.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1844
	pY := pO y.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1845
    ] ifFalse:[
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1846
	pX := x.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1847
	pY := y.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1848
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1849
    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
  1850
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1851
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1852
displayUnscaledOpaqueString:aString x:x y:y
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1853
    "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
  1854
     Draw foreground pixels in paint-color, background pixels in bgPaint color."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1855
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1856
    |pX pY pO|
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
    transformation notNil ifTrue:[
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1859
	pO := transformation transformPoint:(x@y).
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1860
	pX := pO x.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1861
	pY := pO y.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1862
    ] ifFalse:[
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1863
	pX := x.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1864
	pY := y.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1865
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1866
    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
  1867
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1868
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1869
displayUnscaledString:aString from:index1 to:index2 x:x y:y
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1870
    "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
  1871
     draw foreground-pixels only (in current paint-color), leaving background as-is."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1872
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1873
    |pX pY pO|
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1874
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1875
    transformation notNil ifTrue:[
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1876
	pO := transformation transformPoint:(x@y).
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1877
	pX := pO x.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1878
	pY := pO y.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1879
    ] ifFalse:[
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1880
	pX := x.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1881
	pY := y.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1882
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1883
    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
  1884
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1885
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1886
displayUnscaledString:aString x:x y:y
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1887
    "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
  1888
     draw foreground-pixels only (in current paint-color), leaving background as-is."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1889
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1890
    |pX pY pO|
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1891
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1892
    transformation notNil ifTrue:[
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1893
	pO := transformation transformPoint:(x@y).
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1894
	pX := pO x.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1895
	pY := pO y.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1896
    ] ifFalse:[
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1897
	pX := x.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1898
	pY := y.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1899
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1900
    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
  1901
! !
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1902
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1903
!DeviceGraphicsContext methodsFor:'drawing in device coordinates'!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1904
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1905
displayDeviceForm:aForm x:x y:y
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1906
    "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
  1907
     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
  1908
     current paint-color, leaving pixels with 0-bits unchanged
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1909
     (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
  1910
     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
  1911
     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
  1912
     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
  1913
7752
81c84fab0aac #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 7749
diff changeset
  1914
     The form should have been allocated on the same device,
1592
7ec770f2047a faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents: 1517
diff changeset
  1915
     otherwise its converted here, which slows down the draw.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1916
     No transformation or scaling is done.
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1917
     Care must be taken, that the paint color is correctly allocated
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1918
     (by sending #on: to the color) before doing so.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1919
     Using functions other than #copy only makes sense if you are
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1920
     certain, that the colors are real colors (actually, only for
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1921
     noColor or allColor)."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1922
6497
8edaeadf6658 Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents: 6484
diff changeset
  1923
    |id w h easy paintDither depth tmpForm tmpId tmpGCId
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1924
     fgId noColor allColor allBits pX pY
7752
81c84fab0aac #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 7749
diff changeset
  1925
     mask maskId deviceForm deviceFormGCId deviceMask deviceMaskGcId colorMap|
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1926
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1927
    w := aForm width.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1928
    h := aForm height.
6612
5c05ccaf6275 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6514
diff changeset
  1929
    (w = 0 or:[h = 0]) ifTrue:[^ self].
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1930
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1931
    pX := x rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1932
    pY := y rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1933
1034
5f6f417dcb12 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1033
diff changeset
  1934
    deviceForm := aForm asFormOn:device.
2192
01f76f23f03f handle case when no deviceForms can be created,
Claus Gittinger <cg@exept.de>
parents: 2065
diff changeset
  1935
    deviceForm isNil ifTrue:[
7629
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  1936
        Logger warning:'cannot create device-form'.
6484
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  1937
        ^self
2192
01f76f23f03f handle case when no deviceForms can be created,
Claus Gittinger <cg@exept.de>
parents: 2065
diff changeset
  1938
    ].
7629
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  1939
    id := deviceForm drawableId.
7752
81c84fab0aac #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 7749
diff changeset
  1940
    "temporary ... what the heck is this??"
7629
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  1941
    (id isNil
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  1942
     or:[aForm graphicsDevice ~~ device]) ifTrue:[
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  1943
        deviceForm := deviceForm asFormOn:device.
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  1944
        id := deviceForm drawableId.
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  1945
        id isNil ifTrue:[
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  1946
            Logger warning:'invalid form draw - ignored'.
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  1947
            ^ self
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  1948
        ].
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1949
    ].
7629
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  1950
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1951
    gcId isNil ifTrue:[
6484
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  1952
        self initGC
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1953
    ].
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1954
    "/ device needGCForBitmapSource  - i.e. WIN32
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1955
    device isWindowsPlatform ifTrue:[
7749
f4ad7601ae41 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 7746
diff changeset
  1956
        deviceFormGCId := deviceForm initGC.
2865
a97dc9f1e21a no need to create a GC for source bitmap under X
Claus Gittinger <cg@exept.de>
parents: 2835
diff changeset
  1957
    ].
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1958
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1959
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1960
     a deep form ignores paint/bgPaint settings
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1961
    "
1085
3513a4cae87b handle depth1-images with a mask
Claus Gittinger <cg@exept.de>
parents: 1064
diff changeset
  1962
    mask := aForm mask.
6497
8edaeadf6658 Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents: 6484
diff changeset
  1963
    depth := aForm depth.
8edaeadf6658 Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents: 6484
diff changeset
  1964
8edaeadf6658 Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents: 6484
diff changeset
  1965
    (mask notNil or:[depth ~~ 1]) ifTrue:[
6484
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  1966
        mask notNil ifTrue:[
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  1967
            mask depth ~~ 1 ifTrue:[
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  1968
                'DEVGC: alpha channel not yet supported' errorPrintCR.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  1969
            ] ifFalse:[
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  1970
                deviceMask := mask asFormOn:device.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  1971
                deviceMask isNil ifTrue:[
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  1972
                    'DeviceGraphicsContext [warning]: cannot create device-mask' errorPrintCR.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  1973
                    ^self
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  1974
                ].
7629
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  1975
                maskId := deviceMask drawableId.
6484
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  1976
                maskId notNil ifTrue:[
7752
81c84fab0aac #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 7749
diff changeset
  1977
                    deviceMaskGcId := deviceMask initGC.
6484
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  1978
                    allColor := Color allColor.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  1979
                    allBits := allColor colorId.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  1980
6497
8edaeadf6658 Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents: 6484
diff changeset
  1981
                    (aForm maskedPixelsAre0
8edaeadf6658 Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents: 6484
diff changeset
  1982
                     and:[depth == 1 or:[deviceForm depth == device depth]]) ifTrue:[
6484
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  1983
                        "/ can do it without a temporary pixmap:
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  1984
                        "/   or-in the form into the inverse stamped-out area
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  1985
                        "/   of the destination.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  1986
                        "/   Oring is of course only possible if we know that
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  1987
                        "/   masked pixels are already zero in the form.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  1988
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  1989
                        "/ stamp out using mask
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1990
                        device
6497
8edaeadf6658 Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents: 6484
diff changeset
  1991
                            setForeground:0 background:allBits in:gcId;
8edaeadf6658 Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents: 6484
diff changeset
  1992
                            setFunction:#and in:gcId;
6484
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  1993
                            copyPlaneFromPixmapId:maskId
6497
8edaeadf6658 Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents: 6484
diff changeset
  1994
                                x:0
8edaeadf6658 Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents: 6484
diff changeset
  1995
                                y:0
7752
81c84fab0aac #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 7749
diff changeset
  1996
                                gc:deviceMaskGcId
6497
8edaeadf6658 Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents: 6484
diff changeset
  1997
                                to:drawableId
8edaeadf6658 Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents: 6484
diff changeset
  1998
                                x:pX
8edaeadf6658 Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents: 6484
diff changeset
  1999
                                y:pY
8edaeadf6658 Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents: 6484
diff changeset
  2000
                                gc:gcId
8edaeadf6658 Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents: 6484
diff changeset
  2001
                                width:w
8edaeadf6658 Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents: 6484
diff changeset
  2002
                                height:h.
8edaeadf6658 Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents: 6484
diff changeset
  2003
6484
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2004
                        "/ or-in the form
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2005
                        device setFunction:#or in:gcId.
6497
8edaeadf6658 Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents: 6484
diff changeset
  2006
                        depth == 1 ifTrue:[
8edaeadf6658 Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents: 6484
diff changeset
  2007
                            (colorMap := deviceForm colorMap) notNil ifTrue:[
8edaeadf6658 Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents: 6484
diff changeset
  2008
                                colorMap size < 2 ifTrue:[
8edaeadf6658 Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents: 6484
diff changeset
  2009
                                    device
8edaeadf6658 Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents: 6484
diff changeset
  2010
                                        setForegroundColor:(colorMap at:1)
8edaeadf6658 Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents: 6484
diff changeset
  2011
                                        backgroundColor:(Color noColor)
8edaeadf6658 Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents: 6484
diff changeset
  2012
                                        in:gcId.
8edaeadf6658 Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents: 6484
diff changeset
  2013
                                ] ifFalse:[
8edaeadf6658 Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents: 6484
diff changeset
  2014
                                    device
8edaeadf6658 Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents: 6484
diff changeset
  2015
                                        setForegroundColor:(colorMap at:2)
8edaeadf6658 Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents: 6484
diff changeset
  2016
                                        backgroundColor:(colorMap at:1)
8edaeadf6658 Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents: 6484
diff changeset
  2017
                                        in:gcId.
8edaeadf6658 Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents: 6484
diff changeset
  2018
                                ]
8edaeadf6658 Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents: 6484
diff changeset
  2019
                            ].
8edaeadf6658 Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents: 6484
diff changeset
  2020
                            device
8edaeadf6658 Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents: 6484
diff changeset
  2021
                                copyPlaneFromPixmapId:id
8edaeadf6658 Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents: 6484
diff changeset
  2022
                                x:0
8edaeadf6658 Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents: 6484
diff changeset
  2023
                                y:0
8edaeadf6658 Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents: 6484
diff changeset
  2024
                                gc:deviceFormGCId
8edaeadf6658 Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents: 6484
diff changeset
  2025
                                to:drawableId
8edaeadf6658 Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents: 6484
diff changeset
  2026
                                x:pX
8edaeadf6658 Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents: 6484
diff changeset
  2027
                                y:pY
8edaeadf6658 Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents: 6484
diff changeset
  2028
                                gc:gcId
8edaeadf6658 Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents: 6484
diff changeset
  2029
                                width:w
8edaeadf6658 Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents: 6484
diff changeset
  2030
                                height:h.
8edaeadf6658 Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents: 6484
diff changeset
  2031
                        ] ifFalse:[
8edaeadf6658 Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents: 6484
diff changeset
  2032
                            device
8edaeadf6658 Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents: 6484
diff changeset
  2033
                                copyFromPixmapId:id
8edaeadf6658 Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents: 6484
diff changeset
  2034
                                x:0
8edaeadf6658 Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents: 6484
diff changeset
  2035
                                y:0
8edaeadf6658 Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents: 6484
diff changeset
  2036
                                gc:deviceFormGCId
8edaeadf6658 Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents: 6484
diff changeset
  2037
                                to:drawableId
8edaeadf6658 Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents: 6484
diff changeset
  2038
                                x:pX
8edaeadf6658 Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents: 6484
diff changeset
  2039
                                y:pY
8edaeadf6658 Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents: 6484
diff changeset
  2040
                                gc:gcId
8edaeadf6658 Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents: 6484
diff changeset
  2041
                                width:w
8edaeadf6658 Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents: 6484
diff changeset
  2042
                                height:h.
8edaeadf6658 Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents: 6484
diff changeset
  2043
                        ].
6484
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2044
                    ] ifFalse:[
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2045
                        "/ must do it slow, using a temporary form ..
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2046
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2047
                        "
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2048
                         create temp-form;
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2049
                        "
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2050
                        tmpForm := Form width:w height:h depth:device depth onDevice:device.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2051
                        tmpForm isNil ifTrue:[
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2052
                            'DeviceGraphicsContext [warning]: cannot create temp form' errorPrintCR.
6497
8edaeadf6658 Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents: 6484
diff changeset
  2053
                            ^ self
6484
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2054
                        ].
7629
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2055
                        tmpId := tmpForm drawableId.
7752
81c84fab0aac #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 7749
diff changeset
  2056
                        tmpGCId := tmpForm initGC.
6484
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2057
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2058
                        "
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2059
                         fill tempform with image
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2060
                        "
6497
8edaeadf6658 Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents: 6484
diff changeset
  2061
                        depth == 1 ifTrue:[
6484
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2062
                            (colorMap := deviceForm colorMap) notNil ifTrue:[
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2063
                                colorMap size < 2 ifTrue:[
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2064
                                    device
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2065
                                        setForegroundColor:(colorMap at:1)
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2066
                                        in:tmpGCId.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2067
                                ] ifFalse:[
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2068
                                    device
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2069
                                        setForegroundColor:(colorMap at:2)
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2070
                                        backgroundColor:(colorMap at:1)
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2071
                                        in:tmpGCId.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2072
                                ]
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2073
                            ].
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2074
                            device
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2075
                                copyPlaneFromPixmapId:id
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2076
                                x:0
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2077
                                y:0
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2078
                                gc:deviceFormGCId
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2079
                                to:tmpId
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2080
                                x:0
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2081
                                y:0
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2082
                                gc:tmpGCId
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2083
                                width:w
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2084
                                height:h.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2085
                        ] ifFalse:[
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2086
                            device
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2087
                                copyFromPixmapId:id
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2088
                                x:0
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2089
                                y:0
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2090
                                gc:deviceFormGCId
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2091
                                to:tmpId
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2092
                                x:0
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2093
                                y:0
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2094
                                gc:tmpGCId
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2095
                                width:w
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2096
                                height:h.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2097
                        ].
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2098
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2099
                        "
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2100
                         stamp out mask in temp form
7350
cbe52e085dbf #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7345
diff changeset
  2101
                         set unmasked pixels to allBits and masked pixels to 0
6484
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2102
                        "
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  2103
                        device
6484
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2104
                            setForeground:allBits background:0 in:tmpGCId;
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2105
                            setFunction:#and in:tmpGCId;
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2106
                            copyPlaneFromPixmapId:maskId
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2107
                                x:0
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2108
                                y:0
7752
81c84fab0aac #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 7749
diff changeset
  2109
                                gc:deviceMaskGcId
6484
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2110
                                to:tmpId
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2111
                                x:0
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2112
                                y:0
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2113
                                gc:tmpGCId
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2114
                                width:w
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2115
                                height:h.
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  2116
"/Debug = 1 ifTrue:[
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  2117
"/    Debug := 0.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  2118
"/    tmpForm asImage inspect.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  2119
"/    deviceForm inspect.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  2120
"/].
6484
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2121
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2122
                        "
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2123
                         stamp out mask in destination
7350
cbe52e085dbf #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7345
diff changeset
  2124
                         set unmasked pixels to 0 and masked pixels to allBits
6484
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2125
                        "
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  2126
                        device
6484
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2127
                            setForeground:0 background:allBits in:gcId;
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2128
                            setFunction:#and in:gcId;
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2129
                            copyPlaneFromPixmapId:maskId
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2130
                                x:0
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2131
                                y:0
7752
81c84fab0aac #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 7749
diff changeset
  2132
                                gc:deviceMaskGcId
6484
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2133
                                to:drawableId
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2134
                                x:pX
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2135
                                y:pY
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2136
                                gc:gcId
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2137
                                width:w
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2138
                                height:h.
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
                        "
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2141
                         or-in tempform-bits ...
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2142
                        "
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  2143
                        device
7350
cbe52e085dbf #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7345
diff changeset
  2144
                            setForeground:0 background:0 in:gcId;
6484
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2145
                            setFunction:#or in:gcId;
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2146
                            copyFromPixmapId:tmpId
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2147
                                x:0
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2148
                                y:0
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2149
                                gc:tmpGCId
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2150
                                to:drawableId
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2151
                                x:pX
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2152
                                y:pY
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2153
                                gc:gcId
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2154
                                width:w
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2155
                                height:h.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2156
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2157
                        "
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2158
                         release tempForm immediately
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2159
                         (although GC will eventually do it,
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2160
                          this creates less stress to the Xserver in the meanwhile ...)
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2161
                        "
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2162
                        tmpForm destroy.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2163
                    ].
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2164
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2165
                    "/ restore GC
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2166
                    foreground notNil ifTrue:[
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2167
                        device setForegroundColor:foreground in:gcId.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2168
                    ].
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2169
                    background notNil ifTrue:[
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2170
                        device setBackgroundColor:background in:gcId
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2171
                    ].
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2172
                    device setFunction:function in:gcId.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2173
                    ^ self
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2174
                ]
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2175
            ]
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2176
        ].
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
        device
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2179
            copyFromPixmapId:id
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2180
            x:0
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2181
            y:0
7752
81c84fab0aac #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 7749
diff changeset
  2182
            gc:deviceFormGCId
6484
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2183
            to:drawableId
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2184
            x:pX
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2185
            y:pY
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2186
            gc:gcId
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2187
            width:w
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2188
            height:h.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2189
        ^ self
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2190
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2191
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2192
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2193
     the following code is somewhat complicated, since it has to deal
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2194
     with dithered paint colors, which cannot be done directly on most
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2195
     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
  2196
     (just assume drawing a bitmap with dithered paint color ... sigh)
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2197
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2198
1507
358603f58138 faster drawing in or-mode.
Claus Gittinger <cg@exept.de>
parents: 1453
diff changeset
  2199
    easy := (function == #copy).
358603f58138 faster drawing in or-mode.
Claus Gittinger <cg@exept.de>
parents: 1453
diff changeset
  2200
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2201
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2202
     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
  2203
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2204
    easy ifTrue:[
6484
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2205
        paint isColor ifTrue:[
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2206
            paintDither := paint ditherForm.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2207
            paintDither notNil ifTrue:[
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2208
                easy := false.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2209
            ]
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2210
        ] ifFalse:[
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2211
            paintDither := paint.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2212
            easy := false
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2213
        ].
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2214
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2215
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2216
    allColor := Color allColor.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2217
    allBits := allColor colorId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2218
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2219
    easy ifTrue:[
6484
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2220
        "
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2221
         paint is a real color
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
        "
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2225
         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
  2226
         operation ...
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2227
        "
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2228
        fgId := paint colorId.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2229
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2230
        ((fgId ~~ ((1 bitShift:device depth)-1))
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2231
        and:[fgId ~~ allBits]) ifTrue:[
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2232
            "
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2233
             clear fg-bits ...
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2234
            "
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2235
            device setForeground:0 background:allBits in:gcId.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2236
            device setFunction:#and in:gcId.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2237
            device
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2238
                copyPlaneFromPixmapId:id
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2239
                x:0
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2240
                y:0
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2241
                gc:deviceFormGCId
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2242
                to:drawableId
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2243
                x:pX
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2244
                y:pY
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2245
                gc:gcId
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2246
                width:w
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2247
                height:h.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2248
        ].
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2249
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2250
        fgId ~~ 0 ifTrue:[
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2251
            "
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2252
             or-in fg-bits ...
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2253
            "
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2254
            device setForeground:fgId background:0 in:gcId.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2255
            device setFunction:#or in:gcId.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2256
            device
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2257
                copyPlaneFromPixmapId:id
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2258
                x:0
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2259
                y:0
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2260
                gc:deviceFormGCId
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2261
                to:drawableId
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2262
                x:pX
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2263
                y:pY
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2264
                gc:gcId
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2265
                width:w
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2266
                height:h
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2267
        ].
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2268
        "
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2269
         flush foreground/background cache
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2270
        "
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2271
        foreground := nil.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2272
        background := nil.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2273
        device setFunction:function in:gcId.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2274
        ^ self
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2275
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2276
1507
358603f58138 faster drawing in or-mode.
Claus Gittinger <cg@exept.de>
parents: 1453
diff changeset
  2277
    function == #or ifTrue:[
6484
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2278
        easy := paint notNil
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2279
                and:[paint isColor
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2280
                and:[paint ditherForm isNil]].
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2281
        easy ifTrue:[
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2282
            easy := bgPaint isNil
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2283
                        or:[bgPaint isColor
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2284
                            and:[bgPaint colorId == 0]]
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2285
        ].
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2286
        easy ifTrue:[
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2287
            fgId := paint colorId.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2288
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2289
            fgId ~~ 0 ifTrue:[
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
                 or-in fg-bits ...
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
                device setForeground:fgId background:0 in:gcId.
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
                    copyPlaneFromPixmapId: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:deviceFormGCId
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
            ].
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2306
            "
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2307
             flush foreground/background cache
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2308
            "
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2309
            foreground := nil.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2310
            background := nil.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2311
            ^ self
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2312
        ].
1507
358603f58138 faster drawing in or-mode.
Claus Gittinger <cg@exept.de>
parents: 1453
diff changeset
  2313
    ].
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2314
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2315
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2316
     hard case; paint is a dithered color
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
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2319
    noColor := Color noColor.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2320
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2321
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2322
     create temp-form;
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2323
    "
4756
dd597f8839cb changed #displayDeviceForm:x:y:
Claus Gittinger <cg@exept.de>
parents: 4752
diff changeset
  2324
    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
  2325
    tmpForm isNil ifTrue:[
6484
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2326
        'DeviceGraphicsContext [warning]: cannot create temp form' errorPrintCR.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2327
        ^self
2192
01f76f23f03f handle case when no deviceForms can be created,
Claus Gittinger <cg@exept.de>
parents: 2065
diff changeset
  2328
    ].
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2329
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2330
     fill tempform
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
    tmpForm paint:paint.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2333
    tmpForm fillRectangleX:0 y:0 width:w height:h.
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
     stamp out background
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2336
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2337
    tmpForm paint:allColor on:noColor.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2338
    tmpForm function:#and.
976
807b42b00353 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 975
diff changeset
  2339
    tmpForm displayOpaqueForm:deviceForm x:0 y:0.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2340
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2341
     stamp out foreground from destination
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2342
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2343
    device setForeground:0 background:allBits in:gcId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2344
    device setFunction:#and in:gcId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2345
    device
6484
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2346
        copyPlaneFromPixmapId:id
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2347
        x:0
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2348
        y:0
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2349
        gc:deviceFormGCId
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2350
        to:drawableId
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2351
        x:pX
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2352
        y:pY
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2353
        gc:gcId
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2354
        width:w
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2355
        height:h.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2356
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2357
     or-in temp into destination
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2358
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2359
    device setForeground:allBits background:0 in:gcId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2360
    device setFunction:#or in:gcId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2361
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2362
    device
7629
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2363
        copyFromPixmapId:tmpForm drawableId
6484
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2364
        x:0
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2365
        y:0
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2366
        gc:tmpForm gcId
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2367
        to:drawableId
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2368
        x:pX
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2369
        y:pY
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2370
        gc:gcId
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2371
        width:w
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2372
        height:h.
1637
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  2373
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  2374
    "
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  2375
     release tempForm immediately
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2376
     (although GC will eventually do it,
1637
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  2377
      this creates less stress to the Xserver in the meanwhile ...)
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  2378
    "
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  2379
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  2380
    tmpForm destroy.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2381
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2382
     flush foreground/background cache
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2383
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2384
    foreground := nil.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2385
    background := nil.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2386
    device setFunction:function in:gcId.
768
77e4f9d30a22 fixes for b&w screens
Claus Gittinger <cg@exept.de>
parents: 745
diff changeset
  2387
4756
dd597f8839cb changed #displayDeviceForm:x:y:
Claus Gittinger <cg@exept.de>
parents: 4752
diff changeset
  2388
    "Modified: / 27-05-2007 / 12:45:10 / cg"
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2389
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2390
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2391
displayDeviceLineFromX:x0 y:y0 toX:x1 y:y1
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2392
    "draw a line (with current paint-color) in device coordinate space.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2393
     This ignores any transformations. The coordinates must be integers."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2394
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2395
    gcId isNil ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2396
	self initGC
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2397
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2398
    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
  2399
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2400
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2401
displayDeviceOpaqueForm:aForm x:x y:y
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2402
    "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
  2403
     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
  2404
     current paint-color and 0-bits in the bgPaint color.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2405
     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
  2406
     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
  2407
     Any mask is ignored.
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2408
     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
  2409
     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
  2410
     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
  2411
     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
  2412
     its converted here, which slows down the draw.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2413
     Drawing is in device coordinates; no scaling is done."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2414
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2415
    |id w h easy savedPaint bgForm fgForm tmpForm
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2416
     fgId bgId noColor allColor allBits dx dy
7749
f4ad7601ae41 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 7746
diff changeset
  2417
     pX pY deviceDepth deviceForm deviceFormGCId map|
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2418
1033
b5cd84ed805f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1029
diff changeset
  2419
    deviceForm := aForm asFormOn:device.
7629
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2420
    id := deviceForm drawableId.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2421
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2422
    "temporary ..."
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2423
    (id isNil
7629
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2424
     or:[aForm graphicsDevice ~~ device]) ifTrue:[
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2425
        deviceForm := deviceForm asFormOn:device.
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2426
        id := deviceForm drawableId.
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2427
        id isNil ifTrue:[
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2428
            Logger warning:'invalid form draw (opaque) - ignored'.
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2429
            ^ self
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2430
        ].
732
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
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2433
    gcId isNil ifTrue:[
7629
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2434
        self initGC
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2435
    ].
7749
f4ad7601ae41 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 7746
diff changeset
  2436
    deviceFormGCId := deviceForm initGC.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2437
1592
7ec770f2047a faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents: 1517
diff changeset
  2438
    w := aForm width.
7ec770f2047a faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents: 1517
diff changeset
  2439
    h := aForm height.
7ec770f2047a faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents: 1517
diff changeset
  2440
7ec770f2047a faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents: 1517
diff changeset
  2441
    pX := x rounded.
7ec770f2047a faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents: 1517
diff changeset
  2442
    pY := y rounded.
7ec770f2047a faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents: 1517
diff changeset
  2443
902
7f5d81d377de opaque image display fix
Claus Gittinger <cg@exept.de>
parents: 895
diff changeset
  2444
    "
7f5d81d377de opaque image display fix
Claus Gittinger <cg@exept.de>
parents: 895
diff changeset
  2445
     a deep form ignores paint/bgPaint settings
7f5d81d377de opaque image display fix
Claus Gittinger <cg@exept.de>
parents: 895
diff changeset
  2446
     and is always drawn opaque.
7f5d81d377de opaque image display fix
Claus Gittinger <cg@exept.de>
parents: 895
diff changeset
  2447
    "
7f5d81d377de opaque image display fix
Claus Gittinger <cg@exept.de>
parents: 895
diff changeset
  2448
    (aForm depth ~~ 1) ifTrue:[
7629
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2449
        device
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2450
            copyFromPixmapId:id
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2451
            x:0
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2452
            y:0
7749
f4ad7601ae41 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 7746
diff changeset
  2453
            gc:deviceFormGCId
7629
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2454
            to:drawableId
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2455
            x:pX
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2456
            y:pY
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2457
            gc:gcId
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2458
            width:w
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2459
            height:h.
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2460
        ^ self
902
7f5d81d377de opaque image display fix
Claus Gittinger <cg@exept.de>
parents: 895
diff changeset
  2461
    ].
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  2462
    map := aForm colorMap.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  2463
    map notNil ifTrue:[
7629
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2464
        paint := map at:2.
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2465
        bgPaint := map at:1.
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  2466
    ].
902
7f5d81d377de opaque image display fix
Claus Gittinger <cg@exept.de>
parents: 895
diff changeset
  2467
7f5d81d377de opaque image display fix
Claus Gittinger <cg@exept.de>
parents: 895
diff changeset
  2468
    "/ 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
  2469
7f5d81d377de opaque image display fix
Claus Gittinger <cg@exept.de>
parents: 895
diff changeset
  2470
    bgPaint isNil ifTrue:[
7629
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2471
        self displayDeviceForm:aForm x:x y:y.
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2472
        ^ self
902
7f5d81d377de opaque image display fix
Claus Gittinger <cg@exept.de>
parents: 895
diff changeset
  2473
    ].
7f5d81d377de opaque image display fix
Claus Gittinger <cg@exept.de>
parents: 895
diff changeset
  2474
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2475
    "the following code is somewhat complicated, since it has to deal
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2476
     with dithered fg/bg colors, which cannot be done directly on most
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2477
     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
  2478
     (just assume drawing a bitmap with dithered fg/bg colors ... sigh)
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2479
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2480
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2481
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2482
     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
  2483
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2484
    easy := true.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2485
    paint isColor ifFalse:[
7629
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2486
        easy := false
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2487
    ] ifTrue:[
7629
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2488
        fgId := paint colorId.
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2489
        fgId isNil ifTrue:[
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2490
            easy := false
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2491
        ]
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2492
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2493
    bgPaint isColor ifFalse:[
7629
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2494
        easy := false
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2495
    ] ifTrue:[
7629
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2496
        bgId := bgPaint colorId.
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2497
        bgId isNil ifTrue:[
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2498
            easy := false
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2499
        ]
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2500
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2501
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2502
    easy ifTrue:[
7629
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2503
        "
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2504
         easy: both paint and bgPaint are real colors
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2505
        "
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2506
        ((foreground ~~ paint) or:[background ~~ bgPaint]) ifTrue:[
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2507
            device setForeground:fgId background:bgId in:gcId.
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2508
            foreground := paint.
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2509
            background := bgPaint.
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2510
        ].
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2511
        device
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2512
            copyPlaneFromPixmapId:id
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2513
            x:0
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2514
            y:0
7749
f4ad7601ae41 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 7746
diff changeset
  2515
            gc:deviceFormGCId
7629
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2516
            to:drawableId
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2517
            x:pX
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2518
            y:pY
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2519
            gc:gcId
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2520
            width:w
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2521
            height:h.
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2522
        ^ self
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2523
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2524
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2525
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2526
     hard case: paint and/or bgPaint are dithered or patterns
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2527
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2528
    allColor := Color allColor.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2529
    allBits := allColor colorId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2530
    deviceDepth := device depth.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2531
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2532
    (fgId notNil and:[function == #copy]) ifTrue:[
7629
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2533
        "
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2534
         only bg is dithered; fill with bg first ...
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2535
        "
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2536
        savedPaint := paint.
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2537
        self paint:bgPaint.
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2538
        self fillDeviceRectangleX:pX y:pY width:w height:h.
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2539
        self paint:savedPaint.
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2540
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2541
        "
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2542
         if paint color is all-0 or all-1's, we can do it in one
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2543
         operation ...
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2544
        "
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2545
        ((fgId ~~ ((1 bitShift:deviceDepth)-1))
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2546
        and:[fgId ~~ allBits]) ifTrue:[
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2547
            "
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2548
             clear fg-bits ...
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2549
            "
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2550
            device setForeground:0 background:allBits in:gcId.
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2551
            device setFunction:#and in:gcId.
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2552
            device
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2553
                copyPlaneFromPixmapId:id
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2554
                x:0
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2555
                y:0
7749
f4ad7601ae41 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 7746
diff changeset
  2556
                gc:deviceFormGCId
7629
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2557
                to:drawableId
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2558
                x:pX
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2559
                y:pY
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2560
                gc:gcId
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2561
                width:w
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2562
                height:h
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2563
        ].
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2564
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2565
        fgId ~~ 0 ifTrue:[
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2566
            "
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2567
             or-in fg-bits ...
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2568
            "
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2569
            device setForeground:fgId background:0 in:gcId.
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2570
            device setFunction:#or in:gcId.
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2571
            device
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2572
                copyPlaneFromPixmapId:id
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2573
                x:0
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2574
                y:0
7749
f4ad7601ae41 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 7746
diff changeset
  2575
                gc:deviceFormGCId
7629
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2576
                to:drawableId
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2577
                x:pX
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2578
                y:pY
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2579
                gc:gcId
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2580
                width:w
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2581
                height:h
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2582
        ].
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2583
        "
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2584
         flush foreground/background cache
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2585
        "
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2586
        foreground := nil.
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2587
        background := nil.
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2588
        device setFunction:function in:gcId.
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2589
        ^ self
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2590
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2591
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2592
    (bgId notNil and:[function == #copy]) ifTrue:[
7629
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2593
        "
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2594
         only fg is dithered; fill with fg first ...
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2595
        "
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2596
        self fillDeviceRectangleX:pX y:pY width:w height:h.
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2597
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2598
        "
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2599
         if paint color is all-0 or all-1's, we can do it in one
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2600
         operation ...
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2601
        "
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2602
        ((bgId ~~ ((1 bitShift:deviceDepth)-1))
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2603
        and:[bgId ~~ allBits]) ifTrue:[
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2604
            "
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2605
             clear bg-bits ...
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2606
            "
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2607
            device setForeground:allBits background:0 in:gcId.
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2608
            device setFunction:#and in:gcId.
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2609
            device
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2610
                copyPlaneFromPixmapId:id
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2611
                x:0
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2612
                y:0
7749
f4ad7601ae41 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 7746
diff changeset
  2613
                gc:deviceFormGCId
7629
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2614
                to:drawableId
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2615
                x:pX
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2616
                y:pY
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2617
                gc:gcId
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2618
                width:w
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2619
                height:h
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2620
        ].
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2621
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2622
        "
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2623
         or-in bg-bits ...
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2624
        "
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2625
        bgId ~~ 0 ifTrue:[
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2626
            device setForeground:0 background:bgId in:gcId.
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2627
            device setFunction:#or in:gcId.
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2628
            device
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2629
                copyPlaneFromPixmapId:id
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2630
                x:0
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2631
                y:0
7749
f4ad7601ae41 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 7746
diff changeset
  2632
                gc:deviceFormGCId
7629
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2633
                to:drawableId
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2634
                x:pX
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2635
                y:pY
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2636
                gc:gcId
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2637
                width:w
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2638
                height:h
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2639
        ].
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2640
        "
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2641
         flush foreground/background cache
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2642
        "
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2643
        foreground := nil.
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2644
        background := nil.
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2645
        device setFunction:function in:gcId.
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2646
        ^ self
732
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
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2649
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2650
     very hard case; both fg and bg are dithered colors
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2651
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2652
    noColor := Color noColor.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2653
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2654
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2655
     create temp-forms;
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2656
    "
4781
7f2473db5652 Change senders of obsolete messages Form>>...on: to ...onDevice:
Stefan Vogel <sv@exept.de>
parents: 4756
diff changeset
  2657
    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
  2658
    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
  2659
    tmpForm := Form width:w height:h depth:deviceDepth onDevice:device.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2660
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2661
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2662
     fill
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2663
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2664
    dx := dy := 0.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2665
    maskOrigin notNil ifTrue:[
7629
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2666
        dx := maskOrigin x.
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2667
        dy := maskOrigin y
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2668
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2669
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2670
    bgForm paint:bgPaint.
4983
14c28ec55880 Replace usage of obsolete methods
Stefan Vogel <sv@exept.de>
parents: 4914
diff changeset
  2671
    bgForm maskOriginX:(x negated + dx) y:(y negated + dy).
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2672
    bgForm fillRectangleX:0 y:0 width:w height:h.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2673
    fgForm paint:paint.
4983
14c28ec55880 Replace usage of obsolete methods
Stefan Vogel <sv@exept.de>
parents: 4914
diff changeset
  2674
    fgForm maskOriginX:(x negated + dx) y:(y negated + dy).
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2675
    fgForm fillRectangleX:0 y:0 width:w height:h.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2676
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2677
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2678
     stamp-out background
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2679
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2680
    bgForm paint:noColor on:allColor.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2681
    bgForm function:#and.
976
807b42b00353 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 975
diff changeset
  2682
    bgForm displayOpaqueForm:deviceForm x:0 y:0.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2683
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2684
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2685
     stamp-out foreground
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2686
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2687
    fgForm paint:allColor on:noColor.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2688
    fgForm function:#and.
976
807b42b00353 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 975
diff changeset
  2689
    fgForm displayOpaqueForm:deviceForm x:0 y:0.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2690
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2691
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2692
     clear tempform
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2693
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2694
    tmpForm paint:noColor.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2695
    tmpForm fillRectangleX:0 y:0 width:w height:h.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2696
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2697
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2698
     merge fg-temp and bg-temp into tmp
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2699
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2700
    tmpForm function:#or.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2701
    tmpForm paint:noColor on:allColor.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2702
    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
  2703
    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
  2704
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2705
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2706
     finally, draw it
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
    device setForeground:0 background:allBits in:gcId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2709
    device
7629
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2710
        copyFromPixmapId:tmpForm drawableId
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2711
        x:0
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2712
        y:0
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2713
        gc:tmpForm gcId
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2714
        to:drawableId
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2715
        x:pX
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2716
        y:pY
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2717
        gc:gcId
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2718
        width:w
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2719
        height:h.
1637
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  2720
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  2721
    "
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  2722
     release tempForms immediately
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2723
     (although GC will eventually do it,
1637
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  2724
      this creates less stress to the Xserver in the meanwhile ...)
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  2725
    "
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  2726
    fgForm destroy.
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  2727
    bgForm destroy.
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  2728
    tmpForm destroy.
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  2729
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2730
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2731
     flush foreground/background cache
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2732
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2733
    foreground := nil.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2734
    background := nil.
868
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
  2735
1637
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  2736
    "Modified: 22.4.1997 / 21:44:10 / cg"
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2737
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2738
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  2739
displayDeviceOpaqueString:aStringArg from:index1 to:index2 in:fontArg x:x y:y
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2740
    "draw a substring at the coordinate x/y - draw foreground pixels in
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2741
     paint-color and background pixels in bgPaint-color.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2742
     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
  2743
     the case where paint and/or bgPaint are dithered colors.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2744
     No translation or scaling is done."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2745
7443
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  2746
    |easy w h savedPaint fgId bgId allColor allBits noColor 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
  2747
     deviceDepth fontsEncoding ascent|
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2748
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2749
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2750
     if backgroundPaint color is nil, we assume
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2751
     this is a non-opaque draw
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2752
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2753
    bgPaint isNil ifTrue:[
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  2754
        self displayDeviceString:aString from:index1 to:index2 in:font x:x y:y.
7064
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  2755
        ^ self
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2756
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2757
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  2758
    gcId isNil ifTrue:[
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  2759
        self initGC
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  2760
    ].
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  2761
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  2762
    fontUsed := fontArg onDevice:device.
7443
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  2763
    deviceFont ~~ fontUsed ifTrue:[
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  2764
        (fontUsed installInDeviceForGCId:gcId) isNil ifTrue:[
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  2765
            "error - no such font"
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  2766
            ^ self.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  2767
        ].
7443
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  2768
        deviceFont := fontUsed.
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  2769
    ].
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  2770
7510
03f621a9cd9d #BUGFIX by sr
sr
parents: 7502
diff changeset
  2771
    (aString notNil 
03f621a9cd9d #BUGFIX by sr
sr
parents: 7502
diff changeset
  2772
    and:[aString isPlainString not]) ifTrue:[
7064
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  2773
        "
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  2774
         hook for non-strings (i.e. attributed text)
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  2775
         that 'thing' should know how to display itself ...
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  2776
        "
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  2777
        aString displayOpaqueOn:self x:x y:y from:index1 to:index2.
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  2778
        ^ self
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2779
    ].
6210
af0bf039ec07 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6108
diff changeset
  2780
af0bf039ec07 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6108
diff changeset
  2781
    pX := x rounded.
af0bf039ec07 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6108
diff changeset
  2782
    pY := y rounded.
af0bf039ec07 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6108
diff changeset
  2783
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  2784
    aString := aStringArg.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  2785
4026
882de378f763 no longer as string for its encoding;
Claus Gittinger <cg@exept.de>
parents: 3943
diff changeset
  2786
    fontsEncoding := fontUsed encoding.
7288
fec0c6c1087b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7257
diff changeset
  2787
    "/ This is now obsolete, as we are always using unicode internally.
fec0c6c1087b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7257
diff changeset
  2788
    "/ so the next line should be changed to fontsEncoding ~~ #unicode
4056
67c4686afbc6 characterEncoding stuff
Claus Gittinger <cg@exept.de>
parents: 4031
diff changeset
  2789
    (characterEncoding ~~ fontsEncoding) ifTrue:[
7064
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  2790
        [
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  2791
            aString := CharacterEncoder encodeString:aString from:characterEncoding into:fontsEncoding.
7064
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  2792
        ] on:CharacterEncoderError do:[:ex|
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  2793
            "substitute a default value for codes that cannot be represented
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  2794
             in the new character set"
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  2795
            ex proceedWith:ex defaultValue.
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  2796
        ].
4026
882de378f763 no longer as string for its encoding;
Claus Gittinger <cg@exept.de>
parents: 3943
diff changeset
  2797
    ].
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2798
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  2799
    fontUsed isAlienFont ifTrue:[
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  2800
        "
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  2801
         hook for alien fonts
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  2802
         that 'font' should know how to display the string ...
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  2803
        "
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  2804
        fontUsed displayOpaqueString:aString from:index1 to:index2 x:pX y:pY in:self.
7064
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  2805
        ^ self
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
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2809
     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
  2810
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2811
    easy := true.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2812
    paint isColor ifFalse:[
7064
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  2813
        easy := false
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2814
    ] ifTrue:[
7064
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  2815
        fgId := paint colorId.
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  2816
        fgId isNil ifTrue:[
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  2817
            easy := false
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  2818
        ]
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2819
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2820
    bgPaint isColor ifFalse:[
7064
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  2821
        easy := false
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2822
    ] ifTrue:[
7064
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  2823
        bgId := bgPaint colorId.
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  2824
        bgId isNil ifTrue:[
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  2825
            easy := false
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  2826
        ]
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2827
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2828
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2829
    easy ifTrue:[
7064
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  2830
        device setForeground:fgId background:bgId in:gcId.
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  2831
        foreground := paint.
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  2832
        background := bgPaint.
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  2833
        self displayDeviceString:aString from:index1 to:index2 x:pX y:pY opaque:true.
7064
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  2834
        ^ self
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2835
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2836
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  2837
    w := fontUsed widthOf:aString from:index1 to:index2.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2838
    h := fontUsed height.
3666
01d7bf1d2333 fixed Text drawing in displayString
Michael Beyl <mb@exept.de>
parents: 3630
diff changeset
  2839
    ascent := fontUsed ascent.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2840
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2841
    (fgId notNil and:[function == #copy]) ifTrue:[
7064
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  2842
        "
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  2843
         only bg is dithered; fill with bg first ...
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  2844
        "
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  2845
        savedPaint := paint.
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  2846
        self paint:bgPaint.
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  2847
        self fillRectangleX:pX y:(pY - ascent) width:w height:h.
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  2848
        self paint:savedPaint.
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  2849
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  2850
        "
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  2851
         then draw using fgPaint (which is a real color)
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  2852
        "
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  2853
        self displayDeviceString:aString from:index1 to:index2 x:pX y:pY opaque:false.
7064
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  2854
        ^ self
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2855
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2856
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2857
    allColor := Color allColor.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2858
    allBits := allColor colorId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2859
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2860
    deviceDepth := device depth.
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
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2863
     the code below is correct, but some (all?) implementations of the
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2864
     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
  2865
     Therefore we use the slower code below.
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
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2868
"/    (bgId notNil and:[function == #copy]) ifTrue:[
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
"/       only fg is dithered; fill with fg first ...
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2871
"/      "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2872
"/      self fillRectangleX:pX y:(pY - fontUsed ascent) width:w height:h.
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
"/      "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2875
"/       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
  2876
"/       operation ...
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2877
"/      "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2878
"/      ((bgId ~~ ((1 bitShift:deviceDepth)-1))
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2879
"/      and:[bgId ~~ allBits]) ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2880
"/          "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2881
"/           clear bg bits ...
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2882
"/          "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2883
"/          device setForeground:allBits background:0 in:gcId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2884
"/          device setFunction:#and in:gcId.
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2885
"/          device displayOpaqueString:s
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2886
"/                                from:index1 to:index2
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2887
"/                                   x:pX y:pY
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2888
"/                                  in:drawableId with:gcId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2889
"/      ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2890
"/
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2891
"/      "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2892
"/       or-in bg bits ...
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2893
"/      "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2894
"/      bgId ~~ 0 ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2895
"/          device setForeground:0 background:bgId in:gcId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2896
"/          device setFunction:#or in:gcId.
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2897
"/          device displayOpaqueString:s
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2898
"/                                from:index1 to:index2
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2899
"/                                   x:pX y:pY
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2900
"/                                  in:drawableId with:gcId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2901
"/      ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2902
"/      "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2903
"/       flush foreground/background cache
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2904
"/      "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2905
"/      foreground := nil.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2906
"/      background := nil.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2907
"/      device setFunction:function in:gcId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2908
"/      ^ self
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2909
"/  ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2910
768
77e4f9d30a22 fixes for b&w screens
Claus Gittinger <cg@exept.de>
parents: 745
diff changeset
  2911
    (bgId notNil and:[function == #copy]) ifTrue:[
7064
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  2912
        "
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  2913
         only fg is dithered; fill with bg first ...
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  2914
        "
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  2915
        device setForeground:bgId in:gcId.
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  2916
        device setFunction:#copy in:gcId.
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  2917
        device setBitmapMask:nil in:gcId.
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  2918
        self fillRectangleX:pX y:(pY - ascent) width:w height:h.
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  2919
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  2920
        mask notNil ifTrue:[
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  2921
            "/ draw fg dithered
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  2922
            (mask depth == 1) ifTrue:[
7629
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2923
                device setBitmapMask:mask drawableId in:gcId.
7064
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  2924
                device setForegroundColor:foreground backgroundColor:background in:gcId.
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  2925
            ] ifFalse:[
7629
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2926
                device setPixmapMask:mask drawableId in:gcId
7064
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  2927
            ].
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  2928
        ].
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  2929
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  2930
        self displayString:aString from:index1 to:index2 x:pX y:pY opaque:false.
7064
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  2931
        ^ self.
832
064890dcfabd fixed opaque string draw with deep-dither
Claus Gittinger <cg@exept.de>
parents: 786
diff changeset
  2932
    ].
064890dcfabd fixed opaque string draw with deep-dither
Claus Gittinger <cg@exept.de>
parents: 786
diff changeset
  2933
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2934
    "
832
064890dcfabd fixed opaque string draw with deep-dither
Claus Gittinger <cg@exept.de>
parents: 786
diff changeset
  2935
     very hard case, both fg and bg are dithered colors/images
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
    noColor := Color noColor.
4026
882de378f763 no longer as string for its encoding;
Claus Gittinger <cg@exept.de>
parents: 3943
diff changeset
  2938
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2939
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2940
     create temp-forms;
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2941
    "
4781
7f2473db5652 Change senders of obsolete messages Form>>...on: to ...onDevice:
Stefan Vogel <sv@exept.de>
parents: 4756
diff changeset
  2942
    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
  2943
    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
  2944
    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
  2945
    maskForm := Form width:w height:h depth:deviceDepth onDevice:device.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2946
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2947
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2948
     fill
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2949
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2950
    dx := 0.
3666
01d7bf1d2333 fixed Text drawing in displayString
Michael Beyl <mb@exept.de>
parents: 3630
diff changeset
  2951
    dy := ascent.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2952
    maskOrigin notNil ifTrue:[
7064
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  2953
        dx := maskOrigin x.
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  2954
        dy := dy + maskOrigin y
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2955
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2956
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2957
    bgForm paint:bgPaint.
4983
14c28ec55880 Replace usage of obsolete methods
Stefan Vogel <sv@exept.de>
parents: 4914
diff changeset
  2958
    bgForm maskOriginX:(pX negated + dx) y:(pY negated + dy).
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2959
    bgForm fillRectangleX:0 y:0 width:w height:h.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2960
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2961
    fgForm paint:paint.
4983
14c28ec55880 Replace usage of obsolete methods
Stefan Vogel <sv@exept.de>
parents: 4914
diff changeset
  2962
    fgForm maskOriginX:(pX negated + dx) y:(pY negated + dy).
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2963
    fgForm fillRectangleX:0 y:0 width:w height:h.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2964
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2965
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2966
     stamp-out background (have now bg-bits with fg=0 in bgForm)
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2967
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2968
    bgForm font:fontUsed.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2969
    bgForm paint:noColor on:allColor.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2970
    bgForm function:#and.
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  2971
    bgForm displayString:aString from:index1 to:index2 x:0 y:ascent.
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
     stamp-out foreground
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2975
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2976
    maskForm font:fontUsed.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2977
    maskForm paint:allColor on:noColor.
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  2978
    maskForm displayString:aString from:index1 to:index2 x:0 y:ascent opaque:true.
732
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
    fgForm function:#and.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2981
    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
  2982
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
     clear tempform
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2985
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2986
    tmpForm paint:noColor.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2987
    tmpForm fillRectangleX:0 y:0 width:w height:h.
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
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2990
     merge fg-temp and bg-temp into tmp
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
    tmpForm function:#or.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2993
    tmpForm paint:noColor on:allColor.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2994
    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
  2995
    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
  2996
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2997
     finally, draw it
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2998
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2999
    device setForeground:0 background:allBits in:gcId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3000
    device
7629
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  3001
        copyFromId:tmpForm drawableId
7064
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3002
        x:0 y:0 gc:tmpForm gcId
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3003
        to:drawableId
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3004
        x:pX y:(pY-ascent) gc:gcId
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3005
        width:w height:h.
1637
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  3006
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  3007
    "
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  3008
     release tempForms immediately
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3009
     (although GC will eventually do it,
1637
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  3010
      this creates less stress to the Xserver in the meanwhile ...)
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  3011
    "
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  3012
    tmpForm destroy.
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  3013
    fgForm destroy.
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  3014
    bgForm destroy.
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  3015
    maskForm destroy.
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  3016
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3017
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3018
     flush foreground/background cache
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
    foreground := nil.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3021
    background := nil.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3022
1805
532a11ba8458 tuned-out another send if encoding is wrong in display-string
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  3023
    "Modified: 1.7.1997 / 17:08:46 / cg"
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3024
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3025
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3026
displayDeviceOpaqueString:aString from:index1 to:index2 x:x y:y
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3027
    "draw a substring at the coordinate x/y - draw foreground pixels in
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3028
     paint-color and background pixels in bgPaint-color.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3029
     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
  3030
     the case where paint and/or bgPaint are dithered colors.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3031
     No translation or scaling is done."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3032
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3033
    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
  3034
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3035
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3036
displayDeviceOpaqueString:aString x:x y:y
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3037
    "draw a string at the coordinate x/y - draw foreground pixels in
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3038
     paint-color and background pixels in bgPaint-color.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3039
     No translation or scaling is done"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3040
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3041
    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
  3042
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3043
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3044
displayDeviceString:aStringArg from:index1 to:index2 in:fontArg x:x y:y
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3045
    "draw a substring at the coordinate x/y -
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3046
     draw foreground-pixels only (in current paint-color), leaving background as-is.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3047
     No translation or scaling is done"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3048
7443
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  3049
    |fontUsed aString fontsEncoding|
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3050
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3051
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3052
     hook for non-strings (i.e. attributed text)
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3053
    "
7064
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3054
    aString isPlainString ifFalse:[
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3055
        ^ aString displayOn:self x:x y:y from:index1 to:index2
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3056
    ].
6210
af0bf039ec07 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6108
diff changeset
  3057
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3058
    gcId isNil ifTrue:[
7064
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3059
        self initGC
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3060
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3061
7443
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  3062
    fontUsed := fontArg onDevice:device.
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  3063
    deviceFont ~~ fontUsed ifTrue:[
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  3064
        (fontUsed installInDeviceForGCId:gcId) isNil ifTrue:[
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  3065
            "error - no such font"
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  3066
            ^ self.
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  3067
        ].
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  3068
        deviceFont := fontUsed.
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  3069
    ].
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  3070
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3071
    aString := aStringArg.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3072
7443
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  3073
    fontsEncoding := fontUsed encoding.
4056
67c4686afbc6 characterEncoding stuff
Claus Gittinger <cg@exept.de>
parents: 4031
diff changeset
  3074
    (characterEncoding ~~ fontsEncoding) ifTrue:[
7064
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3075
        [
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3076
            aString := CharacterEncoder encodeString:aString from:characterEncoding into:fontsEncoding.
7064
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3077
        ] on:CharacterEncoderError do:[:ex|
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3078
            "substitute a default value for codes that cannot be represented
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3079
             in the new character set"
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3080
            ex proceedWith:ex defaultValue.
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3081
        ].
4026
882de378f763 no longer as string for its encoding;
Claus Gittinger <cg@exept.de>
parents: 3943
diff changeset
  3082
    ].
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3083
    fontUsed isAlienFont ifTrue:[
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3084
        "
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3085
         hook for alien fonts
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3086
         that 'font' should know how to display the string ...
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3087
        "
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3088
        fontUsed displayString:aString from:index1 to:index2 x:x rounded y:y rounded in:self.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3089
        ^ self
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3090
    ].
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3091
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3092
    self displayDeviceString:aString from:index1 to:index2 x:x y:y opaque:false.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3093
1805
532a11ba8458 tuned-out another send if encoding is wrong in display-string
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  3094
    "Modified: 1.7.1997 / 17:08:48 / cg"
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3095
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3096
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3097
displayDeviceString:aString from:index1 to:index2 x:x y:y
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3098
    "draw a substring at the coordinate x/y -
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3099
     draw foreground-pixels only (in current paint-color), leaving background as-is.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3100
     No translation or scaling is done"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3101
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3102
    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
  3103
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3104
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3105
displayDeviceString:aString from:index1 to:index2 x:x y:y opaque:opaque
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3106
    "draw a substring at the coordinate x/y -
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3107
     draw foreground-pixels only (in current paint-color), leaving background as-is.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3108
     No translation or scaling is done"
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3109
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3110
    gcId isNil ifTrue:[
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3111
        self initGC
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3112
    ].
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3113
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3114
    device displayString:aString from:index1 to:index2 x:x rounded y:y rounded in:drawableId with:gcId opaque:opaque.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3115
!
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3116
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3117
displayDeviceString:aString x:x y:y
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3118
    "draw a string at the coordinate x/y -
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3119
     draw foreground-pixels only (in current paint-color), leaving background as-is.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3120
     No translation or scaling is done"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3121
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3122
    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
  3123
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3124
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3125
fillDeviceRectangleX:x y:y width:w height:h
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3126
    "draw a filled rectangle in device coordinate space.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3127
     This ignores any transformations. The coordinates must be integers."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3128
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3129
    gcId isNil ifTrue:[
7746
7ad93b0b1545 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 7697
diff changeset
  3130
        self initGC
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3131
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3132
    device
7746
7ad93b0b1545 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 7697
diff changeset
  3133
        fillRectangleX:x y:y
7ad93b0b1545 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 7697
diff changeset
  3134
        width:w height:h
7ad93b0b1545 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 7697
diff changeset
  3135
        in:drawableId with:gcId
732
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
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3138
!DeviceGraphicsContext methodsFor:'evaluating in another context'!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3139
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3140
reverseDo:aBlock
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3141
    "evaluate aBlock with foreground and background interchanged.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3142
     This can be reimplemented here in a faster way."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3143
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3144
    |oldFg oldBg|
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3145
2835
963425946ff3 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 2714
diff changeset
  3146
    oldFg := foreground.
963425946ff3 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 2714
diff changeset
  3147
    oldBg := background.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3148
    self foreground:background background:foreground.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3149
    aBlock value.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3150
    self foreground:oldFg background:oldBg
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
withBackground:fgColor do:aBlock
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3154
    "evaluate aBlock with changed background."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3155
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3156
    |oldBg|
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
    oldBg := background.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3159
    self background:fgColor.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3160
    aBlock value.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3161
    self background:oldBg
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3162
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3163
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3164
withForeground:fgColor background:bgColor do:aBlock
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3165
    "evaluate aBlock with changed foreground and background."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3166
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3167
    |oldFg oldBg|
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
    oldFg := foreground.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3170
    oldBg := background.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3171
    self foreground:fgColor background:bgColor.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3172
    aBlock value.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3173
    self foreground:oldFg background:oldBg
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3174
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3175
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3176
withForeground:fgColor background:bgColor function:aFunction do:aBlock
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3177
    "evaluate aBlock with foreground, background and function"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3178
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3179
    |oldFg oldBg oldFun|
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
    oldFg := foreground.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3182
    oldBg := background.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3183
    oldFun := function.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3184
    self foreground:fgColor background:bgColor function:aFunction.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3185
    aBlock value.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3186
    self foreground:oldFg background:oldBg function:oldFun
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3187
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3188
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3189
withForeground:fgColor background:bgColor mask:aMask do:aBlock
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3190
    "evaluate aBlock with foreground, background and mask"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3191
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3192
    |oldFg oldBg oldMask|
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3193
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3194
    oldFg := foreground.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3195
    oldBg := background.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3196
    oldMask := mask.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3197
    self foreground:fgColor background:bgColor.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3198
    self mask:aMask.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3199
    aBlock value.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3200
    self foreground:oldFg background:oldBg.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3201
    self mask:oldMask
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3202
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3203
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3204
withForeground:fgColor do:aBlock
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3205
    "evaluate aBlock with changed foreground."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3206
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3207
    |oldFg|
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3208
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3209
    oldFg := foreground.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3210
    self foreground:fgColor.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3211
    aBlock value.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3212
    self foreground:oldFg
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3213
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3214
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3215
withForeground:fgColor function:aFunction do:aBlock
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3216
    "evaluate aBlock with changed foreground and function."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3217
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3218
    |oldFg oldFun|
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
    oldFg := foreground.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3221
    oldFun := function.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3222
    self foreground:fgColor background:background function:aFunction.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3223
    aBlock value.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3224
    self foreground:oldFg background:background function:oldFun
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3225
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3226
7759
45386945d6d7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7752
diff changeset
  3227
withPaint:aColor do:aBlock
45386945d6d7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7752
diff changeset
  3228
    "evaluate aBlock with changed paint color."
45386945d6d7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7752
diff changeset
  3229
45386945d6d7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7752
diff changeset
  3230
    |oldPaint|
45386945d6d7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7752
diff changeset
  3231
45386945d6d7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7752
diff changeset
  3232
    oldPaint := paint.
45386945d6d7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7752
diff changeset
  3233
    self paint:aColor.
45386945d6d7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7752
diff changeset
  3234
    aBlock value.
45386945d6d7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7752
diff changeset
  3235
    self paint:oldPaint
45386945d6d7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7752
diff changeset
  3236
!
45386945d6d7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7752
diff changeset
  3237
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3238
xoring:aBlock
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3239
    "evaluate aBlock with function xoring"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3240
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3241
    |fgPixel bgPixel oldFunction|
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3242
2322
6c42f2e0213c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2271
diff changeset
  3243
    fgPixel := device blackpixel.
6c42f2e0213c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2271
diff changeset
  3244
    bgPixel := device whitepixel.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3245
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3246
    gcId isNil ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3247
	self initGC
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3248
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3249
    oldFunction := function.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3250
    device setForeground:(fgPixel bitXor:bgPixel)
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3251
	      background:bgPixel
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3252
		      in:gcId.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3253
    device setFunction:#xor in:gcId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3254
    aBlock value.
2322
6c42f2e0213c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2271
diff changeset
  3255
2879
f1e9b8310d4e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2865
diff changeset
  3256
    paint := bgPaint := nil.        "invalidate"
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3257
    foreground := device blackColor.
1199
f113f6a4c04a use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents: 1177
diff changeset
  3258
    background := device whiteColor.
2322
6c42f2e0213c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2271
diff changeset
  3259
    device setForeground:fgPixel background:bgPixel in:gcId.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3260
    device setFunction:oldFunction in:gcId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3261
    function := oldFunction
1199
f113f6a4c04a use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents: 1177
diff changeset
  3262
2322
6c42f2e0213c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2271
diff changeset
  3263
    "Modified: / 10.9.1998 / 12:17:39 / cg"
732
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
!DeviceGraphicsContext methodsFor:'filling'!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3267
5837
28301409379c added: #clearDeviceRectangleX:y:width:height:
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3268
clearDeviceRectangleX:x y:y width:w height:h
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3269
    "clear a rectangular area to background"
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3270
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3271
    |oldPaint|
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3272
5837
28301409379c added: #clearDeviceRectangleX:y:width:height:
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3273
    oldPaint := paint.
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3274
    self paint:bgPaint.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3275
    self fillDeviceRectangleX:x y:y width:w height:h.
5837
28301409379c added: #clearDeviceRectangleX:y:width:height:
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3276
    self paint:oldPaint
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3277
!
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3278
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3279
clearRectangleX:left y:top width:w height:h
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3280
    "clear the rectangular area in the receiver to background"
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3281
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3282
    |oldPaint|
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3283
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3284
    oldPaint := paint.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3285
    self paint:bgPaint.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3286
    self fillRectangleX:left y:top width:w height:h.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3287
    self paint:oldPaint
5837
28301409379c added: #clearDeviceRectangleX:y:width:height:
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3288
!
28301409379c added: #clearDeviceRectangleX:y:width:height:
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3289
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3290
fillArcX:x y:y width:w height:h from:startAngle angle:angle
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3291
    "draw a filled arc; apply transformation if nonNil"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3292
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  3293
    |pX pY nW nH sA a pO pC|
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3294
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3295
    gcId isNil ifTrue:[
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3296
	self initGC
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3297
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3298
    transformation notNil ifTrue:[
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3299
	pO := transformation transformPoint:x@y.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3300
	pC := transformation transformPoint:(x+w-1)@(y+h-1).
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3301
	pX := pO x.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3302
	pY := pO y.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3303
	nW := pC x - pX + 1.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3304
	nH := pC y - pY + 1.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3305
	nW < 0 ifTrue:[
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3306
	      nW := nW abs.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3307
	      pX := pX - nW.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3308
	].
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3309
	nH < 0 ifTrue:[
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3310
	      nH := nH abs.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3311
	      pY := pY - nH.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3312
	].
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3313
    ] ifFalse:[
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3314
	pX := x.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3315
	pY := y.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3316
	nW := w.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3317
	nH := h.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3318
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3319
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3320
    pX := pX rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3321
    pY := pY rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3322
    nW := nW rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3323
    nH := nH rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3324
2268
1a774fc02c83 fixed non-float (i.e. fraction) args to fillArc/ displayArc
Claus Gittinger <cg@exept.de>
parents: 2259
diff changeset
  3325
    sA := startAngle.
1a774fc02c83 fixed non-float (i.e. fraction) args to fillArc/ displayArc
Claus Gittinger <cg@exept.de>
parents: 2259
diff changeset
  3326
    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
  3327
    a := angle.
1a774fc02c83 fixed non-float (i.e. fraction) args to fillArc/ displayArc
Claus Gittinger <cg@exept.de>
parents: 2259
diff changeset
  3328
    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
  3329
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3330
    device
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3331
	  fillArcX:pX
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3332
		 y:pY
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3333
	     width:nW
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3334
	    height:nH
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3335
	      from:sA
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3336
	     angle:a
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3337
		in:drawableId
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3338
	      with:gcId
732
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
    "Created: 8.5.1996 / 08:29:45 / cg"
784
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
  3341
    "Modified: 4.6.1996 / 17:58:21 / cg"
732
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
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3344
fillPolygon:aPolygon
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3345
    "draw a filled polygon; apply transformation if nonNil"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3346
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3347
    |newPolygon|
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3348
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3349
    gcId isNil ifTrue:[
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3350
	self initGC
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3351
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3352
    transformation notNil ifTrue:[
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3353
	newPolygon := aPolygon collect:[:point | transformation transformPoint:point].
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3354
    ] ifFalse:[
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3355
	newPolygon := aPolygon
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3356
    ].
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3357
    (newPolygon contains:[:p |
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3358
	(p isPoint not
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3359
	or:[(p x class ~~ SmallInteger)
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3360
	or:[(p y class ~~ SmallInteger)]])
4521
6f065906e740 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4477
diff changeset
  3361
     ]) ifTrue:[
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3362
	newPolygon := newPolygon collect:[:p | p asPoint rounded]
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3363
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3364
    device
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3365
	fillPolygon:newPolygon
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3366
		 in:drawableId
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3367
	       with:gcId
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3368
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3369
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3370
fillRectangleX:x y:y width:w height:h
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3371
    "draw a filled rectangle; apply transformation if nonNil"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3372
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  3373
    |pX pY nW nH pO pC|
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3374
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3375
    gcId isNil ifTrue:[
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3376
	self initGC
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3377
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3378
    transformation notNil ifTrue:[
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3379
	pO := transformation transformPoint:x@y.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3380
	pC := transformation transformPoint:(x+w-1)@(y+h-1).
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3381
	pX := pO x.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3382
	pY := pO y.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3383
	nW := pC x - pX + 1.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3384
	nH := pC y - pY + 1.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3385
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3386
	nW < 0 ifTrue:[
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3387
	      nW := nW abs.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3388
	      pX := pX - nW.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3389
	].
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3390
	nH < 0 ifTrue:[
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3391
	      nH := nH abs.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3392
	      pY := pY - nH.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3393
	].
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3394
    ] ifFalse:[
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3395
	pX := x.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3396
	pY := y.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3397
	nW := w.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3398
	nH := h.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3399
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3400
    pX := pX rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3401
    pY := pY rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3402
    nW := nW rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3403
    nH := nH rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3404
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3405
    device
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3406
	fillRectangleX:pX
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3407
		     y:pY
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3408
		 width:nW
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3409
		height:nH
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3410
		    in:drawableId with:gcId
784
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
  3411
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
  3412
    "Modified: 4.6.1996 / 17:58:49 / cg"
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3413
! !
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3414
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3415
!DeviceGraphicsContext methodsFor:'finalization'!
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3417
executor
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3418
    drawableType == #window ifTrue:[
7752
81c84fab0aac #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 7749
diff changeset
  3419
        ^ DeviceWindowGCHandle basicNew
81c84fab0aac #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 7749
diff changeset
  3420
            setDevice:device id:drawableId gcId:gcId parentId:parentId.
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3421
    ] ifFalse:[
7752
81c84fab0aac #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 7749
diff changeset
  3422
        ^ DevicePixmapGCHandle basicNew
81c84fab0aac #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 7749
diff changeset
  3423
            setDevice:device id:drawableId gcId:gcId.
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3424
    ].
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3425
!
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3426
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3427
finalizationLobby
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3428
    "answer the registry used for finalization.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3429
     DeviceGraphicContexts have their own Registry"
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3430
7443
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  3431
    ^ device graphicsContexts
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3432
! !
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3433
3883
4e01a59afccb method category rename
Claus Gittinger <cg@exept.de>
parents: 3880
diff changeset
  3434
!DeviceGraphicsContext methodsFor:'initialization & release'!
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3435
1517
ac751bb3dfdf no need for registration here;
Claus Gittinger <cg@exept.de>
parents: 1514
diff changeset
  3436
close
ac751bb3dfdf no need for registration here;
Claus Gittinger <cg@exept.de>
parents: 1514
diff changeset
  3437
    "same as destroy - for ST-80 compatibility"
ac751bb3dfdf no need for registration here;
Claus Gittinger <cg@exept.de>
parents: 1514
diff changeset
  3438
ac751bb3dfdf no need for registration here;
Claus Gittinger <cg@exept.de>
parents: 1514
diff changeset
  3439
    self destroy
ac751bb3dfdf no need for registration here;
Claus Gittinger <cg@exept.de>
parents: 1514
diff changeset
  3440
ac751bb3dfdf no need for registration here;
Claus Gittinger <cg@exept.de>
parents: 1514
diff changeset
  3441
    "Created: 2.4.1997 / 19:31:27 / cg"
ac751bb3dfdf no need for registration here;
Claus Gittinger <cg@exept.de>
parents: 1514
diff changeset
  3442
!
ac751bb3dfdf no need for registration here;
Claus Gittinger <cg@exept.de>
parents: 1514
diff changeset
  3443
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3444
createGC
1453
e93293618275 only fetch id's once in displayForm.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  3445
    "physically create a device GC.
e93293618275 only fetch id's once in displayForm.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  3446
     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
  3447
     really drawn, none is created up to the first draw.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3448
     This method is sent, when the first drawing happens"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3449
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3450
    drawableType == #pixmap ifTrue:[
7443
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  3451
        gcId := device gcForBitmap:drawableId.
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3452
    ] ifFalse:[
7443
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  3453
        gcId := device gcFor:drawableId.
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3454
    ].
7443
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  3455
    device registerGraphicsContext:self.    "this is a registerChange:"
1453
e93293618275 only fetch id's once in displayForm.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  3456
e93293618275 only fetch id's once in displayForm.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  3457
    "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
  3458
!
4a2b3b407cae need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents: 1094
diff changeset
  3459
4a2b3b407cae need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents: 1094
diff changeset
  3460
destroy
6222
2d670d3bcfd5 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6215
diff changeset
  3461
    |id|
2d670d3bcfd5 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6215
diff changeset
  3462
2d670d3bcfd5 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6215
diff changeset
  3463
    id := gcId.
2d670d3bcfd5 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6215
diff changeset
  3464
    id notNil ifTrue:[
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3465
        gcId := nil.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3466
        device destroyGC:id.
6222
2d670d3bcfd5 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6215
diff changeset
  3467
    ].
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3468
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3469
    id := drawableId.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3470
    id notNil ifTrue:[
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3471
        drawableId := nil.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3472
        drawableType == #window ifTrue:[
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3473
            device destroyView:nil withId:id.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3474
        ] ifFalse:[
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3475
            device destroyPixmap:id.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3476
        ].
7443
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  3477
        device unregisterGraphicsContext:self.    
6266
1503c5e038d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  3478
    ].
1503c5e038d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  3479
!
1503c5e038d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  3480
1138
4a2b3b407cae need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents: 1094
diff changeset
  3481
initGC
4a2b3b407cae need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents: 1094
diff changeset
  3482
    "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
  3483
     really drawn, none is created.
7749
f4ad7601ae41 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 7746
diff changeset
  3484
     This method is sent, when the first drawing happens.
f4ad7601ae41 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 7746
diff changeset
  3485
     Answer the gcId."
1138
4a2b3b407cae need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents: 1094
diff changeset
  3486
4135
a47337e09c40 preset font if already ok for device
werner
parents: 4070
diff changeset
  3487
    |fgId bgId p fontId|
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3488
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3489
    gcId notNil ifTrue:[
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3490
        "already initialized"
7749
f4ad7601ae41 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 7746
diff changeset
  3491
        ^ gcId
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3492
    ].
1514
7c2a921ae46b better error report when drawing on closed view.
Claus Gittinger <cg@exept.de>
parents: 1507
diff changeset
  3493
    drawableId isNil ifTrue:[
7406
e35784ee543c #OTHER by mawalch
mawalch
parents: 7396
diff changeset
  3494
        "/
e35784ee543c #OTHER by mawalch
mawalch
parents: 7396
diff changeset
  3495
        "/ the drawable has been closed (or was never open)
e35784ee543c #OTHER by mawalch
mawalch
parents: 7396
diff changeset
  3496
        "/ no drawing is possible.
e35784ee543c #OTHER by mawalch
mawalch
parents: 7396
diff changeset
  3497
        "/
e35784ee543c #OTHER by mawalch
mawalch
parents: 7396
diff changeset
  3498
        ^ DrawingOnClosedDrawableSignal raiseRequest
1514
7c2a921ae46b better error report when drawing on closed view.
Claus Gittinger <cg@exept.de>
parents: 1507
diff changeset
  3499
    ].
1138
4a2b3b407cae need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents: 1094
diff changeset
  3500
    self createGC.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3501
1199
f113f6a4c04a use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents: 1177
diff changeset
  3502
    foreground isNil ifTrue:[foreground := device blackColor].
f113f6a4c04a use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents: 1177
diff changeset
  3503
    background isNil ifTrue:[background := device whiteColor].
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3504
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3505
    foreground isColor ifTrue:[
7406
e35784ee543c #OTHER by mawalch
mawalch
parents: 7396
diff changeset
  3506
        "get device colors from the device indep. colors"
e35784ee543c #OTHER by mawalch
mawalch
parents: 7396
diff changeset
  3507
        foreground := foreground onDevice:device.
e35784ee543c #OTHER by mawalch
mawalch
parents: 7396
diff changeset
  3508
        fgId := foreground colorId.
e35784ee543c #OTHER by mawalch
mawalch
parents: 7396
diff changeset
  3509
        fgId isNil ifTrue:[
e35784ee543c #OTHER by mawalch
mawalch
parents: 7396
diff changeset
  3510
            (foreground grayIntensity >= 50) ifTrue:[
e35784ee543c #OTHER by mawalch
mawalch
parents: 7396
diff changeset
  3511
                fgId := device whitepixel
e35784ee543c #OTHER by mawalch
mawalch
parents: 7396
diff changeset
  3512
            ] ifFalse:[
e35784ee543c #OTHER by mawalch
mawalch
parents: 7396
diff changeset
  3513
                fgId := device blackpixel
e35784ee543c #OTHER by mawalch
mawalch
parents: 7396
diff changeset
  3514
            ]
e35784ee543c #OTHER by mawalch
mawalch
parents: 7396
diff changeset
  3515
        ].
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3516
    ] ifFalse:[
7406
e35784ee543c #OTHER by mawalch
mawalch
parents: 7396
diff changeset
  3517
        fgId := device blackpixel.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3518
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3519
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3520
    background isColor ifTrue:[
7406
e35784ee543c #OTHER by mawalch
mawalch
parents: 7396
diff changeset
  3521
        background := background onDevice:device.
e35784ee543c #OTHER by mawalch
mawalch
parents: 7396
diff changeset
  3522
        bgId := background colorId.
e35784ee543c #OTHER by mawalch
mawalch
parents: 7396
diff changeset
  3523
        bgId isNil ifTrue:[
e35784ee543c #OTHER by mawalch
mawalch
parents: 7396
diff changeset
  3524
            (background grayIntensity >= 50) ifTrue:[
e35784ee543c #OTHER by mawalch
mawalch
parents: 7396
diff changeset
  3525
                bgId := device whitepixel
e35784ee543c #OTHER by mawalch
mawalch
parents: 7396
diff changeset
  3526
            ] ifFalse:[
e35784ee543c #OTHER by mawalch
mawalch
parents: 7396
diff changeset
  3527
                bgId := device blackpixel
e35784ee543c #OTHER by mawalch
mawalch
parents: 7396
diff changeset
  3528
            ]
e35784ee543c #OTHER by mawalch
mawalch
parents: 7396
diff changeset
  3529
        ].
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3530
    ] ifFalse:[
7406
e35784ee543c #OTHER by mawalch
mawalch
parents: 7396
diff changeset
  3531
        bgId := device whitepixel
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3532
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3533
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3534
    "now, this is something the device can work with ..."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3535
    device setForeground:fgId background:bgId in:gcId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3536
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3537
    "switch to paint"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3538
    p := paint.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3539
    paint := nil.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3540
    self paint:p.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3541
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3542
    ((lineWidth ~~ 0)
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3543
    or:[(lineStyle ~~ #solid)
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3544
    or:[(capStyle ~~ #butt)
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3545
    or:[joinStyle ~~ #miter]]]) ifTrue:[
7406
e35784ee543c #OTHER by mawalch
mawalch
parents: 7396
diff changeset
  3546
        device setLineWidth:lineWidth
e35784ee543c #OTHER by mawalch
mawalch
parents: 7396
diff changeset
  3547
                      style:lineStyle
e35784ee543c #OTHER by mawalch
mawalch
parents: 7396
diff changeset
  3548
                        cap:capStyle
e35784ee543c #OTHER by mawalch
mawalch
parents: 7396
diff changeset
  3549
                       join:joinStyle
e35784ee543c #OTHER by mawalch
mawalch
parents: 7396
diff changeset
  3550
                         in:gcId
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3551
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3552
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3553
    mask notNil ifTrue:[
7406
e35784ee543c #OTHER by mawalch
mawalch
parents: 7396
diff changeset
  3554
        (mask depth == 1) ifTrue:[
7629
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  3555
            device setBitmapMask:(mask drawableId) in:gcId
7406
e35784ee543c #OTHER by mawalch
mawalch
parents: 7396
diff changeset
  3556
        ] ifFalse:[
7629
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  3557
            device setPixmapMask:(mask drawableId) in:gcId
7406
e35784ee543c #OTHER by mawalch
mawalch
parents: 7396
diff changeset
  3558
        ].
e35784ee543c #OTHER by mawalch
mawalch
parents: 7396
diff changeset
  3559
        maskOrigin notNil ifTrue:[
e35784ee543c #OTHER by mawalch
mawalch
parents: 7396
diff changeset
  3560
            device setMaskOriginX:maskOrigin x y:maskOrigin y in:gcId
e35784ee543c #OTHER by mawalch
mawalch
parents: 7396
diff changeset
  3561
        ]
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3562
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3563
    (function ~~ #copy) ifTrue:[device setFunction:function in:gcId].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3564
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3565
    "defer the getting of a device font
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3566
     - this is now done when the first drawstring occurs,
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3567
     since many views (layout-views) will never draw strings and
7406
e35784ee543c #OTHER by mawalch
mawalch
parents: 7396
diff changeset
  3568
     therefore, the overhead of acquiring a font can be avoided.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3569
    "
1138
4a2b3b407cae need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents: 1094
diff changeset
  3570
"/    font := font on:device.
4a2b3b407cae need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents: 1094
diff changeset
  3571
"/    id := font fontId.
4a2b3b407cae need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents: 1094
diff changeset
  3572
"/    id notNil ifTrue:[
4a2b3b407cae need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents: 1094
diff changeset
  3573
"/        device setFont:id in:gcId
4a2b3b407cae need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents: 1094
diff changeset
  3574
"/    ]
1199
f113f6a4c04a use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents: 1177
diff changeset
  3575
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3576
    (font notNil 
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3577
      and:[font graphicsDevice == device 
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3578
      and:[(fontId := font fontId) notNil]]) ifTrue:[
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3579
        deviceFont := font.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3580
        device setFont:fontId in:gcId
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3581
    ].
7749
f4ad7601ae41 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 7746
diff changeset
  3582
    ^ gcId.
4664
02d160974029 fix remembering deviceFont everywhere.
Claus Gittinger <cg@exept.de>
parents: 4657
diff changeset
  3583
02d160974029 fix remembering deviceFont everywhere.
Claus Gittinger <cg@exept.de>
parents: 4657
diff changeset
  3584
    "Modified: / 22-10-2006 / 14:10:53 / cg"
4291
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3585
!
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3586
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3587
initialize
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3588
    "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
  3589
     initColors and initFont, which are usually redefined."
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3590
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3591
    super initialize.
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3592
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3593
    "/ just in case, someone redefined new without setting device
6234
404d91662d49 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6225
diff changeset
  3594
    (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
  3595
6273
d1000b29b5b2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6271
diff changeset
  3596
    foreground isNil ifTrue:[foreground := self blackColor].
d1000b29b5b2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6271
diff changeset
  3597
    background isNil ifTrue:[background := self whiteColor].
4291
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3598
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3599
    "Modified: 10.1.1997 / 17:46:51 / cg"
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3600
!
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3601
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3602
prepareForReinit
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3603
    "kludge - clear drawableId and gcId
4291
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3604
     needed after snapin"
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3605
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3606
    gcId := nil.
7443
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  3607
    drawableId := parentId := nil.
4291
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3608
    deviceFont := nil
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3609
!
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3610
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3611
recreate
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3612
    "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
  3613
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3614
    gcId := nil.
7443
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  3615
    drawableId := parentId := nil.
4291
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3616
    foreground notNil ifTrue:[
7443
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  3617
        foreground := foreground onDevice:device
4291
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3618
    ].
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3619
    background notNil ifTrue:[
7443
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  3620
        background := background onDevice:device
4291
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3621
    ].
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3622
    paint notNil ifTrue:[
7443
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  3623
        paint := paint onDevice:device
4291
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3624
    ].
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3625
    bgPaint notNil ifTrue:[
7443
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  3626
        bgPaint := bgPaint onDevice:device
4291
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3627
    ].
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3628
    font notNil ifTrue:[
7443
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  3629
        font := deviceFont := font onDevice:device
4291
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3630
    ]
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3631
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3632
    "Modified: 28.10.1996 / 13:25:02 / cg"
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3633
!
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3634
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3635
releaseGC
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3636
    "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
  3637
     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
  3638
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3639
    |id|
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3640
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3641
    foreground := background := paint := bgPaint := nil.
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3642
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3643
    id := gcId.
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3644
    id notNil ifTrue:[
7443
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  3645
        gcId := nil.
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  3646
        device destroyGC:id.
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  3647
        device unregisterGraphicsContext:self.
4291
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3648
    ].
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3649
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3650
    "Created: 11.6.1996 / 22:07:30 / cg"
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3651
    "Modified: 2.4.1997 / 19:36:30 / cg"
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
!DeviceGraphicsContext methodsFor:'private'!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3655
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3656
setDevice:aDevice id:aDrawbleId gcId:aGCId
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3657
    "private"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3658
7443
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  3659
    self device:aDevice.
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  3660
    drawableId := aDrawbleId.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3661
    gcId := aGCId.
7445
b792207e3545 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7443
diff changeset
  3662
    (aDrawbleId notNil and:[aDevice notNil]) ifTrue:[
b792207e3545 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7443
diff changeset
  3663
        aDevice registerGraphicsContext:self.
b792207e3545 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7443
diff changeset
  3664
    ].
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3665
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3666
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3667
setGCForPaint
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3668
    "private; given a complex color (i.e. a pixmap or dithered color,
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3669
     setup the GC to draw in this color.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3670
     A helper for paint and paint:on:"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3671
832
064890dcfabd fixed opaque string draw with deep-dither
Claus Gittinger <cg@exept.de>
parents: 786
diff changeset
  3672
    |dither map pixelId p fg bg vOrg ditherDepth deviceDepth|
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3673
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3674
    gcId notNil ifTrue:[
7423
3be657fc460f #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7416
diff changeset
  3675
        paint isSymbol ifTrue:[
3be657fc460f #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7416
diff changeset
  3676
            "map symbols to colors"
3be657fc460f #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7416
diff changeset
  3677
            paint := Color perform:paint ifNotUnderstood:[Color yellow].
3be657fc460f #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7416
diff changeset
  3678
        ].
3be657fc460f #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7416
diff changeset
  3679
        p := paint.
3be657fc460f #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7416
diff changeset
  3680
3be657fc460f #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7416
diff changeset
  3681
        p isColor ifTrue:[
3be657fc460f #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7416
diff changeset
  3682
            paint := p := p onDevice:device.
3be657fc460f #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7416
diff changeset
  3683
            pixelId := p colorId.
3be657fc460f #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7416
diff changeset
  3684
            pixelId notNil ifTrue:[
3be657fc460f #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7416
diff changeset
  3685
                "
3be657fc460f #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7416
diff changeset
  3686
                 a real (undithered) color
3be657fc460f #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7416
diff changeset
  3687
                "
3be657fc460f #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7416
diff changeset
  3688
                mask notNil ifTrue:[
3be657fc460f #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7416
diff changeset
  3689
                    mask := nil.
3be657fc460f #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7416
diff changeset
  3690
                    device setBitmapMask:nil in:gcId
3be657fc460f #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7416
diff changeset
  3691
                ].
3be657fc460f #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7416
diff changeset
  3692
                (p ~~ foreground) ifTrue:[
3be657fc460f #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7416
diff changeset
  3693
                    foreground := paint.
3be657fc460f #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7416
diff changeset
  3694
                    device setForeground:pixelId in:gcId
3be657fc460f #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7416
diff changeset
  3695
                ].
3be657fc460f #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7416
diff changeset
  3696
                ^ self
3be657fc460f #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7416
diff changeset
  3697
            ].
3be657fc460f #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7416
diff changeset
  3698
            "a dithered color"
3be657fc460f #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7416
diff changeset
  3699
            dither := paint ditherForm.
3be657fc460f #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7416
diff changeset
  3700
        ] ifFalse:[
3be657fc460f #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7416
diff changeset
  3701
            "mhmh - seems to be some kind of form ..."
3be657fc460f #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7416
diff changeset
  3702
            paint := paint onDevice:device.
3be657fc460f #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7416
diff changeset
  3703
            dither := paint.
3be657fc460f #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7416
diff changeset
  3704
        ].
3be657fc460f #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7416
diff changeset
  3705
        "
3be657fc460f #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7416
diff changeset
  3706
         a dithered color or image
3be657fc460f #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7416
diff changeset
  3707
        "
3be657fc460f #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7416
diff changeset
  3708
        (ditherDepth := dither depth) == 1 ifTrue:[
3be657fc460f #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7416
diff changeset
  3709
            "a simple 0/1 bitmap"
3be657fc460f #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7416
diff changeset
  3710
            map := dither colorMap.
3be657fc460f #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7416
diff changeset
  3711
            "temporary (kludgy) fix for destroyed paint"
3be657fc460f #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7416
diff changeset
  3712
            p := paint.
3be657fc460f #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7416
diff changeset
  3713
            map isNil ifTrue:[
3be657fc460f #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7416
diff changeset
  3714
                fg := self blackColor.
3be657fc460f #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7416
diff changeset
  3715
                bg := self whiteColor.
3be657fc460f #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7416
diff changeset
  3716
            ] ifFalse:[
3be657fc460f #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7416
diff changeset
  3717
                fg := map at:2.
3be657fc460f #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7416
diff changeset
  3718
                bg := map at:1.
3be657fc460f #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7416
diff changeset
  3719
            ].
3be657fc460f #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7416
diff changeset
  3720
            self foreground:fg background:bg.
3be657fc460f #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7416
diff changeset
  3721
            paint := p
3be657fc460f #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7416
diff changeset
  3722
        ] ifFalse:[
3be657fc460f #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7416
diff changeset
  3723
            deviceDepth := device depth.
3be657fc460f #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7416
diff changeset
  3724
            (ditherDepth ~~ deviceDepth) ifTrue:[
3be657fc460f #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7416
diff changeset
  3725
                dither := dither asFormOn:device.
3be657fc460f #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7416
diff changeset
  3726
                ditherDepth := dither depth.
3be657fc460f #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7416
diff changeset
  3727
                (dither isNil or:[ditherDepth ~~ deviceDepth]) ifTrue:[
3be657fc460f #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7416
diff changeset
  3728
                    self error:'bad dither'.
3be657fc460f #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7416
diff changeset
  3729
                    ^ self
3be657fc460f #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7416
diff changeset
  3730
                ]
3be657fc460f #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7416
diff changeset
  3731
            ]
3be657fc460f #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7416
diff changeset
  3732
        ].
3be657fc460f #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7416
diff changeset
  3733
        self mask:dither.
3be657fc460f #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7416
diff changeset
  3734
        vOrg := self viewOrigin.
3be657fc460f #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7416
diff changeset
  3735
        self maskOriginX:vOrg x negated y:vOrg y negated.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3736
    ]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3737
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3738
    "Created: 16.5.1996 / 15:35:51 / cg"
1742
ca904d85a84c #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1741
diff changeset
  3739
    "Modified: 6.6.1997 / 12:55:38 / cg"
2049
1ceec8ef240e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2031
diff changeset
  3740
!
1ceec8ef240e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2031
diff changeset
  3741
7445
b792207e3545 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7443
diff changeset
  3742
setId:aDrawableId
2049
1ceec8ef240e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2031
diff changeset
  3743
    "private"
1ceec8ef240e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2031
diff changeset
  3744
7445
b792207e3545 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7443
diff changeset
  3745
    drawableId := aDrawableId
2049
1ceec8ef240e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2031
diff changeset
  3746
1ceec8ef240e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2031
diff changeset
  3747
    "Created: / 6.2.1998 / 12:44:45 / cg"
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3748
! !
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3749
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3750
!DeviceGraphicsContext methodsFor:'queries'!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3751
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3752
horizontalIntegerPixelPerMillimeter
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3753
    "return the (rounded) number of pixels per millimeter"
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
    ^ device horizontalPixelPerMillimeter rounded
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3756
!
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
horizontalPixelPerInch
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3759
    "return the number of horizontal pixels per inch of the display"
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 horizontalPixelPerMillimeter * 25.4
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3762
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3763
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3764
horizontalPixelPerMillimeter
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3765
    "return the number of pixels per millimeter (not rounded)"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3766
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3767
    ^ device horizontalPixelPerMillimeter
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3768
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3769
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3770
horizontalPixelPerMillimeter:millis
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3771
    "return the number of pixels (not rounded) for millis millimeter"
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
    ^ device horizontalPixelPerMillimeter * millis
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3774
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3775
784
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
  3776
resolution
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
  3777
    "return a point consisting of pixel-per-inch horizontally and vertically."
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
  3778
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
  3779
    ^ device resolution
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
  3780
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
  3781
    "Created: 4.6.1996 / 15:23:55 / cg"
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
  3782
!
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
  3783
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3784
verticalIntegerPixelPerMillimeter
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3785
    "return the (rounded) number of pixels per millimeter"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3786
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3787
    ^ device verticalPixelPerMillimeter rounded
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3788
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3789
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3790
verticalPixelPerInch
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3791
    "return the number of vertical pixels per inch of the display"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3792
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3793
    ^ device verticalPixelPerMillimeter * 25.4
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3794
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3795
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3796
verticalPixelPerMillimeter
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3797
    "return the number of pixels per millimeter (not rounded)"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3798
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3799
    ^ device verticalPixelPerMillimeter
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3800
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3801
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3802
verticalPixelPerMillimeter:millis
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3803
    "return the number of pixels (not rounded) for millis millimeter"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3804
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3805
    ^ device verticalPixelPerMillimeter * millis
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3806
! !
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3807
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3808
!DeviceGraphicsContext methodsFor:'testing'!
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3809
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3810
isPixmap
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3811
    ^ drawableType == #pixmap
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3812
!
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3813
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3814
isWindow
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3815
    ^ drawableType == #window
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3816
! !
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3817
6225
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  3818
!DeviceGraphicsContext methodsFor:'view creation'!
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  3819
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  3820
createBitmapFromArray:data width:width height:height
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  3821
    "create a bitmap from data and set the drawableId"
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3822
7443
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  3823
    drawableType := #pixmap.
6225
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  3824
    drawableId := device createBitmapFromArray:data width:width height:height.
7443
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  3825
    device registerGraphicsContext:self.    "this is a registerChange:"
6225
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  3826
!
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  3827
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  3828
createPixmapWidth:w height:h depth:d
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  3829
    "create a pixmap and set the drawableId"
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3830
6225
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  3831
    drawableId := device createPixmapWidth:w height:h depth:d.
7356
e6d6fa1a7057 #FEATURE by sr
sr
parents: 7350
diff changeset
  3832
    drawableId isNil ifTrue:[
7443
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  3833
        "/ creation failed
7588
fde403dd9571 #OTHER by mawalch
mawalch
parents: 7582
diff changeset
  3834
        ('[GC] warning: pixmap creation failed: ',((OperatingSystem lastErrorString) ? 'unknown error')) errorPrintCR.
7443
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  3835
        ^ GraphicsDevice::GraphicResourceAllocationFailure query
7356
e6d6fa1a7057 #FEATURE by sr
sr
parents: 7350
diff changeset
  3836
    ].
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3837
    drawableType := #pixmap.
7443
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  3838
    device registerGraphicsContext:self.    "this is a registerChange:"
6225
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  3839
!
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  3840
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3841
createRootWindowFor:aView
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3842
    drawableId := device rootWindowFor:aView.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3843
    drawableType := #window.
6234
404d91662d49 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6225
diff changeset
  3844
!
404d91662d49 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6225
diff changeset
  3845
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3846
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
  3847
    "create a window and set the drawableId"
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3848
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3849
    |container|
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3850
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3851
    drawableId := device
7443
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  3852
            createWindowFor:aView
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  3853
            type:typeSymbol
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  3854
            origin:org
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  3855
            extent:ext
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  3856
            minExtent:minE
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  3857
            maxExtent:maxE
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  3858
            borderWidth:bw
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  3859
            subViewOf:sv
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  3860
            style:styleSymbol
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  3861
            inputOnly:inp
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  3862
            label:label
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  3863
            owner:owner
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  3864
            icon:icn
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  3865
            iconMask:icnM
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  3866
            iconView:icnV.
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3867
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3868
    drawableType := #window.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3869
    container := aView container.
7629
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  3870
    container notNil ifTrue:[ parentId := container drawableId].
7443
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  3871
    device registerGraphicsContext:self.    "this is a registerChange:"
6225
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  3872
! !
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  3873
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  3874
!DeviceGraphicsContext methodsFor:'view properties'!
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  3875
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  3876
backingStore:how
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  3877
    "turn on/off backingStore (saving my pixels)
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  3878
     how may true/false, but also #always, #whenMapped or #never."
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  3879
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  3880
    drawableId notNil ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3881
	device setBackingStore:how in:drawableId
6225
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  3882
    ]
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  3883
!
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  3884
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  3885
bitGravity:gravity
7582
1117b57d97a1 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7560
diff changeset
  3886
    "set the bitGravity 
1117b57d97a1 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7560
diff changeset
  3887
     - that's the direction where the contents will move when the view is resized."
6225
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  3888
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  3889
    drawableId notNil ifTrue:[
7582
1117b57d97a1 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7560
diff changeset
  3890
        device setBitGravity:gravity in:drawableId
6225
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  3891
    ]
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  3892
!
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  3893
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  3894
saveUnder:aBoolean
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  3895
    "turn on/off saveUnder (saving pixels under myself)
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  3896
     - used for temporary views (i.e. PopUps and ModalBoxes)"
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  3897
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  3898
    drawableId notNil ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3899
	device setSaveUnder:aBoolean in:drawableId
6225
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  3900
    ]
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  3901
!
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  3902
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  3903
setCursorId:id
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  3904
    drawableId notNil ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3905
	device setCursor:id in:drawableId.
6225
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  3906
    ]
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  3907
!
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
setWindowPid: pid
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  3910
    "Sets the _NET_WM_PID property for the window.
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  3911
     This may be used by the window manager to group windows.
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  3912
     If anIntegerOrNil is nil, then PID of currently running
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  3913
     Smalltalk is used"
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  3914
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  3915
    drawableId notNil ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3916
	device setWindowPid:pid in:drawableId.
6225
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  3917
    ].
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  3918
!
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  3919
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  3920
viewGravity:gravity
7582
1117b57d97a1 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7560
diff changeset
  3921
    "set the viewGravity 
1117b57d97a1 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7560
diff changeset
  3922
     - that's the direction where the view will move when the superView is resized."
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
    drawableId notNil ifTrue:[
7582
1117b57d97a1 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7560
diff changeset
  3925
        device setWindowGravity:gravity in:drawableId
6225
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  3926
    ].
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  3927
!
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  3928
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  3929
windowBorderShape:aForm
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  3930
    "set the windows border shape"
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  3931
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  3932
    drawableId notNil ifTrue:[
7629
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  3933
        device setWindowBorderShape:(aForm drawableId) in:drawableId
6225
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  3934
    ].
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  3935
!
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  3936
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  3937
windowClass:windowClassNameString name:nameString
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  3938
    "define class and name of a window.
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  3939
     This may be used by the window manager to
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  3940
     select client specific resources."
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  3941
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  3942
    drawableId notNil ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3943
	device setWindowClass:windowClassNameString name:nameString in:drawableId.
6225
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  3944
    ].
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  3945
!
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  3946
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  3947
windowName:aString
7697
4ec49456e2e2 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7651
diff changeset
  3948
    "define the view's name in the window's title area."
6225
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  3949
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  3950
    drawableId notNil ifTrue: [
7697
4ec49456e2e2 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7651
diff changeset
  3951
        device setWindowName:aString in:drawableId.
6225
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  3952
    ]
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  3953
!
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  3954
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  3955
windowShape:aForm
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  3956
    "set the windows shape.
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  3957
     Returns false, if the display does not support the
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  3958
     X shape extension."
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
    drawableId notNil ifTrue:[
7629
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  3961
        ^ device setWindowShape:(aForm drawableId) in:drawableId
6225
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  3962
    ].
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  3963
    ^ false.
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  3964
! !
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  3965
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3966
!DeviceGraphicsContext::DevicePixmapGCHandle methodsFor:'accessing'!
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3967
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3968
parentId
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3969
    "pixmaps do not have a parent"
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3970
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3971
    ^ nil
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3972
! !
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3973
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3974
!DeviceGraphicsContext::DevicePixmapGCHandle methodsFor:'finalization'!
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3975
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3976
finalize
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3977
    "the Form for which I am a handle has been collected - tell it to the x-server"
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3978
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3979
    |id|
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3980
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3981
    drawableId notNil ifTrue:[
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3982
	(id := gcId) notNil ifTrue:[
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3983
	    gcId := nil.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3984
	    device destroyGC:id.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3985
	].
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3986
	id := drawableId.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3987
	drawableId := nil.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3988
	device destroyPixmap:id.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3989
    ]
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3990
! !
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3991
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3992
!DeviceGraphicsContext::DeviceWindowGCHandle methodsFor:'accessing'!
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3993
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3994
parentId
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3995
    ^ parentId
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3996
! !
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3997
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3998
!DeviceGraphicsContext::DeviceWindowGCHandle methodsFor:'finalization'!
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3999
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  4000
finalize
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  4001
    "the view for which I am a handle was collected
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  4002
     - release system resources"
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  4003
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  4004
    drawableId notNil ifTrue:[
7443
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  4005
        [
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  4006
            (device viewIdKnown:drawableId) ifTrue:[
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  4007
"/ 'Display [info]: recycled view (' infoPrint. v infoPrint. ') not destroyed: ' infoPrint.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  4008
"/ drawableId displayString infoPrintCR.
7443
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  4009
                drawableId := nil.
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  4010
            ] ifFalse:[
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  4011
                |id|
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  4012
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  4013
                (id := gcId) notNil ifTrue:[
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  4014
                    gcId := nil.
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  4015
                    device deviceIOErrorSignal handle:[:ex |
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  4016
                    ] do:[
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  4017
                        device destroyGC:id.
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  4018
                    ]
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  4019
                ].
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  4020
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  4021
                id := drawableId.
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  4022
                drawableId := nil.
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  4023
                device deviceIOErrorSignal handle:[:ex |
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  4024
                ] do:[
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  4025
                    device destroyView:nil withId:id.
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  4026
                ].
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  4027
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  4028
                "When a window ist destroyed, all its subwindows are also destroyed.
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  4029
                 Unregister all the subwindows, to avoid destroying of reused windowIds
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  4030
                 later."
7476
801c3083d451 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  4031
                device cleanupLobbyForChildrenOfViewWithId:id.
7443
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  4032
            ]
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  4033
        ] valueUninterruptably.
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  4034
    ].
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  4035
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  4036
    "Created: / 25.9.1997 / 10:01:46 / stefan"
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  4037
    "Modified: / 15.11.2001 / 14:17:12 / cg"
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  4038
! !
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  4039
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  4040
!DeviceGraphicsContext::DeviceWindowGCHandle methodsFor:'private-accessing'!
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  4041
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  4042
setDevice:aDevice id:aDrawableId gcId:aGCId parentId:parentIdArg
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  4043
    "set the handles contents"
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  4044
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  4045
    device := aDevice.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  4046
    drawableId := aDrawableId.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  4047
    gcId := aGCId.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  4048
    parentId := parentIdArg.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  4049
! !
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  4050
1085
3513a4cae87b handle depth1-images with a mask
Claus Gittinger <cg@exept.de>
parents: 1064
diff changeset
  4051
!DeviceGraphicsContext class methodsFor:'documentation'!
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4052
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4053
version
6926
d04d6d93b921 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6765
diff changeset
  4054
    ^ '$Header$'
5360
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  4055
!
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  4056
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  4057
version_CVS
6926
d04d6d93b921 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6765
diff changeset
  4058
    ^ '$Header$'
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4059
! !
3880
c4c8268a2d9f method category rename
Claus Gittinger <cg@exept.de>
parents: 3666
diff changeset
  4060