Merge jv
authorJan Vrany <jan.vrany@fit.cvut.cz>
Sun, 11 Oct 2015 07:57:11 +0100
branchjv
changeset 7034 3205470acdb8
parent 7033 91e900cc092a (current diff)
parent 6945 ead5a294eb81 (diff)
child 7035 b0e610810565
Merge
XftFontDescription.st
stx_libview.st
--- a/AbstractBorder.st	Sun Oct 11 07:52:22 2015 +0100
+++ b/AbstractBorder.st	Sun Oct 11 07:57:11 2015 +0100
@@ -1,3 +1,5 @@
+"{ Encoding: utf8 }"
+
 "
  COPYRIGHT (c) 1997 by eXept Software AG
  COPYRIGHT (c) 2009 by eXept Software AG
@@ -52,6 +54,12 @@
 
 !AbstractBorder class methodsFor:'instance creation'!
 
+color:aColor
+    "create a new instance of the receiver with a border of the given color."
+
+    ^ self width:1 color:aColor
+!
+
 new
     "return an initialized instance"
 
@@ -172,10 +180,10 @@
 !AbstractBorder class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview/AbstractBorder.st,v 1.5 2015-01-06 01:41:40 cg Exp $'
+    ^ '$Header$'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libview/AbstractBorder.st,v 1.5 2015-01-06 01:41:40 cg Exp $'
+    ^ '$Header$'
 ! !
 
--- a/MacButtonBorder.st	Sun Oct 11 07:52:22 2015 +0100
+++ b/MacButtonBorder.st	Sun Oct 11 07:57:11 2015 +0100
@@ -1,3 +1,5 @@
+"{ Encoding: utf8 }"
+
 "{ Package: 'stx:libview' }"
 
 "{ NameSpace: Smalltalk }"
@@ -14,7 +16,7 @@
 documentation
 "
     an as yet unused and unfinished attempt to provide a mac-osx like
-    button border.
+    button border. These will look like mac buttons up to maverick.
     To be continued.
 "
 !
@@ -278,11 +280,11 @@
 !MacButtonBorder class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview/MacButtonBorder.st,v 1.1 2015-01-12 10:23:17 cg Exp $'
+    ^ '$Header$'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libview/MacButtonBorder.st,v 1.1 2015-01-12 10:23:17 cg Exp $'
+    ^ '$Header$'
 ! !
 
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MacFlatButtonBorder.st	Sun Oct 11 07:57:11 2015 +0100
@@ -0,0 +1,251 @@
+"{ Encoding: utf8 }"
+
+"{ Package: 'stx:libview' }"
+
+"{ NameSpace: Smalltalk }"
+
+SimpleBorder subclass:#MacFlatButtonBorder
+	instanceVariableNames:'insideColor imgTopLeft imgTopRight imgBottomLeft imgBottomRight'
+	classVariableNames:''
+	poolDictionaries:''
+	category:'Graphics-Support'
+!
+
+!MacFlatButtonBorder class methodsFor:'documentation'!
+
+documentation
+"
+    an as yet unused and unfinished attempt to provide a mac-osx like
+    button border. These will look like mac buttons in yosemite (i.e. ugly old 70s retro flat style).
+    To be continued.
+"
+! !
+
+!MacFlatButtonBorder class methodsFor:'instance creation'!
+
+color:color1 insideColor:color2
+    "create a new instance of the receiver with a border of the given color."
+
+    ^ self new color:color1; insideColor:color2
+! !
+
+!MacFlatButtonBorder class methodsFor:'image specs'!
+
+topLeftImageFilled
+    "This resource specification was automatically generated
+     by the ImageEditor of ST/X."
+
+    "Do not manually edit this!! If it is corrupted,
+     the ImageEditor may not be able to read the specification."
+
+    "
+     self topLeftImageFilled inspect
+     ImageEditor openOnClass:self andSelector:#topLeftImageFilled
+     Icon flushCachedIcons
+    "
+
+    <resource: #image>
+
+    ^Icon
+        constantNamed:'MacOSXRoundButtonBorder topLeftImageFilled'
+        ifAbsentPut:[(Depth8Image width:4 height:4) bits:(ByteArray fromPackedString:'@@LB@PLA@P@B@P@@@P@@@@@a') colorMapFromArray:#[44 132 251 49 107 245 95 142 236 175 196 234] mask:((ImageMask width:4 height:4) bits:(ByteArray fromPackedString:'\OC0<@@a'); yourself); yourself]
+!
+
+topLeftImageUnfilled
+    "This resource specification was automatically generated
+     by the ImageEditor of ST/X."
+
+    "Do not manually edit this!! If it is corrupted,
+     the ImageEditor may not be able to read the specification."
+
+    "
+     self topLeftImageUnfilled inspect
+     ImageEditor openOnClass:self andSelector:#topLeftImageUnfilled
+     Icon flushCachedIcons
+    "
+
+    <resource: #image>
+
+    ^Icon
+        constantNamed:'MacOSXRoundButtonBorder topLeftImageUnfilled'
+        ifAbsentPut:[(Depth2Image width:4 height:4) bits:(ByteArray fromPackedString:'9HMOO0@a') colorMapFromArray:#[183 183 183 201 201 201 224 224 224 255 255 255] mask:((ImageMask width:4 height:4) bits:(ByteArray fromPackedString:'\OC0<@@a'); yourself); yourself]
+!
+
+topLeftImageUnfilledMasked
+    "This resource specification was automatically generated
+     by the ImageEditor of ST/X."
+
+    "Do not manually edit this!! If it is corrupted,
+     the ImageEditor may not be able to read the specification."
+
+    "
+     self topLeftImageUnfilledMasked inspect
+     ImageEditor openOnClass:self andSelector:#topLeftImageUnfilledMasked
+     Icon flushCachedIcons
+    "
+
+    <resource: #image>
+
+    ^Icon
+        constantNamed:'MacOSXRoundButtonBorder topLeftImageUnfilledMasked'
+        ifAbsentPut:[(Depth2Image width:4 height:4) bits:(ByteArray fromPackedString:'IHA@@@@a') colorMapFromArray:#[183 183 183 201 201 201 224 224 224 255 255 255] mask:((ImageMask width:4 height:4) bits:(ByteArray fromPackedString:'\NC@ @@a'); yourself); yourself]
+!
+
+topLeftImageUnfilledMasked2
+    "This resource specification was automatically generated
+     by the ImageEditor of ST/X."
+
+    "Do not manually edit this!! If it is corrupted,
+     the ImageEditor may not be able to read the specification."
+
+    "
+     self topLeftImageUnfilledMasked2 inspect
+     ImageEditor openOnClass:self andSelector:#topLeftImageUnfilledMasked2
+     Icon flushCachedIcons
+    "
+
+    <resource: #image>
+
+    ^Icon
+        constantNamed:'MacOSXRoundButtonBorder topLeftImageUnfilledMasked2'
+        ifAbsentPut:[(Depth2Image width:4 height:4) bits:(ByteArray fromPackedString:'IH!! @@@a') colorMapFromArray:#[183 183 183 201 201 201 224 224 224 255 255 255] mask:((ImageMask width:4 height:4) bits:(ByteArray fromPackedString:'\NC@ @@a'); yourself); yourself]
+!
+
+topLeftImageUnfilledMasked3
+    "This resource specification was automatically generated
+     by the ImageEditor of ST/X."
+
+    "Do not manually edit this!! If it is corrupted,
+     the ImageEditor may not be able to read the specification."
+
+    "
+     self topLeftImageUnfilledMasked3 inspect
+     ImageEditor openOnClass:self andSelector:#topLeftImageUnfilledMasked3
+     Icon flushCachedIcons
+    "
+
+    <resource: #image>
+
+    ^Icon
+        constantNamed:'MacOSXRoundButtonBorder topLeftImageUnfilledMasked3'
+        ifAbsentPut:[(Depth2Image width:4 height:4) bits:(ByteArray fromPackedString:'HH  @@@a') colorMapFromArray:#[183 183 183 201 201 201 224 224 224 255 255 255] mask:((ImageMask width:4 height:4) bits:(ByteArray fromPackedString:'\NC@ @@a'); yourself); yourself]
+! !
+
+!MacFlatButtonBorder methodsFor:'accessing'!
+
+color:newColor
+    color ~= newColor ifTrue:[        
+        color := newColor.
+        imgTopLeft := imgTopRight := imgBottomLeft := imgBottomRight := nil.
+    ].
+!
+
+insideColor:newColor
+    insideColor ~= newColor ifTrue:[        
+        insideColor := newColor.
+        imgTopLeft := imgTopRight := imgBottomLeft := imgBottomRight := nil.
+    ].
+! !
+
+!MacFlatButtonBorder methodsFor:'displaying'!
+
+displayOn:aGC forDisplayBox:aRectangle
+    |oldPaint boxLeft boxRight boxTop boxBottom boxWidth boxHeight|
+
+    color isNil ifTrue:[ ^ self].
+
+    oldPaint := aGC paint.
+    aGC paint:color.
+
+    boxLeft := aRectangle left.
+    boxTop := aRectangle top.
+    boxWidth := aRectangle width.
+    boxHeight := aRectangle height.
+
+    boxRight := boxLeft + boxWidth.
+    boxBottom := boxTop + boxHeight.
+    
+    imgTopLeft isNil ifTrue:[
+        self makeImages.
+    ].    
+
+    aGC displayImage:imgTopLeft x:boxLeft y:boxTop.
+    aGC displayImage:imgTopRight x:boxRight-4 y:boxTop.
+    aGC displayImage:imgBottomRight x:boxRight-4 y:boxBottom-4.
+    aGC displayImage:imgBottomLeft x:boxLeft y:boxBottom-4.
+
+    aGC displayLineFromX:boxLeft+4 y:boxTop toX:boxRight-4 y:boxTop.
+    aGC displayLineFromX:boxLeft+4 y:boxBottom-1 toX:boxRight-4 y:boxBottom-1.
+    aGC displayLineFromX:boxLeft y:boxTop+4 toX:boxLeft y:boxBottom-4.
+    aGC displayLineFromX:boxRight-1 y:boxTop+4 toX:boxRight-1 y:boxBottom-4.
+
+    aGC paint:oldPaint.
+
+    "
+     |v1 v2|
+
+     v1 := TopView new.
+     v2 := View origin:10@10 corner:100@30 in:v1.
+     v2 border:(MacOSXRoundButtonBorder color:Color red).
+     v1 open.
+    "
+    "
+     |v1 v2|
+
+     v1 := TopView new.
+     v2 := View origin:10@10 corner:100@30 in:v1.
+     v2 border:(MacOSXRoundButtonBorder color:Color red insideColor:Color blue).
+     v1 open.
+    "
+! !
+
+!MacFlatButtonBorder methodsFor:'private'!
+
+makeImages
+    |protoImage img hue light sat innerHue innerLight innerSat|
+    
+    hue := color hue.
+    light := color light.
+    sat := color saturation.
+
+    insideColor isNil ifTrue:[
+        protoImage := self class topLeftImageUnfilledMasked3.
+    ] ifFalse:[    
+        insideColor hue isNil ifTrue:[
+            protoImage := self class topLeftImageUnfilled.
+        ] ifFalse:[    
+            protoImage := self class topLeftImageFilled.
+            innerHue := insideColor hue.
+            innerLight := insideColor light.
+            innerSat := insideColor saturation.
+        ].
+    ].
+    img := protoImage copy.
+
+    innerHue notNil ifTrue:[
+        img colorMap at:1 put:insideColor.
+        img colorMap at:2 put:color.
+        img colorMap at:3 put:(Color hue:hue light:light+8 saturation:sat-12).
+        img colorMap at:4 put:(Color hue:hue light:light+20 saturation:sat-40).
+    ] ifFalse:[
+        img colorMap at:1 put:color.
+        img colorMap at:2 put:(Color hue:hue light:light+15 saturation:sat-12).
+        img colorMap at:3 put:(Color hue:hue light:light+30 saturation:sat-40).
+    ].    
+    
+    imgTopLeft := img.
+    imgTopRight := img rotated:90.
+    imgBottomLeft := img rotated:-90.
+    imgBottomRight := img rotated:180.
+! !
+
+!MacFlatButtonBorder class methodsFor:'documentation'!
+
+version
+    ^ '$Header$'
+!
+
+version_CVS
+    ^ '$Header$'
+! !
+
--- a/XftFontDescription.st	Sun Oct 11 07:52:22 2015 +0100
+++ b/XftFontDescription.st	Sun Oct 11 07:57:11 2015 +0100
@@ -663,13 +663,19 @@
 
     opaque ifTrue:[
         bg  := aGC backgroundPaint.
-        bgPixel := bg colorId.
-        "/bgPixel notNil ifTrue:[
-            bgR := bg scaledRed.
-            bgG := bg scaledGreen.
-            bgB := bg scaledBlue.
-            bgA := (bg alpha * 65535) rounded.
-        "/].
+        bg isColor ifTrue:[
+            bgPixel := bg colorId.
+            "/bgPixel notNil ifTrue:[
+                bgR := bg scaledRed.
+                bgG := bg scaledGreen.
+                bgB := bg scaledBlue.
+                bgA := (bg alpha * 65535) rounded.
+            "/].
+        ] ifFalse:[
+            "images are not yet implemented"
+            "/ #todo: fill background rectangle
+            bgR := bgG := bgB := bgA := 16rFFFF.
+        ].
         bgR isNil ifTrue:[
             "/ when drawing into a pixmap...
             bg colorId == 0 ifTrue:[
--- a/stx_libview.st	Sun Oct 11 07:52:22 2015 +0100
+++ b/stx_libview.st	Sun Oct 11 07:57:11 2015 +0100
@@ -435,15 +435,18 @@
         HostGraphicsDevice
         ImageBackground
         NoBackground
+        (RoundButtonBorder autoload)
         SimpleBorder
         SolidBackground
         SynchronousWindowSensor
+        (TranslucentColor autoload)
         ViewStyle
         WindowEvent
         (XftFontDescription unix)
         DeviceWorkstation
         DisplayRootView
         ImageMask
+        (MacFlatButtonBorder autoload)
         MappedPalette
         SimpleView
         WidgetEvent