--- a/DialogBox.st Tue May 15 19:46:48 2001 +0200
+++ b/DialogBox.st Thu May 17 14:17:46 2001 +0200
@@ -153,434 +153,434 @@
For example:
info & warnings:
- [exBegin]
- Dialog information:'hi there'
- [exEnd]
- [exBegin]
- Dialog warn:'oops'
- [exEnd]
+ [exBegin]
+ Dialog information:'hi there'
+ [exEnd]
+ [exBegin]
+ Dialog warn:'oops'
+ [exEnd]
yes/no questions:
- [exBegin]
- (Dialog confirm:'is this simple ?')
- ifTrue:[
- Transcript showCR:'thats what I expected'
- ] ifFalse:[
- Transcript showCR:'read more examples and documentation'
- ]
- [exEnd]
+ [exBegin]
+ (Dialog confirm:'is this simple ?')
+ ifTrue:[
+ Transcript showCR:'thats what I expected'
+ ] ifFalse:[
+ Transcript showCR:'read more examples and documentation'
+ ]
+ [exEnd]
yes/no question with cancel option:
- [exBegin]
- |answer|
-
- answer := Dialog confirmWithCancel:'is this simple ?'.
- answer isNil ifTrue:[
- Transcript showCR:'no easy decision'
- ] ifFalse:[
- answer ifTrue:[
- Transcript showCR:'thats what I expected'
- ] ifFalse:[
- Transcript showCR:'read more examples and documentation'
- ]
- ]
- [exEnd]
+ [exBegin]
+ |answer|
+
+ answer := Dialog confirmWithCancel:'is this simple ?'.
+ answer isNil ifTrue:[
+ Transcript showCR:'no easy decision'
+ ] ifFalse:[
+ answer ifTrue:[
+ Transcript showCR:'thats what I expected'
+ ] ifFalse:[
+ Transcript showCR:'read more examples and documentation'
+ ]
+ ]
+ [exEnd]
asking for a string:
- [exBegin]
- |s|
-
- s := Dialog request:'enter your name, please:'.
- s notEmpty ifTrue:[
- Transcript showCR:'you entered: ' , s.
- ]
- [exEnd]
+ [exBegin]
+ |s|
+
+ s := Dialog request:'enter your name, please:'.
+ s notEmpty ifTrue:[
+ Transcript showCR:'you entered: ' , s.
+ ]
+ [exEnd]
asking for a string with given default:
- [exBegin]
- |s|
-
- s := Dialog
- request:'enter your name, please:'
- initialAnswer:(OperatingSystem getLoginName).
- s notEmpty ifTrue:[
- Transcript showCR:'you entered: ' , s.
- ]
- [exEnd]
+ [exBegin]
+ |s|
+
+ s := Dialog
+ request:'enter your name, please:'
+ initialAnswer:(OperatingSystem getLoginName).
+ s notEmpty ifTrue:[
+ Transcript showCR:'you entered: ' , s.
+ ]
+ [exEnd]
asking for a filename:
- [exBegin]
- |s|
-
- s := Dialog
- requestFileName:'select a file, please:'
- default:''.
- Transcript show:'you entered: '; showCR:s.
- [exEnd]
+ [exBegin]
+ |s|
+
+ s := Dialog
+ requestFileName:'select a file, please:'
+ default:''.
+ Transcript show:'you entered: '; showCR:s.
+ [exEnd]
with a namefiler pattern:
- [exBegin]
- |s|
-
- s := Dialog
- requestFileName:'select a file, please:'
- default:''
- pattern:'*.rc'.
- Transcript show:'you entered: '; showCR:s.
- [exEnd]
+ [exBegin]
+ |s|
+
+ s := Dialog
+ requestFileName:'select a file, please:'
+ default:''
+ pattern:'*.rc'.
+ Transcript show:'you entered: '; showCR:s.
+ [exEnd]
another namefiler pattern:
- [exBegin]
- |s|
-
- s := Dialog
- requestFileName:'select a file, please:'
- default:''
- pattern:'*.rc;*.st;*.h'.
- Transcript show:'you entered: '; showCR:s.
- [exEnd]
+ [exBegin]
+ |s|
+
+ s := Dialog
+ requestFileName:'select a file, please:'
+ default:''
+ pattern:'*.rc;*.st;*.h'.
+ Transcript show:'you entered: '; showCR:s.
+ [exEnd]
with changed button label and pattern:
- [exBegin]
- |s|
-
- s := Dialog
- requestFileName:'select a file, please:'
- default:''
- ok:'show'
- abort:'cancel'
- pattern:'*.rc'.
- Transcript show:'you entered: '; showCR:s.
- [exEnd]
+ [exBegin]
+ |s|
+
+ s := Dialog
+ requestFileName:'select a file, please:'
+ default:''
+ ok:'show'
+ abort:'cancel'
+ pattern:'*.rc'.
+ Transcript show:'you entered: '; showCR:s.
+ [exEnd]
asking for a password:
- [exBegin]
- |s|
-
- s := Dialog
- requestPassword:'enter your secret, please:'.
- Transcript show:'you entered: '; showCR:s.
- [exEnd]
+ [exBegin]
+ |s|
+
+ s := Dialog
+ requestPassword:'enter your secret, please:'.
+ Transcript show:'you entered: '; showCR:s.
+ [exEnd]
multiple choice dialogs:
- [exBegin]
- Dialog
- choose:'choose any'
- fromList:nil
- values:nil
- buttons:#('one' 'two' 'three' 'four')
- values:#(1 2 3 4)
- lines:nil
- cancel:nil
- [exEnd]
+ [exBegin]
+ Dialog
+ choose:'choose any'
+ fromList:nil
+ values:nil
+ buttons:#('one' 'two' 'three' 'four')
+ values:#(1 2 3 4)
+ lines:nil
+ cancel:nil
+ [exEnd]
multiple choice dialog, with list & buttons:
- [exBegin]
- Transcript showCR:(
- Dialog
- choose:'choose example'
- fromList:#('one' 'two' 'three' 'four')
- values:#(1 2 3 4)
- buttons:#('five' 'six' 'seven')
- values:#(5 6 7)
- lines:4
- cancel:[Transcript flash. #aborted]
- )
- [exEnd]
+ [exBegin]
+ Transcript showCR:(
+ Dialog
+ choose:'choose example'
+ fromList:#('one' 'two' 'three' 'four')
+ values:#(1 2 3 4)
+ buttons:#('five' 'six' 'seven')
+ values:#(5 6 7)
+ lines:4
+ cancel:[Transcript flash. #aborted]
+ )
+ [exEnd]
You can (and often have to) construct custom dialogs programmatically,
from individual components. As shown in the following examples:
basic (unusable) example:
- [exBegin]
- DialogBox new open
- [exEnd]
+ [exBegin]
+ DialogBox new open
+ [exEnd]
still unusable - only an ok-button:
- [exBegin]
- DialogBox new addOkButton; open
- [exEnd]
+ [exBegin]
+ DialogBox new addOkButton; open
+ [exEnd]
both ok- and abortButtons:
- [exBegin]
- DialogBox new addAbortButton; addOkButton; open
- [exEnd]
+ [exBegin]
+ DialogBox new addAbortButton; addOkButton; open
+ [exEnd]
with different ok-label:
- [exBegin]
- DialogBox new addAbortButton; addOkButtonLabelled:'yeah'; open
- [exEnd]
+ [exBegin]
+ DialogBox new addAbortButton; addOkButtonLabelled:'yeah'; open
+ [exEnd]
adding a (centered by default) textlabel gives an infoBox:
- [exBegin]
- DialogBox new
- addTextLabel:'hello';
- addOkButton;
- open
- [exEnd]
+ [exBegin]
+ DialogBox new
+ addTextLabel:'hello';
+ addOkButton;
+ open
+ [exEnd]
a textlabel with abort- and okButton gives a yesNoBox:
- [exBegin]
- DialogBox new
- addTextLabel:'hello';
- addAbortButton;
- addOkButton;
- open
- [exEnd]
+ [exBegin]
+ DialogBox new
+ addTextLabel:'hello';
+ addAbortButton;
+ addOkButton;
+ open
+ [exEnd]
the same, adjusting the labels contents to the left:
- [exBegin]
- |box|
-
- box := DialogBox new.
- (box addTextLabel:'hello') adjust:#left.
- box addAbortButton;
- addOkButton;
- open
- [exEnd]
+ [exBegin]
+ |box|
+
+ box := DialogBox new.
+ (box addTextLabel:'hello') adjust:#left.
+ box addAbortButton;
+ addOkButton;
+ open
+ [exEnd]
with modified buttons:
- [exBegin]
- |box|
-
- box := DialogBox new.
- (box addTextLabel:'are you certain ?') adjust:#left.
- box addAbortButtonLabelled:'not really'.
- (box addOkButtonLabelled:'yes, absolutely')
- activeBackgroundColor:Color red.
- box open
- [exEnd]
+ [exBegin]
+ |box|
+
+ box := DialogBox new.
+ (box addTextLabel:'are you certain ?') adjust:#left.
+ box addAbortButtonLabelled:'not really'.
+ (box addOkButtonLabelled:'yes, absolutely')
+ activeBackgroundColor:Color red.
+ box open
+ [exEnd]
mswindows style (different up/down bitmaps in buttons):
((try tabbing ...)
- [exBegin]
- |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
- [exEnd]
+ [exBegin]
+ |b box|
+
+ box := DialogBox new.
+ (box addTextLabel:'are you certain ?') adjust:#left.
+ b := Button new.
+ b activeLogo:(Image fromFile:'cancel_down.bmp' inPackage:'stx:goodies/bitmaps/winImages').
+ b passiveLogo:(Image fromFile:'cancel_up.bmp' inPackage:'stx:goodies/bitmaps/winImages').
+ b focusLogo:(Image fromFile:'cancel_focus.bmp' inPackage:'stx:goodies/bitmaps/winImages').
+ b beImageButton.
+ box addAbortButton:b.
+
+ b := Button new.
+ b activeLogo:(Image fromFile:'ok_down.bmp' inPackage:'stx:goodies/bitmaps/winImages').
+ b passiveLogo:(Image fromFile:'ok_up.bmp' inPackage:'stx:goodies/bitmaps/winImages').
+ b focusLogo:(Image fromFile:'ok_focus.bmp' inPackage:'stx:goodies/bitmaps/winImages').
+ b beImageButton.
+ box addOkButton:b.
+ box open
+ [exEnd]
two textlabels:
- [exBegin]
- DialogBox new
- addTextLabel:'hello';
- addTextLabel:'world';
- addAbortButton;
- addOkButton;
- open
- [exEnd]
+ [exBegin]
+ DialogBox new
+ addTextLabel:'hello';
+ addTextLabel:'world';
+ addAbortButton;
+ addOkButton;
+ open
+ [exEnd]
fixing the dialogs size (suppres it calculating its size from the
preferredExtents of its components):
- [exBegin]
- DialogBox new
- label:'a simple dialog';
- addTextLabel:'hello';
- addAbortButton;
- addOkButton;
- extent:200@200;
- sizeFixed:true;
- open
- [exEnd]
+ [exBegin]
+ DialogBox new
+ label:'a simple dialog';
+ addTextLabel:'hello';
+ addAbortButton;
+ addOkButton;
+ extent:200@200;
+ sizeFixed:true;
+ open
+ [exEnd]
asking the box if it was closed via ok:
- [exBegin]
- (DialogBox new
- label:'a simple dialog';
- addTextLabel:'hello';
- addAbortButton;
- addOkButton;
- extent:200@200;
- sizeFixed:true;
- open
- ) accepted ifTrue:[
- Transcript showCR:'yes'
- ] ifFalse:[
- Transcript showCR:'no'
- ]
- [exEnd]
+ [exBegin]
+ (DialogBox new
+ label:'a simple dialog';
+ addTextLabel:'hello';
+ addAbortButton;
+ addOkButton;
+ extent:200@200;
+ sizeFixed:true;
+ open
+ ) accepted ifTrue:[
+ Transcript showCR:'yes'
+ ] ifFalse:[
+ Transcript showCR:'no'
+ ]
+ [exEnd]
textLabels are not limited to strings (although, the name which is
used for ST-80 compatibility, suggests it):
- [exBegin]
- DialogBox new
- addTextLabel:(Image fromFile:'bitmaps/garfield.gif');
- addOkButton;
- open
- [exEnd]
-
- [exBegin]
- DialogBox new
- addTextLabel:'hello';
- addTextLabel:((Image fromFile:'bitmaps/garfield.gif')
- magnifiedTo:200@150);
- addTextLabel:'world';
- addAbortButton;
- addOkButton;
- open
- [exEnd]
+ [exBegin]
+ DialogBox new
+ addTextLabel:(Image fromFile:'garfield.gif' inPackage:'stx:goodies/bitmaps/gifImages');
+ addOkButton;
+ open
+ [exEnd]
+
+ [exBegin]
+ DialogBox new
+ addTextLabel:'hello';
+ addTextLabel:((Image fromFile:'garfield.gif' inPackage:'stx:goodies/bitmaps/gifImages')
+ magnifiedTo:200@150);
+ addTextLabel:'world';
+ addAbortButton;
+ addOkButton;
+ open
+ [exEnd]
adding an input field (on a string model):
- [exBegin]
- |stringModel|
-
- stringModel := '' asValue.
- (DialogBox new
- addTextLabel:'Please enter a string:';
- addInputFieldOn:stringModel;
- addAbortButton;
- addOkButton;
- open
- ) accepted ifTrue:[
- Transcript showCR:'entered: ', stringModel value
- ]
- [exEnd]
+ [exBegin]
+ |stringModel|
+
+ stringModel := '' asValue.
+ (DialogBox new
+ addTextLabel:'Please enter a string:';
+ addInputFieldOn:stringModel;
+ addAbortButton;
+ addOkButton;
+ open
+ ) accepted ifTrue:[
+ Transcript showCR:'entered: ', stringModel value
+ ]
+ [exEnd]
multiple input fields (notice, that the dialog connects the fields
in a group, so stepping is allowed via Cursor and Return keys):
- [exBegin]
- |firstName lastName|
-
- firstName := '' asValue.
- lastName := '' asValue.
- (DialogBox new
- addTextLabel:'Please enter your name:';
- addInputFieldOn:firstName;
- addVerticalSpace;
- addInputFieldOn:lastName;
- addAbortButton;
- addOkButton;
- open
- ) accepted ifTrue:[
- Transcript showCR:'entered: ', firstName value , ' ' , lastName value
- ]
- [exEnd]
+ [exBegin]
+ |firstName lastName|
+
+ firstName := '' asValue.
+ lastName := '' asValue.
+ (DialogBox new
+ addTextLabel:'Please enter your name:';
+ addInputFieldOn:firstName;
+ addVerticalSpace;
+ addInputFieldOn:lastName;
+ addAbortButton;
+ addOkButton;
+ open
+ ) accepted ifTrue:[
+ Transcript showCR:'entered: ', firstName value , ' ' , lastName value
+ ]
+ [exEnd]
of course, the model may contain a value initially:
- [exBegin]
- |firstName lastName p line i name|
-
- firstName := '' asValue.
- lastName := '' asValue.
- p := PipeStream readingFrom:'finger ' , OperatingSystem getLoginName.
- p notNil ifTrue:[
- line := p nextLine.
- (i := line findString:'Name:') ~~ 0 ifTrue:[
- name := line copyFrom:(i + 'Name:' size).
- ] ifFalse:[
- (i := line findString:'real life:') == 0 ifTrue:[
- line := p nextLine.
- ].
- (i := line findString:'real life:') ~~ 0 ifTrue:[
- name := line copyFrom:(i + 'real life:' size).
- ]
- ].
- name notNil ifTrue:[
- firstName value: name asCollectionOfWords first.
- lastName value: name asCollectionOfWords last.
- Transcript showCR:'initially ' , firstName value , ' ' , lastName value.
- ].
- p close.
- ].
-
- (DialogBox new
- addTextLabel:'Please enter your name:';
- addInputFieldOn:firstName;
- addVerticalSpace;
- addInputFieldOn:lastName;
- addAbortButton;
- addOkButton;
- open
- ) accepted ifTrue:[
- Transcript showCR:'entered: ', firstName value , ' ' , lastName value
- ]
- [exEnd]
+ [exBegin]
+ |firstName lastName p line i name|
+
+ firstName := '' asValue.
+ lastName := '' asValue.
+ p := PipeStream readingFrom:'finger ' , OperatingSystem getLoginName.
+ p notNil ifTrue:[
+ line := p nextLine.
+ (i := line findString:'Name:') ~~ 0 ifTrue:[
+ name := line copyFrom:(i + 'Name:' size).
+ ] ifFalse:[
+ (i := line findString:'real life:') == 0 ifTrue:[
+ line := p nextLine.
+ ].
+ (i := line findString:'real life:') ~~ 0 ifTrue:[
+ name := line copyFrom:(i + 'real life:' size).
+ ]
+ ].
+ name notNil ifTrue:[
+ firstName value: name asCollectionOfWords first.
+ lastName value: name asCollectionOfWords last.
+ Transcript showCR:'initially ' , firstName value , ' ' , lastName value.
+ ].
+ p close.
+ ].
+
+ (DialogBox new
+ addTextLabel:'Please enter your name:';
+ addInputFieldOn:firstName;
+ addVerticalSpace;
+ addInputFieldOn:lastName;
+ addAbortButton;
+ addOkButton;
+ open
+ ) accepted ifTrue:[
+ Transcript showCR:'entered: ', firstName value , ' ' , lastName value
+ ]
+ [exEnd]
validated password entry:
- [exBegin]
- |box firstEntry secondEntry|
-
- firstEntry := '' asValue.
- secondEntry := '' asValue.
-
- box := DialogBox new.
- (box addTextLabel:'Please enter your secret:') adjust:#left.
- (box addInputFieldOn:firstEntry) passwordCharacter:$*.
- box addVerticalSpace.
- (box addInputFieldOn:secondEntry) passwordCharacter:$*.
- box addAbortButton.
- box addOkButton.
- box open.
- box accepted ifTrue:[
- firstEntry value ~= secondEntry value ifTrue:[
- Transcript showCR:'wrong input - try again'
- ] ifFalse:[
- Transcript showCR:'entered: ', firstEntry value
- ]
- ]
- [exEnd]
+ [exBegin]
+ |box firstEntry secondEntry|
+
+ firstEntry := '' asValue.
+ secondEntry := '' asValue.
+
+ box := DialogBox new.
+ (box addTextLabel:'Please enter your secret:') adjust:#left.
+ (box addInputFieldOn:firstEntry) passwordCharacter:$*.
+ box addVerticalSpace.
+ (box addInputFieldOn:secondEntry) passwordCharacter:$*.
+ box addAbortButton.
+ box addOkButton.
+ box open.
+ box accepted ifTrue:[
+ firstEntry value ~= secondEntry value ifTrue:[
+ Transcript showCR:'wrong input - try again'
+ ] ifFalse:[
+ Transcript showCR:'entered: ', firstEntry value
+ ]
+ ]
+ [exEnd]
input fields with a label:
- [exBegin]
- |box firstNameHolder middleNameHolder lastNameHolder|
-
- firstNameHolder := 'John' asValue.
- middleNameHolder := 'F' asValue.
- lastNameHolder := 'Peters' asValue.
-
- box := DialogBox new.
- box
- addLabelledInputField:'first name:'
- adjust:#right
- on:firstNameHolder
- tabable:true
- separateAtX:0.4.
-
- box
- addLabelledInputField:'middle initial:'
- adjust:#right
- on:middleNameHolder
- tabable:true
- separateAtX:0.4.
-
- box
- addLabelledInputField:'last name:'
- adjust:#right
- on:lastNameHolder
- tabable:true
- separateAtX:0.4.
-
- box addOkButton.
- box open.
- [exEnd]
+ [exBegin]
+ |box firstNameHolder middleNameHolder lastNameHolder|
+
+ firstNameHolder := 'John' asValue.
+ middleNameHolder := 'F' asValue.
+ lastNameHolder := 'Peters' asValue.
+
+ box := DialogBox new.
+ box
+ addLabelledInputField:'first name:'
+ adjust:#right
+ on:firstNameHolder
+ tabable:true
+ separateAtX:0.4.
+
+ box
+ addLabelledInputField:'middle initial:'
+ adjust:#right
+ on:middleNameHolder
+ tabable:true
+ separateAtX:0.4.
+
+ box
+ addLabelledInputField:'last name:'
+ adjust:#right
+ on:lastNameHolder
+ tabable:true
+ separateAtX:0.4.
+
+ box addOkButton.
+ box open.
+ [exEnd]
constructing a dialog from other elements:
@@ -588,359 +588,359 @@
(since the dialog adds the component with its preferred extent,
ignoring the 300-height, this looks ugly ...
... especially when resized vertically)
- [exBegin]
- |top l scr fileName|
-
- fileName := '' asValue.
-
- top := DialogBox new.
-
- l := FileSelectionList new.
- l useIndex:false.
- l doubleClickAction:[:name | top okPressed].
- l action:[:name | fileName value:name].
- scr := ScrollableView forView:l.
- scr extent:(1.0 @ 300).
-
- top addComponent:scr.
- top addAbortButton; addOkButton.
- top openModal.
-
- top accepted ifTrue:[
- Transcript show:'fileName: '; showCR:fileName value storeString.
- ]
- [exEnd]
+ [exBegin]
+ |top l scr fileName|
+
+ fileName := '' asValue.
+
+ top := DialogBox new.
+
+ l := FileSelectionList new.
+ l useIndex:false.
+ l doubleClickAction:[:name | top okPressed].
+ l action:[:name | fileName value:name].
+ scr := ScrollableView forView:l.
+ scr extent:(1.0 @ 300).
+
+ top addComponent:scr.
+ top addAbortButton; addOkButton.
+ top openModal.
+
+ top accepted ifTrue:[
+ Transcript show:'fileName: '; showCR:fileName value storeString.
+ ]
+ [exEnd]
same, looks better, since the height is made larger (not using
fileLists preferredExtent):
- [exBegin]
- |top l scr fileName|
-
- fileName := '' asValue.
-
- top := DialogBox new.
-
- l := FileSelectionList new.
- l useIndex:false.
- l doubleClickAction:[:name | top okPressed].
- l action:[:name | fileName value:name].
- scr := ScrollableView forView:l.
-
- top addComponent:scr withExtent:300@300.
- top addAbortButton; addOkButton.
- top openModal.
-
- top accepted ifTrue:[
- Transcript show:'fileName: '; showCR:fileName value storeString.
- ]
- [exEnd]
+ [exBegin]
+ |top l scr fileName|
+
+ fileName := '' asValue.
+
+ top := DialogBox new.
+
+ l := FileSelectionList new.
+ l useIndex:false.
+ l doubleClickAction:[:name | top okPressed].
+ l action:[:name | fileName value:name].
+ scr := ScrollableView forView:l.
+
+ top addComponent:scr withExtent:300@300.
+ top addAbortButton; addOkButton.
+ top openModal.
+
+ top accepted ifTrue:[
+ Transcript show:'fileName: '; showCR:fileName value storeString.
+ ]
+ [exEnd]
again, setting the boxes initial size and fixing it
(let it ignore the components' preferredExtent):
- [exBegin]
- |top fixFrame l scr fileName|
-
- fileName := '' asValue.
-
- top := DialogBox new.
- top extent:300@300.
-
- fixFrame := View new.
- fixFrame extent:(1.0 @ 300).
-
- l := FileSelectionList new.
- l useIndex:false.
- l doubleClickAction:[:name | top okPressed].
- l action:[:name | fileName value:name].
- scr := ScrollableView forView:l.
- scr origin:0.0@0.0 corner:1.0@1.0.
- fixFrame add:scr.
-
- top addComponent:fixFrame.
- top addAbortButton; addOkButton.
- top openModal.
-
- top accepted ifTrue:[
- Transcript show:'fileName: '; showCR:fileName value storeString.
- ]
- [exEnd]
+ [exBegin]
+ |top fixFrame l scr fileName|
+
+ fileName := '' asValue.
+
+ top := DialogBox new.
+ top extent:300@300.
+
+ fixFrame := View new.
+ fixFrame extent:(1.0 @ 300).
+
+ l := FileSelectionList new.
+ l useIndex:false.
+ l doubleClickAction:[:name | top okPressed].
+ l action:[:name | fileName value:name].
+ scr := ScrollableView forView:l.
+ scr origin:0.0@0.0 corner:1.0@1.0.
+ fixFrame add:scr.
+
+ top addComponent:fixFrame.
+ top addAbortButton; addOkButton.
+ top openModal.
+
+ top accepted ifTrue:[
+ Transcript show:'fileName: '; showCR:fileName value storeString.
+ ]
+ [exEnd]
adding a panel with checkBoxes:
- [exBegin]
- |top panel b value1 value2 value3 value4|
-
- value1 := true asValue.
- value2 := false asValue.
- value3 := false asValue.
- value4 := true asValue.
-
- top := DialogBox new.
- top extent:200@300.
-
- panel := VerticalPanelView new.
-
- b := CheckBox on:value1. b label:'check1'.
- panel addSubView:b.
-
- b := CheckBox on:value2. b label:'check2'.
- panel addSubView:b.
-
- b := CheckBox on:value3. b label:'check3'.
- panel addSubView:b.
-
- b := CheckBox on:value4. b label:'check4'.
- panel addSubView:b.
-
- top addComponent:panel.
- top addAbortButton; addOkButton.
- top open.
-
- top accepted ifTrue:[
- Transcript show:'value1: '; showCR:value1 value.
- Transcript show:'value2: '; showCR:value2 value.
- Transcript show:'value3: '; showCR:value3 value.
- Transcript show:'value4: '; showCR:value4 value.
- ]
- [exEnd]
+ [exBegin]
+ |top panel b value1 value2 value3 value4|
+
+ value1 := true asValue.
+ value2 := false asValue.
+ value3 := false asValue.
+ value4 := true asValue.
+
+ top := DialogBox new.
+ top extent:200@300.
+
+ panel := VerticalPanelView new.
+
+ b := CheckBox on:value1. b label:'check1'.
+ panel addSubView:b.
+
+ b := CheckBox on:value2. b label:'check2'.
+ panel addSubView:b.
+
+ b := CheckBox on:value3. b label:'check3'.
+ panel addSubView:b.
+
+ b := CheckBox on:value4. b label:'check4'.
+ panel addSubView:b.
+
+ top addComponent:panel.
+ top addAbortButton; addOkButton.
+ top open.
+
+ top accepted ifTrue:[
+ Transcript show:'value1: '; showCR:value1 value.
+ Transcript show:'value2: '; showCR:value2 value.
+ Transcript show:'value3: '; showCR:value3 value.
+ Transcript show:'value4: '; showCR:value4 value.
+ ]
+ [exEnd]
same, using a more convenient interface:
- [exBegin]
- |box value1 value2 value3 value4|
-
- value1 := true asValue.
- value2 := false asValue.
- value3 := false asValue.
- value4 := true asValue.
-
- box := DialogBox new.
- box extent:200@300.
-
- box addCheckBox:'check1' on:value1.
- box addVerticalSpace.
- box addCheckBox:'check2' on:value2.
- box addVerticalSpace.
- box addCheckBox:'check3' on:value3.
- box addVerticalSpace.
- box addCheckBox:'check4' on:value4.
-
- box addAbortButton; addOkButton.
- box open.
-
- box accepted ifTrue:[
- Transcript show:'value1: '; showCR:value1 value.
- Transcript show:'value2: '; showCR:value2 value.
- Transcript show:'value3: '; showCR:value3 value.
- Transcript show:'value4: '; showCR:value4 value.
- ]
- [exEnd]
+ [exBegin]
+ |box value1 value2 value3 value4|
+
+ value1 := true asValue.
+ value2 := false asValue.
+ value3 := false asValue.
+ value4 := true asValue.
+
+ box := DialogBox new.
+ box extent:200@300.
+
+ box addCheckBox:'check1' on:value1.
+ box addVerticalSpace.
+ box addCheckBox:'check2' on:value2.
+ box addVerticalSpace.
+ box addCheckBox:'check3' on:value3.
+ box addVerticalSpace.
+ box addCheckBox:'check4' on:value4.
+
+ box addAbortButton; addOkButton.
+ box open.
+
+ box accepted ifTrue:[
+ Transcript show:'value1: '; showCR:value1 value.
+ Transcript show:'value2: '; showCR:value2 value.
+ Transcript show:'value3: '; showCR:value3 value.
+ Transcript show:'value4: '; showCR:value4 value.
+ ]
+ [exEnd]
same, using an even better interface:
- [exBegin]
- |box values labels|
-
- values := #(true false false true) collect:[:val | val asValue].
- labels := #('check1' 'check2' 'check3' 'check4').
-
- box := Dialog new.
-
- box
- addColumn:(1 to:labels size)
- fromX:0.0
- toX:1.0
- collect:[:index | CheckBox label:(labels at:index) model:(values at:index)]
- tabable:true.
+ [exBegin]
+ |box values labels|
+
+ values := #(true false false true) collect:[:val | val asValue].
+ labels := #('check1' 'check2' 'check3' 'check4').
+
+ box := Dialog new.
+
+ box
+ addColumn:(1 to:labels size)
+ fromX:0.0
+ toX:1.0
+ collect:[:index | CheckBox label:(labels at:index) model:(values at:index)]
+ tabable:true.
- box addAbortButton; addOkButton.
- box open.
-
- box accepted ifTrue:[
- values with:labels do:[:val :lbl |
- Transcript show:(lbl , ': '); showCR:val value.
- ]
- ]
- [exEnd]
+ box addAbortButton; addOkButton.
+ box open.
+
+ box accepted ifTrue:[
+ values with:labels do:[:val :lbl |
+ Transcript show:(lbl , ': '); showCR:val value.
+ ]
+ ]
+ [exEnd]
adding two panels in a frame:
- [exBegin]
- |box frame vPanel1 vPanel2 m1 m2 m3 m4 chk ef|
-
- box := Dialog new.
- box label:'example'.
-
- frame := FramedBox label:'frame'.
-
- vPanel1 := VerticalPanelView origin:0.0@0.0 corner:0.5@1.0 in:frame.
- vPanel1 horizontalLayout:#leftSpace.
- vPanel1 verticalLayout:#spreadSpace.
-
- vPanel2 := VerticalPanelView origin:0.5@0.0 corner:1.0@1.0 in:frame.
- vPanel2 horizontalLayout:#leftSpace.
- vPanel2 verticalLayout:#spreadSpace.
-
- m1 := true asValue.
- m2 := true asValue.
- m3 := true asValue.
- m4 := 'hello' asValue.
-
- vPanel1 add:(Label label:'check1').
- vPanel1 add:(Label label:'m2').
- vPanel1 add:(Label label:'m3').
- vPanel1 add:(Label label:'enter').
- vPanel1 add:(Label label:'lbl1').
- vPanel1 add:(Label label:'lbl2').
-
- vPanel2 add:(chk := CheckToggle on:m1).
- box makeTabable:chk.
-
- vPanel2 add:(chk := CheckToggle on:m2).
- box makeTabable:chk.
-
- vPanel2 add:(chk := CheckToggle on:m3).
- box makeTabable:chk.
-
- vPanel2 add:(chk := CheckToggle on:m3).
- box makeTabable:chk.
-
- vPanel2 add:(chk := CheckToggle on:m3).
- box makeTabable:chk.
-
- vPanel2 add:(ef := EditField on:m4).
- ef immediateAccept:true.
- box makeTabable:ef.
-
- box addComponent:frame.
-
- box addAbortButton; addOkButton.
- box openModal.
- box accepted ifTrue:[
- Transcript showCR:'accepted with:'.
- Transcript showCR:' m1: ' , m1 value printString.
- Transcript showCR:' m2: ' , m2 value printString.
- Transcript showCR:' m3: ' , m3 value printString.
- Transcript showCR:' m4: ' , m4 value printString.
- ]
- [exEnd]
+ [exBegin]
+ |box frame vPanel1 vPanel2 m1 m2 m3 m4 chk ef|
+
+ box := Dialog new.
+ box label:'example'.
+
+ frame := FramedBox label:'frame'.
+
+ vPanel1 := VerticalPanelView origin:0.0@0.0 corner:0.5@1.0 in:frame.
+ vPanel1 horizontalLayout:#leftSpace.
+ vPanel1 verticalLayout:#spreadSpace.
+
+ vPanel2 := VerticalPanelView origin:0.5@0.0 corner:1.0@1.0 in:frame.
+ vPanel2 horizontalLayout:#leftSpace.
+ vPanel2 verticalLayout:#spreadSpace.
+
+ m1 := true asValue.
+ m2 := true asValue.
+ m3 := true asValue.
+ m4 := 'hello' asValue.
+
+ vPanel1 add:(Label label:'check1').
+ vPanel1 add:(Label label:'m2').
+ vPanel1 add:(Label label:'m3').
+ vPanel1 add:(Label label:'enter').
+ vPanel1 add:(Label label:'lbl1').
+ vPanel1 add:(Label label:'lbl2').
+
+ vPanel2 add:(chk := CheckToggle on:m1).
+ box makeTabable:chk.
+
+ vPanel2 add:(chk := CheckToggle on:m2).
+ box makeTabable:chk.
+
+ vPanel2 add:(chk := CheckToggle on:m3).
+ box makeTabable:chk.
+
+ vPanel2 add:(chk := CheckToggle on:m3).
+ box makeTabable:chk.
+
+ vPanel2 add:(chk := CheckToggle on:m3).
+ box makeTabable:chk.
+
+ vPanel2 add:(ef := EditField on:m4).
+ ef immediateAccept:true.
+ box makeTabable:ef.
+
+ box addComponent:frame.
+
+ box addAbortButton; addOkButton.
+ box openModal.
+ box accepted ifTrue:[
+ Transcript showCR:'accepted with:'.
+ Transcript showCR:' m1: ' , m1 value printString.
+ Transcript showCR:' m2: ' , m2 value printString.
+ Transcript showCR:' m3: ' , m3 value printString.
+ Transcript showCR:' m4: ' , m4 value printString.
+ ]
+ [exEnd]
a full example (combined settings dialog - as in launcher):
- [exBegin]
- |box warnSTX allowUnderscore immutableArrays logDoits
- listOfLanguages listOfStyles styleNames
- frame panel c resourceDir dir |
-
- warnSTX := Compiler warnSTXSpecials asValue.
- allowUnderscore := Compiler allowUnderscoreInIdentifier asValue.
- immutableArrays := Compiler arraysAreImmutable asValue.
-
- logDoits := Smalltalk logDoits asValue.
-
- listOfLanguages := SelectionInList with:#('english'
- 'french'
- 'german'
- 'italian'
- 'spanish'
- ).
- listOfLanguages selection:(Language asString).
-
-
- resourceDir := Smalltalk getSystemFileName:'resources'.
- dir := FileDirectory directoryNamed:resourceDir.
-
- styleNames := dir select:[:aFileName | aFileName endsWith:'.style'].
- styleNames := styleNames collect:[:aFileName | aFileName copyWithoutLast:6].
- listOfStyles := SelectionInList with:styleNames sort.
- listOfStyles selection:(View defaultStyle asString).
-
- box := Dialog new.
- box label:'Settings'.
-
- frame := FramedBox label:'Compiler'.
- panel := VerticalPanelView origin:0.0@0.0 corner:1.0@1.0 in:frame.
- panel horizontalLayout:#leftSpace.
-
- panel add:((CheckBox on:warnSTX) label:'warn about ST/X language extensions'; resize).
- panel add:((CheckBox on:allowUnderscore) label:'allow underscore in identifiers'; resize).
- panel add:((CheckBox on:immutableArrays) label:'literal arrays are immutable'; resize).
- box addComponent:frame.
-
- frame := FramedBox label:'Misc'.
- panel := VerticalPanelView origin:0.0@0.0 corner:1.0@1.0 in:frame.
- panel horizontalLayout:#leftSpace.
-
- panel add:((CheckBox on:logDoits) label:'log doIts in changes file'; resize).
- box addComponent:frame.
-
- frame := FramedBox label:'Language'.
- panel := VerticalPanelView origin:0.0@0.0 corner:1.0@1.0 in:frame.
- panel horizontalLayout:#leftSpace.
-
- panel add:((PopUpList on:listOfLanguages) width:0.5).
- box addComponent:frame.
-
- frame := FramedBox label:'Style'.
- panel := VerticalPanelView origin:0.0@0.0 corner:1.0@1.0 in:frame.
- panel horizontalLayout:#leftSpace.
-
- panel add:((PopUpList on:listOfStyles) width:0.5).
- box addComponent:frame.
-
- box addAbortButton; addOkButton.
- box showAtPointer.
-
- box accepted ifTrue:[
- Transcript topView withCursor:Cursor wait do:[
- Compiler warnSTXSpecials:warnSTX value.
- Compiler allowUnderscoreInIdentifier:allowUnderscore value.
- Compiler arraysAreImmutable:immutableArrays value.
-
- Smalltalk logDoits:logDoits value.
-
- Transcript showCR:'change language to ' , listOfLanguages selection , ' ...'.
- Smalltalk at:#Language put:listOfLanguages selection asSymbol.
- Smalltalk changed:#Language.
- ResourcePack flushCachedResourcePacks.
-
- Transcript showCR:'change style to ' , listOfStyles selection , ' ...'.
- View defaultStyle:listOfStyles selection asSymbol.
- ]
- ]
- [exEnd]
+ [exBegin]
+ |box warnSTX allowUnderscore immutableArrays logDoits
+ listOfLanguages listOfStyles styleNames
+ frame panel c resourceDir dir |
+
+ warnSTX := Compiler warnSTXSpecials asValue.
+ allowUnderscore := Compiler allowUnderscoreInIdentifier asValue.
+ immutableArrays := Compiler arraysAreImmutable asValue.
+
+ logDoits := Smalltalk logDoits asValue.
+
+ listOfLanguages := SelectionInList with:#('english'
+ 'french'
+ 'german'
+ 'italian'
+ 'spanish'
+ ).
+ listOfLanguages selection:(Language asString).
+
+
+ resourceDir := Smalltalk getSystemFileName:'resources'.
+ dir := FileDirectory directoryNamed:resourceDir.
+
+ styleNames := dir select:[:aFileName | aFileName endsWith:'.style'].
+ styleNames := styleNames collect:[:aFileName | aFileName copyWithoutLast:6].
+ listOfStyles := SelectionInList with:styleNames sort.
+ listOfStyles selection:(View defaultStyle asString).
+
+ box := Dialog new.
+ box label:'Settings'.
+
+ frame := FramedBox label:'Compiler'.
+ panel := VerticalPanelView origin:0.0@0.0 corner:1.0@1.0 in:frame.
+ panel horizontalLayout:#leftSpace.
+
+ panel add:((CheckBox on:warnSTX) label:'warn about ST/X language extensions'; resize).
+ panel add:((CheckBox on:allowUnderscore) label:'allow underscore in identifiers'; resize).
+ panel add:((CheckBox on:immutableArrays) label:'literal arrays are immutable'; resize).
+ box addComponent:frame.
+
+ frame := FramedBox label:'Misc'.
+ panel := VerticalPanelView origin:0.0@0.0 corner:1.0@1.0 in:frame.
+ panel horizontalLayout:#leftSpace.
+
+ panel add:((CheckBox on:logDoits) label:'log doIts in changes file'; resize).
+ box addComponent:frame.
+
+ frame := FramedBox label:'Language'.
+ panel := VerticalPanelView origin:0.0@0.0 corner:1.0@1.0 in:frame.
+ panel horizontalLayout:#leftSpace.
+
+ panel add:((PopUpList on:listOfLanguages) width:0.5).
+ box addComponent:frame.
+
+ frame := FramedBox label:'Style'.
+ panel := VerticalPanelView origin:0.0@0.0 corner:1.0@1.0 in:frame.
+ panel horizontalLayout:#leftSpace.
+
+ panel add:((PopUpList on:listOfStyles) width:0.5).
+ box addComponent:frame.
+
+ box addAbortButton; addOkButton.
+ box showAtPointer.
+
+ box accepted ifTrue:[
+ Transcript topView withCursor:Cursor wait do:[
+ Compiler warnSTXSpecials:warnSTX value.
+ Compiler allowUnderscoreInIdentifier:allowUnderscore value.
+ Compiler arraysAreImmutable:immutableArrays value.
+
+ Smalltalk logDoits:logDoits value.
+
+ Transcript showCR:'change language to ' , listOfLanguages selection , ' ...'.
+ Smalltalk at:#Language put:listOfLanguages selection asSymbol.
+ Smalltalk changed:#Language.
+ ResourcePack flushCachedResourcePacks.
+
+ Transcript showCR:'change style to ' , listOfStyles selection , ' ...'.
+ View defaultStyle:listOfStyles selection asSymbol.
+ ]
+ ]
+ [exEnd]
an example from Hopkins/Horan:
- [exBegin]
- |aText index|
-
- aText := 'Smalltalk/X: An Introduction to Application Development' asText.
- index := aText findString:'Smalltalk/X' startingAt:1.
- aText emphasizeFrom:index
- to:'Smalltalk/X' size + index - 1
- with:#bold.
- index := aText findString:'Introduction' startingAt:index.
- aText emphasizeFrom:index
- to:'Introduction' size + index - 1
- with:#italic.
- Dialog warn:aText
+ [exBegin]
+ |aText index|
+
+ aText := 'Smalltalk/X: An Introduction to Application Development' asText.
+ index := aText findString:'Smalltalk/X' startingAt:1.
+ aText emphasizeFrom:index
+ to:'Smalltalk/X' size + index - 1
+ with:#bold.
+ index := aText findString:'Introduction' startingAt:index.
+ aText emphasizeFrom:index
+ to:'Introduction' size + index - 1
+ with:#italic.
+ Dialog warn:aText
- [exEnd]
+ [exEnd]
the same, with colors:
- [exBegin]
- |aText index|
-
- aText := 'Smalltalk/X: An Introduction to Application Development' asText.
- index := aText findString:'Smalltalk/X' startingAt:1.
- aText emphasizeFrom:index
- to:'Smalltalk/X' size + index - 1
- with:(Array with:#bold with:#underline with:(#color->Color red)).
- index := aText findString:'Introduction' startingAt:index.
- aText emphasizeFrom:index
- to:'Introduction' size + index - 1
- with:#italic.
- Dialog warn:aText
- [exEnd]
+ [exBegin]
+ |aText index|
+
+ aText := 'Smalltalk/X: An Introduction to Application Development' asText.
+ index := aText findString:'Smalltalk/X' startingAt:1.
+ aText emphasizeFrom:index
+ to:'Smalltalk/X' size + index - 1
+ with:(Array with:#bold with:#underline with:(#color->Color red)).
+ index := aText findString:'Introduction' startingAt:index.
+ aText emphasizeFrom:index
+ to:'Introduction' size + index - 1
+ with:#italic.
+ Dialog warn:aText
+ [exEnd]
"
!
@@ -4847,7 +4847,7 @@
"
|dialog b|
- b := Button label:((Image fromFile:'garfield.gif') magnifiedBy:0.5).
+ b := Button label:((Image fromFile:'garfield.gif' inPackage:'stx:goodies/bitmaps/gifImages') magnifiedBy:0.5).
dialog := DialogBox new.
dialog addOkButton:b.
@@ -6861,6 +6861,6 @@
!DialogBox class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libwidg/DialogBox.st,v 1.164 2001-05-15 17:46:38 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libwidg/DialogBox.st,v 1.165 2001-05-17 12:17:44 cg Exp $'
! !
DialogBox initialize!
--- a/InfoBox.st Tue May 15 19:46:48 2001 +0200
+++ b/InfoBox.st Thu May 17 14:17:46 2001 +0200
@@ -12,6 +12,8 @@
+"{ Package: 'stx:libwidg' }"
+
DialogBox subclass:#InfoBox
instanceVariableNames:'formLabel textLabel'
classVariableNames:'InfoBitmap'
@@ -130,10 +132,10 @@
changing the icon:
[exBegin]
-|box|
+ |box|
box := InfoBox title:'hello world '.
- box image:(Image fromFile:'bitmaps/SBrowser.xbm').
+ box image:(Image fromFile:'bitmaps/SBrowser.xbm' inPackage:'stx:libtool').
box okText:'wow'.
box open
[exEnd]
@@ -143,7 +145,7 @@
|box|
box := InfoBox title:'hello garfield '.
- box image:((Image fromFile:'bitmaps/garfield.gif') magnifiedTo:200@100).
+ box image:((Image fromFile:'garfield.gif' inPackage:'stx:goodies/bitmaps/gifImages') magnifiedTo:200@100).
box okText:'wow'.
box open
[exEnd]
@@ -155,7 +157,7 @@
|box|
box := InfoBox title:'hello garfield '.
- box image:((Image fromFile:'bitmaps/garfield.gif') magnifiedTo:200@100).
+ box image:((Image fromFile:'garfield.gif' inPackage:'stx:goodies/bitmaps/gifImages') magnifiedTo:200@100).
box okText:'wow'.
box open.
@@ -369,5 +371,5 @@
!InfoBox class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libwidg/InfoBox.st,v 1.36 1999-12-09 11:13:43 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libwidg/InfoBox.st,v 1.37 2001-05-17 12:17:40 cg Exp $'
! !
--- a/WarningBox.st Tue May 15 19:46:48 2001 +0200
+++ b/WarningBox.st Thu May 17 14:17:46 2001 +0200
@@ -10,6 +10,8 @@
hereby transferred.
"
+"{ Package: 'stx:libwidg' }"
+
InfoBox subclass:#WarningBox
instanceVariableNames:''
classVariableNames:'WarnBitmap'
@@ -124,7 +126,7 @@
aBox := WarningBox title:'Press ''OK'' to continue'.
aBox okText:'yes, continue'.
- image := Image fromFile:'bitmaps/SmalltalkX.xbm'.
+ image := Image fromFile:'bitmaps/SmalltalkX.xbm' inPackage:'stx:libtool'.
aBox form:image.
aBox showAtPointer.
[exEnd]
@@ -164,7 +166,7 @@
|box|
box := WarningBox title:'foo bar'.
- box image:(Image fromFile:'bitmaps/QUESTION.xpm').
+ box image:(Image fromFile:'QUESTION.xpm' inPackage:'stx:goodies/bitmaps/xpmBitmaps').
box showAtPointer.
"
@@ -208,5 +210,5 @@
!WarningBox class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libwidg/WarningBox.st,v 1.27 1999-12-09 11:10:21 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libwidg/WarningBox.st,v 1.28 2001-05-17 12:17:46 cg Exp $'
! !