SimpleDialog.st
changeset 1793 eba6da749414
parent 1640 5bd912083327
child 1881 22a568696a7b
--- a/SimpleDialog.st	Tue Aug 19 19:54:07 2003 +0200
+++ b/SimpleDialog.st	Tue Aug 19 19:55:33 2003 +0200
@@ -66,127 +66,6 @@
     ^super isVisualStartable
 ! !
 
-!SimpleDialog methodsFor:'RefactoringBrowser'!
-
-addMultiList: model lines: maxLines validation: valid
-	| height layout field grid font scrollW max fullMax |
-
-	height := builder window displayBox height.
-	layout := LayoutFrame new.
-	layout leftOffset: 16 topOffset: height.
-	layout rightFraction: 1 offset: -16.
-	field := SequenceViewSpec model: model menu: nil layout: layout.
-	field multipleSelections: true.
-	builder add: field.
-	builder wrapper widget controller setDispatcher:
-		(UIDispatcher new doubleClick: [valid value ifTrue: [accept value: true]]).
-	"builder wrapper widget setValidTargetIndex: model selectionIndex."
-	scrollW := builder wrapper decorator scrollerComponent.
-	scrollW preferredBoundsBlock:
-				[:sw | | rect |
-				rect := sw component preferredBounds
-						translatedBy: sw translation.
-				rect height: maxLines*sw scrollGrid y.
-				rect].
-
-	font := builder wrapper widget textStyle defaultFont.
-	font := Screen default defaultFontPolicy findFont: font.
-	max := model list inject: 0 into: [:i :str | i max: str size].
-		"Instead of exactly measuring every string, we
-		assume that $o will be a fairly representative
-		character.  Actually, $o will probably be wider
-		than the average, but this will usually be OK."
-	max := (font widthOf: $o) * max.
-
-		"Don't let the dialog get too wide."
-	fullMax := 350.
-	max > fullMax
-		ifTrue:
-			[max := fullMax.
-			builder wrapper decorator useHorizontalScrollBar.
-			builder wrapper widget measureWidth: true].
-
-	grid := builder wrapper preferredBounds height.
-	layout bottomOffset: height+grid.
-	self addGap: grid.
-	self minWidth: max + 48.
-	^builder wrapper
-!
-
-chooseMultiple: messageString fromList: list values: listValues buttons: buttons values: buttonValues lines: maxLines cancel: cancelBlock 
-	^self
-		chooseMultiple: messageString
-		fromList: list
-		values: listValues
-		buttons: buttons
-		values: buttonValues
-		lines: maxLines
-		cancel: cancelBlock
-		for: nil
-!
-
-chooseMultiple: messageString fromList: list values: listValues buttons: buttons values: buttonValues lines: maxLines cancel: cancelBlock for: aVisualOrNil
-	"Ask the user a question.  Let the user pick from a row of buttons made up
-	to match the labels collection.  Return the response from the corresponding
-	item from the values collection."
-
-	"aVisualOrNil, if not nil, may be either a VisualPart or a
-	ScheduledWindow.  It controls the look and feel and color choices
-	used by the dialog, and supplies the dialog's master window, which
-	is used by some window systems to create a visual connection between
-	the dialog and the window that created it."
-
-	"SimpleDialog new
-		chooseMultiple: 'Which one do you want?'
-		fromList: #('first' 'second' 'third' 'fourth') values: #(1 2 3 4)
-		buttons: #() values: #()
-		lines: 8
-		cancel: [#noChoice]
-		for: Dialog defaultParentWindow"
-
-	| result spec okValue sequence wrappers listW |
-	wrappers := OrderedCollection new.
-	result := ValueHolder new.
-	sequence := MultiSelectionInList new.
-	sequence list: list.
-	spec := (self class interfaceSpecFor: #emptySpec).
-	okValue := Object new.
-	self initializeBuilderFor: aVisualOrNil.
-	builder add: spec window.
-	builder add: spec component.
-	self initializeWindowFor: aVisualOrNil.
-
-	self setInitialGap.
-	self addMessage: messageString centered: false.
-	self addGap: 8.
-	listW := self
-			addMultiList: sequence
-			lines: (maxLines min: list size+2)
-			validation: [true].
-	self addGap: 4.
-	wrappers add: (self addOK: [sequence selectionIndex ~= 0]).
-	buttons isEmpty
-		ifFalse:
-			[self addGap: 4.
-			wrappers add: (self addDivider).
-			self addGap: 4.
-			wrappers add:
-					(self addLabels: buttons
-						values: buttonValues
-						default: okValue
-						storeInto: result
-						takeKeyboard: true
-						equalize: true)].
-	self addGap: 6.
-	self bottomAlignLowerEdge: listW.
-	self bottomAlign: wrappers.
-
-	self preOpen.
-	builder openDialogWithExtent: builder window displayBox extent.
-	^accept value
-		ifTrue: [sequence selectionIndexes collect: [:each | listValues at: each]]
-		ifFalse: [cancel value ifTrue: [cancelBlock value] ifFalse: [result value]]
-! !
 
 !SimpleDialog methodsFor:'accessing'!
 
@@ -392,6 +271,10 @@
     "Modified: / 20.5.1998 / 21:53:35 / cg"
 !
 
+doAcceptByReturnKey
+    self doAccept
+!
+
 doCancel
     "force cancel"
 
@@ -399,6 +282,10 @@
 
     "Created: / 18.10.1997 / 05:18:22 / cg"
     "Modified: / 20.5.1998 / 21:53:40 / cg"
+!
+
+doCancelByEscapeKey
+    self doCancel
 ! !
 
 !SimpleDialog methodsFor:'initialization'!
@@ -612,5 +499,5 @@
 !SimpleDialog class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview2/SimpleDialog.st,v 1.40 2002-10-23 08:15:12 stefan Exp $'
+    ^ '$Header: /cvs/stx/stx/libview2/SimpleDialog.st,v 1.41 2003-08-19 17:55:33 cg Exp $'
 ! !