DialogBox.st
changeset 6576 9c51b70b047f
parent 6573 a2a5d33886ab
child 6589 011fb7979501
equal deleted inserted replaced
6575:f0d5fbcbace8 6576:9c51b70b047f
       
     1 "{ Encoding: utf8 }"
       
     2 
     1 "
     3 "
     2  COPYRIGHT (c) 1994 by Claus Gittinger
     4  COPYRIGHT (c) 1994 by Claus Gittinger
     3 	      All Rights Reserved
     5 	      All Rights Reserved
     4 
     6 
     5  This software is furnished under a license and may be used
     7  This software is furnished under a license and may be used
  8560 !
  8562 !
  8561 
  8563 
  8562 addButton:aButton after:someOtherButtonOrNil
  8564 addButton:aButton after:someOtherButtonOrNil
  8563     "add a button into the buttonPanel.
  8565     "add a button into the buttonPanel.
  8564      If the argument someOtherButtonOrNil is nil, the button is
  8566      If the argument someOtherButtonOrNil is nil, the button is
  8565      added at the end."
  8567      added at the end.
       
  8568      Returns the button"
  8566 
  8569 
  8567     |h|
  8570     |h|
  8568 
  8571 
  8569     buttonPanel addSubView:aButton after:someOtherButtonOrNil.
  8572     buttonPanel addSubView:aButton after:someOtherButtonOrNil.
  8570     buttonPanel subViews size > 1 ifTrue:[
  8573     buttonPanel subViews size > 1 ifTrue:[
  8617      dialog accepted ifTrue:[Transcript showCR:'yes'].
  8620      dialog accepted ifTrue:[Transcript showCR:'yes'].
  8618     "
  8621     "
  8619 
  8622 
  8620     "Modified: / 09-02-1996 / 22:13:51 / cg"
  8623     "Modified: / 09-02-1996 / 22:13:51 / cg"
  8621     "Modified: / 09-11-2018 / 20:14:23 / Claus Gittinger"
  8624     "Modified: / 09-11-2018 / 20:14:23 / Claus Gittinger"
       
  8625     "Modified (comment): / 30-04-2019 / 10:36:25 / Claus Gittinger"
  8622 !
  8626 !
  8623 
  8627 
  8624 addButton:aButton before:someOtherButtonOrNil
  8628 addButton:aButton before:someOtherButtonOrNil
  8625     "add a button into the buttonPanel.
  8629     "add a button into the buttonPanel.
  8626      If the argument someOtherButtonOrNil is nil, the button is
  8630      If the argument someOtherButtonOrNil is nil, the button is
  8627      added upFront."
  8631      added upFront.
       
  8632      Returns the button"
  8628 
  8633 
  8629     |h|
  8634     |h|
  8630 
  8635 
  8631     buttonPanel addSubView:aButton before:someOtherButtonOrNil.
  8636     buttonPanel addSubView:aButton before:someOtherButtonOrNil.
  8632     buttonPanel subViews size > 1 ifTrue:[
  8637     buttonPanel subViews size > 1 ifTrue:[
  8668     "
  8673     "
  8669 
  8674 
  8670     "Modified: / 09-02-1996 / 22:13:51 / cg"
  8675     "Modified: / 09-02-1996 / 22:13:51 / cg"
  8671     "Created: / 10-02-1996 / 16:04:35 / cg"
  8676     "Created: / 10-02-1996 / 16:04:35 / cg"
  8672     "Modified: / 09-11-2018 / 20:14:28 / Claus Gittinger"
  8677     "Modified: / 09-11-2018 / 20:14:28 / Claus Gittinger"
       
  8678     "Modified (comment): / 30-04-2019 / 10:36:34 / Claus Gittinger"
  8673 !
  8679 !
  8674 
  8680 
  8675 addHelpButtonFor:pathToHelpText 
  8681 addHelpButtonFor:pathToHelpText 
  8676     "add a help button to the buttonPanel.
  8682     "add a help button to the buttonPanel.
  8677      The argument, pathToHelpText should specify the path to the help
  8683      The argument, pathToHelpText should specify the path to the help
  8678      text under either the doc/online/<language> or the help/<language>
  8684      text under either the doc/online/<language> or the help/<language>
  8679      directory."
  8685      directory.
       
  8686      Returns the button"
  8680 
  8687 
  8681     ^ self addHelpButtonWithAction:[HTMLDocumentView openFullOnHelpFile:pathToHelpText].
  8688     ^ self addHelpButtonWithAction:[HTMLDocumentView openFullOnHelpFile:pathToHelpText].
  8682 
  8689 
  8683     "
  8690     "
  8684      |box|
  8691      |box|
  8692      box open
  8699      box open
  8693     "
  8700     "
  8694 
  8701 
  8695     "Modified: / 09-09-1996 / 22:40:21 / stefan"
  8702     "Modified: / 09-09-1996 / 22:40:21 / stefan"
  8696     "Modified: / 26-01-2011 / 18:04:53 / cg"
  8703     "Modified: / 26-01-2011 / 18:04:53 / cg"
       
  8704     "Modified (comment): / 30-04-2019 / 10:36:52 / Claus Gittinger"
  8697 !
  8705 !
  8698 
  8706 
  8699 addHelpButtonWithAction:helpAction
  8707 addHelpButtonWithAction:helpAction
  8700     "add a help button to the buttonPanel.
  8708     "add a help button to the buttonPanel.
  8701      The argument, helpAction is avaluated when clicked"
  8709      The argument, helpAction is avaluated when clicked.
       
  8710      Returns the button"
  8702 
  8711 
  8703     |helpButton|
  8712     |helpButton|
  8704 
  8713 
  8705     helpButton := Button label:(resources string:'Help').
  8714     helpButton := Button label:(resources string:'Help').
  8706     helpButton action:[
  8715     helpButton action:[
  8731      box open
  8740      box open
  8732     "
  8741     "
  8733 
  8742 
  8734     "Modified: / 09-09-1996 / 22:40:21 / stefan"
  8743     "Modified: / 09-09-1996 / 22:40:21 / stefan"
  8735     "Created: / 26-01-2011 / 18:04:16 / cg"
  8744     "Created: / 26-01-2011 / 18:04:16 / cg"
       
  8745     "Modified (comment): / 30-04-2019 / 10:36:47 / Claus Gittinger"
  8736 !
  8746 !
  8737 
  8747 
  8738 addOK:checkBlock
  8748 addOK:checkBlock
       
  8749     "Visualworks compatibility method. Here, checkBlock is ignored"
       
  8750     
  8739     |butt|
  8751     |butt|
  8740 
  8752 
  8741     butt := self addOkButton.
  8753     butt := self addOkButton.
  8742     "/ what is checkBlock ?
  8754     "/ what is checkBlock ?
  8743     ^ butt
  8755     ^ butt
  8744 
  8756 
  8745     "Modified: / 4.2.2000 / 00:09:15 / cg"
  8757     "Modified: / 04-02-2000 / 00:09:15 / cg"
       
  8758     "Modified (comment): / 30-04-2019 / 10:37:54 / Claus Gittinger"
  8746 !
  8759 !
  8747 
  8760 
  8748 addOkButton
  8761 addOkButton
  8749     "create an okButton - to be sent from redefined initialize
  8762     "create an okButton - to be sent from redefined initialize
  8750      methods in subclasses or when creating a box programmatically.
  8763      methods in subclasses or when creating a box programmatically.
  8844 
  8857 
  8845 !DialogBox methodsFor:'construction-check & comboboxes'!
  8858 !DialogBox methodsFor:'construction-check & comboboxes'!
  8846 
  8859 
  8847 addCheckBox:label on:aModel
  8860 addCheckBox:label on:aModel
  8848     "create a checkBox with label on aModel and add it.
  8861     "create a checkBox with label on aModel and add it.
  8849      Returns the box."
  8862      Returns the checkBox widget."
  8850 
  8863 
  8851     ^ self addCheckBox:label on:aModel tabable:true
  8864     ^ self addCheckBox:label on:aModel tabable:true
  8852 
  8865 
  8853     "
  8866     "
  8854      |dialog check|
  8867      |dialog check|
  8860      dialog addOkButton.
  8873      dialog addOkButton.
  8861      dialog open.
  8874      dialog open.
  8862      dialog accepted ifTrue:[Transcript showCR:check value].
  8875      dialog accepted ifTrue:[Transcript showCR:check value].
  8863     "
  8876     "
  8864 
  8877 
  8865     "Modified: 9.2.1996 / 22:15:38 / cg"
  8878     "Modified: / 09-02-1996 / 22:15:38 / cg"
       
  8879     "Modified (comment): / 30-04-2019 / 10:35:07 / Claus Gittinger"
  8866 !
  8880 !
  8867 
  8881 
  8868 addCheckBox:label on:aModel tabable:tabable
  8882 addCheckBox:label on:aModel tabable:tabable
  8869     "create a checkBox with label on aModel and add it.
  8883     "create a checkBox with label on aModel and add it.
  8870      Returns the box."
  8884      Returns the checkBox widget."
  8871 
  8885 
  8872     |b|
  8886     |b|
  8873 
  8887 
  8874     b := CheckBox on:aModel.
  8888     b := CheckBox on:aModel.
  8875     b label:label.
  8889     b label:label.
  8891      dialog addCheckBox:'on or off' on:check3 tabable:true.
  8905      dialog addCheckBox:'on or off' on:check3 tabable:true.
  8892      dialog addOkButton.
  8906      dialog addOkButton.
  8893      dialog open.
  8907      dialog open.
  8894     "
  8908     "
  8895 
  8909 
  8896     "Modified: 9.2.1996 / 22:16:49 / cg"
  8910     "Modified: / 09-02-1996 / 22:16:49 / cg"
       
  8911     "Modified (comment): / 30-04-2019 / 10:35:01 / Claus Gittinger"
  8897 !
  8912 !
  8898 
  8913 
  8899 addCheckBoxAtBottom:checkLabel on:aValueHolder
  8914 addCheckBoxAtBottom:checkLabel on:aValueHolder
  8900     "add a checkbox and make it stick at the bottom"
  8915     "add a checkbox and make it stick at the bottom.
       
  8916      Returns the checkBox widget."
  8901 
  8917 
  8902     |box|
  8918     |box|
  8903 
  8919 
  8904     box := here addCheckBox:checkLabel on:aValueHolder.
  8920     box := here addCheckBox:checkLabel on:aValueHolder.
  8905 
  8921 
  8910                 bottomOffset:(buttonPanel preferredHeight 
  8926                 bottomOffset:(buttonPanel preferredHeight 
  8911                           + ViewSpacing ) negated).
  8927                           + ViewSpacing ) negated).
  8912     ^ box.
  8928     ^ box.
  8913 
  8929 
  8914     "Created: / 28-02-2012 / 09:03:22 / cg"
  8930     "Created: / 28-02-2012 / 09:03:22 / cg"
       
  8931     "Modified (comment): / 30-04-2019 / 10:35:20 / Claus Gittinger"
  8915 !
  8932 !
  8916 
  8933 
  8917 addComboBoxOn:aModel
  8934 addComboBoxOn:aModel
  8918     "create a comboBoxView on aModel and add it.
  8935     "create a comboBoxView on aModel and add it.
  8919      Returns the comboBoxView."
  8936      Returns the comboBox widget."
  8920 
  8937 
  8921     ^ self addComboBoxOn:aModel tabable:true
  8938     ^ self addComboBoxOn:aModel tabable:true
  8922 
  8939 
  8923     "
  8940     "
  8924      without a list, the comboBox is disabled:
  8941      without a list, the comboBox is disabled:
  8933      box addVerticalSpace.
  8950      box addVerticalSpace.
  8934      (box addComboBoxOn:val).
  8951      (box addComboBoxOn:val).
  8935      box addOkButton.
  8952      box addOkButton.
  8936      box open.
  8953      box open.
  8937      box accepted ifTrue:[
  8954      box accepted ifTrue:[
  8938 	Transcript showCR:val value
  8955         Transcript showCR:val value
  8939      ].
  8956      ].
  8940     "
  8957     "
  8941 
  8958 
  8942     "with a list, it can be pulled:
  8959     "with a list, it can be pulled:
  8943 
  8960 
  8951      box addVerticalSpace.
  8968      box addVerticalSpace.
  8952      (box addComboBoxOn:val) list:#('one' 'two' 'three' 'four').
  8969      (box addComboBoxOn:val) list:#('one' 'two' 'three' 'four').
  8953      box addOkButton.
  8970      box addOkButton.
  8954      box open.
  8971      box open.
  8955      box accepted ifTrue:[
  8972      box accepted ifTrue:[
  8956 	Transcript showCR:val value
  8973         Transcript showCR:val value
  8957      ].
  8974      ].
  8958     "
  8975     "
  8959 
  8976 
  8960     "Modified: 28.2.1996 / 15:17:39 / cg"
  8977     "Modified: / 28-02-1996 / 15:17:39 / cg"
  8961     "Created: 4.3.1996 / 17:21:45 / cg"
  8978     "Created: / 04-03-1996 / 17:21:45 / cg"
       
  8979     "Modified (comment): / 30-04-2019 / 10:35:25 / Claus Gittinger"
  8962 !
  8980 !
  8963 
  8981 
  8964 addComboBoxOn:aModel list:list tabable:tabable
  8982 addComboBoxOn:aModel list:list tabable:tabable
  8965     "create a comboBoxView on aModel and add it.
  8983     "create a comboBoxView on aModel and add it.
  8966      Returns the comboBoxView."
  8984      Returns the comboBox widget."
  8967 
  8985 
  8968     ^ (self addComboBoxOn:aModel tabable:tabable) list:list
  8986     ^ (self addComboBoxOn:aModel tabable:tabable) list:list
  8969 
  8987 
  8970     "
  8988     "
  8971      without a list, the comboBox is disabled:
  8989      without a list, the comboBox is disabled:
  9002      box accepted ifTrue:[
  9020      box accepted ifTrue:[
  9003         Transcript showCR:val value
  9021         Transcript showCR:val value
  9004      ].
  9022      ].
  9005     "
  9023     "
  9006 
  9024 
  9007     "Modified: 4.3.1996 / 17:21:57 / cg"
  9025     "Modified: / 04-03-1996 / 17:21:57 / cg"
       
  9026     "Modified (comment): / 30-04-2019 / 10:35:29 / Claus Gittinger"
  9008 !
  9027 !
  9009 
  9028 
  9010 addComboBoxOn:aModel tabable:tabable
  9029 addComboBoxOn:aModel tabable:tabable
  9011     "create a comboBoxView on aModel and add it.
  9030     "create a comboBoxView on aModel and add it.
  9012      Returns the comboBoxView."
  9031      Returns the comboBox widget."
  9013 
  9032 
  9014     |f|
  9033     |f|
  9015 
  9034 
  9016     f := ComboBoxView new.
  9035     f := ComboBoxView new.
  9017     f model:aModel.
  9036     f model:aModel.
  9018     self addComponent:f tabable:tabable.
  9037     self addComponent:f tabable:tabable.
  9019     tabable ifTrue:[
  9038     tabable ifTrue:[
  9020 	self addToInputFieldGroup:f editor.
  9039         self addToInputFieldGroup:f editor.
  9021     ].
  9040     ].
  9022     ^ f
  9041     ^ f
  9023 
  9042 
  9024     "
  9043     "
  9025      without a list, the comboBox is disabled:
  9044      without a list, the comboBox is disabled:
  9034      box addVerticalSpace.
  9053      box addVerticalSpace.
  9035      (box addComboBoxOn:val tabable:true).
  9054      (box addComboBoxOn:val tabable:true).
  9036      box addOkButton.
  9055      box addOkButton.
  9037      box open.
  9056      box open.
  9038      box accepted ifTrue:[
  9057      box accepted ifTrue:[
  9039 	Transcript showCR:val value
  9058         Transcript showCR:val value
  9040      ].
  9059      ].
  9041     "
  9060     "
  9042 
  9061 
  9043     "with a list, it can be pulled:
  9062     "with a list, it can be pulled:
  9044 
  9063 
  9052      box addVerticalSpace.
  9071      box addVerticalSpace.
  9053      (box addComboBoxOn:val tabable:true) list:#('one' 'two' 'three' 'four').
  9072      (box addComboBoxOn:val tabable:true) list:#('one' 'two' 'three' 'four').
  9054      box addOkButton.
  9073      box addOkButton.
  9055      box open.
  9074      box open.
  9056      box accepted ifTrue:[
  9075      box accepted ifTrue:[
  9057 	Transcript showCR:val value
  9076         Transcript showCR:val value
  9058      ].
  9077      ].
  9059     "
  9078     "
  9060 
  9079 
  9061     "Modified: 4.3.1996 / 17:21:57 / cg"
  9080     "Modified: / 04-03-1996 / 17:21:57 / cg"
       
  9081     "Modified (comment): / 30-04-2019 / 10:35:31 / Claus Gittinger"
  9062 !
  9082 !
  9063 
  9083 
  9064 addComboListOn:aModel
  9084 addComboListOn:aModel
  9065     "create a comboListView on aModel and add it.
  9085     "create a comboListView on aModel and add it.
  9066      Returns the comboListView."
  9086      Returns the comboList widget."
  9067 
  9087 
  9068     ^ self addComboListOn:aModel tabable:true 
  9088     ^ self addComboListOn:aModel tabable:true 
  9069 
  9089 
  9070     "without a list, the comboList is disabled:
  9090     "without a list, the comboList is disabled:
  9071 
  9091 
  9079      box addVerticalSpace.
  9099      box addVerticalSpace.
  9080      (box addComboListOn:val).
  9100      (box addComboListOn:val).
  9081      box addOkButton.
  9101      box addOkButton.
  9082      box open.
  9102      box open.
  9083      box accepted ifTrue:[
  9103      box accepted ifTrue:[
  9084 	Transcript showCR:val value
  9104         Transcript showCR:val value
  9085      ].
  9105      ].
  9086     "
  9106     "
  9087 
  9107 
  9088     "with a list, it can be pulled:
  9108     "with a list, it can be pulled:
  9089 
  9109 
  9097      box addVerticalSpace.
  9117      box addVerticalSpace.
  9098      (box addComboListOn:val) list:#('one' 'two' 'three' 'four').
  9118      (box addComboListOn:val) list:#('one' 'two' 'three' 'four').
  9099      box addOkButton.
  9119      box addOkButton.
  9100      box open.
  9120      box open.
  9101      box accepted ifTrue:[
  9121      box accepted ifTrue:[
  9102 	Transcript showCR:val value
  9122         Transcript showCR:val value
  9103      ].
  9123      ].
  9104     "
  9124     "
  9105 
  9125 
  9106     "Created: 28.2.1996 / 15:16:34 / cg"
  9126     "Created: / 28-02-1996 / 15:16:34 / cg"
  9107     "Modified: 4.3.1996 / 17:22:59 / cg"
  9127     "Modified: / 04-03-1996 / 17:22:59 / cg"
       
  9128     "Modified (comment): / 30-04-2019 / 10:35:36 / Claus Gittinger"
  9108 !
  9129 !
  9109 
  9130 
  9110 addComboListOn:aModel list:list tabable:tabable
  9131 addComboListOn:aModel list:list tabable:tabable
  9111     "create a comboListView on aModel and add it.
  9132     "create a comboListView on aModel and add it.
  9112      Returns the comboListView."
  9133      Returns the comboList widget."
  9113 
  9134 
  9114     ^ (self addComboListOn:aModel tabable:tabable) list:list
  9135     ^ (self addComboListOn:aModel tabable:tabable) list:list
  9115 
  9136 
  9116     "
  9137     "
  9117      |box val|
  9138      |box val|
  9127      box open.
  9148      box open.
  9128      box accepted ifTrue:[
  9149      box accepted ifTrue:[
  9129         Transcript showCR:val value
  9150         Transcript showCR:val value
  9130      ].
  9151      ].
  9131     "
  9152     "
       
  9153 
       
  9154     "Modified (comment): / 30-04-2019 / 10:35:39 / Claus Gittinger"
  9132 !
  9155 !
  9133 
  9156 
  9134 addComboListOn:aModel tabable:tabable
  9157 addComboListOn:aModel tabable:tabable
  9135     "create a comboListView on aModel and add it.
  9158     "create a comboListView on aModel and add it.
  9136      Returns the comboListView."
  9159      Returns the comboList widget."
  9137 
  9160 
  9138     |f|
  9161     |f|
  9139 
  9162 
  9140     f := ComboListView new.
  9163     f := ComboListView new.
  9141     f model:aModel.
  9164     f model:aModel.
  9154      box addVerticalSpace.
  9177      box addVerticalSpace.
  9155      (box addComboListOn:val tabable:true).
  9178      (box addComboListOn:val tabable:true).
  9156      box addOkButton.
  9179      box addOkButton.
  9157      box open.
  9180      box open.
  9158      box accepted ifTrue:[
  9181      box accepted ifTrue:[
  9159 	Transcript showCR:val value
  9182         Transcript showCR:val value
  9160      ].
  9183      ].
  9161     "
  9184     "
  9162 
  9185 
  9163     "with a list, it can be pulled:
  9186     "with a list, it can be pulled:
  9164 
  9187 
  9172      box addVerticalSpace.
  9195      box addVerticalSpace.
  9173      (box addComboListOn:val tabable:true) list:#('one' 'two' 'three' 'four').
  9196      (box addComboListOn:val tabable:true) list:#('one' 'two' 'three' 'four').
  9174      box addOkButton.
  9197      box addOkButton.
  9175      box open.
  9198      box open.
  9176      box accepted ifTrue:[
  9199      box accepted ifTrue:[
  9177 	Transcript showCR:val value
  9200         Transcript showCR:val value
  9178      ].
  9201      ].
  9179     "
  9202     "
  9180 
  9203 
  9181     "Created: 28.2.1996 / 15:16:34 / cg"
  9204     "Created: / 28-02-1996 / 15:16:34 / cg"
  9182     "Modified: 4.3.1996 / 17:23:38 / cg"
  9205     "Modified: / 04-03-1996 / 17:23:38 / cg"
       
  9206     "Modified (comment): / 30-04-2019 / 10:35:42 / Claus Gittinger"
  9183 !
  9207 !
  9184 
  9208 
  9185 addTriggerBox:label action:aBlock
  9209 addTriggerBox:label action:aBlock
  9186     "create a triggerBox with label and action and add it.
  9210     "create a triggerBox with label and action and add it.
  9187      Returns the box."
  9211      Returns the triggerBox widget"
  9188 
  9212 
  9189     |b|
  9213     |b|
  9190 
  9214 
  9191     b := TriggerBox new action:aBlock.
  9215     b := TriggerBox new action:aBlock.
  9192     b label:label.
  9216     b label:label.
  9208      dialog addTriggerBox:'trigger' action:[Transcript showCR:'3'].
  9232      dialog addTriggerBox:'trigger' action:[Transcript showCR:'3'].
  9209      dialog addOkButton.
  9233      dialog addOkButton.
  9210      dialog open.
  9234      dialog open.
  9211     "
  9235     "
  9212 
  9236 
  9213     "Modified: 9.2.1996 / 22:16:49 / cg"
  9237     "Modified: / 09-02-1996 / 22:16:49 / cg"
       
  9238     "Modified (comment): / 30-04-2019 / 10:35:52 / Claus Gittinger"
  9214 ! !
  9239 ! !
  9215 
  9240 
  9216 !DialogBox methodsFor:'construction-inputfields'!
  9241 !DialogBox methodsFor:'construction-inputfields'!
  9217 
  9242 
  9218 addFilenameInputFieldOn:aModel in:aDirectory tabable:tabable
  9243 addFilenameInputFieldOn:aModel in:aDirectory tabable:tabable