Form.st
changeset 3067 908e910e6c94
parent 3025 11d768e415c2
child 3068 7f4b0dd1f738
--- a/Form.st	Thu Dec 02 19:40:38 1999 +0100
+++ b/Form.st	Thu Dec 02 19:40:53 1999 +0100
@@ -296,9 +296,8 @@
 width:w height:h offset:offs fromArray:anArray
     "create a new form on the default device"
 
-    ^ (self onDevice:Screen current) width:w height:h offset:offs fromArray:anArray
+    ^ self width:w height:h offset:offs fromArray:anArray on:Screen current
 
-    "Modified: 18.1.1997 / 18:26:28 / cg"
 !
 
 width:w height:h offset:offs fromArray:anArray on:aDevice
@@ -1665,22 +1664,27 @@
 
     |pathName|
 
+    "/ this method is a historic leftover; it uses
+    "/ the X-libs bitmap file reading function, which is not
+    "/ available with other windowing systems ...
+    self obsoleteMethodWarning:'use Image fromFile:'.
+
     pathName := self class findBitmapFile:fn.
     pathName notNil ifTrue:[
-	drawableId := device createBitmapFromFile:pathName for:self.
-	drawableId isNil ifTrue:[^ nil].
+        drawableId := device createBitmapFromFile:pathName for:self.
+        drawableId isNil ifTrue:[^ nil].
 
 "/        fileName := pathName. "/ keep the actual name (wrong)
-	fileName := fn.         "/ keep the relative name (better - SEARCHPATH may be different at restart)
+        fileName := fn.         "/ keep the relative name (better - SEARCHPATH may be different at restart)
 
-	offset := 0@0.
-	realized := true.
-	BlackAndWhiteColorMap isNil ifTrue:[
-	    BlackAndWhiteColorMap := Array with:(Color white) with:(Color black)
-	].
-	localColorMap := BlackAndWhiteColorMap.
-	Lobby registerChange:self.
-	^ self
+        offset := 0@0.
+        realized := true.
+        BlackAndWhiteColorMap isNil ifTrue:[
+            BlackAndWhiteColorMap := Array with:(Color white) with:(Color black)
+        ].
+        localColorMap := BlackAndWhiteColorMap.
+        Lobby registerChange:self.
+        ^ self
     ].
     ^ nil
 
@@ -1700,14 +1704,14 @@
     "if the device is within +- 50% of dpi, no magnify is needed"
     dev := device.
     dev isNil ifTrue:[
-	"should not happen ..."
-	dev := Screen current
+        "should not happen ..."
+        dev := Screen current
     ].
-    dpiH := dev horizontalPixelPerInch.
+    dpiH := dev isNil ifTrue:[90] ifFalse:[dev horizontalPixelPerInch].
     ((dpi >= (dpiH * 0.75)) and:[dpi <= (dpiH * 1.5)]) ifTrue:[^ self].
     mag := (dpiH / dpi) rounded.
     mag == 0 ifTrue:[
-	^ self
+        ^ self
     ].
     ^ self magnifiedBy:(mag @ mag)
 
@@ -1740,21 +1744,24 @@
     "actual create of a monochrome form"
 
     ((w == 0) or:[h == 0]) ifTrue:[
-	self error:'invalid form extent'.
-	^ nil
+        self error:'invalid form extent'.
+        ^ nil
     ].
     width := w.
     height := h.
     depth := 1.
     offset := 0@0.
-    drawableId := device createBitmapWidth:w height:h.
-    drawableId isNil ifTrue:[^ nil].
     BlackAndWhiteColorMap isNil ifTrue:[
-	BlackAndWhiteColorMap := Array with:(Color white) with:(Color black)
+        BlackAndWhiteColorMap := Array with:(Color white) with:(Color black)
     ].
     localColorMap := BlackAndWhiteColorMap.
-    realized := true.
-    Lobby registerChange:self.
+
+    device notNil ifTrue:[
+        drawableId := device createBitmapWidth:w height:h.
+"/        drawableId isNil ifTrue:[^ nil].
+        realized := true.
+        Lobby registerChange:self.
+    ].
 !
 
 width:w height:h depth:d
@@ -1763,11 +1770,13 @@
     width := w.
     height := h.
     offset := 0@0.
-    drawableId := device createPixmapWidth:w height:h depth:d.
-    drawableId isNil ifTrue:[^ nil].
-    realized := true.
     depth := d.
-    Lobby registerChange:self.
+    device notNil ifTrue:[
+        drawableId := device createPixmapWidth:w height:h depth:d.
+"/        drawableId isNil ifTrue:[^ nil].
+        realized := true.
+        Lobby registerChange:self.
+    ].
 !
 
 width:wIn height:hIn fromArray:anArray
@@ -1856,16 +1865,18 @@
     height := h.
     depth := 1.
     offset := 0@0.
-    drawableId := device createBitmapFromArray:bytes width:w height:h.
-    drawableId isNil ifTrue:[^ nil].
-
     data := bytes.
     BlackAndWhiteColorMap isNil ifTrue:[
         BlackAndWhiteColorMap := Array with:(Color white) with:(Color black)
     ].
     localColorMap := BlackAndWhiteColorMap.
-    realized := true.
-    Lobby registerChange:self.
+
+    device notNil ifTrue:[
+        drawableId := device createBitmapFromArray:bytes width:w height:h.
+"/        drawableId isNil ifTrue:[^ nil].
+        realized := true.
+        Lobby registerChange:self.
+    ].
 !
 
 width:w height:h offset:offs fromArray:anArray
@@ -1990,6 +2001,6 @@
 !Form class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview/Form.st,v 1.103 1999-11-13 12:25:22 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libview/Form.st,v 1.104 1999-12-02 18:40:53 cg Exp $'
 ! !
 Form initialize!