SimpleView.st
branchjv
changeset 7541 39940e2446a5
parent 7489 07c626716aed
parent 7479 0d77199594d6
child 7542 9e125aa140f9
--- a/SimpleView.st	Thu Sep 01 23:27:10 2016 +0100
+++ b/SimpleView.st	Mon Aug 01 23:30:02 2016 +0100
@@ -851,11 +851,10 @@
     ] ifFalse:[
         viewsDevice := Screen current
     ].
-    newView device:viewsDevice.
+    newView initializeForDevice:viewsDevice.
     (viewsDevice supportsNativeWidgetType:newView nativeWindowType) ifTrue:[
         newView beNativeWidget
     ].
-    newView initialize.
     aView notNil ifTrue:[aView addSubView:newView].
     ^ newView
 
@@ -1777,7 +1776,6 @@
     "Created: / 13.2.1999 / 10:31:39 / cg"
 ! !
 
-
 !SimpleView methodsFor:'accessing-behavior'!
 
 disable
@@ -1953,15 +1951,15 @@
     |clr|
 
     (superView notNil and:[superView isBorderedWrapper]) ifTrue:[
-	^ superView borderColor
+        ^ superView borderColor
     ].
 
     "/ ^ borderColor
     border notNil ifTrue:[
-	clr := border color
+        clr := border color
     ].
     clr isNil ifTrue:[
-	^ Color black
+        ^ self blackColor
     ].
     ^ clr.
 
@@ -2088,7 +2086,7 @@
     "return the foreground color of the contents -
      here, (since there is no contents), some default is returned."
 
-    ^ Color black
+    ^ self blackColor
 
     "Modified: / 3.5.1997 / 10:28:04 / cg"
     "Created: / 18.6.1998 / 16:57:33 / cg"
@@ -3991,7 +3989,7 @@
 
 bitGravity
     "return the bitGravity - that's the direction where the contents will move
-     when the the view is resized."
+     when the view is resized."
 
     ^ bitGravity
 !
@@ -4015,59 +4013,53 @@
 
     currentClippingBounds := gc clippingBoundsOrNil.
     (currentClippingBounds = aRectangleOrNil) ifTrue:[
-	^ self
+        ^ self
     ].
     newBounds := aRectangleOrNil.
 
     aRectangleOrNil notNil ifTrue:[
-	|currentTransformation pO pC|
-
-	x := aRectangleOrNil left.
-	y := aRectangleOrNil top.
-	w := aRectangleOrNil width.
-	h := aRectangleOrNil height.
-	currentTransformation := gc transformation.
-	currentTransformation notNil ifTrue:[
-		pO := currentTransformation transformPoint:x@y.
-		pC := currentTransformation transformPoint:(x+w-1)@(y+h-1).
-		x := pO x.
-		y := pO y.
-		w := pC x - x + 1.
-		h := pC y - y + 1.
-"/                x := currentTransformation applyToX:x.
-"/                y := currentTransformation applyToY:y.
-"/                w := currentTransformation applyScaleX:w.
-"/                h := currentTransformation applyScaleY:h.
-	].
-	(x isMemberOf:SmallInteger) ifFalse:[
-	    w := w + (x - x truncated).
-	    x := x truncated
-	].
-	(y isMemberOf:SmallInteger) ifFalse:[
-	    h := h + (y - y truncated).
-	    y := y truncated
-	].
-	(w isMemberOf:SmallInteger) ifFalse:[
-	    w := w truncated + 1
-	].
-	(h isMemberOf:SmallInteger) ifFalse:[
-	    h := h truncated + 1
-	].
-	x < margin ifTrue:[
-	    x := margin.
-	].
-	y < margin ifTrue:[
-	    y := margin.
-	].
-	x + w - 1 >= (width-margin) ifTrue:[
-	    w := width - margin - x
-	].
-	y + h - 1 >= (height-margin) ifTrue:[
-	    h := height - margin - y
-	].
-	w := w max:0.
-	h := h max:0.
-	newBounds := Rectangle left:x top:y width:w height:h.
+        |currentTransformation|
+
+        x := aRectangleOrNil left.
+        y := aRectangleOrNil top.
+        w := aRectangleOrNil width.
+        h := aRectangleOrNil height.
+        currentTransformation := gc transformation.
+        currentTransformation notNil ifTrue:[
+            x := currentTransformation applyToX:x.
+            y := currentTransformation applyToY:y.
+            w := currentTransformation applyScaleX:w.
+            h := currentTransformation applyScaleY:h.
+        ].
+        (x class ~~ SmallInteger) ifTrue:[
+            w := w + (x - x truncated).
+            x := x truncated
+        ].
+        (y class ~~ SmallInteger) ifTrue:[
+            h := h + (y - y truncated).
+            y := y truncated
+        ].
+        (w class ~~ SmallInteger) ifTrue:[
+            w := w truncated + 1
+        ].
+        (h class ~~ SmallInteger) ifTrue:[
+            h := h truncated + 1
+        ].
+        x < margin ifTrue:[
+            x := margin.
+        ].
+        y < margin ifTrue:[
+            y := margin.
+        ].
+        x + w - 1 >= (width-margin) ifTrue:[
+            w := width - margin - x
+        ].
+        y + h - 1 >= (height-margin) ifTrue:[
+            h := height - margin - y
+        ].
+        w := w max:0.
+        h := h max:0.
+        newBounds := Rectangle left:x top:y width:w height:h.
     ].
     gc deviceClippingBounds:newBounds
 
@@ -6131,10 +6123,10 @@
     "a low level redraw event from device
       - let subclass handle the redraw and take care of edges here"
 
-    |leftEdge topEdge rightEdge botEdge anyEdge nx ny nw nh dx  dy dh dw old oldPaint|
+    |leftEdge topEdge rightEdge botEdge anyEdge nx ny nw nh old oldPaint|
 
     shown ifFalse:[
-	^ self
+        ^ self
     ].
     "/ JV@2016-02-21: Double check to make sure GC is not already destroyed
     "/ to avoid 'attempt to draw to closed drawable. Not sure how this could 
@@ -6154,122 +6146,110 @@
      check if there is a need to draw an edge (i.e. if margin is hit)
     "
     (margin ~~ 0) ifTrue:[
-	|currentTransformation|
-
-	leftEdge := false.
-	topEdge := false.
-	rightEdge := false.
-	botEdge := false.
-	currentTransformation := gc transformation.
-	currentTransformation notNil ifTrue:[
-	    |pO pC|
-
-	    "
-	     need device coordinates for this test
-	    "
-	    pO := currentTransformation transformPoint:x@y.
-	    pC := currentTransformation transformPoint:(x+w-1)@(y+h-1).
-	    nx := pO x.
-	    ny := pO y.
-	    nw := pC x - nx + 1.
-	    nh := pC y - ny + 1.
-"/            nx := currentTransformation applyToX:nx.
-"/            ny := currentTransformation applyToY:ny.
-"/            nw := currentTransformation applyScaleX:nw.
-"/            nh := currentTransformation applyScaleY:nh.
-	].
-	"
-	 adjust expose rectangle, to exclude the margin.
-	 Care for rounding errors ...
-	"
-	(nx isMemberOf:SmallInteger) ifFalse:[
-	    old := nx.
-	    nx := nx truncated.
-	    nw := nw + (nx - old).
-	].
-	(ny isMemberOf:SmallInteger) ifFalse:[
-	    old := ny.
-	    ny := ny truncated.
-	    nh := nh + (ny - old).
-	].
-	(nw isMemberOf:SmallInteger) ifFalse:[
-	    nw := nw truncated + 1
-	].
-	(nh isMemberOf:SmallInteger) ifFalse:[
-	    nh := nh truncated + 1
-	].
-
-	dx := nx.
-	dy := ny.
-	dw := nw.
-	dh := nh.
-	(nx < margin) ifTrue:[
-	    old := nx.
-	    nx := margin.
-	    nw := nw - (nx - old).
-	    leftEdge := anyEdge := true.
-	].
-	((nx + nw - 1) >= (width - margin)) ifTrue:[
-	    nw := (width - margin - nx).
-	    rightEdge := anyEdge := true.
-	].
-	(ny < margin) ifTrue:[
-	    old := ny.
-	    ny := margin.
-	    nh := nh - (ny - old).
-	    topEdge := anyEdge := true.
-	].
-	((ny + nh - 1) >= (height - margin)) ifTrue:[
-	    nh := (height - margin - ny).
-	    botEdge := anyEdge := true.
-	].
-	currentTransformation notNil ifTrue:[
-	    "
-	     need logical coordinates for redraw
-	    "
-	    nx := currentTransformation applyInverseToX:nx.
-	    ny := currentTransformation applyInverseToY:ny.
-	    nw := currentTransformation applyInverseScaleX:nw.
-	    nh := currentTransformation applyInverseScaleY:nh.
-	].
+        |currentTransformation|
+
+        leftEdge := false.
+        topEdge := false.
+        rightEdge := false.
+        botEdge := false.
+        currentTransformation := gc transformation.
+        currentTransformation notNil ifTrue:[
+            "
+             need device coordinates for this test
+            "
+            nx := currentTransformation applyToX:nx.
+            ny := currentTransformation applyToY:ny.
+            nw := currentTransformation applyScaleX:nw.
+            nh := currentTransformation applyScaleY:nh.
+        ].
+        "
+         adjust expose rectangle, to exclude the margin.
+         Care for rounding errors ...
+        "
+        (nx class ~~ SmallInteger) ifTrue:[
+            old := nx.
+            nx := nx truncated.
+            nw := nw + (nx - old).
+        ].
+        (ny class ~~ SmallInteger) ifTrue:[
+            old := ny.
+            ny := ny truncated.
+            nh := nh + (ny - old).
+        ].
+        (nw class ~~ SmallInteger) ifTrue:[
+            nw := nw truncated + 1
+        ].
+        (nh class ~~ SmallInteger) ifTrue:[
+            nh := nh truncated + 1
+        ].
+
+        (nx < margin) ifTrue:[
+            old := nx.
+            nx := margin.
+            nw := nw - (nx - old).
+            leftEdge := anyEdge := true.
+        ].
+        ((nx + nw - 1) >= (width - margin)) ifTrue:[
+            nw := (width - margin - nx).
+            rightEdge := anyEdge := true.
+        ].
+        (ny < margin) ifTrue:[
+            old := ny.
+            ny := margin.
+            nh := nh - (ny - old).
+            topEdge := anyEdge := true.
+        ].
+        ((ny + nh - 1) >= (height - margin)) ifTrue:[
+            nh := (height - margin - ny).
+            botEdge := anyEdge := true.
+        ].
+        currentTransformation notNil ifTrue:[
+            "
+             need logical coordinates for redraw
+            "
+            nx := currentTransformation applyInverseToX:nx.
+            ny := currentTransformation applyInverseToY:ny.
+            nw := currentTransformation applyInverseScaleX:nw.
+            nh := currentTransformation applyInverseScaleY:nh.
+        ].
     ].
 
     (nw > 0 and:[nh > 0]) ifTrue:[
-	"
-	 redraw inside area
-	"
-	self
-	    clippingBounds:(Rectangle left:nx top:ny width:nw height:nh);
-	    redrawX:nx y:ny width:nw height:nh.
+        "
+         redraw inside area
+        "
+        self
+            clippingBounds:(Rectangle left:nx top:ny width:nw height:nh);
+            redrawX:nx y:ny width:nw height:nh.
     ].
 
     "
      redraw edge(s)
     "
     anyEdge ifTrue:[
-	self clippingBounds:nil.
-	oldPaint := self paint.
-	border notNil ifTrue:[
-	    border displayOn:self forDisplayBox:(Rectangle left:0 top:0 width:width height:height).
-	] ifFalse:[
-	    (topEdge and:[leftEdge and:[botEdge and:[rightEdge]]]) ifTrue:[
-		self drawEdges
-	    ] ifFalse:[
-		topEdge ifTrue:[
-		    self drawTopEdge
-		].
-		leftEdge ifTrue:[
-		    self drawLeftEdge
-		].
-		botEdge ifTrue:[
-		    self drawBottomEdge
-		].
-		rightEdge ifTrue:[
-		    self drawRightEdge
-		]
-	    ].
-	].
-	self paint:oldPaint.
+        self clippingBounds:nil.
+        oldPaint := self paint.
+        border notNil ifTrue:[
+            border displayOn:self forDisplayBox:(Rectangle left:0 top:0 width:width height:height).
+        ] ifFalse:[
+            (topEdge and:[leftEdge and:[botEdge and:[rightEdge]]]) ifTrue:[
+                self drawEdges
+            ] ifFalse:[
+                topEdge ifTrue:[
+                    self drawTopEdge
+                ].
+                leftEdge ifTrue:[
+                    self drawLeftEdge
+                ].
+                botEdge ifTrue:[
+                    self drawBottomEdge
+                ].
+                rightEdge ifTrue:[
+                    self drawRightEdge
+                ]
+            ].
+        ].
+        self paint:oldPaint.
     ].
     gc deviceClippingBounds:innerClipRect.
 
@@ -6370,6 +6350,13 @@
     "Created: 8.5.1996 / 23:45:28 / cg"
 !
 
+keyboardZoom:larger
+    "CTRL+/- action.
+     ignored here - redefined in views which can zoom"
+
+"/    self changeScaleForMouseWheelZoom:amount
+!
+
 mapped
     "the view has been mapped (by some outside
      action - i.e. window manager de-iconified me)"
@@ -7012,9 +6999,9 @@
     sendDisplayEvent ifTrue:[
         "/ translate to screen coordinates
         pointXLated := device translatePoint:aPoint from:(self id) to:(device rootWindowId).
-        device 
-            sendKeyOrButtonEvent:ev type 
-            x:pointXLated x y:pointXLated y 
+        device
+            sendKeyOrButtonEvent:ev type
+            x:pointXLated x y:pointXLated y
             keyOrButton:(ev isKeyEvent ifTrue:[ev rawKey] ifFalse:[ev button])
             state:(ev modifierFlags)
             toViewId:self id.
@@ -8111,6 +8098,22 @@
     ].
 ! !
 
+!SimpleView methodsFor:'menu & menu actions'!
+
+fontLargerOrSmaller:largerBoolean
+    |font oldSize newFont|
+
+    font := gc font.
+    oldSize := font size.
+    newFont := font asSize:(largerBoolean
+                            ifTrue:[(oldSize + 1) min:100]
+                            ifFalse:[(oldSize-1) max:4]).
+    self font:newFont.
+
+    "Modified: / 27-02-1996 / 00:53:51 / cg"
+    "Created: / 10-03-2012 / 09:38:32 / cg"
+! !
+
 !SimpleView methodsFor:'menu handling'!
 
 activateMenu
@@ -8274,7 +8277,6 @@
     ^ aMenu startUpFor:self
 ! !
 
-
 !SimpleView methodsFor:'native widget support'!
 
 nativeWindowType
@@ -8699,9 +8701,6 @@
                                            width:width height:height.
         ].
 
-        "Tell the GC that the size has changed"
-        gc width:width height:height.
-
         "if view becomes bigger, send sizeChanged after"
         false "(how ~~ #smaller)" ifTrue:[
             self sizeChanged:how
@@ -8766,8 +8765,7 @@
         dependents notNil ifTrue:[ self changed:#origin ].
     ].
 
-    "Modified: / 25-05-1999 / 14:49:56 / cg"
-    "Modified: / 02-04-2016 / 14:35:52 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 25.5.1999 / 14:49:56 / cg"
 !
 
 pointFromRelative:p
@@ -10328,16 +10326,16 @@
 
     self fill:flashColor.
     messageOrNil notNil ifTrue:[
-	self withForeground:Color white do:[
-	    self displayString:messageOrNil centeredAt:(self center).
-	].
+        self withForeground:self whiteColor do:[
+            self displayString:messageOrNil centeredAt:(self center).
+        ].
     ].
     Delay waitForSeconds:0.1.
     self fill:self whiteColor.
     messageOrNil notNil ifTrue:[
-	self withForeground:Color black do:[
-	    self displayString:messageOrNil centeredAt:(self center).
-	].
+        self withForeground:self blackColor do:[
+            self displayString:messageOrNil centeredAt:(self center).
+        ].
     ].
     Delay waitForSeconds:0.1.
     self fill:viewBackground.
@@ -10561,22 +10559,17 @@
 
     area := Rectangle left:x top:y width:w height:h.
     oldClip := gc clippingBoundsOrNil.
-    self clippingRectangle:area.
+    self clippingBounds:area.
 
     self clearExposedAreaInRedraw ifTrue:[
-        "/ win95 workaround: non-existing bg-pixmap support (obsolete)
-        (viewBackground isImageOrForm and:[ device supportsAnyViewBackgroundPixmaps not ]) ifTrue:[
-            self fillRectangleWithViewBackgroundX:x y:y width:w height:h
-        ] ifFalse:[
-            self clearRectangleX:x y:y width:w height:h.
-        ]
+        self clearRectangleX:x y:y width:w height:h.
     ].
 
     self renderOrRedraw.
 
     "/ draw them afterwards - they can be used to replace heavy-weight views.
     self redrawComponentsIn:area.
-    self clippingRectangle:oldClip.
+    self clippingBounds:oldClip.
 
     "Modified: 19.4.1997 / 11:55:08 / cg"
 !
@@ -10623,7 +10616,6 @@
     ^ self
 ! !
 
-
 !SimpleView methodsFor:'scrolling'!
 
 halfPageDown
@@ -11278,7 +11270,7 @@
     windowGroup isNil ifTrue:[
 	"/ create a new window group put myself into it
         windowGroup := self windowGroupClass new.
-        windowGroup 
+        windowGroup
 				addTopView:self;
 				setPreviousGroup:previousGroup.