DeviceGraphicsContext.st
author Claus Gittinger <cg@exept.de>
Mon, 15 Jul 2019 15:39:44 +0200
changeset 8731 5506d148b369
parent 8687 798853409109
child 8763 6bb85bdf4955
permissions -rw-r--r--
#OTHER by cg unneeded subProjects method removed (already inherited)
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:[
8312
31d9c10d010e #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 8296
diff changeset
   109
        (self class name,' [warning]: no Display') infoPrintCR.
31d9c10d010e #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 8296
diff changeset
   110
        device := Smalltalk lateOpenDisplay.
31d9c10d010e #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 8296
diff changeset
   111
        device isNil ifTrue:[ 
31d9c10d010e #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 8296
diff changeset
   112
            Screen deviceOpenErrorSignal raiseErrorString:'no screen device'. 
31d9c10d010e #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 8296
diff changeset
   113
        ]
6290
b6886e346ae9 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6273
diff changeset
   114
    ].
6926
d04d6d93b921 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6765
diff changeset
   115
    ^ self onDevice:device
8312
31d9c10d010e #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 8296
diff changeset
   116
31d9c10d010e #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 8296
diff changeset
   117
    "Modified: / 20-03-2018 / 12:46:25 / stefan"
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   118
!
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
on:aDevice
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   121
    "create a new drawable on aDevice"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   122
3429
7f87cd2ae010 Use <resource:#obsolete>
Stefan Vogel <sv@exept.de>
parents: 3300
diff changeset
   123
    <resource:#obsolete>
7f87cd2ae010 Use <resource:#obsolete>
Stefan Vogel <sv@exept.de>
parents: 3300
diff changeset
   124
1741
b84a2f4317e9 warn #on: vs. #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1722
diff changeset
   125
    "/ 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
   126
    "/ operating on a model.
b84a2f4317e9 warn #on: vs. #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1722
diff changeset
   127
    "/ Please use #onDevice: to avoid confusion.
b84a2f4317e9 warn #on: vs. #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1722
diff changeset
   128
1255
bdf4cbcae668 on: -> onDevice:
Claus Gittinger <cg@exept.de>
parents: 1249
diff changeset
   129
    self obsoleteMethodWarning:'use #onDevice:'.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   130
    ^ self onDevice:aDevice
1255
bdf4cbcae668 on: -> onDevice:
Claus Gittinger <cg@exept.de>
parents: 1249
diff changeset
   131
1741
b84a2f4317e9 warn #on: vs. #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1722
diff changeset
   132
    "Modified: 5.6.1997 / 21:04:16 / cg"
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   133
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   134
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   135
onDevice:aDevice
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   136
    "create a new drawable on aDevice"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   137
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   138
    |newDrawable|
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   139
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   140
    newDrawable := self basicNew.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   141
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   142
    "
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   143
     set display before its initialized
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   144
     - so it can do something useful (i.e. get font sizes etc.) in its
8027
6fbc6eee1156 #OTHER by mawalch
mawalch
parents: 8010
diff changeset
   145
     initialize method(s)
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   146
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   147
    newDrawable device:aDevice.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   148
    newDrawable initialize.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   149
    ^ newDrawable
1517
ac751bb3dfdf no need for registration here;
Claus Gittinger <cg@exept.de>
parents: 1514
diff changeset
   150
8027
6fbc6eee1156 #OTHER by mawalch
mawalch
parents: 8010
diff changeset
   151
    "Modified: / 02-04-1997 / 19:19:35 / cg"
6fbc6eee1156 #OTHER by mawalch
mawalch
parents: 8010
diff changeset
   152
    "Modified (comment): / 17-05-2017 / 15:13:23 / mawalch"
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
8661
84710f77ba75 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 8651
diff changeset
   158
    "in low memory situations, give up cached forms"
84710f77ba75 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 8651
diff changeset
   159
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   160
    CachedScaledForms := CachedScales := nil
8661
84710f77ba75 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 8651
diff changeset
   161
84710f77ba75 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 8651
diff changeset
   162
    "Modified (comment): / 21-03-2019 / 19:21:32 / Claus Gittinger"
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   163
! !
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   164
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   165
!DeviceGraphicsContext methodsFor:'accessing'!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   166
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   167
at:aPoint
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   168
    "return the pixel at the coordinate given by aPoint"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   169
3160
89905f311a09 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3137
diff changeset
   170
    ^ self atX:aPoint x y:aPoint y
89905f311a09 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3137
diff changeset
   171
89905f311a09 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3137
diff changeset
   172
    "Modified: / 29.1.2000 / 12:17:42 / cg"
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   173
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   174
4204
947a5a5620d3 comments
Claus Gittinger <cg@exept.de>
parents: 4199
diff changeset
   175
at:aPoint put:aPixelColor
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   176
    "set a pixel"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   177
4204
947a5a5620d3 comments
Claus Gittinger <cg@exept.de>
parents: 4199
diff changeset
   178
    ^ self atX:aPoint x y:aPoint y put:aPixelColor
947a5a5620d3 comments
Claus Gittinger <cg@exept.de>
parents: 4199
diff changeset
   179
947a5a5620d3 comments
Claus Gittinger <cg@exept.de>
parents: 4199
diff changeset
   180
    "
947a5a5620d3 comments
Claus Gittinger <cg@exept.de>
parents: 4199
diff changeset
   181
     Display rootView at:(0@0) put:(Color red).
947a5a5620d3 comments
Claus Gittinger <cg@exept.de>
parents: 4199
diff changeset
   182
     Display rootView at:(1@1) put:(Color red).
947a5a5620d3 comments
Claus Gittinger <cg@exept.de>
parents: 4199
diff changeset
   183
     Display rootView at:(2@2) put:(Color red).
947a5a5620d3 comments
Claus Gittinger <cg@exept.de>
parents: 4199
diff changeset
   184
     Display rootView at:(3@3) put:(Color red).
947a5a5620d3 comments
Claus Gittinger <cg@exept.de>
parents: 4199
diff changeset
   185
     Display rootView at:(4@4) put:(Color red).
947a5a5620d3 comments
Claus Gittinger <cg@exept.de>
parents: 4199
diff changeset
   186
     Display rootView at:(5@5) put:(Color red).
947a5a5620d3 comments
Claus Gittinger <cg@exept.de>
parents: 4199
diff changeset
   187
    "
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   188
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   189
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   190
atX:x y:y
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   191
    "return the pixel at the coordinate given by x/y"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   192
2714
e5d16e41cbab need gcId-argument in getPixel
Claus Gittinger <cg@exept.de>
parents: 2680
diff changeset
   193
    ^ device getPixelX:x y:y from:drawableId with:gcId
e5d16e41cbab need gcId-argument in getPixel
Claus Gittinger <cg@exept.de>
parents: 2680
diff changeset
   194
e5d16e41cbab need gcId-argument in getPixel
Claus Gittinger <cg@exept.de>
parents: 2680
diff changeset
   195
    "Modified: / 22.5.1999 / 01:40:23 / cg"
732
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
4204
947a5a5620d3 comments
Claus Gittinger <cg@exept.de>
parents: 4199
diff changeset
   198
atX:x y:y put:aPixelColor
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   199
    "set a pixel"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   200
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   201
    |oldFg|
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   202
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   203
    oldFg := foreground.
4204
947a5a5620d3 comments
Claus Gittinger <cg@exept.de>
parents: 4199
diff changeset
   204
    self foreground:aPixelColor.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   205
    self displayPointX:x y:y.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   206
    self foreground:oldFg
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   207
!
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
backgroundPaint:aColor
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   210
    "set the background-paint color; this is used in opaque-draw
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   211
     operations"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   212
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   213
    (aColor ~~ bgPaint) ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   214
	aColor notNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   215
	    bgPaint := aColor.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   216
	    gcId notNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   217
		bgPaint isColor ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   218
		    bgPaint := aColor onDevice:device.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   219
		    bgPaint colorId notNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   220
			background := bgPaint.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   221
			gcId notNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   222
			    device setBackground:(bgPaint colorId) in:gcId.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   223
			].
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   224
			^ self
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   225
		    ]
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   226
		].
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   227
		self paint:paint on:aColor
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   228
	    ]
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   229
	]
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   230
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   231
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   232
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   233
basicFont:aFont
7560
086e2f28082c #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7510
diff changeset
   234
    "compatibility with GraphicsMedium"
086e2f28082c #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7510
diff changeset
   235
086e2f28082c #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7510
diff changeset
   236
    self font:aFont.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   237
!
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
capStyle:aSymbol
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   240
    "set the style in which the endpoints of lines
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   241
     are drawn - aSymbol may be #notLast, #butt, #round, #projecting"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   242
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   243
    |s|
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 := aSymbol) isNil ifTrue:[
1029
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
   246
	s := #butt.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   247
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   248
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   249
    (s ~~ capStyle) ifTrue:[
1029
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
   250
	capStyle := s.
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
   251
	gcId notNil ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   252
	    device setLineWidth:lineWidth
1029
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
   253
			  style:lineStyle
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
   254
			    cap:s
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
   255
			   join:joinStyle
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
   256
			     in:gcId
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
   257
	]
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   258
    ]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   259
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   260
    "Modified: 12.5.1996 / 22:23:03 / cg"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   261
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   262
950
d4d907fc7d78 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 927
diff changeset
   263
clippedByChildren:aBoolean
d4d907fc7d78 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 927
diff changeset
   264
    "turn on/off drawing over children.
d4d907fc7d78 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 927
diff changeset
   265
     If on, a superview may draw 'over' its children.
d4d907fc7d78 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 927
diff changeset
   266
     If off (the default), drawing is 'under' its children.
d4d907fc7d78 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 927
diff changeset
   267
     Only useful for the rootView, to draw over any visible views.
d4d907fc7d78 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 927
diff changeset
   268
     (for example, when dragging a rubber-line)"
d4d907fc7d78 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 927
diff changeset
   269
d4d907fc7d78 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 927
diff changeset
   270
    gcId isNil ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   271
	self initGC
950
d4d907fc7d78 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 927
diff changeset
   272
    ].
1715
c70e31496f91 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1714
diff changeset
   273
    device noClipIn:drawableId gc:gcId.
c70e31496f91 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1714
diff changeset
   274
    device setClipByChildren:aBoolean in:drawableId gc:gcId.
950
d4d907fc7d78 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 927
diff changeset
   275
d4d907fc7d78 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 927
diff changeset
   276
    "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
   277
    "Modified: 29.4.1997 / 15:33:55 / dq"
950
d4d907fc7d78 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 927
diff changeset
   278
!
d4d907fc7d78 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 927
diff changeset
   279
6215
701d3f1f91f7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6210
diff changeset
   280
clippingBounds:aRectangleOrNil
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   281
    "set the clipping rectangle for drawing (in logical coordinates);
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   282
     a nil argument turn off clipping (i.e. whole view is drawable)"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   283
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   284
    |x y w h newBounds|
7066
ac2d03dac697 #REFACTORING
Stefan Vogel <sv@exept.de>
parents: 7064
diff changeset
   285
ac2d03dac697 #REFACTORING
Stefan Vogel <sv@exept.de>
parents: 7064
diff changeset
   286
    aRectangleOrNil isNil ifTrue:[
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   287
	clipRect isNil ifTrue:[^ self].
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   288
	gcId notNil ifTrue:[
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   289
	    device noClipIn:drawableId gc:gcId
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
	clipRect := nil.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   292
	^ self.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   293
    ].
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   294
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   295
    x := aRectangleOrNil left.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   296
    y := aRectangleOrNil top.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   297
    w := aRectangleOrNil width.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   298
    h := aRectangleOrNil height.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   299
    transformation notNil ifTrue:[
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   300
	x := transformation applyToX:x.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   301
	y := transformation applyToY:y.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   302
	w := transformation applyScaleX:w.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   303
	h := transformation applyScaleY:h.
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
    (x class == SmallInteger) ifFalse:[
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   306
	w := w + (x - x truncated).
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   307
	x := x 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
    (y class == SmallInteger) ifFalse:[
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   310
	h := h + (y - y truncated).
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   311
	y := y truncated
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   312
    ].
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   313
    (w class == SmallInteger) ifFalse:[
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   314
	w := w truncated + 1
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   315
    ].
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   316
    (h class == SmallInteger) ifFalse:[
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   317
	h := h truncated + 1
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   318
    ].
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   319
    w := w max:0.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   320
    h := h max:0.
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
    newBounds := Rectangle left:x top:y width:w height:h.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   323
    (clipRect notNil and:[clipRect = newBounds]) ifTrue:[
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   324
	^ self
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   325
    ].
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   326
    clipRect := newBounds.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   327
    gcId notNil ifTrue:[
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   328
	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
   329
    ].
2d670d3bcfd5 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6215
diff changeset
   330
2d670d3bcfd5 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6215
diff changeset
   331
    "Created: / 28.5.1996 / 19:40:20 / cg"
2d670d3bcfd5 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6215
diff changeset
   332
    "Modified: / 16.5.1999 / 19:40:37 / cg"
2d670d3bcfd5 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6215
diff changeset
   333
!
2d670d3bcfd5 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6215
diff changeset
   334
1842
502aa16b146e added #colorAt:
Claus Gittinger <cg@exept.de>
parents: 1805
diff changeset
   335
colorAt:aPoint
502aa16b146e added #colorAt:
Claus Gittinger <cg@exept.de>
parents: 1805
diff changeset
   336
    "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
   337
502aa16b146e added #colorAt:
Claus Gittinger <cg@exept.de>
parents: 1805
diff changeset
   338
    ^ self colorAtX:(aPoint x) y:(aPoint y)
502aa16b146e added #colorAt:
Claus Gittinger <cg@exept.de>
parents: 1805
diff changeset
   339
502aa16b146e added #colorAt:
Claus Gittinger <cg@exept.de>
parents: 1805
diff changeset
   340
    "Modified: 1.8.1997 / 20:01:58 / cg"
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
502aa16b146e added #colorAt:
Claus Gittinger <cg@exept.de>
parents: 1805
diff changeset
   343
colorAtX:x y:y
502aa16b146e added #colorAt:
Claus Gittinger <cg@exept.de>
parents: 1805
diff changeset
   344
    "return the color of the pixel at the coordinate given by aPoint"
502aa16b146e added #colorAt:
Claus Gittinger <cg@exept.de>
parents: 1805
diff changeset
   345
502aa16b146e added #colorAt:
Claus Gittinger <cg@exept.de>
parents: 1805
diff changeset
   346
    |pixel|
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
    pixel := self atX:x y:y.
502aa16b146e added #colorAt:
Claus Gittinger <cg@exept.de>
parents: 1805
diff changeset
   349
    device getScaledRGBFrom:pixel into:[:r :g :b |
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   350
	^ Color scaledRed:r scaledGreen:g scaledBlue:b
1842
502aa16b146e added #colorAt:
Claus Gittinger <cg@exept.de>
parents: 1805
diff changeset
   351
    ].
502aa16b146e added #colorAt:
Claus Gittinger <cg@exept.de>
parents: 1805
diff changeset
   352
502aa16b146e added #colorAt:
Claus Gittinger <cg@exept.de>
parents: 1805
diff changeset
   353
    "Created: 1.8.1997 / 20:01:32 / cg"
502aa16b146e added #colorAt:
Claus Gittinger <cg@exept.de>
parents: 1805
diff changeset
   354
!
502aa16b146e added #colorAt:
Claus Gittinger <cg@exept.de>
parents: 1805
diff changeset
   355
4199
c01c62e8c7a5 dummy container
Claus Gittinger <cg@exept.de>
parents: 4172
diff changeset
   356
container
c01c62e8c7a5 dummy container
Claus Gittinger <cg@exept.de>
parents: 4172
diff changeset
   357
    "return my container - for protocol compatibility"
c01c62e8c7a5 dummy container
Claus Gittinger <cg@exept.de>
parents: 4172
diff changeset
   358
c01c62e8c7a5 dummy container
Claus Gittinger <cg@exept.de>
parents: 4172
diff changeset
   359
    ^ nil
c01c62e8c7a5 dummy container
Claus Gittinger <cg@exept.de>
parents: 4172
diff changeset
   360
!
c01c62e8c7a5 dummy container
Claus Gittinger <cg@exept.de>
parents: 4172
diff changeset
   361
786
af5fecf93126 added dashStyle: ...
Claus Gittinger <cg@exept.de>
parents: 784
diff changeset
   362
dashStyle:aDashList offset:dashOffset
af5fecf93126 added dashStyle: ...
Claus Gittinger <cg@exept.de>
parents: 784
diff changeset
   363
    "define dashes. Each element of the dashList specifies the length
af5fecf93126 added dashStyle: ...
Claus Gittinger <cg@exept.de>
parents: 784
diff changeset
   364
     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
   365
     defines 4on-4off dashing;
786
af5fecf93126 added dashStyle: ...
Claus Gittinger <cg@exept.de>
parents: 784
diff changeset
   366
     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
   367
     The dashOffset specifies where in the dashList the dashing starts.
af5fecf93126 added dashStyle: ...
Claus Gittinger <cg@exept.de>
parents: 784
diff changeset
   368
     This may not be supported by all graphics devices."
af5fecf93126 added dashStyle: ...
Claus Gittinger <cg@exept.de>
parents: 784
diff changeset
   369
af5fecf93126 added dashStyle: ...
Claus Gittinger <cg@exept.de>
parents: 784
diff changeset
   370
    gcId notNil ifTrue:[
1029
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
   371
	device setDashes:(ByteArray withAll:aDashList)
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
   372
	      dashOffset:dashOffset
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
   373
		      in:gcId
786
af5fecf93126 added dashStyle: ...
Claus Gittinger <cg@exept.de>
parents: 784
diff changeset
   374
    ]
af5fecf93126 added dashStyle: ...
Claus Gittinger <cg@exept.de>
parents: 784
diff changeset
   375
af5fecf93126 added dashStyle: ...
Claus Gittinger <cg@exept.de>
parents: 784
diff changeset
   376
    "Modified: 4.6.1996 / 19:03:06 / cg"
af5fecf93126 added dashStyle: ...
Claus Gittinger <cg@exept.de>
parents: 784
diff changeset
   377
!
af5fecf93126 added dashStyle: ...
Claus Gittinger <cg@exept.de>
parents: 784
diff changeset
   378
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   379
device
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   380
    "return the device, the receiver is associated with"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   381
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   382
    ^ device
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   383
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   384
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   385
device:aDevice
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   386
    "set the device"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   387
7443
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
   388
    device == aDevice ifTrue:[
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
   389
        ^ self.
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
   390
    ].
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
   391
    device notNil ifTrue:[
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
   392
        "change of device of an already existing GraphicsContext"
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
   393
        drawableId notNil ifTrue:[
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
   394
            device unregisterGraphicsContext: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
        device := aDevice.
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
   397
        self recreate.
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
   398
        ^ self.
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
   399
    ].
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
   400
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
   401
    "set device of a new GraphicsContext"
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   402
    device := aDevice
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   403
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   404
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   405
deviceClippingBounds:aRectangleOrNil
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   406
    "set the clipping rectangle for drawing (in device coordinates);
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   407
     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
   408
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   409
    clipRect = aRectangleOrNil ifTrue:[
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   410
	^ self
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   411
    ].
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   412
    clipRect := aRectangleOrNil.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   413
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   414
    gcId isNil ifTrue:[
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   415
	^ self.
7060
Stefan Vogel <sv@exept.de>
parents: 6926
diff changeset
   416
    ].
Stefan Vogel <sv@exept.de>
parents: 6926
diff changeset
   417
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   418
    aRectangleOrNil isNil ifTrue:[
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   419
	device noClipIn:drawableId gc:gcId
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   420
    ] ifFalse:[
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   421
	device setClipX:aRectangleOrNil left
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   422
		    y:aRectangleOrNil top
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   423
		    width:aRectangleOrNil width
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   424
		    height:aRectangleOrNil height
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   425
		    in:drawableId
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   426
		    gc:gcId
7060
Stefan Vogel <sv@exept.de>
parents: 6926
diff changeset
   427
    ].
7416
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
    "Modified: / 22.5.1996 / 13:12:07 / cg"
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   430
    "Created: / 14.9.1998 / 18:50:31 / cg"
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   431
!
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
deviceClippingBoundsOrNil
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   434
    "get the clipping rectangle for drawing (in device coordinates);
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   435
     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
   436
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   437
    ^ clipRect
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   438
!
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   439
7502
83e3d1504fc2 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7476
diff changeset
   440
deviceFont
83e3d1504fc2 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7476
diff changeset
   441
    "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
   442
     the GC is realized."
83e3d1504fc2 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7476
diff changeset
   443
83e3d1504fc2 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7476
diff changeset
   444
    (device notNil and:[font notNil]) ifTrue:[
83e3d1504fc2 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7476
diff changeset
   445
        font := font onDevice:device
83e3d1504fc2 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7476
diff changeset
   446
    ].
83e3d1504fc2 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7476
diff changeset
   447
    ^ font
83e3d1504fc2 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7476
diff changeset
   448
!
83e3d1504fc2 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7476
diff changeset
   449
6222
2d670d3bcfd5 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6215
diff changeset
   450
drawableId
2d670d3bcfd5 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6215
diff changeset
   451
    "return the id of the drawable on the device"
2d670d3bcfd5 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6215
diff changeset
   452
2d670d3bcfd5 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6215
diff changeset
   453
    ^ drawableId
2d670d3bcfd5 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6215
diff changeset
   454
!
2d670d3bcfd5 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6215
diff changeset
   455
2918
1e777dc8588a #font answers device font if possible (cg)
Stefan Vogel <sv@exept.de>
parents: 2913
diff changeset
   456
font
1e777dc8588a #font answers device font if possible (cg)
Stefan Vogel <sv@exept.de>
parents: 2913
diff changeset
   457
    "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
   458
     the GC is realized."
1e777dc8588a #font answers device font if possible (cg)
Stefan Vogel <sv@exept.de>
parents: 2913
diff changeset
   459
7218
4c15124a9431 #BUGFIX
Stefan Vogel <sv@exept.de>
parents: 7066
diff changeset
   460
    (device notNil and:[font notNil]) ifTrue:[
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   461
	font := font onDevice:device
2918
1e777dc8588a #font answers device font if possible (cg)
Stefan Vogel <sv@exept.de>
parents: 2913
diff changeset
   462
    ].
1e777dc8588a #font answers device font if possible (cg)
Stefan Vogel <sv@exept.de>
parents: 2913
diff changeset
   463
    ^ font
1e777dc8588a #font answers device font if possible (cg)
Stefan Vogel <sv@exept.de>
parents: 2913
diff changeset
   464
!
1e777dc8588a #font answers device font if possible (cg)
Stefan Vogel <sv@exept.de>
parents: 2913
diff changeset
   465
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   466
font:aFont
7560
086e2f28082c #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7510
diff changeset
   467
    "set the font for drawing if it has changed.
086e2f28082c #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7510
diff changeset
   468
     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
   469
     (i.e. it must not imply a redraw operation)"
086e2f28082c #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7510
diff changeset
   470
086e2f28082c #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7510
diff changeset
   471
    |id|
086e2f28082c #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7510
diff changeset
   472
086e2f28082c #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7510
diff changeset
   473
    (aFont notNil and:[aFont ~~ font]) ifTrue:[
086e2f28082c #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7510
diff changeset
   474
        font := aFont.
086e2f28082c #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7510
diff changeset
   475
        device notNil ifTrue:[
086e2f28082c #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7510
diff changeset
   476
            font := font onDevice:device.
086e2f28082c #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7510
diff changeset
   477
            gcId notNil ifTrue:[
086e2f28082c #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7510
diff changeset
   478
                id := font fontId.
086e2f28082c #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7510
diff changeset
   479
                id notNil ifTrue:[
086e2f28082c #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7510
diff changeset
   480
                    deviceFont := font.
086e2f28082c #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7510
diff changeset
   481
                    device setFont:id in:gcId
086e2f28082c #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7510
diff changeset
   482
                ]
086e2f28082c #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7510
diff changeset
   483
            ]
086e2f28082c #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7510
diff changeset
   484
        ]
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
7560
086e2f28082c #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7510
diff changeset
   487
    "Created: / 23-02-1996 / 17:16:51 / cg"
086e2f28082c #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7510
diff changeset
   488
    "Modified: / 22-10-2006 / 14:11:37 / cg"
732
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
8296
bc1956bd5d3a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 8283
diff changeset
   491
function:functionSymbol
bc1956bd5d3a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 8283
diff changeset
   492
    "set the drawing function if it has changed.
bc1956bd5d3a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 8283
diff changeset
   493
     functionSymbol is one of:
bc1956bd5d3a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 8283
diff changeset
   494
            #copy,#copyInverted,#xor,#and,#andReverse
bc1956bd5d3a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 8283
diff changeset
   495
            #andInverted,#or,#orReverse,#orInverted
bc1956bd5d3a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 8283
diff changeset
   496
            #invert,#clear,#set,#noop,#equiv,#nand.
bc1956bd5d3a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 8283
diff changeset
   497
     Notice: not all graphicMedia support all functions"
bc1956bd5d3a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 8283
diff changeset
   498
bc1956bd5d3a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 8283
diff changeset
   499
    (functionSymbol ~~ function) ifTrue:[
bc1956bd5d3a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 8283
diff changeset
   500
        function := functionSymbol.
bc1956bd5d3a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 8283
diff changeset
   501
        gcId notNil ifTrue:[
bc1956bd5d3a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 8283
diff changeset
   502
            device setFunction:functionSymbol in:gcId
bc1956bd5d3a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 8283
diff changeset
   503
        ]
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   504
    ]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   505
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   506
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   507
gcId
7237
9482956af0f1 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 7218
diff changeset
   508
    "return the receiver's graphic context id on the device"
732
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
    ^ gcId
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   511
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   512
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   513
id
6222
2d670d3bcfd5 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6215
diff changeset
   514
    "return the id of the drawable on the device"
732
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
    ^ drawableId
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   517
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   518
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   519
joinStyle:aSymbol
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   520
    "set the style in which 2 lines are connected in polygons -
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   521
     aSymbol may be #miter, #bevel, #round"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   522
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   523
    |s|
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   524
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   525
    (s := aSymbol) isNil ifTrue:[
1029
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
   526
	s := #miter
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   527
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   528
    (s ~~ joinStyle) ifTrue:[
1029
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
   529
	joinStyle := s.
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   530
1029
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
   531
	gcId notNil ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   532
	    device setLineWidth:lineWidth
1029
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
   533
			  style:lineStyle
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
   534
			    cap:capStyle
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
   535
			   join:s
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
   536
			     in:gcId
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
   537
	]
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
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   540
    "Modified: 12.5.1996 / 22:20:43 / cg"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   541
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   542
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   543
lineStyle:aSymbol
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   544
    "set the style in which lines are drawn -
2360
c7ca5d55d8ce comment
Claus Gittinger <cg@exept.de>
parents: 2343
diff changeset
   545
     aSymbol may be #solid, #dashed, #doubleDashed,
c7ca5d55d8ce comment
Claus Gittinger <cg@exept.de>
parents: 2343
diff changeset
   546
     #dotted, #dashDot or #dashDotDot."
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   547
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   548
    |s|
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   549
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   550
    (s := aSymbol) isNil ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   551
	s := #solid
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   552
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   553
    (s ~~ lineStyle) ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   554
	lineStyle := s.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   555
	gcId notNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   556
	    device setLineWidth:lineWidth
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   557
			  style:s
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   558
			    cap:capStyle
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   559
			   join:joinStyle
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   560
			     in:gcId
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   561
	]
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   562
    ]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   563
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   564
    "Modified: 12.5.1996 / 22:21:25 / cg"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   565
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   566
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   567
lineWidth:aNumber
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   568
    "set the line width for drawing if it has changed"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   569
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   570
    |n|
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   571
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   572
    (aNumber ~~ lineWidth) ifTrue:[
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   573
	lineWidth := aNumber.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   574
	transformation isNil ifTrue:[
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   575
	    n := aNumber.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   576
	] ifFalse:[
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   577
	    n := transformation applyScaleX:aNumber.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   578
	    n := n rounded
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   579
	].
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   580
	gcId notNil ifTrue:[
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   581
	    device setLineWidth:n style:lineStyle cap:capStyle join:joinStyle in:gcId
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   582
	]
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   583
    ]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   584
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   585
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   586
mask:aForm
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   587
    "set the mask form for drawing"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   588
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   589
    |id|
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   590
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   591
    (aForm ~~ mask) ifTrue:[
7629
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
   592
        mask := aForm.
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
   593
        gcId notNil ifTrue:[
7799
68deff7c0fd9 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7759
diff changeset
   594
            mask isNil ifTrue:[
7629
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
   595
                device setBitmapMask:nil in:gcId
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
   596
            ] ifFalse:[
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
   597
                mask := mask asFormOn:device.
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
   598
                id := mask drawableId.
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
   599
                (mask depth == 1) ifTrue:[
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
   600
                    device setBitmapMask:id in:gcId
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
   601
                ] ifFalse:[
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
   602
                    device setPixmapMask:id in:gcId
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
   603
                ]
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
   604
            ]
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
   605
        ]
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   606
    ]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   607
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   608
2018
1ad552e97c67 maskOrigin
Claus Gittinger <cg@exept.de>
parents: 2016
diff changeset
   609
maskOrigin:aPoint
1ad552e97c67 maskOrigin
Claus Gittinger <cg@exept.de>
parents: 2016
diff changeset
   610
    "set the origin of the mask-pattern"
1ad552e97c67 maskOrigin
Claus Gittinger <cg@exept.de>
parents: 2016
diff changeset
   611
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
   612
    |x y pO|
2018
1ad552e97c67 maskOrigin
Claus Gittinger <cg@exept.de>
parents: 2016
diff changeset
   613
1ad552e97c67 maskOrigin
Claus Gittinger <cg@exept.de>
parents: 2016
diff changeset
   614
    x := aPoint x.
1ad552e97c67 maskOrigin
Claus Gittinger <cg@exept.de>
parents: 2016
diff changeset
   615
    y := aPoint y.
1ad552e97c67 maskOrigin
Claus Gittinger <cg@exept.de>
parents: 2016
diff changeset
   616
1ad552e97c67 maskOrigin
Claus Gittinger <cg@exept.de>
parents: 2016
diff changeset
   617
    (maskOrigin isNil or:[
1ad552e97c67 maskOrigin
Claus Gittinger <cg@exept.de>
parents: 2016
diff changeset
   618
     ((x ~= maskOrigin x) or:[y ~= maskOrigin y]) ]) ifTrue:[
1ad552e97c67 maskOrigin
Claus Gittinger <cg@exept.de>
parents: 2016
diff changeset
   619
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
   620
        maskOrigin := aPoint.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
   621
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
   622
        transformation notNil ifTrue:[
6711
2b50385f7257 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6691
diff changeset
   623
            pO := transformation transformPoint:aPoint.
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
   624
            x:= pO x.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
   625
            y := pO y.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
   626
        ].
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
   627
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
   628
        gcId notNil ifTrue:[
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   629
            device setMaskOriginX:x rounded y:y rounded in:gcId
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
   630
        ]
2018
1ad552e97c67 maskOrigin
Claus Gittinger <cg@exept.de>
parents: 2016
diff changeset
   631
    ]
1ad552e97c67 maskOrigin
Claus Gittinger <cg@exept.de>
parents: 2016
diff changeset
   632
1ad552e97c67 maskOrigin
Claus Gittinger <cg@exept.de>
parents: 2016
diff changeset
   633
    "Created: / 26.1.1998 / 19:03:02 / cg"
1ad552e97c67 maskOrigin
Claus Gittinger <cg@exept.de>
parents: 2016
diff changeset
   634
!
1ad552e97c67 maskOrigin
Claus Gittinger <cg@exept.de>
parents: 2016
diff changeset
   635
2016
bef5fe2ec2ca checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2013
diff changeset
   636
maskOriginX:orgX y:orgY
bef5fe2ec2ca checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2013
diff changeset
   637
    "set the origin of the pattern"
bef5fe2ec2ca checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2013
diff changeset
   638
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
   639
    self maskOrigin:(orgX @ orgY)
2016
bef5fe2ec2ca checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2013
diff changeset
   640
!
bef5fe2ec2ca checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2013
diff changeset
   641
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   642
paint:aColor
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   643
    "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
   644
     or even an image."
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
    (aColor ~~ paint) ifTrue:[
1029
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
   647
	aColor notNil ifTrue:[
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
   648
	    paint := aColor.
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
   649
	    self setGCForPaint.
0b03a4f98dcd pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
   650
	]
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   651
    ]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   652
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   653
    "Modified: 16.5.1996 / 15:35:57 / cg"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   654
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   655
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   656
paint:fgColor on:bgColor
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   657
    "set the paint and background-paint color.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   658
     The bg-paint is used in opaque-draw operations"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   659
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   660
    |fgId bgId|
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   661
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   662
    ((fgColor ~~ paint) or:[bgColor ~~ bgPaint]) ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   663
	fgColor notNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   664
	    paint := fgColor
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   665
	].
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   666
	bgColor notNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   667
	    bgPaint := bgColor
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   668
	].
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   669
	gcId notNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   670
	    paint isColor ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   671
		paint := paint onDevice:device.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   672
	    ].
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   673
	    paint isColor ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   674
		fgId := paint colorId.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   675
		fgId notNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   676
		    mask notNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   677
			mask := nil.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   678
			device setBitmapMask:nil in:gcId
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   679
		    ].
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   680
		    bgPaint isColor ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   681
			bgPaint := bgPaint onDevice:device.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   682
		    ].
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   683
		    bgPaint isColor ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   684
			bgId := bgPaint colorId.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   685
			bgId notNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   686
			    "the common case, both are real colors"
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   687
			    (paint ~~ foreground) ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   688
				foreground := paint.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   689
				(bgPaint ~~ background) ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   690
				    background := bgPaint.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   691
				    device setForeground:fgId background:bgId in:gcId.
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
				device setForeground:fgId in:gcId.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   695
				^ self
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
			    (bgPaint ~~ background) ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   698
				background := bgPaint.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   699
				device setBackground:bgId 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
			"bgPaint is dithered, setup paint here, leave bgPaint
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   704
			 till next opaque draw comes around."
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   705
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   706
			(paint ~~ foreground) ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   707
			    foreground := paint.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   708
			    device setForeground:fgId in:gcId
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   709
			].
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   710
			^ self
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   711
		    ]
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   712
		]
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   713
	    ].
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   714
	    "either paint or bgPaint (or both) are dithered colors,
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   715
	     setup for paint, leave bg-problem till next opaque draw
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   716
	     comes around.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   717
	    "
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   718
	    self setGCForPaint.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   719
	]
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   720
    ]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   721
4797
91ee43d3acf5 changed #paint:on:
Claus Gittinger <cg@exept.de>
parents: 4781
diff changeset
   722
    "Modified: / 31-08-2007 / 10:56:49 / cg"
732
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
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   725
paint:fgColor on:bgColor function:f
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   726
    "set paint, background-paint and function"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   727
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   728
    self paint:fgColor on:bgColor.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   729
    self function:f
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   730
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   731
    "Modified: 16.5.1996 / 15:36:35 / cg"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   732
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   733
6266
1503c5e038d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   734
setClippingBounds:aRectangleOrNil
6501
ef63b2302cba class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6497
diff changeset
   735
    "set the clipping rectangle for drawing (in logical coordinates).
6266
1503c5e038d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   736
     Only set the variable, do not change the gc"
1503c5e038d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   737
1503c5e038d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   738
    clipRect := aRectangleOrNil
1503c5e038d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   739
!
1503c5e038d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   740
8372
8156eaa8cf64 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8315
diff changeset
   741
setDeviceLineWidth:aNumber
8156eaa8cf64 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8315
diff changeset
   742
    "set the untransformed line width.
8156eaa8cf64 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8315
diff changeset
   743
     This ignores any transformation and sets the lineWidth to the given number of
8156eaa8cf64 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8315
diff changeset
   744
     pixels."
8156eaa8cf64 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8315
diff changeset
   745
8156eaa8cf64 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8315
diff changeset
   746
    device setLineWidth:aNumber style:lineStyle cap:capStyle join:joinStyle in:gcId
8156eaa8cf64 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8315
diff changeset
   747
8156eaa8cf64 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8315
diff changeset
   748
    "Created: / 24-05-2018 / 08:03:25 / Claus Gittinger"
8156eaa8cf64 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8315
diff changeset
   749
!
8156eaa8cf64 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8315
diff changeset
   750
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   751
setDeviceMaskOriginX:x y:y
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   752
    "set the origin of the mask-pattern"
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   753
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   754
    gcId notNil ifTrue:[
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   755
        device setMaskOriginX:x rounded y:y rounded in:gcId
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   756
    ].
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   757
!
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   758
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   759
setGraphicsExposures:aBoolean
7651
ad5c7f222b7c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7647
diff changeset
   760
    "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
   761
     of graphics exposures"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   762
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   763
    gcId notNil ifTrue:[
7651
ad5c7f222b7c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7647
diff changeset
   764
        device setGraphicsExposures:aBoolean in:gcId
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   765
    ]
6266
1503c5e038d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   766
!
1503c5e038d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   767
1503c5e038d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   768
setPaint:fgColor on:bgColor
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   769
    "set the paint and background-paint color.
6266
1503c5e038d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   770
     The bg-paint is used in opaque-draw operations.
1503c5e038d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   771
     Only set the variables, but do not send it to the device,
1503c5e038d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   772
     Used on initialization."
1503c5e038d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   773
1503c5e038d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   774
    fgColor notNil ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   775
	foreground := paint := fgColor
6266
1503c5e038d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   776
    ].
1503c5e038d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   777
    bgColor notNil ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   778
	background := bgPaint := bgColor
6266
1503c5e038d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   779
    ].
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   780
! !
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   781
1092
1b6391f333de category rename
Claus Gittinger <cg@exept.de>
parents: 1085
diff changeset
   782
!DeviceGraphicsContext methodsFor:'accessing-internals'!
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   783
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   784
background
6266
1503c5e038d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   785
    <resource: #obsolete>
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   786
    "return the current background drawing color.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   787
     OBSOLETE: use #paint: / #backgroundPaint: / #paint:on:"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   788
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   789
    ^ background
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   790
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   791
    "Modified: 12.5.1996 / 22:28:09 / cg"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   792
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   793
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   794
background:aColor
6266
1503c5e038d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   795
    <resource: #obsolete>
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   796
    "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
   797
     OBSOLETE: this method will vanish; use #paint: / #backgroundPaint: / #paint:on:"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   798
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   799
    |bgId|
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   800
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   801
    (aColor ~~ background) ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   802
	aColor notNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   803
	    background := aColor.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   804
	    gcId notNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   805
		background := background onDevice:device.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   806
		bgId := background colorId.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   807
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   808
		"
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   809
		 mhmh the following is a kludge ....
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   810
		"
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   811
		bgId isNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   812
		    (background grayIntensity >= 50) ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   813
			bgId := device whitepixel
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   814
		    ] ifFalse:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   815
			bgId := device blackpixel
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   816
		    ]
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   817
		].
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   818
		device setBackground:bgId in:gcId
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   819
	    ]
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   820
	]
732
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
745
d4465098f2c0 gray vs. grey
Claus Gittinger <cg@exept.de>
parents: 735
diff changeset
   823
    "Modified: 28.5.1996 / 20:44:55 / cg"
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   824
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   825
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   826
foreground
6266
1503c5e038d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   827
    <resource: #obsolete>
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   828
    "return the current foreground drawing color.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   829
     OBSOLETE: use #paint: / #paint:on:"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   830
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   831
    ^ foreground
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   832
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   833
    "Modified: 12.5.1996 / 22:28:03 / cg"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   834
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   835
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   836
foreground:aColor
6266
1503c5e038d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   837
    <resource: #obsolete>
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   838
    "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
   839
     OBSOLETE: this method will vanish; use #paint: / #paint:on:"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   840
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   841
    |fgId|
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   842
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   843
    (aColor ~~ foreground) ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   844
	aColor notNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   845
	    foreground := aColor.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   846
	    gcId notNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   847
		(foreground class == SmallInteger) ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   848
		    fgId := foreground
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   849
		] ifFalse:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   850
		    foreground := foreground onDevice:device.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   851
		    fgId := foreground colorId.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   852
		].
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   853
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   854
		"mhmh the following is a kludge ...."
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   855
		fgId isNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   856
		    (foreground grayIntensity >= 50) ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   857
			fgId := device whitepixel
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   858
		    ] ifFalse:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   859
			fgId := device blackpixel
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   860
		    ]
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   861
		].
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   862
		device setForeground:fgId in:gcId.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   863
		paint := foreground
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   864
	    ]
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   865
	]
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   866
    ]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   867
745
d4465098f2c0 gray vs. grey
Claus Gittinger <cg@exept.de>
parents: 735
diff changeset
   868
    "Modified: 28.5.1996 / 20:45:02 / cg"
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   869
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   870
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   871
foreground:fgColor background:bgColor
6266
1503c5e038d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   872
    <resource: #obsolete>
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   873
    "set both internal foreground and internal background colors
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   874
     - these must be real colors.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   875
     OBSOLETE: this method will vanish; use #paint: / #paint:on:"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   876
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   877
    |fgPixel bgPixel|
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   878
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   879
    ((fgColor ~~ foreground) or:[bgColor ~~ background]) ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   880
	fgColor notNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   881
	    foreground := fgColor
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   882
	].
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   883
	bgColor notNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   884
	    background := bgColor
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   885
	].
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   886
	gcId notNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   887
	    foreground := foreground onDevice:device.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   888
	    background := background onDevice:device.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   889
	    fgPixel := foreground colorId.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   890
	    bgPixel := background colorId.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   891
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   892
	    "mhmh the following is a kludge ...."
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   893
	    fgPixel isNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   894
		(foreground grayIntensity >= 50) ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   895
		    fgPixel := device whitepixel
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   896
		] ifFalse:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   897
		    fgPixel := device blackpixel
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   898
		]
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   899
	    ].
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   900
	    bgPixel isNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   901
		(background grayIntensity >= 50) ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   902
		    bgPixel := device whitepixel
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   903
		] ifFalse:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   904
		    bgPixel := device blackpixel
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   905
		]
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   906
	    ].
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   907
	    device setForeground:fgPixel background:bgPixel in:gcId.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   908
	    paint := foreground
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   909
	]
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   910
    ]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   911
745
d4465098f2c0 gray vs. grey
Claus Gittinger <cg@exept.de>
parents: 735
diff changeset
   912
    "Modified: 28.5.1996 / 20:45:27 / cg"
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   913
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   914
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   915
foreground:aColor function:fun
6266
1503c5e038d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
   916
    <resource: #obsolete>
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   917
    "set the foreground color and function for drawing.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   918
     OBSOLETE: this method will vanish; use #paint: / #paint:on:"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   919
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   920
    |fgPixel|
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   921
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   922
    ((aColor ~~ foreground) or:[fun ~~ function]) ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   923
	foreground := aColor.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   924
	function := fun.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   925
	gcId notNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   926
	    foreground := foreground onDevice:device.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   927
	    fgPixel := foreground colorId.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   928
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   929
	    "mhmh the following is a kludge ...."
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   930
	    fgPixel isNil ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   931
		(foreground grayIntensity >= 50) ifTrue:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   932
		    fgPixel := device whitepixel
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   933
		] ifFalse:[
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   934
		    fgPixel := device blackpixel
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   935
		]
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   936
	    ].
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   937
	    device setForeground:fgPixel in:gcId.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   938
	    device setFunction:fun in:gcId.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   939
	    paint := foreground
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   940
	]
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   941
    ]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   942
745
d4465098f2c0 gray vs. grey
Claus Gittinger <cg@exept.de>
parents: 735
diff changeset
   943
    "Modified: 28.5.1996 / 20:45:09 / cg"
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   944
! !
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   945
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   946
!DeviceGraphicsContext methodsFor:'bit blitting'!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   947
2016
bef5fe2ec2ca checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2013
diff changeset
   948
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
   949
    "copy bits from a smalltalk byteArray.
bef5fe2ec2ca checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2013
diff changeset
   950
     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
   951
     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
   952
     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
   953
     method to whatever the device needs."
bef5fe2ec2ca checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2013
diff changeset
   954
bef5fe2ec2ca checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2013
diff changeset
   955
    device
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   956
	drawBits:aByteArray
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   957
	bitsPerPixel:bpp
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   958
	depth:depth
2016
bef5fe2ec2ca checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2013
diff changeset
   959
	padding:pad
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   960
	width:srcW height:srcH
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   961
	x:srcX y:srcY
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   962
	into:drawableId
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
   963
	x:dstX y:dstY
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
   964
	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
   965
	with:gcId.
2016
bef5fe2ec2ca checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2013
diff changeset
   966
!
bef5fe2ec2ca checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2013
diff changeset
   967
7456
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
   968
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
   969
    "copy from aDrawable into the receiver;
1480f8aae3bb explicit sync/async bitBlt.
Claus Gittinger <cg@exept.de>
parents: 1255
diff changeset
   970
     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
   971
     All coordinates are in device coordinates."
1291
1480f8aae3bb explicit sync/async bitBlt.
Claus Gittinger <cg@exept.de>
parents: 1255
diff changeset
   972
7456
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
   973
    |srcGCId srcDrawableId|
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   974
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   975
    gcId isNil ifTrue:[
7456
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
   976
        self initGC
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   977
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   978
7749
f4ad7601ae41 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 7746
diff changeset
   979
    srcGCId := aGC initGC.
7456
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
   980
    srcDrawableId := aGC drawableId.
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
   981
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
   982
    ((depth == 1) and:[device depth ~~ 1]) ifTrue:[
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
   983
        aGC isPixmap ifTrue:[
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
   984
            device
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
   985
                copyPlaneFromPixmapId:srcDrawableId
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
   986
                x:srcX
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
   987
                y:srcY
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
   988
                gc:srcGCId
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
   989
                to:drawableId
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
   990
                x:dstX
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
   991
                y:dstY
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
   992
                gc:gcId
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
   993
                width:w
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
   994
                height:h
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
   995
        ] ifFalse:[
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
   996
            device
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
   997
                copyPlaneFromId:srcDrawableId
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
   998
                x:srcX
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
   999
                y:srcY
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
  1000
                gc:srcGCId
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
  1001
                to:drawableId
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
  1002
                x:dstX
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
  1003
                y:dstY
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
  1004
                gc:gcId
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
  1005
                width:w
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
  1006
                height:h
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
  1007
        ]
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1008
    ] ifFalse:[
7456
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
  1009
        aGC isPixmap ifTrue:[
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
  1010
            device
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
  1011
                copyFromPixmapId:srcDrawableId
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
  1012
                x:srcX
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
  1013
                y:srcY
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
  1014
                gc:srcGCId
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
  1015
                to:drawableId
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
  1016
                x:dstX
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
  1017
                y:dstY
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
  1018
                gc:gcId
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
  1019
                width:w
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
  1020
                height:h
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
  1021
        ] ifFalse:[
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
  1022
            device
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
  1023
                copyFromId:srcDrawableId
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
  1024
                x:srcX
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
  1025
                y:srcY
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
  1026
                gc:srcGCId
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
  1027
                to:drawableId
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
  1028
                x:dstX
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
  1029
                y:dstY
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
  1030
                gc:gcId
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
  1031
                width:w
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
  1032
                height:h.
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
    ].
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1035
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1036
7456
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
  1037
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
  1038
    "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
  1039
     background, while 1's are drawn with foreground color.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1040
     The depth of aDrawable must (should) be 1.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1041
     The drawable must have been allocated on the same device.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1042
     All coordinates are in device coordinates."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1043
7456
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
  1044
    |srcGCId srcDrawableId|
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1045
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1046
    gcId isNil ifTrue:[
7456
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
  1047
        self initGC
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1048
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1049
7749
f4ad7601ae41 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 7746
diff changeset
  1050
    srcGCId := aGC initGC.
7456
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
  1051
    srcDrawableId := aGC drawableId.
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
  1052
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
  1053
    aGC isPixmap ifTrue:[
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
  1054
        device
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
  1055
            copyPlaneFromPixmapId:srcDrawableId
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
  1056
            x:srcX
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
  1057
            y:srcY
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
  1058
            gc:srcGCId
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
  1059
            to:drawableId
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
  1060
            x:dstX
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
  1061
            y:dstY
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
  1062
            gc:gcId
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
  1063
            width:w
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
  1064
            height:h
1249
5224bb7a97bf use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  1065
    ] ifFalse:[
7456
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
  1066
        device
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
  1067
            copyPlaneFromId:srcDrawableId
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
  1068
            x:srcX
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
  1069
            y:srcY
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
  1070
            gc:srcGCId
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
  1071
            to:drawableId
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
  1072
            x:dstX
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
  1073
            y:dstY
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
  1074
            gc:gcId
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
  1075
            width:w
ca68c27cda30 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7445
diff changeset
  1076
            height:h
1249
5224bb7a97bf use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  1077
    ]
5224bb7a97bf use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents: 1237
diff changeset
  1078
2271
46b68ae54cbc win32 needs source-gc to be initialized in a bitBlt.
Claus Gittinger <cg@exept.de>
parents: 2268
diff changeset
  1079
    "Modified: / 22.8.1998 / 15:15:52 / cg"
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1080
! !
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1081
8687
798853409109 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 8661
diff changeset
  1082
!DeviceGraphicsContext methodsFor:'copying-private'!
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
postCopy
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1085
    "this may not be enough to allow copying of views ..."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1086
7851
002470b149b2 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7799
diff changeset
  1087
    <modifier: #super> "must be called if redefined"
002470b149b2 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7799
diff changeset
  1088
002470b149b2 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7799
diff changeset
  1089
    "/ super postCopy.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1090
    device := drawableId := gcId := nil.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1091
    self recreate
7851
002470b149b2 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7799
diff changeset
  1092
002470b149b2 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7799
diff changeset
  1093
    "Modified: / 08-02-2017 / 01:07:46 / cg"
4403
3342601d3fed +postDeepCopy
Claus Gittinger <cg@exept.de>
parents: 4389
diff changeset
  1094
!
3342601d3fed +postDeepCopy
Claus Gittinger <cg@exept.de>
parents: 4389
diff changeset
  1095
3342601d3fed +postDeepCopy
Claus Gittinger <cg@exept.de>
parents: 4389
diff changeset
  1096
postDeepCopy
3342601d3fed +postDeepCopy
Claus Gittinger <cg@exept.de>
parents: 4389
diff changeset
  1097
    device := drawableId := gcId := nil.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1098
! !
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1099
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1100
!DeviceGraphicsContext methodsFor:'drawing'!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1101
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1102
displayArcX:x y:y width:w height:h from:startAngle angle:angle
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1103
    "draw an arc; apply transformation if nonNil"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1104
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1105
    |pX pY nW nH sA a pO pC|
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1106
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1107
    gcId isNil ifTrue:[
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1108
	self initGC
732
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
    transformation notNil ifTrue:[
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1111
	pO := transformation transformPoint:x@y.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1112
	pC := transformation transformPoint:(x+w-1)@(y+h-1).
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1113
	pX := pO x.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1114
	pY := pO y.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1115
	nW := pC x - pX + 1.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1116
	nH := pC y - pY + 1.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1117
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1118
	nW < 0 ifTrue:[
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1119
	      nW := nW abs.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1120
	      pX := pX - nW.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1121
	].
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1122
	nH < 0 ifTrue:[
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1123
	      nH := nH abs.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1124
	      pY := pY - nH.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1125
	].
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1126
    ] ifFalse:[
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1127
	pX := x.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1128
	pY := y.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1129
	nW := w.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1130
	nH := h.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1131
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1132
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1133
    pX := pX rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1134
    pY := pY rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1135
    nW := nW rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1136
    nH := nH rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1137
2268
1a774fc02c83 fixed non-float (i.e. fraction) args to fillArc/ displayArc
Claus Gittinger <cg@exept.de>
parents: 2259
diff changeset
  1138
    sA := startAngle.
1a774fc02c83 fixed non-float (i.e. fraction) args to fillArc/ displayArc
Claus Gittinger <cg@exept.de>
parents: 2259
diff changeset
  1139
    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
  1140
    a := angle.
1a774fc02c83 fixed non-float (i.e. fraction) args to fillArc/ displayArc
Claus Gittinger <cg@exept.de>
parents: 2259
diff changeset
  1141
    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
  1142
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1143
    device
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1144
	  displayArcX:pX
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1145
		    y:pY
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1146
		width:nW
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1147
	       height:nH
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1148
		 from:sA
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1149
		angle:a
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1150
		   in:drawableId
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1151
		 with:gcId
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1152
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1153
    "Created: 8.5.1996 / 08:31:30 / cg"
784
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
  1154
    "Modified: 4.6.1996 / 17:59:28 / cg"
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1155
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1156
8281
88f62a43293a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8174
diff changeset
  1157
displayForm:formOrImageToDraw x:x y:y
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1158
    "draw a form or image non opaque;
7882
8b2d2f3f247d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7851
diff changeset
  1159
     if it's a 1-plane bitmap, 1-bits are drawn in the
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1160
     current paint-color, leaving pixels with 0-bits unchanged
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1161
     (i.e. only 1-bits are drawn from the form).
7882
8b2d2f3f247d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7851
diff changeset
  1162
     If it's a deep form (i.e. a pixmap) the current paint
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1163
     settings are ignored and the form is drawn as-is.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1164
     Care must be taken, that the paint color is correctly allocated
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1165
     (by sending #on: to the color) before doing so.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1166
     Using functions other than #copy only makes sense if you are
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1167
     certain, that the colors are real colors (actually, only for
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1168
     noColor or allColor)."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1169
8281
88f62a43293a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8174
diff changeset
  1170
    |realFormOrImage pX pY w h nW nH pO pC|
88f62a43293a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8174
diff changeset
  1171
88f62a43293a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8174
diff changeset
  1172
    realFormOrImage := formOrImageToDraw.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1173
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1174
    transformation notNil ifTrue:[
7882
8b2d2f3f247d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7851
diff changeset
  1175
        pO := transformation transformPoint:x@y.
8b2d2f3f247d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7851
diff changeset
  1176
        pX := pO x.
8b2d2f3f247d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7851
diff changeset
  1177
        pY := pO y.
8b2d2f3f247d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7851
diff changeset
  1178
8b2d2f3f247d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7851
diff changeset
  1179
        transformation isNoScale ifFalse:[
8281
88f62a43293a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8174
diff changeset
  1180
            w := formOrImageToDraw width.
88f62a43293a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8174
diff changeset
  1181
            h := formOrImageToDraw height.
7882
8b2d2f3f247d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7851
diff changeset
  1182
            pC := transformation applyTo:(x+w-1)@(y+h-1).
8b2d2f3f247d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7851
diff changeset
  1183
            nW := pC x - pX + 1.
8b2d2f3f247d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7851
diff changeset
  1184
            nH := pC y - pY + 1.
8b2d2f3f247d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7851
diff changeset
  1185
            "/ nW := (transformation applyScaleX:w) rounded.
8b2d2f3f247d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7851
diff changeset
  1186
            "/ nH := (transformation applyScaleY:h) rounded.
8b2d2f3f247d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7851
diff changeset
  1187
8b2d2f3f247d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7851
diff changeset
  1188
            ((nW ~= w) or:[nH ~= h]) ifTrue:[
8b2d2f3f247d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7851
diff changeset
  1189
                "/
8b2d2f3f247d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7851
diff changeset
  1190
                "/ hard case - someone is drawing forms with scaling in effect
8b2d2f3f247d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7851
diff changeset
  1191
                "/ look if we have a scaled version in our pocket ...
8b2d2f3f247d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7851
diff changeset
  1192
                "/
8281
88f62a43293a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8174
diff changeset
  1193
                realFormOrImage := nil.
7882
8b2d2f3f247d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7851
diff changeset
  1194
                CachedScaledForms notNil ifTrue:[
8281
88f62a43293a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8174
diff changeset
  1195
                    (CachedScales at:formOrImageToDraw ifAbsent:nil) = transformation scale ifTrue:[
88f62a43293a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8174
diff changeset
  1196
                        realFormOrImage := CachedScaledForms at:formOrImageToDraw ifAbsent:nil.
7882
8b2d2f3f247d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7851
diff changeset
  1197
                    ]
8b2d2f3f247d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7851
diff changeset
  1198
                ].
8281
88f62a43293a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8174
diff changeset
  1199
                realFormOrImage isNil ifTrue:[
7882
8b2d2f3f247d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7851
diff changeset
  1200
                    "/
8b2d2f3f247d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7851
diff changeset
  1201
                    "/ nope - must do the work ...
8b2d2f3f247d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7851
diff changeset
  1202
                    "/
8281
88f62a43293a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8174
diff changeset
  1203
                    realFormOrImage := formOrImageToDraw magnifiedBy:(nW / w) @ (nH / h).
7882
8b2d2f3f247d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7851
diff changeset
  1204
                    CachedScaledForms isNil ifTrue:[
8b2d2f3f247d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7851
diff changeset
  1205
                        CachedScaledForms := WeakIdentityDictionary new.
8b2d2f3f247d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7851
diff changeset
  1206
                        CachedScales := WeakIdentityDictionary new.
8b2d2f3f247d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7851
diff changeset
  1207
                    ].
8281
88f62a43293a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8174
diff changeset
  1208
                    CachedScaledForms at:formOrImageToDraw put:realFormOrImage.
88f62a43293a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8174
diff changeset
  1209
                    CachedScales at:formOrImageToDraw put:transformation scale.
7882
8b2d2f3f247d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7851
diff changeset
  1210
                ]
8b2d2f3f247d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7851
diff changeset
  1211
            ]
8b2d2f3f247d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7851
diff changeset
  1212
        ]
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1213
    ] ifFalse:[
7882
8b2d2f3f247d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7851
diff changeset
  1214
        pX := x.
8b2d2f3f247d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7851
diff changeset
  1215
        pY := y.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1216
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1217
8281
88f62a43293a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8174
diff changeset
  1218
    self displayDeviceForm:realFormOrImage x:pX y:pY
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1219
7882
8b2d2f3f247d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7851
diff changeset
  1220
    "Modified: / 12-04-1997 / 12:47:29 / cg"
8b2d2f3f247d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7851
diff changeset
  1221
    "Modified (comment): / 13-02-2017 / 20:00:13 / cg"
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1222
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1223
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1224
displayLineFrom:p0 to:p1
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1225
    "draw a line (with current paint-color); apply transformation if nonNil"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1226
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1227
    |pX0 pY0 pX1 pY1 easy fgId bgId tp0 tp1|
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1228
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1229
    gcId isNil ifTrue:[
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1230
	self initGC
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1231
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1232
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1233
    lineStyle == #doubleDashed ifTrue:[
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1234
	"
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1235
	 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
  1236
	"
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1237
	easy := true.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1238
	paint isColor ifFalse:[
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1239
	    easy := false
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1240
	] ifTrue:[
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1241
	    fgId := paint colorId.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1242
	    fgId isNil ifTrue:[
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1243
		easy := false
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1244
	    ]
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1245
	].
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1246
	bgPaint isColor ifFalse:[
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1247
	    easy := false
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1248
	] ifTrue:[
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1249
	    bgId := bgPaint colorId.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1250
	    bgId isNil ifTrue:[
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1251
		easy := false
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1252
	    ]
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1253
	].
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1254
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1255
	easy ifTrue:[
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1256
	    ((foreground ~~ paint) or:[background ~~ bgPaint]) ifTrue:[
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1257
		device setForeground:fgId background:bgId in:gcId.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1258
		foreground := paint.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1259
		background := bgPaint.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1260
	    ].
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1261
	] ifFalse:[
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1262
	    'DeviceGraphicsContext [warning]: cannot draw dashes with dithered colors' errorPrintCR
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1263
	].
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1264
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1265
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1266
    transformation notNil ifTrue:[
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1267
	tp0 := transformation transformPoint:p0.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1268
	tp1 := transformation transformPoint:p1.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1269
	pX0 := tp0 x.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1270
	pY0 := tp0 y.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1271
	pX1 := tp1 x.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1272
	pY1 := tp1 y.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1273
    ] ifFalse:[
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1274
	pX0 := p0 x.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1275
	pY0 := p0 y.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1276
	pX1 := p1 x.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1277
	pY1 := p1 y
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1278
    ].
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1279
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1280
    pX0 := pX0 rounded.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1281
    pY0 := pY0 rounded.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1282
    pX1 := pX1 rounded.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1283
    pY1 := pY1 rounded.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1284
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1285
    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
  1286
!
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1287
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1288
displayLineFromX:x0 y:y0 toX:x1 y:y1
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1289
    "draw a line (with current paint-color); apply transformation if nonNil"
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1290
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1291
    |pX0 pY0 pX1 pY1 easy fgId bgId p0 p1|
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1292
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1293
    gcId isNil ifTrue:[
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1294
	self initGC
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1295
    ].
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1296
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1297
    lineStyle == #doubleDashed ifTrue:[
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1298
	"
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1299
	 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
  1300
	"
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1301
	easy := true.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1302
	paint isColor ifFalse:[
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1303
	    easy := false
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1304
	] ifTrue:[
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1305
	    fgId := paint colorId.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1306
	    fgId isNil ifTrue:[
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1307
		easy := false
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1308
	    ]
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1309
	].
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1310
	bgPaint isColor ifFalse:[
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1311
	    easy := false
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1312
	] ifTrue:[
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1313
	    bgId := bgPaint colorId.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1314
	    bgId isNil ifTrue:[
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1315
		easy := false
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1316
	    ]
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1317
	].
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1318
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1319
	easy ifTrue:[
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1320
	    ((foreground ~~ paint) or:[background ~~ bgPaint]) ifTrue:[
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1321
		device setForeground:fgId background:bgId in:gcId.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1322
		foreground := paint.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1323
		background := bgPaint.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1324
	    ].
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1325
	] ifFalse:[
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1326
	    'DeviceGraphicsContext [warning]: cannot draw dashes with dithered colors' errorPrintCR
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1327
	].
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1328
    ].
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1329
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1330
    transformation notNil ifTrue:[
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1331
	p0 := transformation transformPoint:x0@y0.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1332
	p1 := transformation transformPoint:x1@y1.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1333
	pX0 := p0 x.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1334
	pY0 := p0 y.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1335
	pX1 := p1 x.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1336
	pY1 := p1 y.
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1337
    ] ifFalse:[
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1338
	pX0 := x0.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1339
	pY0 := y0.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1340
	pX1 := x1.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1341
	pY1 := y1
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
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1344
    pX0 := pX0 rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1345
    pY0 := pY0 rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1346
    pX1 := pX1 rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1347
    pY1 := pY1 rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1348
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1349
    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
  1350
1177
e89408c15bb5 newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 1138
diff changeset
  1351
    "Modified: 10.1.1997 / 17:46:32 / cg"
732
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
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1354
displayOpaqueForm:formToDraw x:x y:y
8154
065b15ce117a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8143
diff changeset
  1355
    "draw a form or image opaque.
065b15ce117a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8143
diff changeset
  1356
     Somewhat backward compatible hacky:
065b15ce117a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8143
diff changeset
  1357
     
065b15ce117a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8143
diff changeset
  1358
     if it's a 1-plane form, 
065b15ce117a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8143
diff changeset
  1359
        1-bits are drawn in the current paint-color and 
065b15ce117a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8143
diff changeset
  1360
        0-bits in the bgPaint color.
065b15ce117a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8143
diff changeset
  1361
     
065b15ce117a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8143
diff changeset
  1362
     If it's a deep form (i.e. a pixmap) or an image,
065b15ce117a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8143
diff changeset
  1363
     the current paint/bgPaint settings are ignored and the image is drawn as-is.
065b15ce117a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8143
diff changeset
  1364
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1365
     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
  1366
     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
  1367
     (by sending #on: to the colors) before doing so.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1368
     If there is a transformation, the image is scaled as appropiate."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1369
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1370
    |w h realForm pX pY nW nH pO pC|
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1371
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1372
    bgPaint isNil ifTrue:[
7882
8b2d2f3f247d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7851
diff changeset
  1373
        "/
8b2d2f3f247d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7851
diff changeset
  1374
        "/ actually not an opaque draw
8b2d2f3f247d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7851
diff changeset
  1375
        "/
8b2d2f3f247d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7851
diff changeset
  1376
        self displayForm:formToDraw x:x y:y.
8b2d2f3f247d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7851
diff changeset
  1377
        ^ self
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1378
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1379
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1380
    realForm := formToDraw.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1381
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1382
    transformation notNil ifTrue:[
7882
8b2d2f3f247d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7851
diff changeset
  1383
        pO := transformation transformPoint:x@y.
8b2d2f3f247d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7851
diff changeset
  1384
        pX := pO x.
8b2d2f3f247d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7851
diff changeset
  1385
        pY := pO y.
8b2d2f3f247d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7851
diff changeset
  1386
        "/ pX := transformation applyToX:x.
8b2d2f3f247d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7851
diff changeset
  1387
        "/ pY := transformation applyToY:y.
8b2d2f3f247d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7851
diff changeset
  1388
8b2d2f3f247d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7851
diff changeset
  1389
        transformation isNoScale ifFalse:[
8b2d2f3f247d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7851
diff changeset
  1390
            w := formToDraw width.
8b2d2f3f247d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7851
diff changeset
  1391
            h := formToDraw height.
8b2d2f3f247d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7851
diff changeset
  1392
            pC := transformation applyTo:(x+w-1)@(y+h-1).
8b2d2f3f247d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7851
diff changeset
  1393
            nW := pX - x + 1.
8b2d2f3f247d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7851
diff changeset
  1394
            nH := pY - y + 1.
8b2d2f3f247d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7851
diff changeset
  1395
            "/ nW := (transformation applyScaleX:w) rounded.
8b2d2f3f247d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7851
diff changeset
  1396
            "/ nH := (transformation applyScaleY:h) rounded.
8b2d2f3f247d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7851
diff changeset
  1397
8b2d2f3f247d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7851
diff changeset
  1398
            ((nW ~= w) or:[nH ~= h]) ifTrue:[
8b2d2f3f247d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7851
diff changeset
  1399
                "/
8b2d2f3f247d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7851
diff changeset
  1400
                "/ hard case - someone is drawing forms with scaling in effect
8b2d2f3f247d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7851
diff changeset
  1401
                "/ look if we have a scaled version in our pocket ...
8b2d2f3f247d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7851
diff changeset
  1402
                "/
8b2d2f3f247d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7851
diff changeset
  1403
                realForm := nil.
8b2d2f3f247d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7851
diff changeset
  1404
                CachedScaledForms notNil ifTrue:[
8b2d2f3f247d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7851
diff changeset
  1405
                    (CachedScales at:formToDraw ifAbsent:nil) = transformation scale ifTrue:[
8b2d2f3f247d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7851
diff changeset
  1406
                        realForm := CachedScaledForms at:formToDraw ifAbsent:nil.
8b2d2f3f247d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7851
diff changeset
  1407
                    ]
8b2d2f3f247d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7851
diff changeset
  1408
                ].
8b2d2f3f247d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7851
diff changeset
  1409
                realForm isNil ifTrue:[
8b2d2f3f247d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7851
diff changeset
  1410
                    "/
8b2d2f3f247d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7851
diff changeset
  1411
                    "/ nope - must do the work ...
8b2d2f3f247d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7851
diff changeset
  1412
                    "/
8b2d2f3f247d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7851
diff changeset
  1413
                    realForm := formToDraw magnifiedBy:(nW / w) @ (nH / h).
8b2d2f3f247d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7851
diff changeset
  1414
                    CachedScaledForms isNil ifTrue:[
8b2d2f3f247d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7851
diff changeset
  1415
                        CachedScaledForms := WeakIdentityDictionary new.
8b2d2f3f247d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7851
diff changeset
  1416
                        CachedScales := WeakIdentityDictionary new.
8b2d2f3f247d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7851
diff changeset
  1417
                    ].
8b2d2f3f247d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7851
diff changeset
  1418
                    CachedScaledForms at:formToDraw put:realForm.
8b2d2f3f247d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7851
diff changeset
  1419
                    CachedScales at:formToDraw put:transformation scale.
8b2d2f3f247d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7851
diff changeset
  1420
                ]
8b2d2f3f247d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7851
diff changeset
  1421
            ]
8b2d2f3f247d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7851
diff changeset
  1422
        ]
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1423
    ] ifFalse:[
7882
8b2d2f3f247d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7851
diff changeset
  1424
        pX := x.
8b2d2f3f247d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7851
diff changeset
  1425
        pY := y.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1426
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1427
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1428
    self displayDeviceOpaqueForm:realForm x:pX y:pY
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1429
7882
8b2d2f3f247d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7851
diff changeset
  1430
    "Modified: / 12-04-1997 / 12:49:02 / cg"
8154
065b15ce117a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8143
diff changeset
  1431
    "Modified (comment): / 31-08-2017 / 19:28:22 / cg"
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
displayOpaqueString:aString from:index1 to:index2 x:x y:y
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1435
    "draw a substring at the coordinate x/y - draw foreground pixels in
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1436
     paint-color and background pixels in bgPaint-color.
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1437
     If the transformation involves scaling,
7345
8eea38c33a0b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7301
diff changeset
  1438
     the font's point-size is scaled as appropriate.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1439
     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
  1440
     the case where paint and/or bgPaint are dithered colors"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1441
5360
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1442
    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
  1443
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1444
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1445
displayOpaqueString:aString x:x y:y
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1446
    "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
  1447
     background pixels in bgPaint color. If the transformation involves scaling,
7345
8eea38c33a0b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7301
diff changeset
  1448
     the font's point-size is scaled as appropriate.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1449
     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
  1450
     the case where paint and/or bgPaint are dithered colors or images."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1451
7064
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  1452
    aString isPlainString ifFalse:[
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1453
	"
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1454
	 hook for non-strings (i.e. attributed text)
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1455
	 that 'thing' should know how to display itself ...
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1456
	"
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1457
	aString displayOpaqueOn:self x:x y:y.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1458
	^ self
732
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
5360
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1461
    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
  1462
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1463
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1464
displayPointX:x y:y
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1465
    "draw a point (with current paint-color); apply transformation if nonNil"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1466
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1467
    |pX pY pO|
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1468
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1469
    gcId isNil ifTrue:[
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1470
	self initGC
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1471
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1472
    transformation notNil ifTrue:[
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1473
	pO := transformation transformPoint:x@y.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1474
	pX := pO x.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1475
	pY := pO y.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1476
    ] ifFalse:[
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1477
	pX := x.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1478
	pY := y
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1479
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1480
    pX := pX rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1481
    pY := pY rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1482
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1483
    device displayPointX:pX y:pY in:drawableId with:gcId
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1484
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1485
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1486
displayPolygon:aPolygon
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1487
    "draw (the outline of) a polygon (with current paint-color).
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1488
     Apply transformation if nonNil"
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
    |newPolygon|
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1491
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1492
    gcId isNil ifTrue:[
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1493
	self initGC
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1494
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1495
    transformation notNil ifTrue:[
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1496
	newPolygon := aPolygon collect:[:point | transformation transformPoint:point].
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1497
    ] ifFalse:[
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1498
	newPolygon := aPolygon
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1499
    ].
6645
6066dcf16c20 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6626
diff changeset
  1500
    (newPolygon contains:[:p |
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1501
	(p isPoint not
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1502
	or:[(p x class ~~ SmallInteger)
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1503
	or:[(p y class ~~ SmallInteger)]])
6645
6066dcf16c20 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6626
diff changeset
  1504
     ]) ifTrue:[
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1505
	newPolygon := newPolygon collect:[:p | p asPoint rounded]
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1506
    ].
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1507
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1508
    device displayPolygon:newPolygon in:drawableId with:gcId
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1509
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1510
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1511
displayRectangleX:x y:y width:w height:h
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1512
    "draw a rectangle (with current paint-color).
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1513
     If transformation is nonNil, drawing is in logical coordinates."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1514
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1515
    |pX pY nW nH easy fgId bgId pO pC|
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1516
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1517
    gcId isNil ifTrue:[
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1518
	self initGC
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1519
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1520
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1521
    lineStyle == #doubleDashed ifTrue:[
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1522
	"
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1523
	 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
  1524
	"
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1525
	easy := true.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1526
	paint isColor ifFalse:[
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1527
	    easy := false
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1528
	] ifTrue:[
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1529
	    fgId := paint colorId.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1530
	    fgId isNil ifTrue:[
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1531
		easy := false
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1532
	    ]
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1533
	].
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1534
	bgPaint isColor ifFalse:[
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1535
	    easy := false
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1536
	] ifTrue:[
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1537
	    bgId := bgPaint colorId.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1538
	    bgId isNil ifTrue:[
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1539
		easy := false
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1540
	    ]
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1541
	].
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1542
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1543
	easy ifTrue:[
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1544
	    ((foreground ~~ paint) or:[background ~~ bgPaint]) ifTrue:[
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1545
		device setForeground:fgId background:bgId in:gcId.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1546
		foreground := paint.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1547
		background := bgPaint.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1548
	    ].
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1549
	] ifFalse:[
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1550
	    'DeviceGraphicsContext [warning]: cannot draw dashes with dithered colors' errorPrintCR
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1551
	].
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1552
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1553
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1554
    transformation notNil ifTrue:[
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1555
	pO := transformation transformPoint:x@y.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1556
	pC := transformation transformPoint:(x+w-1)@(y+h-1).
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1557
	pX := pO x.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1558
	pY := pO y.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1559
	nW := pC x - pX + 1.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1560
	nH := pC y - pY + 1.
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1561
"/        pX := transformation applyToX:x.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1562
"/        pY := transformation applyToY:y.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1563
"/        nW := transformation applyScaleX:w.
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1564
"/        nH := transformation applyScaleY:h.
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1565
	nW < 0 ifTrue:[
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1566
	      nW := nW abs.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1567
	      pX := pX - nW.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1568
	].
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1569
	nH < 0 ifTrue:[
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1570
	      nH := nH abs.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1571
	      pY := pY - nH.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1572
	].
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1573
    ] ifFalse:[
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1574
	pX := x.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1575
	pY := y.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1576
	nW := w.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1577
	nH := h
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1578
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1579
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1580
    pX := pX rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1581
    pY := pY rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1582
    nW := nW rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1583
    nH := nH rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1584
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1585
    "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
  1586
     this one seems mathematically incorrect but allows to draw and fill
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1587
     a rectangle using the same extents.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1588
     I'm not certain if is the right thing to do ...
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1589
    "
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1590
    device displayRectangleX:pX
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1591
			   y:pY
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1592
		       width:(nW - 1)
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1593
		      height:(nH - 1)
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1594
			  in:drawableId with:gcId
1177
e89408c15bb5 newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 1138
diff changeset
  1595
e89408c15bb5 newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 1138
diff changeset
  1596
    "Modified: 10.1.1997 / 17:46:41 / cg"
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1597
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1598
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1599
displayString:aString from:index1 to:index2 x:x y:y
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1600
    "draw a substring at the coordinate x/y -
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1601
     draw foreground-pixels only (in current paint-color),
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1602
     leaving background as-is. If the transformation involves scaling,
7345
8eea38c33a0b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7301
diff changeset
  1603
     the font's point-size is scaled as appropriate."
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1604
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1605
    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
  1606
!
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1607
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1608
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
  1609
    "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
  1610
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1611
    ^ 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
  1612
!
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1613
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1614
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
  1615
    "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
  1616
     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
  1617
     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
  1618
     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
  1619
     the case where paint and/or bgPaint are dithered colors.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1620
     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
  1621
7443
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  1622
    |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
  1623
     nSkipLeft nChars wString wSkipLeft index2Guess|
5360
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1624
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1625
    index1 := index1Arg.
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1626
    index2 := index2Arg.
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1627
    opaque := opaqueArg.
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1628
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1629
    "
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1630
     if backgroundPaint color is nil, we assume
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1631
     this is a non-opaque draw
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1632
    "
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1633
    bgPaint isNil ifTrue:[
6626
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1634
        opaque := false.
5360
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1635
    ].
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1636
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1637
    gcId isNil ifTrue:[
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1638
        self initGC
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1639
    ].
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1640
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1641
    aStringArg isPlainString ifFalse:[
6626
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1642
        "
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1643
         hook for non-strings (i.e. attributed text)
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1644
         that 'thing' should know how to display itself ...
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1645
        "
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1646
        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
  1647
        ^ self
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1648
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1649
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1650
    "/ transcode the string into the fonts encoding...
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1651
    aString := aStringArg.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1652
    fontsEncoding := font encoding.
4056
67c4686afbc6 characterEncoding stuff
Claus Gittinger <cg@exept.de>
parents: 4031
diff changeset
  1653
    (characterEncoding ~~ fontsEncoding) ifTrue:[
6626
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1654
        [
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1655
            aString := CharacterEncoder encodeString:aString from:characterEncoding into:fontsEncoding.
6626
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1656
        ] on:CharacterEncoderError do:[:ex|
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1657
            "substitute a default value for codes that cannot be represented
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1658
             in the new character set"
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1659
            ex proceedWith:ex defaultValue.
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1660
        ].
4026
882de378f763 no longer as string for its encoding;
Claus Gittinger <cg@exept.de>
parents: 3943
diff changeset
  1661
    ].
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1662
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1663
    fontUsed := font.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1664
    transformation notNil ifTrue:[
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1665
        pX := transformation applyToX:x.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1666
        pY := transformation applyToY:y.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1667
        transformation noScale ifFalse:[
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1668
            sz := font size.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1669
            sz notNil ifTrue:[
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1670
                fontUsed := font asSize:(transformation applyScaleY:sz) rounded.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1671
            ]
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1672
        ]
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1673
    ] ifFalse:[
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1674
        pX := x.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1675
        pY := y.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1676
    ].
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1677
7063
2be1214a5dcf #BUGFIX
Stefan Vogel <sv@exept.de>
parents: 7062
diff changeset
  1678
    fontUsed isAlienFont ifTrue:[
2be1214a5dcf #BUGFIX
Stefan Vogel <sv@exept.de>
parents: 7062
diff changeset
  1679
        "
2be1214a5dcf #BUGFIX
Stefan Vogel <sv@exept.de>
parents: 7062
diff changeset
  1680
         hook for alien fonts
2be1214a5dcf #BUGFIX
Stefan Vogel <sv@exept.de>
parents: 7062
diff changeset
  1681
         that 'font' should know how to display the string...
2be1214a5dcf #BUGFIX
Stefan Vogel <sv@exept.de>
parents: 7062
diff changeset
  1682
        "
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1683
        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
  1684
        ^ self
2be1214a5dcf #BUGFIX
Stefan Vogel <sv@exept.de>
parents: 7062
diff changeset
  1685
    ].
2be1214a5dcf #BUGFIX
Stefan Vogel <sv@exept.de>
parents: 7062
diff changeset
  1686
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1687
    pX := pX rounded.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1688
    pY := pY rounded.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1689
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1690
    fontUsed := fontUsed onDevice:device.
7443
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  1691
    deviceFont ~~ fontUsed ifTrue:[
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  1692
        (fontUsed installInDeviceForGCId:gcId) isNil ifTrue:[
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  1693
            "error - no such font"
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1694
            ^ self.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1695
        ].
7443
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  1696
        deviceFont := fontUsed.
7064
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  1697
    ].
5360
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1698
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1699
    "
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1700
     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
  1701
    "
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1702
    paint isColor ifTrue:[
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1703
        easy := true.
6626
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1704
        fgId := paint colorId.
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1705
        fgId isNil ifTrue:[
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1706
            easy := false
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1707
        ]
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1708
    ] ifFalse:[
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1709
        easy := false
5360
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1710
    ].
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1711
    opaque ifTrue:[
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1712
        bgPaint isColor ifTrue:[
6626
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1713
            bgId := bgPaint colorId.
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1714
            bgId isNil ifTrue:[
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1715
                easy := false
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1716
            ]
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1717
        ] ifFalse:[
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1718
            easy := false
6626
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1719
        ].
5360
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1720
    ].
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1721
7064
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  1722
    pX := pX rounded.
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  1723
    pY := pY rounded.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1724
5360
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1725
    "/ 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
  1726
    "/ 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
  1727
    "/ which are drawn longer than 32k pixels.
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1728
    nChars := 500.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1729
    (maxWidth notNil and:[(index2 - index1) > nChars]) ifTrue:[
6626
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1730
        nSkipLeft := wSkipLeft := 0.
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1731
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1732
        "/ if the draw starts to the left of the window start,
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1733
        "/ skip some characters at the beginning...
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1734
        pX < 0 ifTrue:[
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1735
"/ ('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
  1736
            nSkipLeft := (pX negated // font width) min:index2.                         "/ estimate
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1737
            wSkipLeft := fontUsed widthOf:aString from:index1 to:index1+nSkipLeft-1.    "/ actual number of pixels
8283
f0ea83eed994 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 8281
diff changeset
  1738
            [ ((pX+wSkipLeft) > 0) and:[nSkipLeft > 0]] whileTrue:[                     "/ too many
f0ea83eed994 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 8281
diff changeset
  1739
                nSkipLeft := (nSkipLeft * 0.9) truncated.                               "/ truncate, to avoid endless loop (4 * 0.9) rounded = 4
6626
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1740
                wSkipLeft := fontUsed widthOf:aString from:index1 to:index1+nSkipLeft-1.
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1741
            ].
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1742
            index1 := index1 + nSkipLeft.
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1743
            pX := pX + wSkipLeft.
5360
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1744
"/ ('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
  1745
        ].
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1746
5360
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1747
"/ ('n=%d w=%d' printfWith:nChars with:wString) printCR.
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1748
        [
6626
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1749
            index2Guess := (index1+nChars-1) min:index2.
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1750
            wString := fontUsed widthOf:aString from:index1 to:index2Guess.
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1751
            ((pX+wString) < maxWidth) and:[ index2Guess < index2]
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1752
        ] whileTrue:[  "/ not enough...
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1753
            nChars := (nChars * 1.1) rounded.
6626
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1754
        ].
5360
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1755
"/ ('n=%d w=%d' printfWith:nChars with:wString) printCR.
6626
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1756
        index2 := index2Guess.
5360
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1757
    ].
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1758
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1759
    easy ifTrue:[
6626
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1760
        opaque ifTrue:[
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1761
            device setForeground:fgId background:bgId in:gcId.
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1762
            background := bgPaint.
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1763
        ] ifFalse:[
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1764
            device setForeground:fgId in:gcId.
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1765
        ].
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1766
        foreground := paint.
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1767
        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
  1768
        ^ self
5360
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1769
    ].
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1770
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1771
    "/
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1772
    "/ 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
  1773
    "/ but dithered or a pattern
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1774
    "/
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1775
    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
  1776
    h := fontUsed height.
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1777
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1778
    (fgId notNil and:[function == #copy]) ifTrue:[
6626
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1779
        "
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1780
         only bg is dithered or a pattern; fill with bg first ...
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1781
        "
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1782
        savedPaint := paint.
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1783
        self paint:bgPaint.
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1784
        self fillDeviceRectangleX:pX y:(pY - fontUsed ascent) width:w height:h.
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1785
        self paint:savedPaint.
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1786
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1787
        "
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1788
         then draw using fgPaint (which is a real color)
4afe1d3883b4 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  1789
        "
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1790
        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
  1791
        ^ self
5360
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1792
    ].
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1793
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1794
    "/ the very hard case (fg-dither)
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  1795
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1796
    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
  1797
5742
3edcdffa74ec changed: #displayString:from:to:x:y:opaque:
Stefan Vogel <sv@exept.de>
parents: 5406
diff changeset
  1798
    "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
  1799
    "Modified: / 14-04-2011 / 11:11:00 / Stefan Vogel <sv@exept.de>"
8283
f0ea83eed994 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 8281
diff changeset
  1800
    "Modified (comment): / 31-01-2018 / 22:26:36 / stefan"
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1801
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1802
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1803
displayString:aString x:x y:y
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1804
    "draw a string at the coordinate x/y -
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1805
     draw foreground-pixels only (in current paint-color),
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1806
     leaving background as-is. If the transformation involves scaling,
7345
8eea38c33a0b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7301
diff changeset
  1807
     the font's point-size is scaled as appropriate."
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1808
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1809
    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
  1810
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1811
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1812
displayUnscaledForm:formToDraw x:x y:y
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1813
    "draw a form or image non opaque and unscaled;
7882
8b2d2f3f247d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7851
diff changeset
  1814
     if it's a 1-plane bitmap, 1-bits are drawn in the
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1815
     current paint-color, leaving pixels with 0-bits unchanged
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1816
     (i.e. only 1-bits are drawn from the form).
7882
8b2d2f3f247d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7851
diff changeset
  1817
     If it's a deep form (i.e. a pixmap) the current paint
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1818
     settings are ignored and the form is drawn as-is.
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1819
     Care must be taken, that the paint color is correctly allocated
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1820
     (by sending #on: to the color) before doing so.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1821
     Using functions other than #copy only makes sense if you are
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1822
     certain, that the colors are real colors (actually, only for
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1823
     noColor or allColor).
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1824
     The origins coordinate is transformed, but the image itself is unscaled."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1825
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1826
    |pX pY pO|
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1827
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1828
    transformation notNil ifTrue:[
7882
8b2d2f3f247d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7851
diff changeset
  1829
        pO := transformation transformPoint:(x@y).
8b2d2f3f247d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7851
diff changeset
  1830
        pX := pO x.
8b2d2f3f247d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7851
diff changeset
  1831
        pY := pO y.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1832
    ] ifFalse:[
7882
8b2d2f3f247d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7851
diff changeset
  1833
        pX := x.
8b2d2f3f247d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7851
diff changeset
  1834
        pY := y.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1835
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1836
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1837
    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
  1838
7882
8b2d2f3f247d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7851
diff changeset
  1839
    "Modified: / 12-04-1997 / 12:48:04 / cg"
8b2d2f3f247d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7851
diff changeset
  1840
    "Modified (comment): / 13-02-2017 / 20:00:22 / cg"
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1841
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1842
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1843
displayUnscaledOpaqueForm:formToDraw x:x y:y
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1844
    "draw a form or image opaque and unscaled;
7882
8b2d2f3f247d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7851
diff changeset
  1845
     if it's a 1-plane bitmap, 1-bits are drawn in the
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1846
     current paint-color, 0 bits in background color.
7882
8b2d2f3f247d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7851
diff changeset
  1847
     If it's a deep form (i.e. a pixmap) the current paint
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1848
     settings are ignored and the form is drawn as-is (opaque).
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1849
     The origins coordinate is transformed, but the image itself is unscaled."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1850
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1851
    |pX pY pO|
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1852
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1853
    transformation notNil ifTrue:[
7882
8b2d2f3f247d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7851
diff changeset
  1854
        pO := transformation transformPoint:(x@y).
8b2d2f3f247d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7851
diff changeset
  1855
        pX := pO x.
8b2d2f3f247d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7851
diff changeset
  1856
        pY := pO y.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1857
    ] ifFalse:[
7882
8b2d2f3f247d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7851
diff changeset
  1858
        pX := x.
8b2d2f3f247d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7851
diff changeset
  1859
        pY := y.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1860
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1861
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1862
    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
  1863
7882
8b2d2f3f247d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7851
diff changeset
  1864
    "Modified: / 12-04-1997 / 12:49:21 / cg"
8b2d2f3f247d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7851
diff changeset
  1865
    "Modified (comment): / 13-02-2017 / 20:00:28 / cg"
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1866
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1867
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1868
displayUnscaledOpaqueString:aString from:index1 to:index2 x:x y:y
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1869
    "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
  1870
     Draw foreground pixels in paint-color, background pixels in bgPaint color."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1871
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1872
    |pX pY pO|
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1873
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1874
    transformation notNil ifTrue:[
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1875
	pO := transformation transformPoint:(x@y).
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1876
	pX := pO x.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1877
	pY := pO y.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1878
    ] ifFalse:[
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1879
	pX := x.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1880
	pY := y.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1881
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1882
    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
  1883
!
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
displayUnscaledOpaqueString:aString x:x y:y
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1886
    "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
  1887
     Draw foreground pixels in paint-color, background pixels in bgPaint color."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1888
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1889
    |pX pY pO|
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1890
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1891
    transformation notNil ifTrue:[
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1892
	pO := transformation transformPoint:(x@y).
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1893
	pX := pO x.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1894
	pY := pO y.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1895
    ] ifFalse:[
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1896
	pX := x.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1897
	pY := y.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1898
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1899
    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
  1900
!
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
displayUnscaledString:aString from:index1 to:index2 x:x y:y
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1903
    "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
  1904
     draw foreground-pixels only (in current paint-color), leaving background as-is."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1905
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1906
    |pX pY pO|
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1907
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1908
    transformation notNil ifTrue:[
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1909
	pO := transformation transformPoint:(x@y).
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1910
	pX := pO x.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1911
	pY := pO y.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1912
    ] ifFalse:[
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1913
	pX := x.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1914
	pY := y.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1915
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1916
    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
  1917
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1918
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1919
displayUnscaledString:aString x:x y:y
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1920
    "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
  1921
     draw foreground-pixels only (in current paint-color), leaving background as-is."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1922
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  1923
    |pX pY pO|
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1924
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1925
    transformation notNil ifTrue:[
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1926
	pO := transformation transformPoint:(x@y).
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1927
	pX := pO x.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1928
	pY := pO y.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1929
    ] ifFalse:[
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1930
	pX := x.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  1931
	pY := y.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1932
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1933
    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
  1934
! !
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1935
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1936
!DeviceGraphicsContext methodsFor:'drawing in device coordinates'!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1937
8005
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  1938
displayDeviceForm:aFormOrImage x:x y:y
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1939
    "draw a form or image non opaque (i.e. only foreground color is drawn);
7882
8b2d2f3f247d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7851
diff changeset
  1940
     If it's a 1-plane bitmap, 1-bits are drawn in the
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1941
     current paint-color, leaving pixels with 0-bits unchanged
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1942
     (i.e. only 1-bits are drawn from the form).
8005
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  1943
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  1944
     If it's a deep form (i.e. a pixmap) the current paint
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  1945
     settings are ignored and the form is drawn as-is;
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  1946
     however, the mask is applied if present.
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  1947
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  1948
     The form should have been allocated on the same device,
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  1949
     otherwise it's converted here, which slows down the draw.
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  1950
     No transformation or scaling is done.
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  1951
     Care must be taken, that the paint color is correctly allocated
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  1952
     (by sending #on: to the color) before doing so.
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  1953
     Using functions other than #copy only makes sense if you are
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  1954
     certain, that the colors are real colors (actually, only for
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  1955
     noColor or allColor)."
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  1956
8281
88f62a43293a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8174
diff changeset
  1957
    (aFormOrImage isImage and:[aFormOrImage hasAlphaChannel]) ifTrue:[
8005
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  1958
        Error handle:[:ex |
8010
775d6d381f20 #BUGFIX by expecco
Claus Gittinger <cg@exept.de>
parents: 8009
diff changeset
  1959
            Logger error:'error when drawing alpha: %1' with:ex description.
8611
02dd0ea7a038 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8439
diff changeset
  1960
            self displayDeviceFormNoAlpha:(Depth24Image fromImage:aFormOrImage) x:x y:y
8005
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  1961
        ] do:[    
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  1962
            self displayDeviceFormWithAlpha:aFormOrImage x:x y:y.
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  1963
        ].
8281
88f62a43293a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8174
diff changeset
  1964
        ^ self.
8005
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  1965
    ].
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  1966
    self displayDeviceFormNoAlpha:aFormOrImage x:x y:y.
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  1967
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  1968
    "Modified: / 11-04-2017 / 18:29:56 / cg"
8315
d28a7b7f19e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 8312
diff changeset
  1969
    "Modified: / 20-03-2018 / 17:25:40 / stefan"
8611
02dd0ea7a038 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8439
diff changeset
  1970
    "Modified: / 10-01-2019 / 19:18:57 / Claus Gittinger"
8005
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  1971
!
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  1972
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  1973
displayDeviceFormNoAlpha:aForm x:x y:y
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  1974
    "draw a form or image non opaque (i.e. only foreground color is drawn);
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  1975
     If it's a 1-plane bitmap, 1-bits are drawn in the
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  1976
     current paint-color, leaving pixels with 0-bits unchanged
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  1977
     (i.e. only 1-bits are drawn from the form).
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  1978
     
7882
8b2d2f3f247d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7851
diff changeset
  1979
     If it's a deep form (i.e. a pixmap) the current paint
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1980
     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
  1981
     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
  1982
7752
81c84fab0aac #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 7749
diff changeset
  1983
     The form should have been allocated on the same device,
7882
8b2d2f3f247d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7851
diff changeset
  1984
     otherwise it's converted here, which slows down the draw.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1985
     No transformation or scaling is done.
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1986
     Care must be taken, that the paint color is correctly allocated
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1987
     (by sending #on: to the color) before doing so.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1988
     Using functions other than #copy only makes sense if you are
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1989
     certain, that the colors are real colors (actually, only for
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1990
     noColor or allColor)."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1991
6497
8edaeadf6658 Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents: 6484
diff changeset
  1992
    |id w h easy paintDither depth tmpForm tmpId tmpGCId
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  1993
     fgId noColor allColor allBits pX pY
7752
81c84fab0aac #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 7749
diff changeset
  1994
     mask maskId deviceForm deviceFormGCId deviceMask deviceMaskGcId colorMap|
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1995
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1996
    w := aForm width.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1997
    h := aForm height.
6612
5c05ccaf6275 class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6514
diff changeset
  1998
    (w = 0 or:[h = 0]) ifTrue:[^ self].
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1999
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2000
    pX := x rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2001
    pY := y rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2002
1034
5f6f417dcb12 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1033
diff changeset
  2003
    deviceForm := aForm asFormOn:device.
2192
01f76f23f03f handle case when no deviceForms can be created,
Claus Gittinger <cg@exept.de>
parents: 2065
diff changeset
  2004
    deviceForm isNil ifTrue:[
7629
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2005
        Logger warning:'cannot create device-form'.
6484
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2006
        ^self
2192
01f76f23f03f handle case when no deviceForms can be created,
Claus Gittinger <cg@exept.de>
parents: 2065
diff changeset
  2007
    ].
7629
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2008
    id := deviceForm drawableId.
7752
81c84fab0aac #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 7749
diff changeset
  2009
    "temporary ... what the heck is this??"
7629
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2010
    (id isNil
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2011
     or:[aForm graphicsDevice ~~ device]) ifTrue:[
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2012
        deviceForm := deviceForm asFormOn:device.
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2013
        id := deviceForm drawableId.
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2014
        id isNil ifTrue:[
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2015
            Logger warning:'invalid form draw - ignored'.
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2016
            ^ self
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2017
        ].
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2018
    ].
7629
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2019
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2020
    gcId isNil ifTrue:[
6484
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2021
        self initGC
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2022
    ].
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  2023
    "/ device needGCForBitmapSource  - i.e. WIN32
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  2024
    device isWindowsPlatform ifTrue:[
7749
f4ad7601ae41 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 7746
diff changeset
  2025
        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
  2026
    ].
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2027
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2028
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2029
     a deep form ignores paint/bgPaint settings
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2030
    "
1085
3513a4cae87b handle depth1-images with a mask
Claus Gittinger <cg@exept.de>
parents: 1064
diff changeset
  2031
    mask := aForm mask.
6497
8edaeadf6658 Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents: 6484
diff changeset
  2032
    depth := aForm depth.
8edaeadf6658 Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents: 6484
diff changeset
  2033
8edaeadf6658 Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents: 6484
diff changeset
  2034
    (mask notNil or:[depth ~~ 1]) ifTrue:[
6484
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2035
        mask notNil ifTrue:[
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2036
            mask depth ~~ 1 ifTrue:[
7980
c7b42695fdc9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7920
diff changeset
  2037
                'DeviceGraphicsContext [info]: alpha channel not yet supported' errorPrintCR.
6484
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2038
            ] ifFalse:[
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2039
                deviceMask := mask asFormOn:device.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2040
                deviceMask isNil ifTrue:[
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2041
                    'DeviceGraphicsContext [warning]: cannot create device-mask' errorPrintCR.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2042
                    ^self
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2043
                ].
7629
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2044
                maskId := deviceMask drawableId.
6484
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2045
                maskId notNil ifTrue:[
7752
81c84fab0aac #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 7749
diff changeset
  2046
                    deviceMaskGcId := deviceMask initGC.
6484
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2047
                    allColor := Color allColor.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2048
                    allBits := allColor colorId.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2049
6497
8edaeadf6658 Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents: 6484
diff changeset
  2050
                    (aForm maskedPixelsAre0
8edaeadf6658 Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents: 6484
diff changeset
  2051
                     and:[depth == 1 or:[deviceForm depth == device depth]]) ifTrue:[
6484
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2052
                        "/ can do it without a temporary pixmap:
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2053
                        "/   or-in the form into the inverse stamped-out area
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2054
                        "/   of the destination.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2055
                        "/   Oring is of course only possible if we know that
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2056
                        "/   masked pixels are already zero in the form.
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
                        "/ stamp out using mask
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  2059
                        device
8005
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  2060
                            setForeground:0 background:allBits function:#and in:gcId;
6484
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2061
                            copyPlaneFromPixmapId:maskId
7980
c7b42695fdc9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7920
diff changeset
  2062
                                x:0 y:0 gc:deviceMaskGcId
6497
8edaeadf6658 Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents: 6484
diff changeset
  2063
                                to:drawableId
7980
c7b42695fdc9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7920
diff changeset
  2064
                                x:pX y:pY gc:gcId
c7b42695fdc9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7920
diff changeset
  2065
                                width:w height:h.
6497
8edaeadf6658 Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents: 6484
diff changeset
  2066
6484
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2067
                        "/ or-in the form
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2068
                        device setFunction:#or in:gcId.
6497
8edaeadf6658 Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents: 6484
diff changeset
  2069
                        depth == 1 ifTrue:[
8edaeadf6658 Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents: 6484
diff changeset
  2070
                            (colorMap := deviceForm colorMap) notNil ifTrue:[
8edaeadf6658 Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents: 6484
diff changeset
  2071
                                colorMap size < 2 ifTrue:[
8edaeadf6658 Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents: 6484
diff changeset
  2072
                                    device
8edaeadf6658 Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents: 6484
diff changeset
  2073
                                        setForegroundColor:(colorMap at:1)
8edaeadf6658 Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents: 6484
diff changeset
  2074
                                        backgroundColor:(Color noColor)
8edaeadf6658 Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents: 6484
diff changeset
  2075
                                        in:gcId.
8edaeadf6658 Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents: 6484
diff changeset
  2076
                                ] ifFalse:[
8edaeadf6658 Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents: 6484
diff changeset
  2077
                                    device
8edaeadf6658 Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents: 6484
diff changeset
  2078
                                        setForegroundColor:(colorMap at:2)
8edaeadf6658 Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents: 6484
diff changeset
  2079
                                        backgroundColor:(colorMap at:1)
8edaeadf6658 Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents: 6484
diff changeset
  2080
                                        in:gcId.
8edaeadf6658 Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents: 6484
diff changeset
  2081
                                ]
8edaeadf6658 Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents: 6484
diff changeset
  2082
                            ].
8edaeadf6658 Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents: 6484
diff changeset
  2083
                            device
8edaeadf6658 Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents: 6484
diff changeset
  2084
                                copyPlaneFromPixmapId:id
7980
c7b42695fdc9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7920
diff changeset
  2085
                                x:0 y:0 gc:deviceFormGCId
6497
8edaeadf6658 Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents: 6484
diff changeset
  2086
                                to:drawableId
7980
c7b42695fdc9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7920
diff changeset
  2087
                                x:pX y:pY gc:gcId
c7b42695fdc9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7920
diff changeset
  2088
                                width:w height:h.
6497
8edaeadf6658 Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents: 6484
diff changeset
  2089
                        ] ifFalse:[
8edaeadf6658 Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents: 6484
diff changeset
  2090
                            device
8edaeadf6658 Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents: 6484
diff changeset
  2091
                                copyFromPixmapId:id
7980
c7b42695fdc9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7920
diff changeset
  2092
                                x:0 y:0 gc:deviceFormGCId
6497
8edaeadf6658 Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents: 6484
diff changeset
  2093
                                to:drawableId
7980
c7b42695fdc9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7920
diff changeset
  2094
                                x:pX y:pY gc:gcId
c7b42695fdc9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7920
diff changeset
  2095
                                width:w height:h.
6497
8edaeadf6658 Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents: 6484
diff changeset
  2096
                        ].
6484
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2097
                    ] ifFalse:[
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2098
                        "/ must do it slow, using a temporary form ..
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2099
8005
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  2100
                        "/ create temp-form;
6484
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2101
                        tmpForm := Form width:w height:h depth:device depth onDevice:device.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2102
                        tmpForm isNil ifTrue:[
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2103
                            '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
  2104
                            ^ self
6484
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2105
                        ].
7629
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2106
                        tmpId := tmpForm drawableId.
7752
81c84fab0aac #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 7749
diff changeset
  2107
                        tmpGCId := tmpForm initGC.
6484
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2108
8005
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  2109
                        "/ fill tempform with image
6497
8edaeadf6658 Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents: 6484
diff changeset
  2110
                        depth == 1 ifTrue:[
6484
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2111
                            (colorMap := deviceForm colorMap) notNil ifTrue:[
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2112
                                colorMap size < 2 ifTrue:[
8005
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  2113
                                    device setForegroundColor:(colorMap at:1) in:tmpGCId.
6484
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2114
                                ] ifFalse:[
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2115
                                    device
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2116
                                        setForegroundColor:(colorMap at:2)
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2117
                                        backgroundColor:(colorMap at:1)
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2118
                                        in:tmpGCId.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2119
                                ]
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2120
                            ].
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2121
                            device
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2122
                                copyPlaneFromPixmapId:id
7980
c7b42695fdc9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7920
diff changeset
  2123
                                x:0 y:0 gc:deviceFormGCId
8005
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  2124
                                to:tmpId x:0 y:0 gc:tmpGCId
7980
c7b42695fdc9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7920
diff changeset
  2125
                                width:w height:h.
6484
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2126
                        ] ifFalse:[
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2127
                            device
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2128
                                copyFromPixmapId:id
7980
c7b42695fdc9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7920
diff changeset
  2129
                                x:0 y:0 gc:deviceFormGCId
8005
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  2130
                                to:tmpId x:0 y:0 gc:tmpGCId
7980
c7b42695fdc9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7920
diff changeset
  2131
                                width:w height:h.
6484
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2132
                        ].
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2133
8005
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  2134
                        "/ stamp out mask in temp form
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  2135
                        "/ set unmasked pixels to allBits and masked pixels to 0
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  2136
                        device
8005
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  2137
                            setForeground:allBits background:0 function:#and in:tmpGCId;
6484
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2138
                            copyPlaneFromPixmapId:maskId
7980
c7b42695fdc9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7920
diff changeset
  2139
                                x:0 y:0 gc:deviceMaskGcId
8005
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  2140
                                to:tmpId x:0 y:0 gc:tmpGCId
7980
c7b42695fdc9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7920
diff changeset
  2141
                                width:w height:h.
8005
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  2142
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  2143
                        "/ stamp out mask in destination
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  2144
                        "/ set unmasked pixels to 0 and masked pixels to allBits
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  2145
                        device
8005
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  2146
                            setForeground:0 background:allBits function:#and in:gcId;
6484
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2147
                            copyPlaneFromPixmapId:maskId
7980
c7b42695fdc9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7920
diff changeset
  2148
                                x:0 y:0 gc:deviceMaskGcId
8005
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  2149
                                to:drawableId x:pX y:pY gc:gcId
7980
c7b42695fdc9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7920
diff changeset
  2150
                                width:w height:h.
6484
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2151
8005
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  2152
                        "/ or-in tempform-bits ...
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  2153
                        device
8005
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  2154
                            setForeground:0 background:0 function:#or in:gcId;
6484
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2155
                            copyFromPixmapId:tmpId
7980
c7b42695fdc9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7920
diff changeset
  2156
                                x:0 y:0 gc:tmpGCId
8005
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  2157
                                to:drawableId x:pX y:pY gc:gcId
7980
c7b42695fdc9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7920
diff changeset
  2158
                                width:w height:h.
6484
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2159
8005
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  2160
                        "/ release tempForm immediately
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  2161
                        "/ (although GC will eventually do it,
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  2162
                        "/  this creates less stress to the Xserver in the meanwhile ...)
6484
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2163
                        tmpForm destroy.
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
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2166
                    "/ restore GC
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2167
                    foreground notNil ifTrue:[
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2168
                        device setForegroundColor:foreground in:gcId.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2169
                    ].
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2170
                    background notNil ifTrue:[
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2171
                        device setBackgroundColor:background in:gcId
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2172
                    ].
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2173
                    device setFunction:function in:gcId.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2174
                    ^ self
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
7980
c7b42695fdc9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7920
diff changeset
  2180
            x:0 y:0 gc:deviceFormGCId
6484
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2181
            to:drawableId
7980
c7b42695fdc9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7920
diff changeset
  2182
            x:pX y:pY gc:gcId
c7b42695fdc9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7920
diff changeset
  2183
            width:w height:h.
6484
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2184
        ^ self
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2185
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2186
8005
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  2187
    "/ the following code is somewhat complicated, since it has to deal
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  2188
    "/ with dithered paint colors, which cannot be done directly on most
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  2189
    "/ devices (actually, a test for the device's capabilities has to be added here)
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  2190
    "/ (just assume drawing a bitmap with dithered paint color ... sigh)
1507
358603f58138 faster drawing in or-mode.
Claus Gittinger <cg@exept.de>
parents: 1453
diff changeset
  2191
    easy := (function == #copy).
358603f58138 faster drawing in or-mode.
Claus Gittinger <cg@exept.de>
parents: 1453
diff changeset
  2192
8005
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  2193
    "/ if paint is not a real color, we have to do it the hard way ...
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2194
    easy ifTrue:[
6484
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2195
        paint isColor ifTrue:[
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2196
            paintDither := paint ditherForm.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2197
            paintDither notNil ifTrue:[
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2198
                easy := false.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2199
            ]
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2200
        ] ifFalse:[
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2201
            paintDither := paint.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2202
            easy := false
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2203
        ].
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2204
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2205
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2206
    allColor := Color allColor.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2207
    allBits := allColor colorId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2208
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2209
    easy ifTrue:[
8005
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  2210
        "/ paint is a real color
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  2211
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  2212
        "/ if paint color is all-0 or all-1's, we can do it in one operation ...
6484
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2213
        fgId := paint colorId.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2214
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2215
        ((fgId ~~ ((1 bitShift:device depth)-1))
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2216
        and:[fgId ~~ allBits]) ifTrue:[
8005
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  2217
            "/ clear fg-bits ...
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  2218
            device setForeground:0 background:allBits function:#and in:gcId.
6484
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2219
            device
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2220
                copyPlaneFromPixmapId:id
7980
c7b42695fdc9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7920
diff changeset
  2221
                x:0 y:0 gc:deviceFormGCId
6484
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2222
                to:drawableId
7980
c7b42695fdc9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7920
diff changeset
  2223
                x:pX y:pY gc:gcId
c7b42695fdc9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7920
diff changeset
  2224
                width:w height:h.
6484
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2225
        ].
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2226
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2227
        fgId ~~ 0 ifTrue:[
8005
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  2228
            "/ or-in fg-bits ...
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  2229
            device setForeground:fgId background:0 function:#or in:gcId.
6484
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2230
            device
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2231
                copyPlaneFromPixmapId:id
7980
c7b42695fdc9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7920
diff changeset
  2232
                x:0 y:0 gc:deviceFormGCId
6484
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2233
                to:drawableId
7980
c7b42695fdc9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7920
diff changeset
  2234
                x:pX y:pY gc:gcId
c7b42695fdc9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7920
diff changeset
  2235
                width:w height:h
6484
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2236
        ].
8005
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  2237
        "/ flush foreground/background cache
7980
c7b42695fdc9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7920
diff changeset
  2238
        device setForegroundColor:foreground backgroundColor:background in:gcId.
6484
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2239
        device setFunction:function in:gcId.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2240
        ^ self
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2241
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2242
1507
358603f58138 faster drawing in or-mode.
Claus Gittinger <cg@exept.de>
parents: 1453
diff changeset
  2243
    function == #or ifTrue:[
6484
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2244
        easy := paint notNil
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2245
                and:[paint isColor
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2246
                and:[paint ditherForm isNil]].
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2247
        easy ifTrue:[
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2248
            easy := bgPaint isNil
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2249
                        or:[bgPaint isColor
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2250
                            and:[bgPaint colorId == 0]]
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
        easy ifTrue:[
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2253
            fgId := paint colorId.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2254
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2255
            fgId ~~ 0 ifTrue:[
8005
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  2256
                "/ or-in fg-bits ...
6484
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2257
                device setForeground:fgId background:0 in:gcId.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2258
                device
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2259
                    copyPlaneFromPixmapId:id
7980
c7b42695fdc9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7920
diff changeset
  2260
                    x:0 y:0 gc:deviceFormGCId
6484
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2261
                    to:drawableId
7980
c7b42695fdc9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7920
diff changeset
  2262
                    x:pX y:pY gc:gcId
c7b42695fdc9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7920
diff changeset
  2263
                    width:w height:h
6484
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2264
            ].
8005
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  2265
            "/ flush foreground/background cache
6484
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2266
            foreground := nil.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2267
            background := nil.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2268
            ^ self
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2269
        ].
1507
358603f58138 faster drawing in or-mode.
Claus Gittinger <cg@exept.de>
parents: 1453
diff changeset
  2270
    ].
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2271
8005
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  2272
    "/ hard case; paint is a dithered color
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2273
    noColor := Color noColor.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2274
8005
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  2275
    "/ create temp-form;
4756
dd597f8839cb changed #displayDeviceForm:x:y:
Claus Gittinger <cg@exept.de>
parents: 4752
diff changeset
  2276
    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
  2277
    tmpForm isNil ifTrue:[
6484
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2278
        'DeviceGraphicsContext [warning]: cannot create temp form' errorPrintCR.
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2279
        ^self
2192
01f76f23f03f handle case when no deviceForms can be created,
Claus Gittinger <cg@exept.de>
parents: 2065
diff changeset
  2280
    ].
8005
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  2281
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  2282
    "/ fill tempform
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  2283
    tmpForm paint:paint; fillRectangleX:0 y:0 width:w height:h.
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  2284
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  2285
    "/ stamp out background
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  2286
    tmpForm paint:allColor on:noColor; function:#and.
976
807b42b00353 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 975
diff changeset
  2287
    tmpForm displayOpaqueForm:deviceForm x:0 y:0.
8005
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  2288
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  2289
    "/ stamp out foreground from destination
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  2290
    device setForeground:0 background:allBits function:#and in:gcId.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2291
    device
6484
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2292
        copyPlaneFromPixmapId:id
8005
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  2293
        x:0 y:0
6484
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2294
        gc:deviceFormGCId
8005
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  2295
        to:drawableId x:pX y:pY
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  2296
        gc:gcId width:w height:h.
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  2297
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  2298
    "/ or-in temp into destination
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  2299
    device setForeground:allBits background:0 function:#or in:gcId.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2300
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2301
    device
7629
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2302
        copyFromPixmapId:tmpForm drawableId
8005
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  2303
        x:0 y:0
6484
5d1889e556a7 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6292
diff changeset
  2304
        gc:tmpForm gcId
8005
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  2305
        to:drawableId x:pX y:pY
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  2306
        gc:gcId width:w height:h.
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  2307
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  2308
    "/ release tempForm immediately
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  2309
    "/ (although GC will eventually do it,
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  2310
    "/  this creates less stress to the Xserver in the meanwhile ...)
1637
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  2311
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  2312
    tmpForm destroy.
8005
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  2313
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  2314
    "/ flush foreground/background cache
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2315
    foreground := nil.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2316
    background := nil.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2317
    device setFunction:function in:gcId.
768
77e4f9d30a22 fixes for b&w screens
Claus Gittinger <cg@exept.de>
parents: 745
diff changeset
  2318
8005
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  2319
    "Created: / 11-04-2017 / 16:45:18 / cg"
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  2320
!
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  2321
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  2322
displayDeviceFormWithAlpha:anImage x:x y:y
8008
1c39c7155eaa #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8005
diff changeset
  2323
    "draw a form or image non opaque;
1c39c7155eaa #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8005
diff changeset
  2324
     The current paint settings are ignored and the image is drawn as-is;
8143
cdd9fdf39d88 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 8027
diff changeset
  2325
     however, the alpha channel is taken care of.
8008
1c39c7155eaa #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8005
diff changeset
  2326
     This is a (slow) fallback helper for displays which do not support alpha blending"
8005
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  2327
8281
88f62a43293a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8174
diff changeset
  2328
    |bytesPerLine orgDstData 
88f62a43293a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8174
diff changeset
  2329
     dstBytes imgBytes info w h pX pY bppDrawable 
8005
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  2330
     dstBytesPerRow "{Class: SmallInteger}"
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  2331
     imgBytesPerRow "{Class: SmallInteger}"
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  2332
     dstIndex "{Class: SmallInteger}"
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  2333
     imgIndex "{Class: SmallInteger}"
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  2334
     dstRowIndex "{Class: SmallInteger}"
8010
775d6d381f20 #BUGFIX by expecco
Claus Gittinger <cg@exept.de>
parents: 8009
diff changeset
  2335
     imgRowIndex "{Class: SmallInteger}"
775d6d381f20 #BUGFIX by expecco
Claus Gittinger <cg@exept.de>
parents: 8009
diff changeset
  2336
     oB "{Class: SmallInteger}"
775d6d381f20 #BUGFIX by expecco
Claus Gittinger <cg@exept.de>
parents: 8009
diff changeset
  2337
     oR "{Class: SmallInteger}"
8281
88f62a43293a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8174
diff changeset
  2338
     oG "{Class: SmallInteger}"
88f62a43293a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8174
diff changeset
  2339
     iR "{Class: SmallInteger}"  
88f62a43293a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8174
diff changeset
  2340
     iG "{Class: SmallInteger}"  
88f62a43293a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8174
diff changeset
  2341
     iB "{Class: SmallInteger}"  
88f62a43293a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8174
diff changeset
  2342
     iA "{Class: SmallInteger}"  
88f62a43293a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8174
diff changeset
  2343
     try |
88f62a43293a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8174
diff changeset
  2344
88f62a43293a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8174
diff changeset
  2345
    device flush.
8005
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  2346
    device sync.
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  2347
    
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  2348
    w := anImage width.
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  2349
    h := anImage height.
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  2350
    (w = 0 or:[h = 0]) ifTrue:[^ self].
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  2351
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  2352
    pX := x rounded.
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  2353
    pY := y rounded.
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  2354
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  2355
    "/ give it more than enough bytes
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  2356
    bytesPerLine := (w * 32 + 31) // 32 * 4.
8281
88f62a43293a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8174
diff changeset
  2357
    dstBytes := ByteArray uninitializedNew:(bytesPerLine * h).
88f62a43293a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8174
diff changeset
  2358
88f62a43293a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8174
diff changeset
  2359
    "/ OSX XQuartz bug workaround
88f62a43293a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8174
diff changeset
  2360
    "/ if I do this, the Inspector can read the window's bits
88f62a43293a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8174
diff changeset
  2361
    "/ (sometimes after a retry)
88f62a43293a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8174
diff changeset
  2362
    "/ however, the imageEditor stil has problems to show the image
88f62a43293a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8174
diff changeset
  2363
    "/ in its lower left preview area.
88f62a43293a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8174
diff changeset
  2364
    "/ This should really really not be required!!!!!!
88f62a43293a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8174
diff changeset
  2365
    try := 1.
88f62a43293a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8174
diff changeset
  2366
    Error handle:[:ex |
88f62a43293a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8174
diff changeset
  2367
        try < 5 ifTrue:[
88f62a43293a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8174
diff changeset
  2368
            try := try + 1.
88f62a43293a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8174
diff changeset
  2369
            device flush.
88f62a43293a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8174
diff changeset
  2370
            device sync.
88f62a43293a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8174
diff changeset
  2371
            Delay waitForMilliseconds:20.
88f62a43293a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8174
diff changeset
  2372
            device flush.
88f62a43293a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8174
diff changeset
  2373
            device sync.
88f62a43293a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8174
diff changeset
  2374
            ex restart.
88f62a43293a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8174
diff changeset
  2375
        ].
88f62a43293a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8174
diff changeset
  2376
        ex reject
88f62a43293a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8174
diff changeset
  2377
    ] do:[
88f62a43293a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8174
diff changeset
  2378
        drawableType == #pixmap ifTrue:[
88f62a43293a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8174
diff changeset
  2379
            info := device getBitsFromPixmapId:(self drawableId) x:pX y:pY width:w height:h into:dstBytes.
88f62a43293a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8174
diff changeset
  2380
        ] ifFalse:[
88f62a43293a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8174
diff changeset
  2381
            info := device getBitsFromViewId:(self drawableId) x:pX y:pY width:w height:h into:dstBytes.
88f62a43293a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8174
diff changeset
  2382
        ].
8005
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  2383
    ].
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  2384
    dstBytesPerRow := info at:#bytesPerLine.
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  2385
    imgBytesPerRow := anImage bytesPerRow.
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  2386
    
8281
88f62a43293a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8174
diff changeset
  2387
    imgBytes := anImage bits.
88f62a43293a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8174
diff changeset
  2388
    orgDstData := dstBytes copy.
88f62a43293a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8174
diff changeset
  2389
88f62a43293a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8174
diff changeset
  2390
    iR := 0.
88f62a43293a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8174
diff changeset
  2391
    iG := 1.
88f62a43293a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8174
diff changeset
  2392
    iB := 2.
88f62a43293a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8174
diff changeset
  2393
    iA := 3.
88f62a43293a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8174
diff changeset
  2394
    anImage photometric == #argb ifTrue:[
88f62a43293a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8174
diff changeset
  2395
        iA := 0.
88f62a43293a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8174
diff changeset
  2396
        iR := 1.
88f62a43293a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8174
diff changeset
  2397
        iG := 2.
88f62a43293a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8174
diff changeset
  2398
        iB := 3.
88f62a43293a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8174
diff changeset
  2399
    ].
88f62a43293a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8174
diff changeset
  2400
88f62a43293a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8174
diff changeset
  2401
    "/ TODO: the following code is a nr1 candidate for inline c-code
8005
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  2402
    bppDrawable := info at:#bitsPerPixel.
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  2403
    bppDrawable == 32 ifTrue:[
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  2404
        "/ data is coming as bytes in r,g,b,a order
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  2405
        dstRowIndex := 1.
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  2406
        imgRowIndex := 1.
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  2407
        
8010
775d6d381f20 #BUGFIX by expecco
Claus Gittinger <cg@exept.de>
parents: 8009
diff changeset
  2408
        oR := 2.
775d6d381f20 #BUGFIX by expecco
Claus Gittinger <cg@exept.de>
parents: 8009
diff changeset
  2409
        oG := 1.
775d6d381f20 #BUGFIX by expecco
Claus Gittinger <cg@exept.de>
parents: 8009
diff changeset
  2410
        oB := 0.
775d6d381f20 #BUGFIX by expecco
Claus Gittinger <cg@exept.de>
parents: 8009
diff changeset
  2411
8005
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  2412
        "/ draw "by hand" here
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  2413
        0 to:h-1 do:[:y |
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  2414
            dstIndex := dstRowIndex.
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  2415
            imgIndex := imgRowIndex.
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  2416
            0 to:w-1 do:[:x |
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  2417
                |rD "{Class: SmallInteger}" 
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  2418
                 gD "{Class: SmallInteger}"
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  2419
                 bD "{Class: SmallInteger}" 
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  2420
                 rI "{Class: SmallInteger}"
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  2421
                 gI "{Class: SmallInteger}"
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  2422
                 bI "{Class: SmallInteger}"
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  2423
                 aI "{Class: SmallInteger}"
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  2424
                 aD "{Class: SmallInteger}"
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  2425
                 nR "{Class: SmallInteger}"
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  2426
                 nG "{Class: SmallInteger}"
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  2427
                 nB "{Class: SmallInteger}"|
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  2428
8281
88f62a43293a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8174
diff changeset
  2429
                rD := dstBytes at:(dstIndex+oR).
88f62a43293a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8174
diff changeset
  2430
                gD := dstBytes at:(dstIndex+oG).
88f62a43293a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8174
diff changeset
  2431
                bD := dstBytes at:(dstIndex+oB).
88f62a43293a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8174
diff changeset
  2432
88f62a43293a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8174
diff changeset
  2433
                rI := imgBytes at:(imgIndex+iR).
88f62a43293a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8174
diff changeset
  2434
                gI := imgBytes at:(imgIndex+iG).
88f62a43293a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8174
diff changeset
  2435
                bI := imgBytes at:(imgIndex+iB).
88f62a43293a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8174
diff changeset
  2436
                aI := imgBytes at:(imgIndex+iA).
8005
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  2437
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  2438
                aI == 255 ifTrue:[
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  2439
                    nR := rI.
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  2440
                    nG := gI.
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  2441
                    nB := bI.
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  2442
                ] ifFalse:[
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  2443
                    aI == 0 ifTrue:[
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  2444
                        nR := rD.
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  2445
                        nG := gD.
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  2446
                        nB := bD.
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  2447
                    ] ifFalse:[
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  2448
                        aD := 255 - aI.
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  2449
                        
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  2450
                        nR := (((rI * aI)+(rD * aD)) // 255).
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  2451
                        nG := (((gI * aI)+(gD * aD)) // 255).
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  2452
                        nB := (((bI * aI)+(bD * aD)) // 255).
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  2453
                    ].
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  2454
                ].
8281
88f62a43293a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8174
diff changeset
  2455
                "/ dstBytes at:(dstIndex) put:255.
88f62a43293a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8174
diff changeset
  2456
                dstBytes at:(dstIndex+1) put:nR.
88f62a43293a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8174
diff changeset
  2457
                dstBytes at:(dstIndex+2) put:nG.
88f62a43293a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8174
diff changeset
  2458
                dstBytes at:(dstIndex+3) put:nB.
8005
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  2459
                
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  2460
                dstIndex := dstIndex + 4.
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  2461
                imgIndex := imgIndex + 4.
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  2462
            ].
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  2463
            dstRowIndex := dstRowIndex + dstBytesPerRow.
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  2464
            imgRowIndex := imgRowIndex + imgBytesPerRow.
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  2465
        ].
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  2466
        "/ draw the pixels (always MSB)
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  2467
        device 
8281
88f62a43293a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8174
diff changeset
  2468
            drawBits:dstBytes bitsPerPixel:32 depth:24 padding:32 
8009
d5e22275f8de #BUGFIX by expecco
Claus Gittinger <cg@exept.de>
parents: 8008
diff changeset
  2469
            width:w height:h x:0 y:0 
d5e22275f8de #BUGFIX by expecco
Claus Gittinger <cg@exept.de>
parents: 8008
diff changeset
  2470
            into:(self drawableId) x:pX y:pY width:w height:h with:gcId.
8281
88f62a43293a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8174
diff changeset
  2471
88f62a43293a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8174
diff changeset
  2472
        device flush.
88f62a43293a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8174
diff changeset
  2473
        device sync.
8009
d5e22275f8de #BUGFIX by expecco
Claus Gittinger <cg@exept.de>
parents: 8008
diff changeset
  2474
        ^ self.
d5e22275f8de #BUGFIX by expecco
Claus Gittinger <cg@exept.de>
parents: 8008
diff changeset
  2475
    ].
8281
88f62a43293a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8174
diff changeset
  2476
8009
d5e22275f8de #BUGFIX by expecco
Claus Gittinger <cg@exept.de>
parents: 8008
diff changeset
  2477
    bppDrawable == 24 ifTrue:[
d5e22275f8de #BUGFIX by expecco
Claus Gittinger <cg@exept.de>
parents: 8008
diff changeset
  2478
        "/ data is coming as bytes in r,g,b order
d5e22275f8de #BUGFIX by expecco
Claus Gittinger <cg@exept.de>
parents: 8008
diff changeset
  2479
        dstRowIndex := 1.
d5e22275f8de #BUGFIX by expecco
Claus Gittinger <cg@exept.de>
parents: 8008
diff changeset
  2480
        imgRowIndex := 1.
d5e22275f8de #BUGFIX by expecco
Claus Gittinger <cg@exept.de>
parents: 8008
diff changeset
  2481
8010
775d6d381f20 #BUGFIX by expecco
Claus Gittinger <cg@exept.de>
parents: 8009
diff changeset
  2482
        (info at:#byteOrder) == #lsbFirst ifTrue:[
8143
cdd9fdf39d88 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 8027
diff changeset
  2483
            oR := 0. oG := 1. oB := 2.
8010
775d6d381f20 #BUGFIX by expecco
Claus Gittinger <cg@exept.de>
parents: 8009
diff changeset
  2484
        ] ifFalse:[
8143
cdd9fdf39d88 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 8027
diff changeset
  2485
            oR := 2. oG := 1. oB := 0.
8010
775d6d381f20 #BUGFIX by expecco
Claus Gittinger <cg@exept.de>
parents: 8009
diff changeset
  2486
        ].
775d6d381f20 #BUGFIX by expecco
Claus Gittinger <cg@exept.de>
parents: 8009
diff changeset
  2487
8009
d5e22275f8de #BUGFIX by expecco
Claus Gittinger <cg@exept.de>
parents: 8008
diff changeset
  2488
        "/ draw "by hand" here
d5e22275f8de #BUGFIX by expecco
Claus Gittinger <cg@exept.de>
parents: 8008
diff changeset
  2489
        0 to:h-1 do:[:y |
d5e22275f8de #BUGFIX by expecco
Claus Gittinger <cg@exept.de>
parents: 8008
diff changeset
  2490
            dstIndex := dstRowIndex.
d5e22275f8de #BUGFIX by expecco
Claus Gittinger <cg@exept.de>
parents: 8008
diff changeset
  2491
            imgIndex := imgRowIndex.
d5e22275f8de #BUGFIX by expecco
Claus Gittinger <cg@exept.de>
parents: 8008
diff changeset
  2492
            0 to:w-1 do:[:x |
d5e22275f8de #BUGFIX by expecco
Claus Gittinger <cg@exept.de>
parents: 8008
diff changeset
  2493
                |rD "{Class: SmallInteger}" 
d5e22275f8de #BUGFIX by expecco
Claus Gittinger <cg@exept.de>
parents: 8008
diff changeset
  2494
                 gD "{Class: SmallInteger}"
d5e22275f8de #BUGFIX by expecco
Claus Gittinger <cg@exept.de>
parents: 8008
diff changeset
  2495
                 bD "{Class: SmallInteger}" 
d5e22275f8de #BUGFIX by expecco
Claus Gittinger <cg@exept.de>
parents: 8008
diff changeset
  2496
                 rI "{Class: SmallInteger}"
d5e22275f8de #BUGFIX by expecco
Claus Gittinger <cg@exept.de>
parents: 8008
diff changeset
  2497
                 gI "{Class: SmallInteger}"
d5e22275f8de #BUGFIX by expecco
Claus Gittinger <cg@exept.de>
parents: 8008
diff changeset
  2498
                 bI "{Class: SmallInteger}"
d5e22275f8de #BUGFIX by expecco
Claus Gittinger <cg@exept.de>
parents: 8008
diff changeset
  2499
                 aI "{Class: SmallInteger}"
d5e22275f8de #BUGFIX by expecco
Claus Gittinger <cg@exept.de>
parents: 8008
diff changeset
  2500
                 aD "{Class: SmallInteger}"
d5e22275f8de #BUGFIX by expecco
Claus Gittinger <cg@exept.de>
parents: 8008
diff changeset
  2501
                 nR "{Class: SmallInteger}"
d5e22275f8de #BUGFIX by expecco
Claus Gittinger <cg@exept.de>
parents: 8008
diff changeset
  2502
                 nG "{Class: SmallInteger}"
d5e22275f8de #BUGFIX by expecco
Claus Gittinger <cg@exept.de>
parents: 8008
diff changeset
  2503
                 nB "{Class: SmallInteger}"|
d5e22275f8de #BUGFIX by expecco
Claus Gittinger <cg@exept.de>
parents: 8008
diff changeset
  2504
8281
88f62a43293a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8174
diff changeset
  2505
                rD := dstBytes at:(dstIndex+oR).
88f62a43293a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8174
diff changeset
  2506
                gD := dstBytes at:(dstIndex+oG).
88f62a43293a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8174
diff changeset
  2507
                bD := dstBytes at:(dstIndex+oB).
88f62a43293a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8174
diff changeset
  2508
88f62a43293a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8174
diff changeset
  2509
                rI := imgBytes at:(imgIndex+iR).
88f62a43293a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8174
diff changeset
  2510
                gI := imgBytes at:(imgIndex+iG).
88f62a43293a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8174
diff changeset
  2511
                bI := imgBytes at:(imgIndex+iB).
88f62a43293a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8174
diff changeset
  2512
                aI := imgBytes at:(imgIndex+iA).
8009
d5e22275f8de #BUGFIX by expecco
Claus Gittinger <cg@exept.de>
parents: 8008
diff changeset
  2513
d5e22275f8de #BUGFIX by expecco
Claus Gittinger <cg@exept.de>
parents: 8008
diff changeset
  2514
                aI == 255 ifTrue:[
d5e22275f8de #BUGFIX by expecco
Claus Gittinger <cg@exept.de>
parents: 8008
diff changeset
  2515
                    nR := rI.
d5e22275f8de #BUGFIX by expecco
Claus Gittinger <cg@exept.de>
parents: 8008
diff changeset
  2516
                    nG := gI.
d5e22275f8de #BUGFIX by expecco
Claus Gittinger <cg@exept.de>
parents: 8008
diff changeset
  2517
                    nB := bI.
d5e22275f8de #BUGFIX by expecco
Claus Gittinger <cg@exept.de>
parents: 8008
diff changeset
  2518
                ] ifFalse:[
d5e22275f8de #BUGFIX by expecco
Claus Gittinger <cg@exept.de>
parents: 8008
diff changeset
  2519
                    aI == 0 ifTrue:[
d5e22275f8de #BUGFIX by expecco
Claus Gittinger <cg@exept.de>
parents: 8008
diff changeset
  2520
                        nR := rD.
d5e22275f8de #BUGFIX by expecco
Claus Gittinger <cg@exept.de>
parents: 8008
diff changeset
  2521
                        nG := gD.
d5e22275f8de #BUGFIX by expecco
Claus Gittinger <cg@exept.de>
parents: 8008
diff changeset
  2522
                        nB := bD.
d5e22275f8de #BUGFIX by expecco
Claus Gittinger <cg@exept.de>
parents: 8008
diff changeset
  2523
                    ] ifFalse:[
d5e22275f8de #BUGFIX by expecco
Claus Gittinger <cg@exept.de>
parents: 8008
diff changeset
  2524
                        aD := 255 - aI.
d5e22275f8de #BUGFIX by expecco
Claus Gittinger <cg@exept.de>
parents: 8008
diff changeset
  2525
d5e22275f8de #BUGFIX by expecco
Claus Gittinger <cg@exept.de>
parents: 8008
diff changeset
  2526
                        nR := (((rI * aI)+(rD * aD)) // 255).
d5e22275f8de #BUGFIX by expecco
Claus Gittinger <cg@exept.de>
parents: 8008
diff changeset
  2527
                        nG := (((gI * aI)+(gD * aD)) // 255).
d5e22275f8de #BUGFIX by expecco
Claus Gittinger <cg@exept.de>
parents: 8008
diff changeset
  2528
                        nB := (((bI * aI)+(bD * aD)) // 255).
d5e22275f8de #BUGFIX by expecco
Claus Gittinger <cg@exept.de>
parents: 8008
diff changeset
  2529
                    ].
d5e22275f8de #BUGFIX by expecco
Claus Gittinger <cg@exept.de>
parents: 8008
diff changeset
  2530
                ].
8281
88f62a43293a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8174
diff changeset
  2531
                dstBytes at:(dstIndex+2) put:nR.
88f62a43293a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8174
diff changeset
  2532
                dstBytes at:(dstIndex+1) put:nG.
88f62a43293a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8174
diff changeset
  2533
                dstBytes at:(dstIndex+0) put:nB.
8009
d5e22275f8de #BUGFIX by expecco
Claus Gittinger <cg@exept.de>
parents: 8008
diff changeset
  2534
d5e22275f8de #BUGFIX by expecco
Claus Gittinger <cg@exept.de>
parents: 8008
diff changeset
  2535
                dstIndex := dstIndex + 3.
d5e22275f8de #BUGFIX by expecco
Claus Gittinger <cg@exept.de>
parents: 8008
diff changeset
  2536
                imgIndex := imgIndex + 4.
d5e22275f8de #BUGFIX by expecco
Claus Gittinger <cg@exept.de>
parents: 8008
diff changeset
  2537
            ].
d5e22275f8de #BUGFIX by expecco
Claus Gittinger <cg@exept.de>
parents: 8008
diff changeset
  2538
            dstRowIndex := dstRowIndex + dstBytesPerRow.
d5e22275f8de #BUGFIX by expecco
Claus Gittinger <cg@exept.de>
parents: 8008
diff changeset
  2539
            imgRowIndex := imgRowIndex + imgBytesPerRow.
d5e22275f8de #BUGFIX by expecco
Claus Gittinger <cg@exept.de>
parents: 8008
diff changeset
  2540
        ].
d5e22275f8de #BUGFIX by expecco
Claus Gittinger <cg@exept.de>
parents: 8008
diff changeset
  2541
        "/ draw the pixels (always MSB)
d5e22275f8de #BUGFIX by expecco
Claus Gittinger <cg@exept.de>
parents: 8008
diff changeset
  2542
        device 
8281
88f62a43293a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8174
diff changeset
  2543
            drawBits:dstBytes bitsPerPixel:24 depth:24 padding:32 
8005
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  2544
            width:w height:h x:0 y:0 
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  2545
            into:(self drawableId) x:pX y:pY width:w height:h with:gcId.
8281
88f62a43293a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8174
diff changeset
  2546
88f62a43293a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8174
diff changeset
  2547
        device flush.
88f62a43293a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8174
diff changeset
  2548
        device sync.
8005
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  2549
        ^ self.
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  2550
    ].
8281
88f62a43293a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8174
diff changeset
  2551
88f62a43293a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8174
diff changeset
  2552
    Logger info:'(X11GC): drawing alpha into non24, non-32 displays is currently not supported'.
88f62a43293a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8174
diff changeset
  2553
    self displayDeviceFormNoAlpha:anImage x:x y:y.
8005
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  2554
44e80d5c9293 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7980
diff changeset
  2555
    "Created: / 11-04-2017 / 16:45:39 / cg"
8008
1c39c7155eaa #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8005
diff changeset
  2556
    "Modified: / 12-04-2017 / 10:38:52 / cg"
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2557
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2558
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2559
displayDeviceLineFromX:x0 y:y0 toX:x1 y:y1
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2560
    "draw a line (with current paint-color) in device coordinate space.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2561
     This ignores any transformations. The coordinates must be integers."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2562
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2563
    gcId isNil ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2564
	self initGC
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2565
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2566
    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
  2567
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2568
8154
065b15ce117a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8143
diff changeset
  2569
displayDeviceOpaqueForm:aFormOrImage x:x y:y
065b15ce117a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8143
diff changeset
  2570
    "draw a form or image opaque (i.e. both fg and bg is drawn)
065b15ce117a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8143
diff changeset
  2571
     Somewhat backward compatible hacky:
065b15ce117a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8143
diff changeset
  2572
065b15ce117a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8143
diff changeset
  2573
     if it's a 1-plane form, 
065b15ce117a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8143
diff changeset
  2574
        1-bits are drawn in the current paint-color and 
065b15ce117a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8143
diff changeset
  2575
        0-bits in the bgPaint color.
065b15ce117a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8143
diff changeset
  2576
065b15ce117a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8143
diff changeset
  2577
     If it's a deep form (i.e. a pixmap) or an image,
065b15ce117a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8143
diff changeset
  2578
     the current paint/bgPaint settings are ignored and the image is drawn as-is.
065b15ce117a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8143
diff changeset
  2579
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2580
     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
  2581
     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
  2582
     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
  2583
     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
  2584
     its converted here, which slows down the draw.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2585
     Drawing is in device coordinates; no scaling is done."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2586
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2587
    |id w h easy savedPaint bgForm fgForm tmpForm
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2588
     fgId bgId noColor allColor allBits dx dy
8315
d28a7b7f19e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 8312
diff changeset
  2589
     pX pY deviceDepth deviceForm deviceFormGCId map paintClr bgPaintClr|
d28a7b7f19e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 8312
diff changeset
  2590
d28a7b7f19e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 8312
diff changeset
  2591
    (aFormOrImage isImage and:[aFormOrImage hasAlphaChannel]) ifTrue:[
d28a7b7f19e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 8312
diff changeset
  2592
        "Drawing opaque with alpha-channel does not really make sense.
d28a7b7f19e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 8312
diff changeset
  2593
         Draw non-opaque."
d28a7b7f19e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 8312
diff changeset
  2594
        Error handle:[:ex |
d28a7b7f19e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 8312
diff changeset
  2595
            Logger error:'error when drawing alpha: %1' with:ex description.
d28a7b7f19e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 8312
diff changeset
  2596
        ] do:[    
d28a7b7f19e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 8312
diff changeset
  2597
            self displayDeviceFormWithAlpha:aFormOrImage x:x y:y.
d28a7b7f19e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 8312
diff changeset
  2598
        ].
d28a7b7f19e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 8312
diff changeset
  2599
        ^ self.
d28a7b7f19e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 8312
diff changeset
  2600
    ].
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2601
8154
065b15ce117a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8143
diff changeset
  2602
    deviceForm := aFormOrImage asFormOn:device.
8174
2704c965b97b #BUGFIX by Maren
matilk
parents: 8154
diff changeset
  2603
    deviceForm isNil ifTrue:[
2704c965b97b #BUGFIX by Maren
matilk
parents: 8154
diff changeset
  2604
        Logger warning:'invalid form draw (no device form) - ignored'.
2704c965b97b #BUGFIX by Maren
matilk
parents: 8154
diff changeset
  2605
        ^ self
2704c965b97b #BUGFIX by Maren
matilk
parents: 8154
diff changeset
  2606
    ].
7629
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2607
    id := deviceForm drawableId.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2608
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2609
    "temporary ..."
8154
065b15ce117a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8143
diff changeset
  2610
    (id isNil or:[aFormOrImage graphicsDevice ~~ device]) ifTrue:[
7629
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2611
        deviceForm := deviceForm asFormOn:device.
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2612
        id := deviceForm drawableId.
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2613
        id isNil ifTrue:[
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2614
            Logger warning:'invalid form draw (opaque) - ignored'.
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2615
            ^ self
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2616
        ].
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2617
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2618
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2619
    gcId isNil ifTrue:[
7629
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2620
        self initGC
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2621
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2622
8154
065b15ce117a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8143
diff changeset
  2623
    w := aFormOrImage width.
065b15ce117a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8143
diff changeset
  2624
    h := aFormOrImage height.
1592
7ec770f2047a faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents: 1517
diff changeset
  2625
7ec770f2047a faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents: 1517
diff changeset
  2626
    pX := x rounded.
7ec770f2047a faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents: 1517
diff changeset
  2627
    pY := y rounded.
7ec770f2047a faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents: 1517
diff changeset
  2628
8315
d28a7b7f19e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 8312
diff changeset
  2629
    deviceForm isForm ifTrue:[
d28a7b7f19e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 8312
diff changeset
  2630
        deviceFormGCId := deviceForm initGC.
d28a7b7f19e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 8312
diff changeset
  2631
    ].
902
7f5d81d377de opaque image display fix
Claus Gittinger <cg@exept.de>
parents: 895
diff changeset
  2632
    "
7f5d81d377de opaque image display fix
Claus Gittinger <cg@exept.de>
parents: 895
diff changeset
  2633
     a deep form ignores paint/bgPaint settings
7f5d81d377de opaque image display fix
Claus Gittinger <cg@exept.de>
parents: 895
diff changeset
  2634
     and is always drawn opaque.
7f5d81d377de opaque image display fix
Claus Gittinger <cg@exept.de>
parents: 895
diff changeset
  2635
    "
8154
065b15ce117a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8143
diff changeset
  2636
    (aFormOrImage depth ~~ 1) ifTrue:[
7629
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2637
        device
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2638
            copyFromPixmapId:id
7980
c7b42695fdc9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7920
diff changeset
  2639
            x:0 y:0 gc:deviceFormGCId
7629
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2640
            to:drawableId
7980
c7b42695fdc9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7920
diff changeset
  2641
            x:pX y:pY gc:gcId
c7b42695fdc9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7920
diff changeset
  2642
            width:w height:h.
7629
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2643
        ^ self
902
7f5d81d377de opaque image display fix
Claus Gittinger <cg@exept.de>
parents: 895
diff changeset
  2644
    ].
7980
c7b42695fdc9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7920
diff changeset
  2645
c7b42695fdc9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7920
diff changeset
  2646
    paintClr := paint.
c7b42695fdc9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7920
diff changeset
  2647
    bgPaintClr := bgPaint.
8154
065b15ce117a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8143
diff changeset
  2648
065b15ce117a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8143
diff changeset
  2649
    "/ images are always drawn with its own colors
065b15ce117a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8143
diff changeset
  2650
    aFormOrImage isImage ifTrue:[
065b15ce117a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8143
diff changeset
  2651
        paintClr := aFormOrImage colorFromValue:1.
065b15ce117a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8143
diff changeset
  2652
        bgPaintClr := aFormOrImage colorFromValue:0.
065b15ce117a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8143
diff changeset
  2653
    ] ifFalse:[
065b15ce117a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8143
diff changeset
  2654
        "/ a form is drawn in the current paint/bgPaint, 
065b15ce117a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8143
diff changeset
  2655
        "/ it has an explicit colormap
065b15ce117a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8143
diff changeset
  2656
        map := aFormOrImage colorMap.
065b15ce117a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8143
diff changeset
  2657
        map notNil ifTrue:[
065b15ce117a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8143
diff changeset
  2658
            paintClr := map at:2.
065b15ce117a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8143
diff changeset
  2659
            bgPaintClr := map at:1.
065b15ce117a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8143
diff changeset
  2660
        ].
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  2661
    ].
902
7f5d81d377de opaque image display fix
Claus Gittinger <cg@exept.de>
parents: 895
diff changeset
  2662
7f5d81d377de opaque image display fix
Claus Gittinger <cg@exept.de>
parents: 895
diff changeset
  2663
    "/ if no bgPaint is set, this is a non-opaque draw
7980
c7b42695fdc9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7920
diff changeset
  2664
    bgPaintClr isNil ifTrue:[
8154
065b15ce117a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8143
diff changeset
  2665
        self displayDeviceForm:aFormOrImage x:x y:y.
7629
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2666
        ^ self
902
7f5d81d377de opaque image display fix
Claus Gittinger <cg@exept.de>
parents: 895
diff changeset
  2667
    ].
7f5d81d377de opaque image display fix
Claus Gittinger <cg@exept.de>
parents: 895
diff changeset
  2668
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2669
    "the following code is somewhat complicated, since it has to deal
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2670
     with dithered fg/bg colors, which cannot be done directly on most
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2671
     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
  2672
     (just assume drawing a bitmap with dithered fg/bg colors ... sigh)
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2673
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2674
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2675
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2676
     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
  2677
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2678
    easy := true.
7980
c7b42695fdc9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7920
diff changeset
  2679
    paintClr isColor ifFalse:[
7629
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2680
        easy := false
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2681
    ] ifTrue:[
7980
c7b42695fdc9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7920
diff changeset
  2682
        fgId := paintClr colorId.
7629
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2683
        fgId isNil ifTrue:[
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2684
            easy := false
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2685
        ]
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2686
    ].
7980
c7b42695fdc9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7920
diff changeset
  2687
    bgPaintClr isColor ifFalse:[
7629
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2688
        easy := false
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2689
    ] ifTrue:[
7980
c7b42695fdc9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7920
diff changeset
  2690
        bgId := bgPaintClr colorId.
7629
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2691
        bgId isNil ifTrue:[
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2692
            easy := false
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2693
        ]
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2694
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2695
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2696
    easy ifTrue:[
7629
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2697
        "
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2698
         easy: both paint and bgPaint are real colors
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2699
        "
7980
c7b42695fdc9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7920
diff changeset
  2700
        ((foreground ~~ paintClr) or:[background ~~ bgPaintClr]) ifTrue:[
7629
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2701
            device setForeground:fgId background:bgId in:gcId.
7980
c7b42695fdc9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7920
diff changeset
  2702
            "/ foreground := paint.
c7b42695fdc9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7920
diff changeset
  2703
            "/ background := bgPaint.
7629
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2704
        ].
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2705
        device
7980
c7b42695fdc9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7920
diff changeset
  2706
            copyPlaneFromPixmapId:id x:0 y:0 gc:deviceFormGCId
c7b42695fdc9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7920
diff changeset
  2707
            to:drawableId x:pX y:pY gc:gcId
c7b42695fdc9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7920
diff changeset
  2708
            width:w height:h.
c7b42695fdc9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7920
diff changeset
  2709
8154
065b15ce117a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8143
diff changeset
  2710
        "/ restore    
065b15ce117a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8143
diff changeset
  2711
        foreground notNil ifTrue:[ device setForegroundColor:foreground in:gcId ].
065b15ce117a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8143
diff changeset
  2712
        background notNil ifTrue:[ device setBackgroundColor:background in:gcId ].
7629
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2713
        ^ self
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2714
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2715
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2716
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2717
     hard case: paint and/or bgPaint are dithered or patterns
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2718
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2719
    allColor := Color allColor.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2720
    allBits := allColor colorId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2721
    deviceDepth := device depth.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2722
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2723
    (fgId notNil and:[function == #copy]) ifTrue:[
7629
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2724
        "
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2725
         only bg is dithered; fill with bg first ...
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2726
        "
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2727
        savedPaint := paint.
7980
c7b42695fdc9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7920
diff changeset
  2728
        self paint:bgPaintClr.
7629
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2729
        self fillDeviceRectangleX:pX y:pY width:w height:h.
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2730
        self paint:savedPaint.
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2731
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2732
        "
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2733
         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
  2734
         operation ...
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2735
        "
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2736
        ((fgId ~~ ((1 bitShift:deviceDepth)-1))
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2737
        and:[fgId ~~ allBits]) ifTrue:[
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2738
            "
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2739
             clear fg-bits ...
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2740
            "
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2741
            device setForeground:0 background:allBits in:gcId.
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2742
            device setFunction:#and in:gcId.
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2743
            device
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2744
                copyPlaneFromPixmapId:id
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2745
                x:0
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2746
                y:0
7749
f4ad7601ae41 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 7746
diff changeset
  2747
                gc:deviceFormGCId
7629
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2748
                to:drawableId
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2749
                x:pX
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2750
                y:pY
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2751
                gc:gcId
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2752
                width:w
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2753
                height:h
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2754
        ].
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2755
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2756
        fgId ~~ 0 ifTrue:[
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2757
            "
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2758
             or-in fg-bits ...
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2759
            "
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2760
            device setForeground:fgId background:0 in:gcId.
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2761
            device setFunction:#or in:gcId.
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2762
            device
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2763
                copyPlaneFromPixmapId:id
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2764
                x:0
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2765
                y:0
7749
f4ad7601ae41 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 7746
diff changeset
  2766
                gc:deviceFormGCId
7629
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2767
                to:drawableId
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2768
                x:pX
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2769
                y:pY
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2770
                gc:gcId
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2771
                width:w
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2772
                height:h
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2773
        ].
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2774
        "
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2775
         flush foreground/background cache
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2776
        "
7980
c7b42695fdc9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7920
diff changeset
  2777
        "/ foreground := nil.
c7b42695fdc9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7920
diff changeset
  2778
        "/ background := nil.
c7b42695fdc9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7920
diff changeset
  2779
        device setForegroundColor:foreground backgroundColor:background in:gcId.
7629
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2780
        device setFunction:function in:gcId.
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2781
        ^ self
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2782
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2783
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2784
    (bgId notNil and:[function == #copy]) ifTrue:[
7629
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2785
        "
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2786
         only fg is dithered; fill with fg first ...
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2787
        "
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2788
        self fillDeviceRectangleX:pX y:pY width:w height:h.
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2789
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2790
        "
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2791
         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
  2792
         operation ...
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2793
        "
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2794
        ((bgId ~~ ((1 bitShift:deviceDepth)-1))
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2795
        and:[bgId ~~ allBits]) ifTrue:[
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2796
            "
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2797
             clear bg-bits ...
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2798
            "
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2799
            device setForeground:allBits background:0 in:gcId.
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2800
            device setFunction:#and in:gcId.
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2801
            device
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2802
                copyPlaneFromPixmapId:id
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2803
                x:0
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2804
                y:0
7749
f4ad7601ae41 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 7746
diff changeset
  2805
                gc:deviceFormGCId
7629
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2806
                to:drawableId
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2807
                x:pX
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2808
                y:pY
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2809
                gc:gcId
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2810
                width:w
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2811
                height:h
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2812
        ].
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2813
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2814
        "
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2815
         or-in bg-bits ...
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2816
        "
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2817
        bgId ~~ 0 ifTrue:[
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2818
            device setForeground:0 background:bgId in:gcId.
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2819
            device setFunction:#or in:gcId.
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2820
            device
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2821
                copyPlaneFromPixmapId:id
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2822
                x:0
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2823
                y:0
7749
f4ad7601ae41 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 7746
diff changeset
  2824
                gc:deviceFormGCId
7629
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2825
                to:drawableId
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2826
                x:pX
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2827
                y:pY
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2828
                gc:gcId
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2829
                width:w
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2830
                height:h
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2831
        ].
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2832
        "
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2833
         flush foreground/background cache
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2834
        "
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2835
        foreground := nil.
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2836
        background := nil.
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2837
        device setFunction:function in:gcId.
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2838
        ^ self
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2839
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2840
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2841
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2842
     very hard case; both fg and bg are dithered colors
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2843
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2844
    noColor := Color noColor.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2845
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2846
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2847
     create temp-forms;
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2848
    "
4781
7f2473db5652 Change senders of obsolete messages Form>>...on: to ...onDevice:
Stefan Vogel <sv@exept.de>
parents: 4756
diff changeset
  2849
    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
  2850
    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
  2851
    tmpForm := Form width:w height:h depth:deviceDepth onDevice:device.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2852
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2853
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2854
     fill
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
    dx := dy := 0.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2857
    maskOrigin notNil ifTrue:[
7629
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2858
        dx := maskOrigin x.
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2859
        dy := maskOrigin y
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2860
    ].
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
    bgForm paint:bgPaint.
4983
14c28ec55880 Replace usage of obsolete methods
Stefan Vogel <sv@exept.de>
parents: 4914
diff changeset
  2863
    bgForm maskOriginX:(x negated + dx) y:(y negated + dy).
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2864
    bgForm fillRectangleX:0 y:0 width:w height:h.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2865
    fgForm paint:paint.
4983
14c28ec55880 Replace usage of obsolete methods
Stefan Vogel <sv@exept.de>
parents: 4914
diff changeset
  2866
    fgForm maskOriginX:(x negated + dx) y:(y negated + dy).
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2867
    fgForm fillRectangleX:0 y:0 width:w height:h.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2868
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
     stamp-out background
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
    bgForm paint:noColor on:allColor.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2873
    bgForm function:#and.
976
807b42b00353 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 975
diff changeset
  2874
    bgForm displayOpaqueForm:deviceForm x:0 y:0.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2875
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2876
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2877
     stamp-out foreground
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2878
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2879
    fgForm paint:allColor on:noColor.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2880
    fgForm function:#and.
976
807b42b00353 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 975
diff changeset
  2881
    fgForm displayOpaqueForm:deviceForm x:0 y:0.
732
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
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2884
     clear tempform
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2885
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2886
    tmpForm paint:noColor.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2887
    tmpForm fillRectangleX:0 y:0 width:w height:h.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2888
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
     merge fg-temp and bg-temp into tmp
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
    tmpForm function:#or.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2893
    tmpForm paint:noColor on:allColor.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2894
    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
  2895
    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
  2896
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2897
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2898
     finally, draw it
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2899
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2900
    device setForeground:0 background:allBits in:gcId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2901
    device
7629
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2902
        copyFromPixmapId:tmpForm drawableId
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2903
        x:0
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2904
        y:0
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2905
        gc:tmpForm gcId
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2906
        to:drawableId
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2907
        x:pX
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2908
        y:pY
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2909
        gc:gcId
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2910
        width:w
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  2911
        height:h.
1637
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  2912
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  2913
    "
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  2914
     release tempForms immediately
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  2915
     (although GC will eventually do it,
1637
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  2916
      this creates less stress to the Xserver in the meanwhile ...)
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  2917
    "
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  2918
    fgForm destroy.
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  2919
    bgForm destroy.
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  2920
    tmpForm destroy.
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  2921
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2922
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2923
     flush foreground/background cache
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2924
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2925
    foreground := nil.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2926
    background := nil.
868
65c93e5f6f8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 844
diff changeset
  2927
8154
065b15ce117a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8143
diff changeset
  2928
    "Modified: / 31-08-2017 / 19:35:55 / cg"
8174
2704c965b97b #BUGFIX by Maren
matilk
parents: 8154
diff changeset
  2929
    "Modified: / 06-09-2017 / 12:31:45 / Maren"
8315
d28a7b7f19e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 8312
diff changeset
  2930
    "Modified: / 20-03-2018 / 17:27:14 / stefan"
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2931
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2932
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  2933
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
  2934
    "draw a substring at the coordinate x/y - draw foreground pixels in
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2935
     paint-color and background pixels in bgPaint-color.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2936
     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
  2937
     the case where paint and/or bgPaint are dithered colors.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2938
     No translation or scaling is done."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2939
7443
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  2940
    |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
  2941
     deviceDepth fontsEncoding ascent|
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2942
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2943
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2944
     if backgroundPaint color is nil, we assume
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2945
     this is a non-opaque draw
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
    bgPaint isNil ifTrue:[
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  2948
        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
  2949
        ^ self
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2950
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2951
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  2952
    gcId isNil ifTrue:[
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  2953
        self initGC
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  2954
    ].
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  2955
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  2956
    fontUsed := fontArg onDevice:device.
7443
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  2957
    deviceFont ~~ fontUsed ifTrue:[
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  2958
        (fontUsed installInDeviceForGCId:gcId) isNil ifTrue:[
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  2959
            "error - no such font"
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  2960
            ^ self.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  2961
        ].
7443
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  2962
        deviceFont := fontUsed.
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  2963
    ].
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  2964
7510
03f621a9cd9d #BUGFIX by sr
sr
parents: 7502
diff changeset
  2965
    (aString notNil 
03f621a9cd9d #BUGFIX by sr
sr
parents: 7502
diff changeset
  2966
    and:[aString isPlainString not]) ifTrue:[
7064
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  2967
        "
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  2968
         hook for non-strings (i.e. attributed text)
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  2969
         that 'thing' should know how to display itself ...
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  2970
        "
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  2971
        aString displayOpaqueOn:self x:x y:y from:index1 to:index2.
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  2972
        ^ self
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2973
    ].
6210
af0bf039ec07 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6108
diff changeset
  2974
af0bf039ec07 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6108
diff changeset
  2975
    pX := x rounded.
af0bf039ec07 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6108
diff changeset
  2976
    pY := y rounded.
af0bf039ec07 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6108
diff changeset
  2977
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  2978
    aString := aStringArg.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  2979
4026
882de378f763 no longer as string for its encoding;
Claus Gittinger <cg@exept.de>
parents: 3943
diff changeset
  2980
    fontsEncoding := fontUsed encoding.
7288
fec0c6c1087b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7257
diff changeset
  2981
    "/ This is now obsolete, as we are always using unicode internally.
fec0c6c1087b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7257
diff changeset
  2982
    "/ so the next line should be changed to fontsEncoding ~~ #unicode
4056
67c4686afbc6 characterEncoding stuff
Claus Gittinger <cg@exept.de>
parents: 4031
diff changeset
  2983
    (characterEncoding ~~ fontsEncoding) ifTrue:[
7064
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  2984
        [
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  2985
            aString := CharacterEncoder encodeString:aString from:characterEncoding into:fontsEncoding.
7064
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  2986
        ] on:CharacterEncoderError do:[:ex|
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  2987
            "substitute a default value for codes that cannot be represented
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  2988
             in the new character set"
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  2989
            ex proceedWith:ex defaultValue.
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  2990
        ].
4026
882de378f763 no longer as string for its encoding;
Claus Gittinger <cg@exept.de>
parents: 3943
diff changeset
  2991
    ].
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2992
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  2993
    fontUsed isAlienFont ifTrue:[
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  2994
        "
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  2995
         hook for alien fonts
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  2996
         that 'font' should know how to display the string ...
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  2997
        "
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  2998
        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
  2999
        ^ self
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3000
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3001
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3002
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3003
     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
  3004
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3005
    easy := true.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3006
    paint isColor ifFalse:[
7064
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3007
        easy := false
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3008
    ] ifTrue:[
7064
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3009
        fgId := paint colorId.
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3010
        fgId isNil ifTrue:[
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3011
            easy := false
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3012
        ]
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3013
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3014
    bgPaint isColor ifFalse:[
7064
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3015
        easy := false
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3016
    ] ifTrue:[
7064
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3017
        bgId := bgPaint colorId.
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3018
        bgId isNil ifTrue:[
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3019
            easy := false
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3020
        ]
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3021
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3022
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3023
    easy ifTrue:[
7064
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3024
        device setForeground:fgId background:bgId in:gcId.
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3025
        foreground := paint.
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3026
        background := bgPaint.
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3027
        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
  3028
        ^ self
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3029
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3030
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3031
    w := fontUsed widthOf:aString from:index1 to:index2.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3032
    h := fontUsed height.
3666
01d7bf1d2333 fixed Text drawing in displayString
Michael Beyl <mb@exept.de>
parents: 3630
diff changeset
  3033
    ascent := fontUsed ascent.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3034
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3035
    (fgId notNil and:[function == #copy]) ifTrue:[
7064
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3036
        "
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3037
         only bg is dithered; fill with bg first ...
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3038
        "
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3039
        savedPaint := paint.
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3040
        self paint:bgPaint.
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3041
        self fillRectangleX:pX y:(pY - ascent) width:w height:h.
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3042
        self paint:savedPaint.
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3043
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3044
        "
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3045
         then draw using fgPaint (which is a real color)
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3046
        "
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3047
        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
  3048
        ^ self
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3049
    ].
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
    allColor := Color allColor.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3052
    allBits := allColor colorId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3053
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3054
    deviceDepth := device depth.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3055
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3056
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3057
     the code below is correct, but some (all?) implementations of the
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3058
     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
  3059
     Therefore we use the slower code below.
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
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3062
"/    (bgId notNil and:[function == #copy]) ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3063
"/      "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3064
"/       only fg is dithered; fill with fg first ...
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3065
"/      "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3066
"/      self fillRectangleX:pX y:(pY - fontUsed ascent) width:w height:h.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3067
"/
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3068
"/      "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3069
"/       if bgPaint 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
  3070
"/       operation ...
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3071
"/      "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3072
"/      ((bgId ~~ ((1 bitShift:deviceDepth)-1))
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3073
"/      and:[bgId ~~ allBits]) ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3074
"/          "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3075
"/           clear bg bits ...
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3076
"/          "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3077
"/          device setForeground:allBits background:0 in:gcId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3078
"/          device setFunction:#and in:gcId.
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3079
"/          device displayOpaqueString:s
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3080
"/                                from:index1 to:index2
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3081
"/                                   x:pX y:pY
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3082
"/                                  in:drawableId with:gcId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3083
"/      ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3084
"/
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3085
"/      "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3086
"/       or-in bg bits ...
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3087
"/      "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3088
"/      bgId ~~ 0 ifTrue:[
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3089
"/          device setForeground:0 background:bgId in:gcId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3090
"/          device setFunction:#or in:gcId.
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3091
"/          device displayOpaqueString:s
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3092
"/                                from:index1 to:index2
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3093
"/                                   x:pX y:pY
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3094
"/                                  in:drawableId with:gcId.
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
"/       flush foreground/background cache
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3098
"/      "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3099
"/      foreground := nil.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3100
"/      background := nil.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3101
"/      device setFunction:function in:gcId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3102
"/      ^ self
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
768
77e4f9d30a22 fixes for b&w screens
Claus Gittinger <cg@exept.de>
parents: 745
diff changeset
  3105
    (bgId notNil and:[function == #copy]) ifTrue:[
7064
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3106
        "
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3107
         only fg is dithered; fill with bg first ...
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3108
        "
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3109
        device setForeground:bgId in:gcId.
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3110
        device setFunction:#copy in:gcId.
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3111
        device setBitmapMask:nil in:gcId.
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3112
        self fillRectangleX:pX y:(pY - ascent) width:w height:h.
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3113
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3114
        mask notNil ifTrue:[
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3115
            "/ draw fg dithered
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3116
            (mask depth == 1) ifTrue:[
7629
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  3117
                device setBitmapMask:mask drawableId in:gcId.
7064
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3118
                device setForegroundColor:foreground backgroundColor:background in:gcId.
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3119
            ] ifFalse:[
7629
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  3120
                device setPixmapMask:mask drawableId in:gcId
7064
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3121
            ].
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3122
        ].
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3123
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3124
        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
  3125
        ^ self.
832
064890dcfabd fixed opaque string draw with deep-dither
Claus Gittinger <cg@exept.de>
parents: 786
diff changeset
  3126
    ].
064890dcfabd fixed opaque string draw with deep-dither
Claus Gittinger <cg@exept.de>
parents: 786
diff changeset
  3127
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3128
    "
832
064890dcfabd fixed opaque string draw with deep-dither
Claus Gittinger <cg@exept.de>
parents: 786
diff changeset
  3129
     very hard case, both fg and bg are dithered colors/images
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3130
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3131
    noColor := Color noColor.
4026
882de378f763 no longer as string for its encoding;
Claus Gittinger <cg@exept.de>
parents: 3943
diff changeset
  3132
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3133
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3134
     create temp-forms;
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3135
    "
4781
7f2473db5652 Change senders of obsolete messages Form>>...on: to ...onDevice:
Stefan Vogel <sv@exept.de>
parents: 4756
diff changeset
  3136
    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
  3137
    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
  3138
    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
  3139
    maskForm := Form width:w height:h depth:deviceDepth onDevice:device.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3140
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3141
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3142
     fill
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
    dx := 0.
3666
01d7bf1d2333 fixed Text drawing in displayString
Michael Beyl <mb@exept.de>
parents: 3630
diff changeset
  3145
    dy := ascent.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3146
    maskOrigin notNil ifTrue:[
7064
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3147
        dx := maskOrigin x.
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3148
        dy := dy + maskOrigin y
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3149
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3150
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3151
    bgForm paint:bgPaint.
4983
14c28ec55880 Replace usage of obsolete methods
Stefan Vogel <sv@exept.de>
parents: 4914
diff changeset
  3152
    bgForm maskOriginX:(pX negated + dx) y:(pY negated + dy).
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3153
    bgForm fillRectangleX:0 y:0 width:w height:h.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3154
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3155
    fgForm paint:paint.
4983
14c28ec55880 Replace usage of obsolete methods
Stefan Vogel <sv@exept.de>
parents: 4914
diff changeset
  3156
    fgForm maskOriginX:(pX negated + dx) y:(pY negated + dy).
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3157
    fgForm fillRectangleX:0 y:0 width:w height:h.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3158
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3159
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3160
     stamp-out background (have now bg-bits with fg=0 in bgForm)
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3161
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3162
    bgForm font:fontUsed.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3163
    bgForm paint:noColor on:allColor.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3164
    bgForm function:#and.
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3165
    bgForm displayString:aString from:index1 to:index2 x:0 y:ascent.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3166
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3167
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3168
     stamp-out foreground
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3169
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3170
    maskForm font:fontUsed.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3171
    maskForm paint:allColor on:noColor.
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3172
    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
  3173
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3174
    fgForm function:#and.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3175
    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
  3176
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3177
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3178
     clear tempform
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3179
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3180
    tmpForm paint:noColor.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3181
    tmpForm fillRectangleX:0 y:0 width:w height:h.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3182
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3183
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3184
     merge fg-temp and bg-temp into tmp
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3185
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3186
    tmpForm function:#or.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3187
    tmpForm paint:noColor on:allColor.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3188
    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
  3189
    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
  3190
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3191
     finally, draw it
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3192
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3193
    device setForeground:0 background:allBits in:gcId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3194
    device
7629
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  3195
        copyFromId:tmpForm drawableId
7064
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3196
        x:0 y:0 gc:tmpForm gcId
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3197
        to:drawableId
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3198
        x:pX y:(pY-ascent) gc:gcId
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3199
        width:w height:h.
1637
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  3200
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  3201
    "
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  3202
     release tempForms immediately
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3203
     (although GC will eventually do it,
1637
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  3204
      this creates less stress to the Xserver in the meanwhile ...)
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  3205
    "
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  3206
    tmpForm destroy.
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  3207
    fgForm destroy.
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  3208
    bgForm destroy.
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  3209
    maskForm destroy.
4e6372dce15d release temporary forms early
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  3210
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3211
    "
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3212
     flush foreground/background cache
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
    foreground := nil.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3215
    background := nil.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3216
1805
532a11ba8458 tuned-out another send if encoding is wrong in display-string
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  3217
    "Modified: 1.7.1997 / 17:08:46 / cg"
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3218
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3219
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3220
displayDeviceOpaqueString:aString from:index1 to:index2 x:x y:y
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3221
    "draw a substring at the coordinate x/y - draw foreground pixels in
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3222
     paint-color and background pixels in bgPaint-color.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3223
     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
  3224
     the case where paint and/or bgPaint are dithered colors.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3225
     No translation or scaling is done."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3226
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3227
    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
  3228
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3229
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3230
displayDeviceOpaqueString:aString x:x y:y
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3231
    "draw a string at the coordinate x/y - draw foreground pixels in
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3232
     paint-color and background pixels in bgPaint-color.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3233
     No translation or scaling is done"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3234
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3235
    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
  3236
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3237
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3238
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
  3239
    "draw a substring at the coordinate x/y -
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3240
     draw foreground-pixels only (in current paint-color), leaving background as-is.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3241
     No translation or scaling is done"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3242
7443
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  3243
    |fontUsed aString fontsEncoding|
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3244
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
     hook for non-strings (i.e. attributed text)
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3247
    "
7064
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3248
    aString isPlainString ifFalse:[
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3249
        ^ aString displayOn:self x:x y:y from:index1 to:index2
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3250
    ].
6210
af0bf039ec07 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6108
diff changeset
  3251
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3252
    gcId isNil ifTrue:[
7064
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3253
        self initGC
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3254
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3255
7443
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  3256
    fontUsed := fontArg onDevice:device.
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  3257
    deviceFont ~~ fontUsed ifTrue:[
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  3258
        (fontUsed installInDeviceForGCId:gcId) isNil ifTrue:[
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  3259
            "error - no such font"
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  3260
            ^ self.
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  3261
        ].
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  3262
        deviceFont := fontUsed.
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  3263
    ].
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  3264
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3265
    aString := aStringArg.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3266
7443
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  3267
    fontsEncoding := fontUsed encoding.
4056
67c4686afbc6 characterEncoding stuff
Claus Gittinger <cg@exept.de>
parents: 4031
diff changeset
  3268
    (characterEncoding ~~ fontsEncoding) ifTrue:[
7064
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3269
        [
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3270
            aString := CharacterEncoder encodeString:aString from:characterEncoding into:fontsEncoding.
7064
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3271
        ] on:CharacterEncoderError do:[:ex|
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3272
            "substitute a default value for codes that cannot be represented
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3273
             in the new character set"
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3274
            ex proceedWith:ex defaultValue.
42f4e6c435e6 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7063
diff changeset
  3275
        ].
4026
882de378f763 no longer as string for its encoding;
Claus Gittinger <cg@exept.de>
parents: 3943
diff changeset
  3276
    ].
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3277
    fontUsed isAlienFont ifTrue:[
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
         hook for alien fonts
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3280
         that 'font' should know how to display the string ...
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
        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
  3283
        ^ self
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3284
    ].
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3285
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3286
    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
  3287
1805
532a11ba8458 tuned-out another send if encoding is wrong in display-string
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  3288
    "Modified: 1.7.1997 / 17:08:48 / cg"
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3289
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3290
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3291
displayDeviceString:aString from:index1 to:index2 x:x y:y
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3292
    "draw a substring at the coordinate x/y -
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3293
     draw foreground-pixels only (in current paint-color), leaving background as-is.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3294
     No translation or scaling is done"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3295
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3296
    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
  3297
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3298
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3299
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
  3300
    "draw a substring at the coordinate x/y -
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3301
     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
  3302
     No translation or scaling is done"
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3303
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3304
    gcId isNil ifTrue:[
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3305
        self initGC
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3306
    ].
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3307
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3308
    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
  3309
!
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3310
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3311
displayDeviceString:aString x:x y:y
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3312
    "draw a string at the coordinate x/y -
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3313
     draw foreground-pixels only (in current paint-color), leaving background as-is.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3314
     No translation or scaling is done"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3315
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3316
    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
  3317
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3318
8439
2e6fff05e9d7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8372
diff changeset
  3319
fillDevicePolygon:aCollectionOfPoints
2e6fff05e9d7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8372
diff changeset
  3320
    "draw a filled polygon in device coordinates"
2e6fff05e9d7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8372
diff changeset
  3321
2e6fff05e9d7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8372
diff changeset
  3322
    gcId isNil ifTrue:[
2e6fff05e9d7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8372
diff changeset
  3323
        self initGC
2e6fff05e9d7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8372
diff changeset
  3324
    ].
2e6fff05e9d7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8372
diff changeset
  3325
    device fillPolygon:aCollectionOfPoints in:drawableId with:gcId
2e6fff05e9d7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8372
diff changeset
  3326
2e6fff05e9d7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8372
diff changeset
  3327
    "Created: / 04-08-2018 / 14:31:03 / Claus Gittinger"
2e6fff05e9d7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8372
diff changeset
  3328
!
2e6fff05e9d7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8372
diff changeset
  3329
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3330
fillDeviceRectangleX:x y:y width:w height:h
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3331
    "draw a filled rectangle in device coordinate space.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3332
     This ignores any transformations. The coordinates must be integers."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3333
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3334
    gcId isNil ifTrue:[
7746
7ad93b0b1545 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 7697
diff changeset
  3335
        self initGC
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3336
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3337
    device
7746
7ad93b0b1545 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 7697
diff changeset
  3338
        fillRectangleX:x y:y
7ad93b0b1545 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 7697
diff changeset
  3339
        width:w height:h
7ad93b0b1545 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 7697
diff changeset
  3340
        in:drawableId with:gcId
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3341
! !
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3342
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3343
!DeviceGraphicsContext methodsFor:'evaluating in another context'!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3344
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3345
reverseDo:aBlock
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3346
    "evaluate aBlock with foreground and background interchanged.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3347
     This can be reimplemented here in a faster way."
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
    |oldFg oldBg|
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3350
2835
963425946ff3 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 2714
diff changeset
  3351
    oldFg := foreground.
963425946ff3 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 2714
diff changeset
  3352
    oldBg := background.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3353
    self foreground:background background:foreground.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3354
    aBlock value.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3355
    self foreground:oldFg background:oldBg
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3356
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3357
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3358
withBackground:fgColor do:aBlock
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3359
    "evaluate aBlock with changed background."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3360
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3361
    |oldBg|
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3362
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3363
    oldBg := background.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3364
    self background:fgColor.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3365
    aBlock value.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3366
    self background:oldBg
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3367
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3368
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3369
withForeground:fgColor background:bgColor do:aBlock
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3370
    "evaluate aBlock with changed foreground and background."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3371
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3372
    |oldFg oldBg|
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3373
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3374
    oldFg := foreground.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3375
    oldBg := background.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3376
    self foreground:fgColor background:bgColor.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3377
    aBlock value.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3378
    self foreground:oldFg background:oldBg
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3379
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3380
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3381
withForeground:fgColor background:bgColor function:aFunction do:aBlock
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3382
    "evaluate aBlock with foreground, background and function"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3383
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3384
    |oldFg oldBg oldFun|
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3385
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3386
    oldFg := foreground.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3387
    oldBg := background.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3388
    oldFun := function.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3389
    self foreground:fgColor background:bgColor function:aFunction.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3390
    aBlock value.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3391
    self foreground:oldFg background:oldBg function:oldFun
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3392
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3393
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3394
withForeground:fgColor background:bgColor mask:aMask do:aBlock
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3395
    "evaluate aBlock with foreground, background and mask"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3396
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3397
    |oldFg oldBg oldMask|
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3398
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3399
    oldFg := foreground.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3400
    oldBg := background.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3401
    oldMask := mask.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3402
    self foreground:fgColor background:bgColor.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3403
    self mask:aMask.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3404
    aBlock value.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3405
    self foreground:oldFg background:oldBg.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3406
    self mask:oldMask
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3407
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3408
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3409
withForeground:fgColor do:aBlock
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3410
    "evaluate aBlock with changed foreground."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3411
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3412
    |oldFg|
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
    oldFg := foreground.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3415
    self foreground:fgColor.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3416
    aBlock value.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3417
    self foreground:oldFg
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3418
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3419
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3420
withForeground:fgColor function:aFunction do:aBlock
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3421
    "evaluate aBlock with changed foreground and function."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3422
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3423
    |oldFg oldFun|
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3424
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3425
    oldFg := foreground.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3426
    oldFun := function.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3427
    self foreground:fgColor background:background function:aFunction.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3428
    aBlock value.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3429
    self foreground:oldFg background:background function:oldFun
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3430
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3431
7759
45386945d6d7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7752
diff changeset
  3432
withPaint:aColor do:aBlock
45386945d6d7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7752
diff changeset
  3433
    "evaluate aBlock with changed paint color."
45386945d6d7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7752
diff changeset
  3434
45386945d6d7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7752
diff changeset
  3435
    |oldPaint|
45386945d6d7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7752
diff changeset
  3436
45386945d6d7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7752
diff changeset
  3437
    oldPaint := paint.
45386945d6d7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7752
diff changeset
  3438
    self paint:aColor.
45386945d6d7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7752
diff changeset
  3439
    aBlock value.
45386945d6d7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7752
diff changeset
  3440
    self paint:oldPaint
45386945d6d7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7752
diff changeset
  3441
!
45386945d6d7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7752
diff changeset
  3442
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3443
xoring:aBlock
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3444
    "evaluate aBlock with function xoring"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3445
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3446
    |fgPixel bgPixel oldFunction|
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3447
2322
6c42f2e0213c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2271
diff changeset
  3448
    fgPixel := device blackpixel.
6c42f2e0213c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2271
diff changeset
  3449
    bgPixel := device whitepixel.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3450
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3451
    gcId isNil ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3452
	self initGC
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3453
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3454
    oldFunction := function.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3455
    device setForeground:(fgPixel bitXor:bgPixel)
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3456
	      background:bgPixel
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3457
		      in:gcId.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3458
    device setFunction:#xor in:gcId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3459
    aBlock value.
2322
6c42f2e0213c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2271
diff changeset
  3460
2879
f1e9b8310d4e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2865
diff changeset
  3461
    paint := bgPaint := nil.        "invalidate"
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3462
    foreground := device blackColor.
1199
f113f6a4c04a use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents: 1177
diff changeset
  3463
    background := device whiteColor.
2322
6c42f2e0213c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2271
diff changeset
  3464
    device setForeground:fgPixel background:bgPixel in:gcId.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3465
    device setFunction:oldFunction in:gcId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3466
    function := oldFunction
1199
f113f6a4c04a use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents: 1177
diff changeset
  3467
2322
6c42f2e0213c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2271
diff changeset
  3468
    "Modified: / 10.9.1998 / 12:17:39 / cg"
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3469
! !
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3470
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3471
!DeviceGraphicsContext methodsFor:'filling'!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3472
5837
28301409379c added: #clearDeviceRectangleX:y:width:height:
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3473
clearDeviceRectangleX:x y:y width:w height:h
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3474
    "clear a rectangular area to background"
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3475
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3476
    |oldPaint|
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3477
5837
28301409379c added: #clearDeviceRectangleX:y:width:height:
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3478
    oldPaint := paint.
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3479
    self paint:bgPaint.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3480
    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
  3481
    self paint:oldPaint
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3482
!
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3483
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3484
clearRectangleX:left y:top width:w height:h
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3485
    "clear the rectangular area in the receiver to background"
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3486
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3487
    |oldPaint|
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3488
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3489
    oldPaint := paint.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3490
    self paint:bgPaint.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3491
    self fillRectangleX:left y:top width:w height:h.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3492
    self paint:oldPaint
5837
28301409379c added: #clearDeviceRectangleX:y:width:height:
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3493
!
28301409379c added: #clearDeviceRectangleX:y:width:height:
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3494
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3495
fillArcX:x y:y width:w height:h from:startAngle angle:angle
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3496
    "draw a filled arc; apply transformation if nonNil"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3497
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  3498
    |pX pY nW nH sA a pO pC|
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3499
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3500
    gcId isNil ifTrue:[
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3501
	self initGC
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3502
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3503
    transformation notNil ifTrue:[
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3504
	pO := transformation transformPoint:x@y.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3505
	pC := transformation transformPoint:(x+w-1)@(y+h-1).
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3506
	pX := pO x.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3507
	pY := pO y.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3508
	nW := pC x - pX + 1.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3509
	nH := pC y - pY + 1.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3510
	nW < 0 ifTrue:[
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3511
	      nW := nW abs.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3512
	      pX := pX - nW.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3513
	].
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3514
	nH < 0 ifTrue:[
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3515
	      nH := nH abs.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3516
	      pY := pY - nH.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3517
	].
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3518
    ] ifFalse:[
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3519
	pX := x.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3520
	pY := y.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3521
	nW := w.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3522
	nH := h.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3523
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3524
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3525
    pX := pX rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3526
    pY := pY rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3527
    nW := nW rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3528
    nH := nH rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3529
2268
1a774fc02c83 fixed non-float (i.e. fraction) args to fillArc/ displayArc
Claus Gittinger <cg@exept.de>
parents: 2259
diff changeset
  3530
    sA := startAngle.
1a774fc02c83 fixed non-float (i.e. fraction) args to fillArc/ displayArc
Claus Gittinger <cg@exept.de>
parents: 2259
diff changeset
  3531
    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
  3532
    a := angle.
1a774fc02c83 fixed non-float (i.e. fraction) args to fillArc/ displayArc
Claus Gittinger <cg@exept.de>
parents: 2259
diff changeset
  3533
    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
  3534
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3535
    device
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3536
	  fillArcX:pX
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3537
		 y:pY
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3538
	     width:nW
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3539
	    height:nH
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3540
	      from:sA
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3541
	     angle:a
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3542
		in:drawableId
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3543
	      with:gcId
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3544
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3545
    "Created: 8.5.1996 / 08:29:45 / cg"
784
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
  3546
    "Modified: 4.6.1996 / 17:58:21 / cg"
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3547
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3548
8439
2e6fff05e9d7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8372
diff changeset
  3549
fillPolygon:aCollectionOfPoints
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3550
    "draw a filled polygon; apply transformation if nonNil"
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
    |newPolygon|
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3553
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3554
    gcId isNil ifTrue:[
8439
2e6fff05e9d7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8372
diff changeset
  3555
        self initGC
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3556
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3557
    transformation notNil ifTrue:[
8439
2e6fff05e9d7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8372
diff changeset
  3558
        newPolygon := aCollectionOfPoints collect:[:point | transformation transformPoint:point].
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3559
    ] ifFalse:[
8439
2e6fff05e9d7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8372
diff changeset
  3560
        newPolygon := aCollectionOfPoints
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3561
    ].
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3562
    (newPolygon contains:[:p |
8439
2e6fff05e9d7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8372
diff changeset
  3563
        (p isPoint not
2e6fff05e9d7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8372
diff changeset
  3564
        or:[(p x class ~~ SmallInteger)
2e6fff05e9d7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8372
diff changeset
  3565
        or:[(p y class ~~ SmallInteger)]])
4521
6f065906e740 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4477
diff changeset
  3566
     ]) ifTrue:[
8439
2e6fff05e9d7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8372
diff changeset
  3567
        newPolygon := newPolygon collect:[:p | p asPoint rounded]
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3568
    ].
8439
2e6fff05e9d7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8372
diff changeset
  3569
    device fillPolygon:newPolygon in:drawableId with:gcId
2e6fff05e9d7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8372
diff changeset
  3570
2e6fff05e9d7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8372
diff changeset
  3571
    "Modified (format): / 04-08-2018 / 14:31:25 / Claus Gittinger"
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3572
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3573
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3574
fillRectangleX:x y:y width:w height:h
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3575
    "draw a filled rectangle; apply transformation if nonNil"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3576
6691
d044fff3447c class: DeviceGraphicsContext
Claus Gittinger <cg@exept.de>
parents: 6645
diff changeset
  3577
    |pX pY nW nH pO pC|
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3578
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3579
    gcId isNil ifTrue:[
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3580
	self initGC
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3581
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3582
    transformation notNil ifTrue:[
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3583
	pO := transformation transformPoint:x@y.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3584
	pC := transformation transformPoint:(x+w-1)@(y+h-1).
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3585
	pX := pO x.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3586
	pY := pO y.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3587
	nW := pC x - pX + 1.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3588
	nH := pC y - pY + 1.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3589
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3590
	nW < 0 ifTrue:[
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3591
	      nW := nW abs.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3592
	      pX := pX - nW.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3593
	].
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3594
	nH < 0 ifTrue:[
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3595
	      nH := nH abs.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3596
	      pY := pY - nH.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3597
	].
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3598
    ] ifFalse:[
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3599
	pX := x.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3600
	pY := y.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3601
	nW := w.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3602
	nH := h.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3603
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3604
    pX := pX rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3605
    pY := pY rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3606
    nW := nW rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3607
    nH := nH rounded.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3608
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3609
    device
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3610
	fillRectangleX:pX
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3611
		     y:pY
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3612
		 width:nW
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3613
		height:nH
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3614
		    in:drawableId with:gcId
784
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
  3615
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
  3616
    "Modified: 4.6.1996 / 17:58:49 / cg"
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3617
! !
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3618
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3619
!DeviceGraphicsContext methodsFor:'finalization'!
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3620
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3621
executor
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3622
    drawableType == #window ifTrue:[
7752
81c84fab0aac #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 7749
diff changeset
  3623
        ^ DeviceWindowGCHandle basicNew
81c84fab0aac #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 7749
diff changeset
  3624
            setDevice:device id:drawableId gcId:gcId parentId:parentId.
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3625
    ] ifFalse:[
7752
81c84fab0aac #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 7749
diff changeset
  3626
        ^ DevicePixmapGCHandle basicNew
81c84fab0aac #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 7749
diff changeset
  3627
            setDevice:device id:drawableId gcId:gcId.
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3628
    ].
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3629
!
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3630
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3631
finalizationLobby
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3632
    "answer the registry used for finalization.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3633
     DeviceGraphicContexts have their own Registry"
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3634
7443
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  3635
    ^ device graphicsContexts
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3636
! !
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3637
3883
4e01a59afccb method category rename
Claus Gittinger <cg@exept.de>
parents: 3880
diff changeset
  3638
!DeviceGraphicsContext methodsFor:'initialization & release'!
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3639
1517
ac751bb3dfdf no need for registration here;
Claus Gittinger <cg@exept.de>
parents: 1514
diff changeset
  3640
close
ac751bb3dfdf no need for registration here;
Claus Gittinger <cg@exept.de>
parents: 1514
diff changeset
  3641
    "same as destroy - for ST-80 compatibility"
ac751bb3dfdf no need for registration here;
Claus Gittinger <cg@exept.de>
parents: 1514
diff changeset
  3642
ac751bb3dfdf no need for registration here;
Claus Gittinger <cg@exept.de>
parents: 1514
diff changeset
  3643
    self destroy
ac751bb3dfdf no need for registration here;
Claus Gittinger <cg@exept.de>
parents: 1514
diff changeset
  3644
ac751bb3dfdf no need for registration here;
Claus Gittinger <cg@exept.de>
parents: 1514
diff changeset
  3645
    "Created: 2.4.1997 / 19:31:27 / cg"
ac751bb3dfdf no need for registration here;
Claus Gittinger <cg@exept.de>
parents: 1514
diff changeset
  3646
!
ac751bb3dfdf no need for registration here;
Claus Gittinger <cg@exept.de>
parents: 1514
diff changeset
  3647
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3648
createGC
1453
e93293618275 only fetch id's once in displayForm.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  3649
    "physically create a device GC.
e93293618275 only fetch id's once in displayForm.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  3650
     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
  3651
     really drawn, none is created up to the first draw.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3652
     This method is sent, when the first drawing happens"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3653
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3654
    drawableType == #pixmap ifTrue:[
7443
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  3655
        gcId := device gcForBitmap:drawableId.
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3656
    ] ifFalse:[
7443
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  3657
        gcId := device gcFor:drawableId.
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3658
    ].
7443
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  3659
    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
  3660
e93293618275 only fetch id's once in displayForm.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  3661
    "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
  3662
!
4a2b3b407cae need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents: 1094
diff changeset
  3663
4a2b3b407cae need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents: 1094
diff changeset
  3664
destroy
6222
2d670d3bcfd5 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6215
diff changeset
  3665
    |id|
2d670d3bcfd5 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6215
diff changeset
  3666
2d670d3bcfd5 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6215
diff changeset
  3667
    id := gcId.
2d670d3bcfd5 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6215
diff changeset
  3668
    id notNil ifTrue:[
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3669
        gcId := nil.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3670
        device destroyGC:id.
6222
2d670d3bcfd5 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6215
diff changeset
  3671
    ].
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3672
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3673
    id := drawableId.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3674
    id notNil ifTrue:[
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3675
        drawableId := nil.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3676
        drawableType == #window ifTrue:[
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3677
            device destroyView:nil withId:id.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3678
        ] ifFalse:[
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3679
            device destroyPixmap:id.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3680
        ].
7443
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  3681
        device unregisterGraphicsContext:self.    
6266
1503c5e038d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  3682
    ].
1503c5e038d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  3683
!
1503c5e038d2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6235
diff changeset
  3684
1138
4a2b3b407cae need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents: 1094
diff changeset
  3685
initGC
4a2b3b407cae need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents: 1094
diff changeset
  3686
    "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
  3687
     really drawn, none is created.
7749
f4ad7601ae41 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 7746
diff changeset
  3688
     This method is sent, when the first drawing happens.
f4ad7601ae41 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 7746
diff changeset
  3689
     Answer the gcId."
1138
4a2b3b407cae need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents: 1094
diff changeset
  3690
4135
a47337e09c40 preset font if already ok for device
werner
parents: 4070
diff changeset
  3691
    |fgId bgId p fontId|
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3692
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3693
    gcId notNil ifTrue:[
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3694
        "already initialized"
7749
f4ad7601ae41 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 7746
diff changeset
  3695
        ^ gcId
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3696
    ].
1514
7c2a921ae46b better error report when drawing on closed view.
Claus Gittinger <cg@exept.de>
parents: 1507
diff changeset
  3697
    drawableId isNil ifTrue:[
7406
e35784ee543c #OTHER by mawalch
mawalch
parents: 7396
diff changeset
  3698
        "/
e35784ee543c #OTHER by mawalch
mawalch
parents: 7396
diff changeset
  3699
        "/ the drawable has been closed (or was never open)
e35784ee543c #OTHER by mawalch
mawalch
parents: 7396
diff changeset
  3700
        "/ no drawing is possible.
e35784ee543c #OTHER by mawalch
mawalch
parents: 7396
diff changeset
  3701
        "/
e35784ee543c #OTHER by mawalch
mawalch
parents: 7396
diff changeset
  3702
        ^ DrawingOnClosedDrawableSignal raiseRequest
1514
7c2a921ae46b better error report when drawing on closed view.
Claus Gittinger <cg@exept.de>
parents: 1507
diff changeset
  3703
    ].
1138
4a2b3b407cae need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents: 1094
diff changeset
  3704
    self createGC.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3705
1199
f113f6a4c04a use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents: 1177
diff changeset
  3706
    foreground isNil ifTrue:[foreground := device blackColor].
f113f6a4c04a use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents: 1177
diff changeset
  3707
    background isNil ifTrue:[background := device whiteColor].
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3708
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3709
    foreground isColor ifTrue:[
7406
e35784ee543c #OTHER by mawalch
mawalch
parents: 7396
diff changeset
  3710
        "get device colors from the device indep. colors"
e35784ee543c #OTHER by mawalch
mawalch
parents: 7396
diff changeset
  3711
        foreground := foreground onDevice:device.
e35784ee543c #OTHER by mawalch
mawalch
parents: 7396
diff changeset
  3712
        fgId := foreground colorId.
e35784ee543c #OTHER by mawalch
mawalch
parents: 7396
diff changeset
  3713
        fgId isNil ifTrue:[
e35784ee543c #OTHER by mawalch
mawalch
parents: 7396
diff changeset
  3714
            (foreground grayIntensity >= 50) ifTrue:[
e35784ee543c #OTHER by mawalch
mawalch
parents: 7396
diff changeset
  3715
                fgId := device whitepixel
e35784ee543c #OTHER by mawalch
mawalch
parents: 7396
diff changeset
  3716
            ] ifFalse:[
e35784ee543c #OTHER by mawalch
mawalch
parents: 7396
diff changeset
  3717
                fgId := device blackpixel
e35784ee543c #OTHER by mawalch
mawalch
parents: 7396
diff changeset
  3718
            ]
e35784ee543c #OTHER by mawalch
mawalch
parents: 7396
diff changeset
  3719
        ].
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3720
    ] ifFalse:[
7406
e35784ee543c #OTHER by mawalch
mawalch
parents: 7396
diff changeset
  3721
        fgId := device blackpixel.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3722
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3723
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3724
    background isColor ifTrue:[
7406
e35784ee543c #OTHER by mawalch
mawalch
parents: 7396
diff changeset
  3725
        background := background onDevice:device.
e35784ee543c #OTHER by mawalch
mawalch
parents: 7396
diff changeset
  3726
        bgId := background colorId.
e35784ee543c #OTHER by mawalch
mawalch
parents: 7396
diff changeset
  3727
        bgId isNil ifTrue:[
e35784ee543c #OTHER by mawalch
mawalch
parents: 7396
diff changeset
  3728
            (background grayIntensity >= 50) ifTrue:[
e35784ee543c #OTHER by mawalch
mawalch
parents: 7396
diff changeset
  3729
                bgId := device whitepixel
e35784ee543c #OTHER by mawalch
mawalch
parents: 7396
diff changeset
  3730
            ] ifFalse:[
e35784ee543c #OTHER by mawalch
mawalch
parents: 7396
diff changeset
  3731
                bgId := device blackpixel
e35784ee543c #OTHER by mawalch
mawalch
parents: 7396
diff changeset
  3732
            ]
e35784ee543c #OTHER by mawalch
mawalch
parents: 7396
diff changeset
  3733
        ].
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3734
    ] ifFalse:[
7406
e35784ee543c #OTHER by mawalch
mawalch
parents: 7396
diff changeset
  3735
        bgId := device whitepixel
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
    "now, this is something the device can work with ..."
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3739
    device setForeground:fgId background:bgId in:gcId.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3740
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3741
    "switch to paint"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3742
    p := paint.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3743
    paint := nil.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3744
    self paint:p.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3745
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3746
    ((lineWidth ~~ 0)
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3747
    or:[(lineStyle ~~ #solid)
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3748
    or:[(capStyle ~~ #butt)
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3749
    or:[joinStyle ~~ #miter]]]) ifTrue:[
7406
e35784ee543c #OTHER by mawalch
mawalch
parents: 7396
diff changeset
  3750
        device setLineWidth:lineWidth
e35784ee543c #OTHER by mawalch
mawalch
parents: 7396
diff changeset
  3751
                      style:lineStyle
e35784ee543c #OTHER by mawalch
mawalch
parents: 7396
diff changeset
  3752
                        cap:capStyle
e35784ee543c #OTHER by mawalch
mawalch
parents: 7396
diff changeset
  3753
                       join:joinStyle
e35784ee543c #OTHER by mawalch
mawalch
parents: 7396
diff changeset
  3754
                         in:gcId
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3755
    ].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3756
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3757
    mask notNil ifTrue:[
7406
e35784ee543c #OTHER by mawalch
mawalch
parents: 7396
diff changeset
  3758
        (mask depth == 1) ifTrue:[
7629
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  3759
            device setBitmapMask:(mask drawableId) in:gcId
7406
e35784ee543c #OTHER by mawalch
mawalch
parents: 7396
diff changeset
  3760
        ] ifFalse:[
7629
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  3761
            device setPixmapMask:(mask drawableId) in:gcId
7406
e35784ee543c #OTHER by mawalch
mawalch
parents: 7396
diff changeset
  3762
        ].
e35784ee543c #OTHER by mawalch
mawalch
parents: 7396
diff changeset
  3763
        maskOrigin notNil ifTrue:[
e35784ee543c #OTHER by mawalch
mawalch
parents: 7396
diff changeset
  3764
            device setMaskOriginX:maskOrigin x y:maskOrigin y in:gcId
e35784ee543c #OTHER by mawalch
mawalch
parents: 7396
diff changeset
  3765
        ]
732
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
    (function ~~ #copy) ifTrue:[device setFunction:function in:gcId].
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3768
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3769
    "defer the getting of a device font
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3770
     - this is now done when the first drawstring occurs,
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3771
     since many views (layout-views) will never draw strings and
7406
e35784ee543c #OTHER by mawalch
mawalch
parents: 7396
diff changeset
  3772
     therefore, the overhead of acquiring a font can be avoided.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3773
    "
1138
4a2b3b407cae need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents: 1094
diff changeset
  3774
"/    font := font on:device.
4a2b3b407cae need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents: 1094
diff changeset
  3775
"/    id := font fontId.
4a2b3b407cae need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents: 1094
diff changeset
  3776
"/    id notNil ifTrue:[
4a2b3b407cae need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents: 1094
diff changeset
  3777
"/        device setFont:id in:gcId
4a2b3b407cae need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents: 1094
diff changeset
  3778
"/    ]
1199
f113f6a4c04a use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents: 1177
diff changeset
  3779
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3780
    (font notNil 
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3781
      and:[font graphicsDevice == device 
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3782
      and:[(fontId := font fontId) notNil]]) ifTrue:[
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3783
        deviceFont := font.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3784
        device setFont:fontId in:gcId
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  3785
    ].
7749
f4ad7601ae41 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 7746
diff changeset
  3786
    ^ gcId.
4664
02d160974029 fix remembering deviceFont everywhere.
Claus Gittinger <cg@exept.de>
parents: 4657
diff changeset
  3787
02d160974029 fix remembering deviceFont everywhere.
Claus Gittinger <cg@exept.de>
parents: 4657
diff changeset
  3788
    "Modified: / 22-10-2006 / 14:10:53 / cg"
4291
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3789
!
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3790
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3791
initialize
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3792
    "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
  3793
     initColors and initFont, which are usually redefined."
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3794
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3795
    super initialize.
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3796
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3797
    "/ just in case, someone redefined new without setting device
6234
404d91662d49 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6225
diff changeset
  3798
    (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
  3799
6273
d1000b29b5b2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6271
diff changeset
  3800
    foreground isNil ifTrue:[foreground := self blackColor].
d1000b29b5b2 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6271
diff changeset
  3801
    background isNil ifTrue:[background := self whiteColor].
4291
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3802
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3803
    "Modified: 10.1.1997 / 17:46:51 / cg"
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3804
!
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3805
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3806
prepareForReinit
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3807
    "kludge - clear drawableId and gcId
4291
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3808
     needed after snapin"
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3809
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3810
    gcId := nil.
7443
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  3811
    drawableId := parentId := nil.
4291
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3812
    deviceFont := nil
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3813
!
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3814
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3815
recreate
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3816
    "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
  3817
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3818
    gcId := nil.
7443
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  3819
    drawableId := parentId := nil.
4291
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3820
    foreground notNil ifTrue:[
7443
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  3821
        foreground := foreground onDevice:device
4291
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3822
    ].
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3823
    background notNil ifTrue:[
7443
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  3824
        background := background onDevice:device
4291
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3825
    ].
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3826
    paint notNil ifTrue:[
7443
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  3827
        paint := paint onDevice:device
4291
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3828
    ].
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3829
    bgPaint notNil ifTrue:[
7443
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  3830
        bgPaint := bgPaint onDevice:device
4291
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3831
    ].
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3832
    font notNil ifTrue:[
7443
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  3833
        font := deviceFont := font onDevice:device
4291
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3834
    ]
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3835
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3836
    "Modified: 28.10.1996 / 13:25:02 / cg"
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3837
!
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3838
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3839
releaseGC
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  3840
    "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
  3841
     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
  3842
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3843
    |id|
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3844
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3845
    foreground := background := paint := bgPaint := nil.
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3846
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3847
    id := gcId.
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3848
    id notNil ifTrue:[
7443
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  3849
        gcId := nil.
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  3850
        device destroyGC:id.
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  3851
        device unregisterGraphicsContext:self.
4291
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3852
    ].
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3853
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3854
    "Created: 11.6.1996 / 22:07:30 / cg"
85475200669d nil gcId before desroying GC
Stefan Vogel <sv@exept.de>
parents: 4204
diff changeset
  3855
    "Modified: 2.4.1997 / 19:36:30 / cg"
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3856
! !
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3857
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3858
!DeviceGraphicsContext methodsFor:'private'!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3859
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3860
setDevice:aDevice id:aDrawbleId gcId:aGCId
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3861
    "private"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3862
7443
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  3863
    self device:aDevice.
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  3864
    drawableId := aDrawbleId.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3865
    gcId := aGCId.
7445
b792207e3545 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7443
diff changeset
  3866
    (aDrawbleId notNil and:[aDevice notNil]) ifTrue:[
b792207e3545 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7443
diff changeset
  3867
        aDevice registerGraphicsContext:self.
b792207e3545 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7443
diff changeset
  3868
    ].
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3869
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3870
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3871
setGCForPaint
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3872
    "private; given a complex color (i.e. a pixmap or dithered color,
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3873
     setup the GC to draw in this color.
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3874
     A helper for paint and paint:on:"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3875
832
064890dcfabd fixed opaque string draw with deep-dither
Claus Gittinger <cg@exept.de>
parents: 786
diff changeset
  3876
    |dither map pixelId p fg bg vOrg ditherDepth deviceDepth|
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3877
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3878
    gcId notNil ifTrue:[
7423
3be657fc460f #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7416
diff changeset
  3879
        paint isSymbol ifTrue:[
3be657fc460f #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7416
diff changeset
  3880
            "map symbols to colors"
3be657fc460f #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7416
diff changeset
  3881
            paint := Color perform:paint ifNotUnderstood:[Color yellow].
3be657fc460f #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7416
diff changeset
  3882
        ].
3be657fc460f #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7416
diff changeset
  3883
        p := paint.
3be657fc460f #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7416
diff changeset
  3884
3be657fc460f #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7416
diff changeset
  3885
        p isColor ifTrue:[
3be657fc460f #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7416
diff changeset
  3886
            paint := p := p onDevice:device.
3be657fc460f #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7416
diff changeset
  3887
            pixelId := p colorId.
3be657fc460f #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7416
diff changeset
  3888
            pixelId notNil ifTrue:[
3be657fc460f #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7416
diff changeset
  3889
                "
3be657fc460f #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7416
diff changeset
  3890
                 a real (undithered) color
3be657fc460f #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7416
diff changeset
  3891
                "
3be657fc460f #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7416
diff changeset
  3892
                mask notNil ifTrue:[
3be657fc460f #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7416
diff changeset
  3893
                    mask := nil.
3be657fc460f #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7416
diff changeset
  3894
                    device setBitmapMask:nil in:gcId
3be657fc460f #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7416
diff changeset
  3895
                ].
3be657fc460f #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7416
diff changeset
  3896
                (p ~~ foreground) ifTrue:[
3be657fc460f #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7416
diff changeset
  3897
                    foreground := paint.
3be657fc460f #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7416
diff changeset
  3898
                    device setForeground:pixelId in:gcId
3be657fc460f #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7416
diff changeset
  3899
                ].
3be657fc460f #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7416
diff changeset
  3900
                ^ self
3be657fc460f #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7416
diff changeset
  3901
            ].
3be657fc460f #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7416
diff changeset
  3902
            "a dithered color"
3be657fc460f #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7416
diff changeset
  3903
            dither := paint ditherForm.
3be657fc460f #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7416
diff changeset
  3904
        ] ifFalse:[
3be657fc460f #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7416
diff changeset
  3905
            "mhmh - seems to be some kind of form ..."
3be657fc460f #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7416
diff changeset
  3906
            paint := paint onDevice:device.
3be657fc460f #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7416
diff changeset
  3907
            dither := paint.
8616
5a205ced085c #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8611
diff changeset
  3908
            dither isColor ifTrue:[^ self].
7423
3be657fc460f #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7416
diff changeset
  3909
        ].
3be657fc460f #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7416
diff changeset
  3910
        "
3be657fc460f #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7416
diff changeset
  3911
         a dithered color or image
3be657fc460f #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7416
diff changeset
  3912
        "
3be657fc460f #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7416
diff changeset
  3913
        (ditherDepth := dither depth) == 1 ifTrue:[
3be657fc460f #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7416
diff changeset
  3914
            "a simple 0/1 bitmap"
3be657fc460f #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7416
diff changeset
  3915
            map := dither colorMap.
3be657fc460f #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7416
diff changeset
  3916
            "temporary (kludgy) fix for destroyed paint"
3be657fc460f #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7416
diff changeset
  3917
            p := paint.
3be657fc460f #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7416
diff changeset
  3918
            map isNil ifTrue:[
3be657fc460f #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7416
diff changeset
  3919
                fg := self blackColor.
3be657fc460f #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7416
diff changeset
  3920
                bg := self whiteColor.
3be657fc460f #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7416
diff changeset
  3921
            ] ifFalse:[
3be657fc460f #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7416
diff changeset
  3922
                fg := map at:2.
3be657fc460f #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7416
diff changeset
  3923
                bg := map at:1.
3be657fc460f #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7416
diff changeset
  3924
            ].
3be657fc460f #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7416
diff changeset
  3925
            self foreground:fg background:bg.
3be657fc460f #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7416
diff changeset
  3926
            paint := p
3be657fc460f #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7416
diff changeset
  3927
        ] ifFalse:[
3be657fc460f #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7416
diff changeset
  3928
            deviceDepth := device depth.
3be657fc460f #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7416
diff changeset
  3929
            (ditherDepth ~~ deviceDepth) ifTrue:[
3be657fc460f #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7416
diff changeset
  3930
                dither := dither asFormOn:device.
3be657fc460f #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7416
diff changeset
  3931
                ditherDepth := dither depth.
3be657fc460f #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7416
diff changeset
  3932
                (dither isNil or:[ditherDepth ~~ deviceDepth]) ifTrue:[
3be657fc460f #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7416
diff changeset
  3933
                    self error:'bad dither'.
3be657fc460f #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7416
diff changeset
  3934
                    ^ self
3be657fc460f #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7416
diff changeset
  3935
                ]
3be657fc460f #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7416
diff changeset
  3936
            ]
3be657fc460f #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7416
diff changeset
  3937
        ].
3be657fc460f #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7416
diff changeset
  3938
        self mask:dither.
3be657fc460f #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7416
diff changeset
  3939
        vOrg := self viewOrigin.
3be657fc460f #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7416
diff changeset
  3940
        self maskOriginX:vOrg x negated y:vOrg y negated.
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3941
    ]
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3942
8616
5a205ced085c #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8611
diff changeset
  3943
    "Created: / 16-05-1996 / 15:35:51 / cg"
5a205ced085c #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8611
diff changeset
  3944
    "Modified: / 06-06-1997 / 12:55:38 / cg"
5a205ced085c #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8611
diff changeset
  3945
    "Modified: / 25-01-2019 / 17:09:21 / Claus Gittinger"
2049
1ceec8ef240e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2031
diff changeset
  3946
!
1ceec8ef240e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2031
diff changeset
  3947
7445
b792207e3545 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7443
diff changeset
  3948
setId:aDrawableId
2049
1ceec8ef240e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2031
diff changeset
  3949
    "private"
1ceec8ef240e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2031
diff changeset
  3950
7445
b792207e3545 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7443
diff changeset
  3951
    drawableId := aDrawableId
2049
1ceec8ef240e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2031
diff changeset
  3952
1ceec8ef240e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2031
diff changeset
  3953
    "Created: / 6.2.1998 / 12:44:45 / cg"
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3954
! !
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3955
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3956
!DeviceGraphicsContext methodsFor:'queries'!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3957
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3958
horizontalIntegerPixelPerMillimeter
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3959
    "return the (rounded) number of pixels per millimeter"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3960
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3961
    ^ device horizontalPixelPerMillimeter rounded
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3962
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3963
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3964
horizontalPixelPerInch
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3965
    "return the number of horizontal pixels per inch of the display"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3966
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3967
    ^ device horizontalPixelPerMillimeter * 25.4
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3968
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3969
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3970
horizontalPixelPerMillimeter
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3971
    "return the number of pixels per millimeter (not rounded)"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3972
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3973
    ^ device horizontalPixelPerMillimeter
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3974
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3975
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3976
horizontalPixelPerMillimeter:millis
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3977
    "return the number of pixels (not rounded) for millis millimeter"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3978
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3979
    ^ device horizontalPixelPerMillimeter * millis
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3980
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3981
784
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
  3982
resolution
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
  3983
    "return a point consisting of pixel-per-inch horizontally and vertically."
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
  3984
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
  3985
    ^ device resolution
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
  3986
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
  3987
    "Created: 4.6.1996 / 15:23:55 / cg"
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
  3988
!
be774c8a672f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 768
diff changeset
  3989
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3990
verticalIntegerPixelPerMillimeter
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3991
    "return the (rounded) number of pixels per millimeter"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3992
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3993
    ^ device verticalPixelPerMillimeter rounded
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3994
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3995
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3996
verticalPixelPerInch
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3997
    "return the number of vertical pixels per inch of the display"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3998
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3999
    ^ device verticalPixelPerMillimeter * 25.4
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4000
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4001
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4002
verticalPixelPerMillimeter
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4003
    "return the number of pixels per millimeter (not rounded)"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4004
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4005
    ^ device verticalPixelPerMillimeter
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4006
!
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4007
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4008
verticalPixelPerMillimeter:millis
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4009
    "return the number of pixels (not rounded) for millis millimeter"
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4010
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4011
    ^ device verticalPixelPerMillimeter * millis
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4012
! !
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4013
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  4014
!DeviceGraphicsContext methodsFor:'testing'!
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  4015
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  4016
isPixmap
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  4017
    ^ drawableType == #pixmap
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  4018
!
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  4019
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  4020
isWindow
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  4021
    ^ drawableType == #window
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  4022
! !
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  4023
6225
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4024
!DeviceGraphicsContext methodsFor:'view creation'!
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4025
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4026
createBitmapFromArray:data width:width height:height
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4027
    "create a bitmap from data and set the drawableId"
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  4028
7443
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  4029
    drawableType := #pixmap.
6225
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4030
    drawableId := device createBitmapFromArray:data width:width height:height.
7443
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  4031
    device registerGraphicsContext:self.    "this is a registerChange:"
6225
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4032
!
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4033
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4034
createPixmapWidth:w height:h depth:d
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4035
    "create a pixmap and set the drawableId"
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  4036
6225
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4037
    drawableId := device createPixmapWidth:w height:h depth:d.
7356
e6d6fa1a7057 #FEATURE by sr
sr
parents: 7350
diff changeset
  4038
    drawableId isNil ifTrue:[
7443
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  4039
        "/ creation failed
7588
fde403dd9571 #OTHER by mawalch
mawalch
parents: 7582
diff changeset
  4040
        ('[GC] warning: pixmap creation failed: ',((OperatingSystem lastErrorString) ? 'unknown error')) errorPrintCR.
7443
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  4041
        ^ GraphicsDevice::GraphicResourceAllocationFailure query
7356
e6d6fa1a7057 #FEATURE by sr
sr
parents: 7350
diff changeset
  4042
    ].
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  4043
    drawableType := #pixmap.
7443
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  4044
    device registerGraphicsContext:self.    "this is a registerChange:"
6225
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4045
!
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4046
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  4047
createRootWindowFor:aView
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  4048
    drawableId := device rootWindowFor:aView.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  4049
    drawableType := #window.
6234
404d91662d49 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6225
diff changeset
  4050
!
404d91662d49 class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6225
diff changeset
  4051
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  4052
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
  4053
    "create a window and set the drawableId"
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  4054
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  4055
    |container|
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  4056
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  4057
    drawableId := device
7443
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  4058
            createWindowFor:aView
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  4059
            type:typeSymbol
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  4060
            origin:org
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  4061
            extent:ext
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  4062
            minExtent:minE
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  4063
            maxExtent:maxE
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  4064
            borderWidth:bw
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  4065
            subViewOf:sv
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  4066
            style:styleSymbol
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  4067
            inputOnly:inp
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  4068
            label:label
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  4069
            owner:owner
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  4070
            icon:icn
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  4071
            iconMask:icnM
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  4072
            iconView:icnV.
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  4073
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  4074
    drawableType := #window.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  4075
    container := aView container.
7629
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  4076
    container notNil ifTrue:[ parentId := container drawableId].
7443
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  4077
    device registerGraphicsContext:self.    "this is a registerChange:"
6225
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4078
! !
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4079
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4080
!DeviceGraphicsContext methodsFor:'view properties'!
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4081
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4082
backingStore:how
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4083
    "turn on/off backingStore (saving my pixels)
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4084
     how may true/false, but also #always, #whenMapped or #never."
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4085
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4086
    drawableId notNil ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  4087
	device setBackingStore:how in:drawableId
6225
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4088
    ]
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4089
!
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4090
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4091
bitGravity:gravity
7582
1117b57d97a1 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7560
diff changeset
  4092
    "set the bitGravity 
1117b57d97a1 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7560
diff changeset
  4093
     - 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
  4094
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4095
    drawableId notNil ifTrue:[
7582
1117b57d97a1 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7560
diff changeset
  4096
        device setBitGravity:gravity in:drawableId
6225
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4097
    ]
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4098
!
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4099
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4100
saveUnder:aBoolean
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4101
    "turn on/off saveUnder (saving pixels under myself)
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4102
     - used for temporary views (i.e. PopUps and ModalBoxes)"
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4103
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4104
    drawableId notNil ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  4105
	device setSaveUnder:aBoolean in:drawableId
6225
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4106
    ]
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4107
!
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4108
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4109
setCursorId:id
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4110
    drawableId notNil ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  4111
	device setCursor:id in:drawableId.
6225
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4112
    ]
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4113
!
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4114
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4115
setWindowPid: pid
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4116
    "Sets the _NET_WM_PID property for the window.
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4117
     This may be used by the window manager to group windows.
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4118
     If anIntegerOrNil is nil, then PID of currently running
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4119
     Smalltalk is used"
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4120
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4121
    drawableId notNil ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  4122
	device setWindowPid:pid in:drawableId.
6225
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4123
    ].
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4124
!
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4125
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4126
viewGravity:gravity
7582
1117b57d97a1 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7560
diff changeset
  4127
    "set the viewGravity 
1117b57d97a1 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7560
diff changeset
  4128
     - 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
  4129
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4130
    drawableId notNil ifTrue:[
7582
1117b57d97a1 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7560
diff changeset
  4131
        device setWindowGravity:gravity in:drawableId
6225
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4132
    ].
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4133
!
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4134
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4135
windowBorderShape:aForm
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4136
    "set the windows border shape"
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4137
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4138
    drawableId notNil ifTrue:[
7629
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  4139
        device setWindowBorderShape:(aForm drawableId) in:drawableId
6225
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4140
    ].
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4141
!
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4142
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4143
windowClass:windowClassNameString name:nameString
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4144
    "define class and name of a window.
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4145
     This may be used by the window manager to
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4146
     select client specific resources."
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4147
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4148
    drawableId notNil ifTrue:[
6292
b5e02ca45876 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6290
diff changeset
  4149
	device setWindowClass:windowClassNameString name:nameString in:drawableId.
6225
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4150
    ].
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4151
!
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4152
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4153
windowName:aString
7697
4ec49456e2e2 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7651
diff changeset
  4154
    "define the view's name in the window's title area."
6225
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4155
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4156
    drawableId notNil ifTrue: [
7697
4ec49456e2e2 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7651
diff changeset
  4157
        device setWindowName:aString in:drawableId.
6225
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4158
    ]
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4159
!
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4160
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4161
windowShape:aForm
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4162
    "set the windows shape.
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4163
     Returns false, if the display does not support the
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4164
     X shape extension."
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4165
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4166
    drawableId notNil ifTrue:[
7629
d1f082c00e07 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7588
diff changeset
  4167
        ^ device setWindowShape:(aForm drawableId) in:drawableId
6225
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4168
    ].
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4169
    ^ false.
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4170
! !
b953824e744c class: DeviceGraphicsContext
Stefan Vogel <sv@exept.de>
parents: 6222
diff changeset
  4171
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  4172
!DeviceGraphicsContext::DevicePixmapGCHandle methodsFor:'accessing'!
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  4173
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  4174
parentId
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  4175
    "pixmaps do not have a parent"
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  4176
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  4177
    ^ nil
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  4178
! !
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  4179
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  4180
!DeviceGraphicsContext::DevicePixmapGCHandle methodsFor:'finalization'!
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  4181
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  4182
finalize
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  4183
    "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
  4184
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  4185
    |id|
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  4186
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  4187
    drawableId notNil ifTrue:[
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  4188
	(id := gcId) notNil ifTrue:[
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  4189
	    gcId := nil.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  4190
	    device destroyGC:id.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  4191
	].
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  4192
	id := drawableId.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  4193
	drawableId := nil.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  4194
	device destroyPixmap:id.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  4195
    ]
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  4196
! !
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  4197
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  4198
!DeviceGraphicsContext::DeviceWindowGCHandle methodsFor:'accessing'!
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  4199
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  4200
parentId
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  4201
    ^ parentId
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  4202
! !
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  4203
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  4204
!DeviceGraphicsContext::DeviceWindowGCHandle methodsFor:'finalization'!
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  4205
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  4206
finalize
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  4207
    "the view for which I am a handle was collected
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  4208
     - release system resources"
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  4209
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  4210
    drawableId notNil ifTrue:[
7443
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  4211
        [
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  4212
            (device viewIdKnown:drawableId) ifTrue:[
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  4213
"/ 'Display [info]: recycled view (' infoPrint. v infoPrint. ') not destroyed: ' infoPrint.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  4214
"/ drawableId displayString infoPrintCR.
7443
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  4215
                drawableId := nil.
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  4216
            ] ifFalse:[
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  4217
                |id|
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  4218
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  4219
                (id := gcId) notNil ifTrue:[
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  4220
                    gcId := nil.
8651
7adde1d5d441 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 8648
diff changeset
  4221
                    device deviceIOErrorSignal catch:[
7443
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  4222
                        device destroyGC:id.
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  4223
                    ]
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  4224
                ].
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  4225
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  4226
                id := drawableId.
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  4227
                drawableId := nil.
8651
7adde1d5d441 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 8648
diff changeset
  4228
                device deviceIOErrorSignal catch:[
7443
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  4229
                    device destroyView:nil withId:id.
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  4230
                ].
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  4231
7920
522478f29bab #DOCUMENTATION by mawalch
mawalch
parents: 7882
diff changeset
  4232
                "When a window is destroyed, all its subwindows are also destroyed.
7443
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  4233
                 Unregister all the subwindows, to avoid destroying of reused windowIds
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  4234
                 later."
7476
801c3083d451 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  4235
                device cleanupLobbyForChildrenOfViewWithId:id.
7443
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  4236
            ]
e2d05b756727 Use devices registry
Stefan Vogel <sv@exept.de>
parents: 7423
diff changeset
  4237
        ] valueUninterruptably.
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  4238
    ].
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  4239
7920
522478f29bab #DOCUMENTATION by mawalch
mawalch
parents: 7882
diff changeset
  4240
    "Created: / 25-09-1997 / 10:01:46 / stefan"
522478f29bab #DOCUMENTATION by mawalch
mawalch
parents: 7882
diff changeset
  4241
    "Modified: / 15-11-2001 / 14:17:12 / cg"
522478f29bab #DOCUMENTATION by mawalch
mawalch
parents: 7882
diff changeset
  4242
    "Modified (comment): / 21-02-2017 / 14:23:18 / mawalch"
8651
7adde1d5d441 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 8648
diff changeset
  4243
    "Modified: / 01-03-2019 / 17:38:56 / Stefan Vogel"
7416
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  4244
! !
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  4245
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  4246
!DeviceGraphicsContext::DeviceWindowGCHandle methodsFor:'private-accessing'!
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  4247
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  4248
setDevice:aDevice id:aDrawableId gcId:aGCId parentId:parentIdArg
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  4249
    "set the handles contents"
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  4250
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  4251
    device := aDevice.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  4252
    drawableId := aDrawableId.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  4253
    gcId := aGCId.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  4254
    parentId := parentIdArg.
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  4255
! !
bd3b9e9edd9e Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents: 7406
diff changeset
  4256
1085
3513a4cae87b handle depth1-images with a mask
Claus Gittinger <cg@exept.de>
parents: 1064
diff changeset
  4257
!DeviceGraphicsContext class methodsFor:'documentation'!
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4258
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4259
version
6926
d04d6d93b921 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6765
diff changeset
  4260
    ^ '$Header$'
5360
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  4261
!
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  4262
878079de94f0 added: #displayString:from:to:x:y:opaque:
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  4263
version_CVS
6926
d04d6d93b921 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6765
diff changeset
  4264
    ^ '$Header$'
732
af737b0a3a37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4265
! !
3880
c4c8268a2d9f method category rename
Claus Gittinger <cg@exept.de>
parents: 3666
diff changeset
  4266