Merge jv
authorJan Vrany <jan.vrany@fit.cvut.cz>
Sun, 09 Oct 2016 22:55:22 +0100
branchjv
changeset 7600 8b42a8f0f649
parent 7599 84f6853ec60d (current diff)
parent 7598 fa0cfb5cedc1 (diff)
child 7602 f1afeef47a60
Merge
Image.st
SimpleView.st
WinWorkstation.st
--- a/Colormap.st	Mon Oct 03 12:49:54 2016 +0100
+++ b/Colormap.st	Sun Oct 09 22:55:22 2016 +0100
@@ -321,7 +321,7 @@
     blueVector := ByteArray new:sz.
 
     1 to:sz do:[:i |
-        |clr r g b|
+        |clr|
 
         clr := aCollectionOfColors at:i.
         clr notNil ifTrue:[
--- a/Depth8Image.st	Mon Oct 03 12:49:54 2016 +0100
+++ b/Depth8Image.st	Sun Oct 09 22:55:22 2016 +0100
@@ -1,3 +1,5 @@
+"{ Encoding: utf8 }"
+
 "
  COPYRIGHT (c) 1993 by Claus Gittinger
 	      All Rights Reserved
@@ -2592,6 +2594,10 @@
     ^ super colorFromValue:pixelValue
 !
 
+nColorsUsed
+    ^ colorMap size
+!
+
 realUsedValues
     "return a collection of color values used in the receiver."
 
--- a/Image.st	Mon Oct 03 12:49:54 2016 +0100
+++ b/Image.st	Sun Oct 09 22:55:22 2016 +0100
@@ -10210,16 +10210,14 @@
      and especially, the color allocations)."
 
     |yS "{Class: SmallInteger }"
-     yE "{Class: SmallInteger }"
-     yR|
+     yE "{Class: SmallInteger }"|
 
     yS := yStart.
     yE := yEnd.
 
     yS to:yE do:[:yRun |
-        yR := yRun.
         self colorsAtY:yRun from:xStart to:xEnd do:[:xRun :color |
-            aBlock value:xRun value:yR value:color
+            aBlock value:xRun value:yRun value:color
         ]
     ]
 
@@ -13634,9 +13632,9 @@
         numRedBits := bitsPerSample at:1.
         numGreenBits := bitsPerSample at:2.
         numBlueBits := bitsPerSample at:3.
-        (r == 0) ifFalse:[ r := (100 / ((1 bitShift:numRedBits)-1) * r)].
-        (g == 0) ifFalse:[ g := (100 / ((1 bitShift:numGreenBits)-1) * g)].
-        (b == 0) ifFalse:[ b := (100 / ((1 bitShift:numBlueBits)-1) * b)].
+        (r ~~ 0) ifTrue:[ r := 100 / ((1 bitShift:numRedBits) - 1) * r].
+        (g ~~ 0) ifTrue:[ g := 100 / ((1 bitShift:numGreenBits) - 1) * g].
+        (b ~~ 0) ifTrue:[ b := 100 / ((1 bitShift:numBlueBits) - 1) * b].
         ^ Color redPercent:r greenPercent:g bluePercent:b
     ].
 
@@ -13862,6 +13860,10 @@
 
 !
 
+nColorsUsed
+    ^ self realUsedValues size
+!
+
 pixelArraySpecies
     "return the kind of pixel-value container in rowAt:/rowAt:put: methods"
 
@@ -14139,18 +14141,19 @@
                 ^ nil
             ]
         ].
-        "/ code below is slightly faster ...
-        "/ colors := usedValues collect:[:pixel | self colorFromValue:pixel].
-        colors := usedValues collect:[:pixel | |r g b|
-                                        r := self redBitsOf:pixel.
-                                        g := self greenBitsOf:pixel.
-                                        b := self blueBitsOf:pixel.
-                                        "/ must scale to byte value...
-                                        r := r bitShift:(8 - (bitsPerSample at:1)).
-                                        g := g bitShift:(8 - (bitsPerSample at:2)).
-                                        b := b bitShift:(8 - (bitsPerSample at:3)).
-                                        Color redByte:r greenByte:g blueByte:b
-                                     ].
+"/        colors := usedValues collect:[:pixel | self colorFromValue:pixel].
+        "/ this code is slightly faster (but wrong for 16-bit images)...
+        colors := usedValues collect:[:pixel | 
+                    |r g b|
+                    r := self redBitsOf:pixel.
+                    g := self greenBitsOf:pixel.
+                    b := self blueBitsOf:pixel.
+                    "/ must scale to byte value...
+                    r := r bitShift:(8 - (bitsPerSample at:1)).
+                    g := g bitShift:(8 - (bitsPerSample at:2)).
+                    b := b bitShift:(8 - (bitsPerSample at:3)).
+                    Color redByte:r greenByte:g blueByte:b
+                 ].
         ^ colors.
     ].
 
--- a/SimpleView.st	Mon Oct 03 12:49:54 2016 +0100
+++ b/SimpleView.st	Sun Oct 09 22:55:22 2016 +0100
@@ -10111,14 +10111,18 @@
      are known to ignore this ..."
 
     realized ifFalse:[
-        "
-         now, make the view visible
-        "
-        realized := true.
-        device
-            mapView:self id:self drawableId iconified:false
-            atX:left y:top width:width height:height
-            minExtent:(self minExtent) maxExtent:(self maxExtent)
+        self drawableId isNil ifTrue:[
+            self realize
+        ] ifFalse:[    
+            "
+             now, make the view visible
+            "
+            realized := true.
+            device
+                mapView:self id:self drawableId iconified:false
+                atX:left y:top width:width height:height
+                minExtent:(self minExtent) maxExtent:(self maxExtent)
+        ]
     ]
 
     "Created: 8.5.1996 / 09:33:06 / cg"
--- a/WinWorkstation.st	Mon Oct 03 12:49:54 2016 +0100
+++ b/WinWorkstation.st	Sun Oct 09 22:55:22 2016 +0100
@@ -1,5 +1,3 @@
-"{ Encoding: utf8 }"
-
 "
 COPYRIGHT (c) 1996 by Claus Gittinger
 	      All Rights Reserved
@@ -2086,7 +2084,7 @@
 		    }
 		    goto again;
 		}
-		/* fail evtl. später ändern und in st verzögert aufrufen
+		/* fail evtl. spter ndern und in st verzgert aufrufen
 		*/
 		console_fprintf(stderr, "WinWorkstation [info]: UnregisterClass %s failed.\n",(char*)ev->ev_arg1);
 	    }
@@ -17756,15 +17754,15 @@
     "If the function succeeds, the return value is a handle to the window that has the specified class name
      and window name. If the function fails, the return value is NULL."
 
-    ((lpClassName notNil and:[lpClassName bitsPerCharacter > 8])
-    or:[ (lpWindowName notNil and:[lpWindowName bitsPerCharacter > 8]) ]) ifTrue:[
-	^ self
-	    primFindWindowW:(lpClassName isNil
-				    ifTrue:[nil]
-				    ifFalse:[lpClassName asUnicode16String asAsciiZ])
-	    windowName:(lpWindowName isNil
-				    ifTrue:[nil]
-				    ifFalse:[lpWindowName asUnicode16String asAsciiZ])
+    ((lpClassName notNil and:[lpClassName isWideString])
+     or:[lpWindowName notNil and:[lpWindowName isWideString]]) ifTrue:[
+        ^ self
+            primFindWindowW:(lpClassName isNil
+                                    ifTrue:[nil]
+                                    ifFalse:[lpClassName asUnicode16StringZ])
+            windowName:(lpWindowName isNil
+                                    ifTrue:[nil]
+                                    ifFalse:[lpWindowName asUnicode16StringZ])
     ].
     ^ self primFindWindowA:lpClassName windowName:lpWindowName
 
@@ -18266,7 +18264,7 @@
     <apicall: handle "FindWindowA" (lpstr lpstr) module: "user32.dll" >
 
     "
-     self primFindWindow: nil windowName: 'WORK2 ST/X Launcher [FELIXM]'
+     Display primFindWindowA: nil windowName: 'ST/X Launcher'
     "
 !
 
@@ -18274,10 +18272,10 @@
     "If the function succeeds, the return value is a handle to the window that has the specified
      class name and window name. If the function fails, the return value is NULL."
 
-    <apicall: handle "FindWindowW" (lpstr lpstr) module: "user32.dll" >
-
-    "
-     self primFindWindow: nil windowName: 'WORK2 ST/X Launcher [FELIXM]' asAsciiZ
+    <apicall: handle "FindWindowW" (pointer pointer) module: "user32.dll" >
+
+    "
+     Display primFindWindowW: nil windowName: 'ST/X Launcher' asUnicode16String 
     "
 !
 
@@ -18304,7 +18302,7 @@
      The SendMessage function calls the window procedure for the specified window and
      does not return until the target's window procedure has processed the message."
 
-    <apicall: bool "SendMessageA" (handle uint ulong ulong) module: "user32.dll" >
+    <apicall: bool "SendMessageA" (handle uint pointer pointer) module: "user32.dll" >
 !
 
 primSetForegroundWindow: aWindowId
@@ -18640,29 +18638,25 @@
 sendCopyData: aByteArray toWindowId: aWindowId
     "send copy-paste data to a window by id (handle)"
 
-    |externalBytes messageType wParam lParam copyDataStruct result|
+    |externalBytes messageType lParam copyDataStruct|
 
     (aWindowId isNil or:[aWindowId address == 0]) ifTrue:[^ self].
 
     messageType := 74 "WM_COPYDATA".
-    wParam := 0.
-
+
+    externalBytes := aByteArray asExternalBytesUnprotected.
     copyDataStruct := CopyDataStructStructure new.
-    copyDataStruct cbData:aByteArray size.
-    externalBytes := ExternalBytes from:aByteArray.
-    copyDataStruct lpData:externalBytes address.
-    lParam := ExternalBytes from:copyDataStruct.
-    result := self primSendMessage:aWindowId message:messageType wParam:wParam lParam:lParam address.
-    externalBytes free.
-    lParam free.
-    ^ result
-
-    "
-     |string bytes externalAddress handle|
-
-     string := 'c:\pipo.net' , 0 asCharacter asString.
-     bytes := string asByteArray.
-     handle := Display primFindWindow: nil windowName: 'ST/X Launcher [FELIXM]' asAsciiZ.
+    copyDataStruct 
+        cbData:externalBytes size;
+        lpData:externalBytes address.
+    lParam := copyDataStruct asExternalBytesUnprotected.
+    ^ self primSendMessage:aWindowId message:messageType wParam:nil lParam:lParam.
+
+    "
+     |bytes externalAddress handle|
+
+     bytes := 'c:\pipo.net' asByteArray.
+     handle := Display primFindWindowA: nil windowName: 'ST/X Launcher'.
      (handle isNil or:[handle address == 0]) ifTrue:[self halt.].
      externalAddress := handle asExternalAddress.
      Display setForegroundWindow: externalAddress.
@@ -18680,13 +18674,12 @@
     self sendCopyData: aByteArray toWindowId: aWindowId
 
     "
-     |string externalAddress handle|
-     string := 'c:\pipo.net' , 0 asCharacter asString.
-     handle := Display primFindWindow: nil windowName: 'WORK6 ST/X Launcher [FELIXM]' asAsciiZ.
+     |externalAddress handle|
+     handle := Display primFindWindowA: nil windowName: 'Windows-Befehlsprozessor'.
      (handle isNil or:[handle address == 0]) ifTrue:[self halt.].
      externalAddress := handle asExternalAddress.
      Display setForegroundWindow: externalAddress.
-     Display sendCopyDataString: string toWindowId: externalAddress.
+     Display sendCopyDataString: 'c:\windows\notepad.exe' toWindowId: externalAddress.
     "
 !
 
@@ -19167,7 +19160,7 @@
     }
 %}
     "
-     (StandardSystemView new label:'äöü') open
+     (StandardSystemView new label:'') open
     "
 !
 
@@ -19421,7 +19414,9 @@
 !WinWorkstation::CopyDataStructStructure class methodsFor:'accessing'!
 
 sizeInBytes
-
+    ExternalAddress pointerSize == 8 ifTrue:[
+        ^ 20.
+    ].
     ^ 12
 ! !
 
@@ -19435,33 +19430,45 @@
 !WinWorkstation::CopyDataStructStructure methodsFor:'accessing'!
 
 cbData
-
-    ^ self doubleWordAt: 4 + 1
+    ExternalAddress pointerSize == 8 ifTrue:[
+        ^ self unsignedInt64At: 8 + 1.
+    ].
+    ^ self unsignedInt32At: 4 + 1.
 !
 
 cbData: cbData
-
-    ^ self doubleWordAt: 4 + 1 put: cbData
+    ExternalAddress pointerSize == 8 ifTrue:[
+        ^ self unsignedInt64At: 8 + 1  put: cbData.
+    ].
+    ^ self unsignedInt32At: 4 + 1  put: cbData.
 !
 
 dwData
-
-    ^ self doubleWordAt: 0 + 1
+    ExternalAddress pointerSize == 8 ifTrue:[
+        ^ self unsignedInt64At: 0 + 1.
+    ].
+    ^ self unsignedInt32At: 0 + 1.
 !
 
 dwData: dwData
-
-    ^ self doubleWordAt: 0 + 1 put: dwData
+    ExternalAddress pointerSize == 8 ifTrue:[
+        ^ self unsignedInt64At: 0 + 1 put:dwData.
+    ].
+    ^ self unsignedInt32At: 0 + 1 put:dwData.
 !
 
 lpData
-
-    ^ self doubleWordAt: 8 + 1
+    ExternalAddress pointerSize == 8 ifTrue:[
+        ^ self unsignedInt64At: 12 + 1.
+    ].
+    ^ self unsignedInt32At: 8 + 1.
 !
 
 lpData: lpData
-
-    ^ self doubleWordAt: 8 + 1 put: lpData
+    ExternalAddress pointerSize == 8 ifTrue:[
+        ^ self unsignedInt64At: 12 + 1  put: lpData.
+    ].
+    ^ self unsignedInt32At: 8 + 1  put: lpData.
 ! !
 
 !WinWorkstation::MonitorInfo methodsFor:'accessing'!