.
authorclaus
Mon, 18 Sep 1995 12:39:22 +0200
changeset 162 1c68705a8903
parent 161 a33764a0af35
child 163 18d87bf16389
.
Button.st
ButtonC.st
ButtonController.st
DialogBox.st
HPanelV.st
HorizontalPanelView.st
Label.st
YesNoBox.st
--- a/Button.st	Sat Sep 16 01:52:06 1995 +0200
+++ b/Button.st	Mon Sep 18 12:39:22 1995 +0200
@@ -11,7 +11,7 @@
 "
 
 Label subclass:#Button
-       instanceVariableNames:'activeLogo passiveLogo
+       instanceVariableNames:'activeLogo passiveLogo disabledLogo focusLogo
 			      onLevel offLevel
 			      disabledFgColor
 			      activeFgColor activeBgColor
@@ -39,7 +39,7 @@
 COPYRIGHT (c) 1989 by Claus Gittinger
 	      All Rights Reserved
 
-$Header: /cvs/stx/stx/libwidg/Button.st,v 1.30 1995-09-09 02:30:32 claus Exp $
+$Header: /cvs/stx/stx/libwidg/Button.st,v 1.31 1995-09-18 10:37:57 claus Exp $
 '!
 
 !Button class methodsFor:'documentation'!
@@ -60,7 +60,7 @@
 
 version
 "
-$Header: /cvs/stx/stx/libwidg/Button.st,v 1.30 1995-09-09 02:30:32 claus Exp $
+$Header: /cvs/stx/stx/libwidg/Button.st,v 1.31 1995-09-18 10:37:57 claus Exp $
 "
 !
 
@@ -1097,6 +1097,23 @@
     ]
 !
 
+beImageButton
+    "make mySelf an image button - that is turn off all levelChanges
+     and logo spacing. This should be sent for buttons which use both
+     passive and active logos, and the 3D effect comes from the bitmaps
+     (i.e. windows buttons)."
+
+    self 
+	sizeFixed:true; 
+	onLevel:0; 
+	offLevel:0; 
+	horizontalSpace:0; 
+	verticalSpace:0;
+	newLayout.
+
+    "Created: 17.9.1995 / 20:41:47 / claus"
+!
+
 onLevel:aNumber
     "set the level of the button when pressed (i.e. how deep)"
 
@@ -1161,6 +1178,31 @@
     ]
 !
 
+disabledLogo:anImageOrString
+    "define the logo to be displayed while active -
+     this is optional; the default is to display the same
+     (logo) in both pressed and released states."
+
+    disabledLogo := anImageOrString.
+    controller enabled ifFalse:[
+	self logo:anImageOrString
+    ]
+
+    "Created: 17.9.1995 / 19:50:17 / claus"
+    "Modified: 17.9.1995 / 19:50:34 / claus"
+!
+
+focusLogo:anImageOrString
+    "define the logo to be displayed while active -
+     this is optional; the default is to display the same
+     (logo) in both pressed and released states."
+
+    focusLogo := anImageOrString.
+
+    "Created: 17.9.1995 / 19:50:17 / claus"
+    "Modified: 17.9.1995 / 20:00:43 / claus"
+!
+
 activeForegroundColor
     "return the foreground color to be used when pressed"
 
@@ -1475,6 +1517,39 @@
     ]
 ! !
 
+!Button methodsFor:'focus change'!
+
+showFocus
+    focusLogo notNil ifTrue:[
+	controller enabled ifTrue:[
+	    logo := focusLogo.  
+	    ^ self redisplay
+	]
+    ].
+    super showFocus
+
+    "Created: 17.9.1995 / 19:58:50 / claus"
+!
+
+showNoFocus
+    focusLogo notNil ifTrue:[
+	disabledLogo notNil ifTrue:[
+	    controller enabled ifTrue:[
+		logo := passiveLogo.  
+	    ] ifFalse:[
+		logo := disabledLogo.  
+	    ].
+	] ifFalse:[
+	    logo := passiveLogo
+	].
+	^ self redisplay
+    ].
+    super showNoFocus
+
+    "Created: 17.9.1995 / 20:00:06 / claus"
+    "Modified: 17.9.1995 / 20:26:32 / claus"
+! !
+
 !Button methodsFor:'redrawing'!
 
 redrawX:x y:y width:w height:h 
@@ -1669,4 +1744,25 @@
 	].
     ].
     self drawWith:fg and:bg
+!
+
+enableStateChangeRedraw
+    "redraw the button after an enable state change"
+
+    disabledLogo notNil ifTrue:[
+	controller enabled ifFalse:[
+	    logo := disabledLogo.
+	] ifTrue:[
+	    controller active ifTrue:[
+		logo := activeLogo
+	    ] ifFalse:[
+		logo := passiveLogo
+	    ].
+	].
+    ].
+    shown ifFalse:[^ self].
+    self redisplay.
+
+    "Created: 17.9.1995 / 19:46:14 / claus"
+    "Modified: 17.9.1995 / 19:56:24 / claus"
 ! !
--- a/ButtonC.st	Sat Sep 16 01:52:06 1995 +0200
+++ b/ButtonC.st	Mon Sep 18 12:39:22 1995 +0200
@@ -40,7 +40,7 @@
 
 version
 "
-$Header: /cvs/stx/stx/libwidg/Attic/ButtonC.st,v 1.18 1995-09-14 17:43:23 claus Exp $
+$Header: /cvs/stx/stx/libwidg/Attic/ButtonC.st,v 1.19 1995-09-18 10:38:03 claus Exp $
 "
 !
 
@@ -154,14 +154,21 @@
 enableChannel:aValueHolder
     "set the valueHolder, which holds the enable boolean value"
 
+    |wasEnabled|
+
     enableChannel notNil ifTrue:[
+	wasEnabled := enableChannel value.
 	enableChannel retractInterrestFor:self. 
+    ] ifFalse:[
+	wasEnabled := true
     ].
     enableChannel := aValueHolder.
     aValueHolder onChangeSend:#enableStateChange to:self.
-    view notNil ifTrue:[
-	view redraw
+    enableChannel value ~~ wasEnabled ifTrue:[
+	self enableStateChange
     ]
+
+    "Modified: 17.9.1995 / 19:41:18 / claus"
 !
 
 pressChannel:aChannel
@@ -518,7 +525,9 @@
 enableStateChange
     "this is sent, whenever the enable value has changed"
 
-    view notNil ifTrue:[view redraw]
+    view notNil ifTrue:[view enableStateChangeRedraw]
+
+    "Modified: 17.9.1995 / 19:55:52 / claus"
 ! !
 
 !ButtonController methodsFor:'initialization'!
--- a/ButtonController.st	Sat Sep 16 01:52:06 1995 +0200
+++ b/ButtonController.st	Mon Sep 18 12:39:22 1995 +0200
@@ -40,7 +40,7 @@
 
 version
 "
-$Header: /cvs/stx/stx/libwidg/ButtonController.st,v 1.18 1995-09-14 17:43:23 claus Exp $
+$Header: /cvs/stx/stx/libwidg/ButtonController.st,v 1.19 1995-09-18 10:38:03 claus Exp $
 "
 !
 
@@ -154,14 +154,21 @@
 enableChannel:aValueHolder
     "set the valueHolder, which holds the enable boolean value"
 
+    |wasEnabled|
+
     enableChannel notNil ifTrue:[
+	wasEnabled := enableChannel value.
 	enableChannel retractInterrestFor:self. 
+    ] ifFalse:[
+	wasEnabled := true
     ].
     enableChannel := aValueHolder.
     aValueHolder onChangeSend:#enableStateChange to:self.
-    view notNil ifTrue:[
-	view redraw
+    enableChannel value ~~ wasEnabled ifTrue:[
+	self enableStateChange
     ]
+
+    "Modified: 17.9.1995 / 19:41:18 / claus"
 !
 
 pressChannel:aChannel
@@ -518,7 +525,9 @@
 enableStateChange
     "this is sent, whenever the enable value has changed"
 
-    view notNil ifTrue:[view redraw]
+    view notNil ifTrue:[view enableStateChangeRedraw]
+
+    "Modified: 17.9.1995 / 19:55:52 / claus"
 ! !
 
 !ButtonController methodsFor:'initialization'!
--- a/DialogBox.st	Sat Sep 16 01:52:06 1995 +0200
+++ b/DialogBox.st	Mon Sep 18 12:39:22 1995 +0200
@@ -25,7 +25,7 @@
 
 version
 "
-$Header: /cvs/stx/stx/libwidg/DialogBox.st,v 1.22 1995-09-10 19:41:52 claus Exp $
+$Header: /cvs/stx/stx/libwidg/DialogBox.st,v 1.23 1995-09-18 10:38:12 claus Exp $
 "
 !
 
@@ -230,6 +230,28 @@
 	box open
 
 
+    mswindows style:
+
+	|b box|
+
+	box := DialogBox new.
+	(box addTextLabel:'are you certain ?') adjust:#left.
+	b := Button new.
+	b activeLogo:(Image fromFile:'bitmaps/cancel_down.bmp').
+	b passiveLogo:(Image fromFile:'bitmaps/cancel_up.bmp').
+	b focusLogo:(Image fromFile:'bitmaps/cancel_focus.bmp').
+	b beImageButton.
+	box addAbortButton:b.
+
+	b := Button new.
+	b activeLogo:(Image fromFile:'bitmaps/ok_down.bmp').
+	b passiveLogo:(Image fromFile:'bitmaps/ok_up.bmp').
+	b focusLogo:(Image fromFile:'bitmaps/ok_focus.bmp').
+	b beImageButton.
+	box addOkButton:b.
+	box open
+
+
     two textlabels:
 
 	DialogBox new
@@ -990,24 +1012,44 @@
      If the argument someOtherButtonOrNil is nil, the button is
      added at the end."
 
+    |h|
+
     buttonPanel addSubView:aButton after:someOtherButtonOrNil.
     buttonPanel subViews size > 1 ifTrue:[
 	buttonPanel horizontalLayout:#fitSpace.
     ].
+    (h := (aButton heightIncludingBorder + (ViewSpacing * 2))) > buttonPanel topInset ifTrue:[
+	 buttonPanel topInset:h negated
+    ].
     ^ aButton
 !
 
+addOkButton:aButton 
+    "add an already created okButton - to be sent from redefined initialize
+     methods in subclasses or when creating a box programmatically.
+     Returns the button."
+
+    okButton := aButton.
+    aButton model:self; change:#okPressed.
+    ^ self addButton:aButton.
+
+    "Modified: 17.9.1995 / 20:20:41 / claus"
+!
+
 addOkButtonLabelled:buttonLabel 
     "create an okButton with a label - to be sent from redefined initialize
      methods in subclasses or when creating a box programmatically.
      A nil argument creates one with the default text.
      Returns the button."
 
-    okButton := Button okButton.
-    okButton model:self; change:#okPressed.
-    buttonLabel notNil ifTrue:[okButton label:buttonLabel].
-    okButton isReturnButton:acceptReturnAsOK.
-    ^ self addButton:okButton.
+    |aButton|
+
+    aButton := Button okButton.
+    buttonLabel notNil ifTrue:[aButton label:buttonLabel].
+    aButton isReturnButton:acceptReturnAsOK.
+    ^ self addOkButton:aButton.
+
+    "Modified: 17.9.1995 / 20:19:49 / claus"
 !
 
 addOkButton
@@ -1025,16 +1067,31 @@
     ^ self addButton:aButton after:nil
 !
 
+addAbortButton:aButton 
+    "add an already created abortButton - to be sent from redefined initialize
+     methods in subclasses or when creating a box programmatically.
+     Returns the button."
+
+    abortButton := aButton.
+    aButton model:self; change:#abortPressed.
+    ^ self addButton:aButton.
+
+    "Created: 17.9.1995 / 20:17:26 / claus"
+!
+
 addAbortButtonLabelled:buttonLabel
     "create an abortButton with a label - to be sent from redefined initialize
      methods in subclasses or when creating a box programmatically.
      A nil argument creates one with the default label.
      Returns the button."
 
-    abortButton := Button abortButton.
-    abortButton model:self; change:#abortPressed.
-    buttonLabel notNil ifTrue:[abortButton label:buttonLabel].
-    ^ self addButton:abortButton.
+    |aButton|
+
+    aButton := Button abortButton.
+    buttonLabel notNil ifTrue:[aButton label:buttonLabel].
+    ^ self addAbortButton:aButton
+
+    "Modified: 17.9.1995 / 20:18:00 / claus"
 !
 
 addAbortButton
--- a/HPanelV.st	Sat Sep 16 01:52:06 1995 +0200
+++ b/HPanelV.st	Mon Sep 18 12:39:22 1995 +0200
@@ -21,7 +21,7 @@
 COPYRIGHT (c) 1989 by Claus Gittinger
 	      All Rights Reserved
 
-$Header: /cvs/stx/stx/libwidg/Attic/HPanelV.st,v 1.15 1995-09-07 12:45:02 claus Exp $
+$Header: /cvs/stx/stx/libwidg/Attic/HPanelV.st,v 1.16 1995-09-18 10:38:31 claus Exp $
 '!
 
 !HorizontalPanelView class methodsFor:'documentation'!
@@ -42,7 +42,7 @@
 
 version
 "
-$Header: /cvs/stx/stx/libwidg/Attic/HPanelV.st,v 1.15 1995-09-07 12:45:02 claus Exp $
+$Header: /cvs/stx/stx/libwidg/Attic/HPanelV.st,v 1.16 1995-09-18 10:38:31 claus Exp $
 "
 !
 
@@ -1064,7 +1064,7 @@
      my size has changed"
 
     |xpos space sumOfWidths numChilds l wEach wInside hL vL resizeToMaxV 
-     resizeToMaxH maxHeight maxWidth|
+     resizeToMaxH maxHeight maxWidth d|
 
     subViews isNil ifTrue:[^ self].
 
@@ -1258,9 +1258,14 @@
 	(hL == #fit 
 	 or:[hL == #fitSpace
 	 or:[resizeToMaxH]]) ifTrue:[
-	    child origin:(xpos truncated @ ypos)
-		  corner:(xpos + wEach - (child borderWidth) - 1) truncated
-			 @ (ypos + child height - 1).
+	    child sizeFixed ifTrue:[
+		d := wEach - (child widthIncludingBorder) // 2.
+		child origin:(xpos truncated + d @ ypos)
+	    ] ifFalse:[
+		child origin:(xpos truncated @ ypos)
+		      corner:(xpos + wEach - (child borderWidth) - 1) truncated
+			     @ (ypos + child height - 1).
+	    ].
 	    advance := wEach.
 	] ifFalse:[
 	    child origin:(xpos @ ypos).
--- a/HorizontalPanelView.st	Sat Sep 16 01:52:06 1995 +0200
+++ b/HorizontalPanelView.st	Mon Sep 18 12:39:22 1995 +0200
@@ -21,7 +21,7 @@
 COPYRIGHT (c) 1989 by Claus Gittinger
 	      All Rights Reserved
 
-$Header: /cvs/stx/stx/libwidg/HorizontalPanelView.st,v 1.15 1995-09-07 12:45:02 claus Exp $
+$Header: /cvs/stx/stx/libwidg/HorizontalPanelView.st,v 1.16 1995-09-18 10:38:31 claus Exp $
 '!
 
 !HorizontalPanelView class methodsFor:'documentation'!
@@ -42,7 +42,7 @@
 
 version
 "
-$Header: /cvs/stx/stx/libwidg/HorizontalPanelView.st,v 1.15 1995-09-07 12:45:02 claus Exp $
+$Header: /cvs/stx/stx/libwidg/HorizontalPanelView.st,v 1.16 1995-09-18 10:38:31 claus Exp $
 "
 !
 
@@ -1064,7 +1064,7 @@
      my size has changed"
 
     |xpos space sumOfWidths numChilds l wEach wInside hL vL resizeToMaxV 
-     resizeToMaxH maxHeight maxWidth|
+     resizeToMaxH maxHeight maxWidth d|
 
     subViews isNil ifTrue:[^ self].
 
@@ -1258,9 +1258,14 @@
 	(hL == #fit 
 	 or:[hL == #fitSpace
 	 or:[resizeToMaxH]]) ifTrue:[
-	    child origin:(xpos truncated @ ypos)
-		  corner:(xpos + wEach - (child borderWidth) - 1) truncated
-			 @ (ypos + child height - 1).
+	    child sizeFixed ifTrue:[
+		d := wEach - (child widthIncludingBorder) // 2.
+		child origin:(xpos truncated + d @ ypos)
+	    ] ifFalse:[
+		child origin:(xpos truncated @ ypos)
+		      corner:(xpos + wEach - (child borderWidth) - 1) truncated
+			     @ (ypos + child height - 1).
+	    ].
 	    advance := wEach.
 	] ifFalse:[
 	    child origin:(xpos @ ypos).
--- a/Label.st	Sat Sep 16 01:52:06 1995 +0200
+++ b/Label.st	Mon Sep 18 12:39:22 1995 +0200
@@ -25,7 +25,7 @@
 COPYRIGHT (c) 1989 by Claus Gittinger
 	      All Rights Reserved
 
-$Header: /cvs/stx/stx/libwidg/Label.st,v 1.31 1995-09-07 12:45:12 claus Exp $
+$Header: /cvs/stx/stx/libwidg/Label.st,v 1.32 1995-09-18 10:38:42 claus Exp $
 '!
 
 !Label class methodsFor:'documentation'!
@@ -46,7 +46,7 @@
 
 version
 "
-$Header: /cvs/stx/stx/libwidg/Label.st,v 1.31 1995-09-07 12:45:12 claus Exp $
+$Header: /cvs/stx/stx/libwidg/Label.st,v 1.32 1995-09-18 10:38:42 claus Exp $
 "
 !
 
@@ -995,14 +995,16 @@
     "set the number of pixels by which the logo
      is vertically inset from the border"
 
-    vSpace := aNumber
+    vSpace := aNumber.
+    self newLayout
 !
 
 horizontalSpace:aNumber
     "set the number of pixels by which the logo
      is horizontally inset from the border"
 
-    hSpace := aNumber
+    hSpace := aNumber.
+    self newLayout
 !
 
 font:aFont
--- a/YesNoBox.st	Sat Sep 16 01:52:06 1995 +0200
+++ b/YesNoBox.st	Mon Sep 18 12:39:22 1995 +0200
@@ -11,7 +11,7 @@
 "
 
 WarningBox subclass:#YesNoBox
-       instanceVariableNames:'noButton noAction'
+       instanceVariableNames:''
        classVariableNames:'RequestBitmap'
        poolDictionaries:''
        category:'Views-DialogBoxes'
@@ -21,7 +21,7 @@
 COPYRIGHT (c) 1989 by Claus Gittinger
 	      All Rights Reserved
 
-$Header: /cvs/stx/stx/libwidg/YesNoBox.st,v 1.17 1995-08-29 16:44:52 claus Exp $
+$Header: /cvs/stx/stx/libwidg/YesNoBox.st,v 1.18 1995-09-18 10:39:22 claus Exp $
 '!
 
 !YesNoBox class methodsFor:'documentation'!
@@ -42,7 +42,7 @@
 
 version
 "
-$Header: /cvs/stx/stx/libwidg/YesNoBox.st,v 1.17 1995-08-29 16:44:52 claus Exp $
+$Header: /cvs/stx/stx/libwidg/YesNoBox.st,v 1.18 1995-09-18 10:39:22 claus Exp $
 "
 !
 
@@ -177,17 +177,17 @@
     buttonPanel horizontalLayout:#fitSpace.  "/ looks better; should it come from the StyleSheet ?
 
     textLabel label:'please Confirm'.
-    okButton label:(resources at:'yes').
+    okButton logo:(resources at:'yes').
 
-    noButton := Button abortButton.
-    buttonPanel addSubView:noButton before:okButton.
-    noButton label:(resources at:'no').
-    noButton height:(okButton height).
-    noButton model:self; change:#noPressed
+    abortButton := Button abortButton.
+    buttonPanel addSubView:abortButton before:okButton.
+    abortButton logo:(resources at:'no').
+    abortButton height:(okButton height).
+    abortButton model:self; change:#noPressed
 !
 
 focusSequence
-    ^ Array with:noButton with:okButton 
+    ^ Array with:abortButton with:okButton 
 ! !
 
 !YesNoBox methodsFor:'startup'!
@@ -230,7 +230,7 @@
 noButton
     "return the no-button"
 
-    ^ noButton
+    ^ abortButton
 !
 
 yesAction:aBlock 
@@ -242,14 +242,14 @@
 noAction:aBlock
     "define the action to be performed when no is pressed"
 
-    noAction := aBlock
+    abortAction := aBlock
 !
 
 yesAction:yesBlock noAction:noBlock
     "define both actions"
 
     okAction := yesBlock.
-    noAction := noBlock
+    abortAction := noBlock
 !
 
 yesText:aString
@@ -261,9 +261,9 @@
 noText:aString
     "define the label of the no-button"
 
-    aString ~= noButton label ifTrue:[
-	noButton label:aString.
-	noButton resize.
+    aString ~= abortButton label ifTrue:[
+	abortButton label:aString.
+	abortButton resize.
 	shown ifTrue:[self resize]
     ]
 !
@@ -277,11 +277,11 @@
 yesText:yesString noText:noString
     "define the labels of both buttons"
 
-    ((yesString ~= okButton label) or:[noString ~= noButton label]) ifTrue:[
+    ((yesString ~= okButton label) or:[noString ~= abortButton label]) ifTrue:[
 	okButton label:yesString.
-	noButton label:noString.
+	abortButton label:noString.
 	okButton resize.
-	noButton resize.
+	abortButton resize.
 	shown ifTrue:[self resize]
     ]
 !
@@ -298,7 +298,7 @@
 
     self title:aString.
     okAction := yesBlock.
-    noAction := noBlock
+    abortAction := noBlock
 ! !
 
 !YesNoBox methodsFor:'user interaction'!
@@ -307,8 +307,8 @@
     "user pressed the no-button;
      hide myself and evaluate the action"
 
-    noButton turnOffWithoutRedraw.
-    self hideAndEvaluate:noAction
+    abortButton turnOffWithoutRedraw.
+    self hideAndEvaluate:abortAction
 ! !
 
 !YesNoBox methodsFor:'queries'!
@@ -319,11 +319,11 @@
     "
      make the two buttons of equal size
     "
-    max := okButton preferredExtent x max:noButton preferredExtent x.
+    max := okButton preferredExtent x max:abortButton preferredExtent x.
     okButton width:max.
-    noButton width:max.
+    abortButton width:max.
     w := (formLabel width + textLabel width) max:max * 2.
-    w := w + (3 * ViewSpacing) + (okButton borderWidth + noButton borderWidth * 2).
+    w := w + (3 * ViewSpacing) + (okButton borderWidth + abortButton borderWidth * 2).
     h := ViewSpacing
 	 + ((formLabel height) max:(textLabel height))
 	 + (ViewSpacing * 3)