DialogBox.st
changeset 5242 2fce587be425
parent 5191 dae927f4f9c2
child 5245 a5a90c899ab2
equal deleted inserted replaced
5241:a994c267e55e 5242:2fce587be425
     8  be provided or otherwise made available to, or used by, any
     8  be provided or otherwise made available to, or used by, any
     9  other person.  No title to or ownership of the software is
     9  other person.  No title to or ownership of the software is
    10  hereby transferred.
    10  hereby transferred.
    11 "
    11 "
    12 "{ Package: 'stx:libwidg' }"
    12 "{ Package: 'stx:libwidg' }"
       
    13 
       
    14 "{ NameSpace: Smalltalk }"
    13 
    15 
    14 ModalBox subclass:#DialogBox
    16 ModalBox subclass:#DialogBox
    15 	instanceVariableNames:'buttonPanel okButton okAction abortButton abortAction
    17 	instanceVariableNames:'buttonPanel okButton okAction abortButton abortAction
    16 		acceptReturnAsOK yPosition leftIndent rightIndent addedComponents
    18 		acceptReturnAsOK yPosition leftIndent rightIndent addedComponents
    17 		inputFieldGroup acceptOnLeave acceptValue tabableElements
    19 		inputFieldGroup acceptOnLeave acceptValue tabableElements
  7133     "Modified: 9.2.1996 / 22:23:15 / cg"
  7135     "Modified: 9.2.1996 / 22:23:15 / cg"
  7134 !
  7136 !
  7135 
  7137 
  7136 addLabelledField:aView label:labelString adjust:labelAdjust tabable:tabable from:leftX to:rightX separateAtX:relativeX
  7138 addLabelledField:aView label:labelString adjust:labelAdjust tabable:tabable from:leftX to:rightX separateAtX:relativeX
  7137     "add a label and some view side-by-side.
  7139     "add a label and some view side-by-side.
  7138      The labels goes from 0.0 to relativeX; the inputField from relativeX to 1.0.
  7140      The label goes from 0.0 to relativeX; the inputField from relativeX to 1.0.
  7139      The labels string is defined by labelString and adjusted according to labelAdjust.
  7141      The label's string is defined by labelString and adjusted according to labelAdjust.
  7140      The inputField gets model as its model.
  7142      The inputField gets model as its model.
  7141      Return the inputField."
  7143      Return the inputField."
  7142 
  7144 
  7143     ^ self
  7145     ^ self
  7144 	addLabelledField:aView 
  7146         addLabelledField:aView 
  7145 	label:labelString 
  7147         label:labelString 
  7146 	adjust:labelAdjust 
  7148         adjust:labelAdjust 
  7147 	tabable:tabable 
  7149         tabable:tabable 
  7148 	from:leftX to:rightX separateAtX:relativeX 
  7150         from:leftX to:rightX separateAtX:relativeX 
  7149 	nameAs:nil
  7151         nameAs:nil
  7150 
  7152 
  7151     "
  7153     "
  7152      |dialog model field|
  7154      |dialog model field|
  7153 
  7155 
  7154      model := '' asValue.
  7156      model := '' asValue.
  7155 
  7157 
  7156      dialog := DialogBox new.
  7158      dialog := DialogBox new.
  7157 
  7159 
  7158      field := dialog 
  7160      field := dialog 
  7159 		addLabelledField:(EditField on:model) label:'input here:' 
  7161                 addLabelledField:(EditField on:model) label:'input here:' 
  7160 		adjust:#left 
  7162                 adjust:#left 
  7161 		tabable:true 
  7163                 tabable:true 
  7162 		separateAtX:0.3.
  7164                 separateAtX:0.3.
  7163 
  7165 
  7164      dialog addAbortButton; addOkButton.
  7166      dialog addAbortButton; addOkButton.
  7165      dialog open.
  7167      dialog open.
  7166      dialog accepted ifTrue:[Transcript showCR:model value].
  7168      dialog accepted ifTrue:[Transcript showCR:model value].
  7167     "
  7169     "
  7174      model selectionIndex:2.
  7176      model selectionIndex:2.
  7175 
  7177 
  7176      dialog := DialogBox new.
  7178      dialog := DialogBox new.
  7177 
  7179 
  7178      field := dialog 
  7180      field := dialog 
  7179 		addLabelledField:(PopUpList on:model) label:'select here:' 
  7181                 addLabelledField:(PopUpList on:model) label:'select here:' 
  7180 		adjust:#left 
  7182                 adjust:#left 
  7181 		tabable:true 
  7183                 tabable:true 
  7182 		separateAtX:0.3.
  7184                 separateAtX:0.3.
  7183 
  7185 
  7184      dialog addAbortButton; addOkButton.
  7186      dialog addAbortButton; addOkButton.
  7185      dialog open.
  7187      dialog open.
  7186      dialog accepted ifTrue:[Transcript showCR:model value].
  7188      dialog accepted ifTrue:[Transcript showCR:model value].
  7187     "
  7189     "
  7192 
  7194 
  7193 addLabelledField:aView label:labelString adjust:labelAdjust 
  7195 addLabelledField:aView label:labelString adjust:labelAdjust 
  7194     tabable:tabable from:leftX to:rightX separateAtX:relativeX nameAs:aName
  7196     tabable:tabable from:leftX to:rightX separateAtX:relativeX nameAs:aName
  7195 
  7197 
  7196     "add a label and some view side-by-side.
  7198     "add a label and some view side-by-side.
  7197      The labels goes from 0.0 to relativeX; the inputField from relativeX to 1.0.
  7199      The label goes from 0.0 to relativeX; the inputField from relativeX to 1.0.
  7198      The labels string is defined by labelString and adjusted according to labelAdjust.
  7200      The label's string is defined by labelString and adjusted according to labelAdjust.
  7199      The inputField gets model as its model.
  7201      The inputField gets model as its model.
  7200      Return the inputField."
  7202      Return the inputField."
  7201 
  7203 
  7202     ^ self
  7204     ^ self
  7203         addLabelledField:aView 
  7205         addLabelledField:aView 
  7275 addLabelledField:aView label:labelString adjust:labelAdjust 
  7277 addLabelledField:aView label:labelString adjust:labelAdjust 
  7276     tabable:tabable from:leftX to:rightX separateAtX:relativeX nameAs:aName
  7278     tabable:tabable from:leftX to:rightX separateAtX:relativeX nameAs:aName
  7277     foregroundColor:fgColor
  7279     foregroundColor:fgColor
  7278 
  7280 
  7279     "add a label and some view side-by-side.
  7281     "add a label and some view side-by-side.
  7280      The labels goes from 0.0 to relativeX; the inputField from relativeX to 1.0.
  7282      The label goes from 0.0 to relativeX; the inputField from relativeX to 1.0.
  7281      The labels string is defined by labelString and adjusted according to labelAdjust.
  7283      The label's string is defined by labelString and adjusted according to labelAdjust.
  7282      The inputField gets model as its model.
  7284      The inputField gets model as its model.
  7283      Return the inputField."
  7285      Return the inputField."
  7284 
  7286 
  7285     |y lbl max relW wLabel|
  7287     |y lbl max relW wLabel|
  7286 
  7288 
  7413     "Modified: / 02-02-2011 / 12:17:55 / cg"
  7415     "Modified: / 02-02-2011 / 12:17:55 / cg"
  7414 !
  7416 !
  7415 
  7417 
  7416 addLabelledField:aView label:labelString adjust:labelAdjust tabable:tabable separateAtX:relativeX
  7418 addLabelledField:aView label:labelString adjust:labelAdjust tabable:tabable separateAtX:relativeX
  7417     "add a label and some view side-by-side.
  7419     "add a label and some view side-by-side.
  7418      The labels goes from 0.0 to relativeX; the inputField from relativeX to 1.0.
  7420      The label goes from 0.0 to relativeX; the inputField from relativeX to 1.0.
  7419      The labels string is defined by labelString and adjusted according to labelAdjust.
  7421      The label's string is defined by labelString and adjusted according to labelAdjust.
  7420      The inputField gets model as its model.
  7422      The inputField gets model as its model.
  7421      Return the inputField."
  7423      Return the inputField."
  7422 
  7424 
  7423     ^ self
  7425     ^ self
  7424 	addLabelledField:aView 
  7426         addLabelledField:aView 
  7425 	label:labelString 
  7427         label:labelString 
  7426 	adjust:labelAdjust 
  7428         adjust:labelAdjust 
  7427 	tabable:tabable 
  7429         tabable:tabable 
  7428 	from:0.0 to:1.0 
  7430         from:0.0 to:1.0 
  7429 	separateAtX:relativeX
  7431         separateAtX:relativeX
  7430 
  7432 
  7431 "/    |y lbl max|
  7433 "/    |y lbl max|
  7432 "/
  7434 "/
  7433 "/    y := self yPosition.
  7435 "/    y := self yPosition.
  7434 "/    lbl := Label label:labelString.
  7436 "/    lbl := Label label:labelString.
  7455      model := '' asValue.
  7457      model := '' asValue.
  7456 
  7458 
  7457      dialog := DialogBox new.
  7459      dialog := DialogBox new.
  7458 
  7460 
  7459      field := dialog 
  7461      field := dialog 
  7460 		addLabelledField:(EditField on:model) label:'input here:' 
  7462                 addLabelledField:(EditField on:model) label:'input here:' 
  7461 		adjust:#left 
  7463                 adjust:#left 
  7462 		tabable:true 
  7464                 tabable:true 
  7463 		separateAtX:0.3.
  7465                 separateAtX:0.3.
  7464 
  7466 
  7465      dialog addAbortButton; addOkButton.
  7467      dialog addAbortButton; addOkButton.
  7466      dialog open.
  7468      dialog open.
  7467      dialog accepted ifTrue:[Transcript showCR:model value].
  7469      dialog accepted ifTrue:[Transcript showCR:model value].
  7468     "
  7470     "
  7475      model selectionIndex:2.
  7477      model selectionIndex:2.
  7476 
  7478 
  7477      dialog := DialogBox new.
  7479      dialog := DialogBox new.
  7478 
  7480 
  7479      field := dialog 
  7481      field := dialog 
  7480 		addLabelledField:(PopUpList on:model) label:'select here:' 
  7482                 addLabelledField:(PopUpList on:model) label:'select here:' 
  7481 		adjust:#left 
  7483                 adjust:#left 
  7482 		tabable:true 
  7484                 tabable:true 
  7483 		separateAtX:0.3.
  7485                 separateAtX:0.3.
  7484 
  7486 
  7485      dialog addAbortButton; addOkButton.
  7487      dialog addAbortButton; addOkButton.
  7486      dialog open.
  7488      dialog open.
  7487      dialog accepted ifTrue:[Transcript showCR:model value].
  7489      dialog accepted ifTrue:[Transcript showCR:model value].
  7488     "
  7490     "
  8517     "Modified: 3.1.1997 / 10:24:04 / stefan"
  8519     "Modified: 3.1.1997 / 10:24:04 / stefan"
  8518 !
  8520 !
  8519 
  8521 
  8520 addLabelledInputField:labelString adjust:labelAdjust on:model tabable:tabable from:leftX to:rightX separateAtX:relativeX
  8522 addLabelledInputField:labelString adjust:labelAdjust on:model tabable:tabable from:leftX to:rightX separateAtX:relativeX
  8521     "add a label and an inputField side-by-side.
  8523     "add a label and an inputField side-by-side.
  8522      The labels goes from 0.0 to relativeX; the inputField from relativeX to 1.0.
  8524      The label goes from 0.0 to relativeX; the inputField from relativeX to 1.0.
  8523      The labels string is defined by labelString and adjusted according to labelAdjust.
  8525      The label's string is defined by labelString and adjusted according to labelAdjust.
  8524      The inputField gets model as its model.
  8526      The inputField gets model as its model.
  8525      Return the inputField."
  8527      Return the inputField."
  8526 
  8528 
  8527 
  8529 
  8528     ^ self 
  8530     ^ self 
  8529 	addLabelledField:(EditField on:model) label:labelString 
  8531         addLabelledField:(EditField on:model) label:labelString 
  8530 	adjust:labelAdjust
  8532         adjust:labelAdjust
  8531 	tabable:tabable 
  8533         tabable:tabable 
  8532 	from:leftX to:rightX
  8534         from:leftX to:rightX
  8533 	separateAtX:relativeX.
  8535         separateAtX:relativeX.
  8534 
  8536 
  8535     "
  8537     "
  8536      |dialog model field|
  8538      |dialog model field|
  8537 
  8539 
  8538      model := '' asValue.
  8540      model := '' asValue.
  8539 
  8541 
  8540      dialog := DialogBox new.
  8542      dialog := DialogBox new.
  8541 
  8543 
  8542      field := dialog 
  8544      field := dialog 
  8543 		addLabelledInputField:'enter a string' 
  8545                 addLabelledInputField:'enter a string' 
  8544 		adjust:#left 
  8546                 adjust:#left 
  8545 		on:model 
  8547                 on:model 
  8546 		tabable:true 
  8548                 tabable:true 
  8547 		separateAtX:0.3.
  8549                 separateAtX:0.3.
  8548 
  8550 
  8549      dialog addAbortButton; addOkButton.
  8551      dialog addAbortButton; addOkButton.
  8550      dialog open.
  8552      dialog open.
  8551      dialog accepted ifTrue:[Transcript showCR:model value].
  8553      dialog accepted ifTrue:[Transcript showCR:model value].
  8552     "
  8554     "
  8561 
  8563 
  8562      dialog addTextLabel:'a two-input box'.
  8564      dialog addTextLabel:'a two-input box'.
  8563      dialog addHorizontalLine.
  8565      dialog addHorizontalLine.
  8564 
  8566 
  8565      field := dialog 
  8567      field := dialog 
  8566 		addLabelledInputField:'string1:' 
  8568                 addLabelledInputField:'string1:' 
  8567 		adjust:#right 
  8569                 adjust:#right 
  8568 		on:model1 
  8570                 on:model1 
  8569 		tabable:true 
  8571                 tabable:true 
  8570 		separateAtX:0.4.
  8572                 separateAtX:0.4.
  8571 
  8573 
  8572      field := dialog 
  8574      field := dialog 
  8573 		addLabelledInputField:'string2:' 
  8575                 addLabelledInputField:'string2:' 
  8574 		adjust:#right 
  8576                 adjust:#right 
  8575 		on:model2 
  8577                 on:model2 
  8576 		tabable:true 
  8578                 tabable:true 
  8577 		separateAtX:0.4.
  8579                 separateAtX:0.4.
  8578 
  8580 
  8579      dialog addAbortButton; addOkButton.
  8581      dialog addAbortButton; addOkButton.
  8580      dialog open.
  8582      dialog open.
  8581      dialog accepted ifTrue:[
  8583      dialog accepted ifTrue:[
  8582 	Transcript showCR:model1 value.
  8584         Transcript showCR:model1 value.
  8583 	Transcript showCR:model2 value.
  8585         Transcript showCR:model2 value.
  8584      ].
  8586      ].
  8585     "
  8587     "
  8586 
  8588 
  8587     "Modified: 19.4.1996 / 17:39:46 / cg"
  8589     "Modified: 19.4.1996 / 17:39:46 / cg"
  8588     "Created: 3.6.1996 / 11:04:23 / cg"
  8590     "Created: 3.6.1996 / 11:04:23 / cg"
  8589 !
  8591 !
  8590 
  8592 
  8591 addLabelledInputField:labelString adjust:labelAdjust on:model tabable:tabable separateAtX:relativeX
  8593 addLabelledInputField:labelString adjust:labelAdjust on:model tabable:tabable separateAtX:relativeX
  8592     "add a label and an inputField side-by-side.
  8594     "add a label and an inputField side-by-side.
  8593      The labels goes from 0.0 to relativeX; the inputField from relativeX to 1.0.
  8595      The label goes from 0.0 to relativeX; the inputField from relativeX to 1.0.
  8594      The labels string is defined by labelString and adjusted according to labelAdjust.
  8596      The label's string is defined by labelString and adjusted according to labelAdjust.
  8595      The inputField gets model as its model.
  8597      The inputField gets model as its model.
  8596      Return the inputField."
  8598      Return the inputField."
  8597 
  8599 
  8598 
  8600 
  8599     ^ self 
  8601     ^ self 
  8600 	addLabelledField:(EditField on:model) label:labelString 
  8602         addLabelledField:(EditField on:model) label:labelString 
  8601 	adjust:labelAdjust
  8603         adjust:labelAdjust
  8602 	tabable:tabable 
  8604         tabable:tabable 
  8603 	separateAtX:relativeX.
  8605         separateAtX:relativeX.
  8604 
  8606 
  8605     "
  8607     "
  8606      |dialog model field|
  8608      |dialog model field|
  8607 
  8609 
  8608      model := '' asValue.
  8610      model := '' asValue.
  8609 
  8611 
  8610      dialog := DialogBox new.
  8612      dialog := DialogBox new.
  8611 
  8613 
  8612      field := dialog 
  8614      field := dialog 
  8613 		addLabelledInputField:'enter a string' 
  8615                 addLabelledInputField:'enter a string' 
  8614 		adjust:#left 
  8616                 adjust:#left 
  8615 		on:model 
  8617                 on:model 
  8616 		tabable:true 
  8618                 tabable:true 
  8617 		separateAtX:0.3.
  8619                 separateAtX:0.3.
  8618 
  8620 
  8619      dialog addAbortButton; addOkButton.
  8621      dialog addAbortButton; addOkButton.
  8620      dialog open.
  8622      dialog open.
  8621      dialog accepted ifTrue:[Transcript showCR:model value].
  8623      dialog accepted ifTrue:[Transcript showCR:model value].
  8622     "
  8624     "
  8631 
  8633 
  8632      dialog addTextLabel:'a two-input box'.
  8634      dialog addTextLabel:'a two-input box'.
  8633      dialog addHorizontalLine.
  8635      dialog addHorizontalLine.
  8634 
  8636 
  8635      field := dialog 
  8637      field := dialog 
  8636 		addLabelledInputField:'string1:' 
  8638                 addLabelledInputField:'string1:' 
  8637 		adjust:#right 
  8639                 adjust:#right 
  8638 		on:model1 
  8640                 on:model1 
  8639 		tabable:true 
  8641                 tabable:true 
  8640 		separateAtX:0.4.
  8642                 separateAtX:0.4.
  8641 
  8643 
  8642      field := dialog 
  8644      field := dialog 
  8643 		addLabelledInputField:'string2:' 
  8645                 addLabelledInputField:'string2:' 
  8644 		adjust:#right 
  8646                 adjust:#right 
  8645 		on:model2 
  8647                 on:model2 
  8646 		tabable:true 
  8648                 tabable:true 
  8647 		separateAtX:0.4.
  8649                 separateAtX:0.4.
  8648 
  8650 
  8649      dialog addAbortButton; addOkButton.
  8651      dialog addAbortButton; addOkButton.
  8650      dialog open.
  8652      dialog open.
  8651      dialog accepted ifTrue:[
  8653      dialog accepted ifTrue:[
  8652 	Transcript showCR:model1 value.
  8654         Transcript showCR:model1 value.
  8653 	Transcript showCR:model2 value.
  8655         Transcript showCR:model2 value.
  8654      ].
  8656      ].
  8655     "
  8657     "
  8656 
  8658 
  8657     "Created: 13.4.1996 / 13:41:31 / cg"
  8659     "Created: 13.4.1996 / 13:41:31 / cg"
  8658     "Modified: 19.4.1996 / 17:39:46 / cg"
  8660     "Modified: 19.4.1996 / 17:39:46 / cg"
 10248 ! !
 10250 ! !
 10249 
 10251 
 10250 !DialogBox class methodsFor:'documentation'!
 10252 !DialogBox class methodsFor:'documentation'!
 10251 
 10253 
 10252 version
 10254 version
 10253     ^ '$Header: /cvs/stx/stx/libwidg/DialogBox.st,v 1.360 2014-11-28 12:35:28 cg Exp $'
 10255     ^ '$Header: /cvs/stx/stx/libwidg/DialogBox.st,v 1.361 2015-01-29 17:41:41 cg Exp $'
 10254 !
 10256 !
 10255 
 10257 
 10256 version_CVS
 10258 version_CVS
 10257     ^ '$Header: /cvs/stx/stx/libwidg/DialogBox.st,v 1.360 2014-11-28 12:35:28 cg Exp $'
 10259     ^ '$Header: /cvs/stx/stx/libwidg/DialogBox.st,v 1.361 2015-01-29 17:41:41 cg Exp $'
 10258 ! !
 10260 ! !
 10259 
 10261 
 10260 
 10262 
 10261 DialogBox initialize!
 10263 DialogBox initialize!