DialogBox.st
branchdelegated_gc_hg
changeset 5128 787b617a99e5
parent 5091 f69c39e3dc9e
child 5191 dae927f4f9c2
equal deleted inserted replaced
5085:52e9f87d45c8 5128:787b617a99e5
  1603     "Modified: / 02-03-2007 / 15:23:31 / cg"
  1603     "Modified: / 02-03-2007 / 15:23:31 / cg"
  1604 !
  1604 !
  1605 
  1605 
  1606 confirm:msg withCancel:aBoolean
  1606 confirm:msg withCancel:aBoolean
  1607     "launch a Dialog, which allows user to enter yes, no and optionally: cancel.
  1607     "launch a Dialog, which allows user to enter yes, no and optionally: cancel.
  1608      return true for 'yes', false for 'no', nil for 'cancel'"
  1608      Return true for 'yes', false for 'no', nil for 'cancel'"
  1609 
  1609 
  1610     aBoolean ifTrue:[
  1610     aBoolean ifTrue:[
  1611         ^ Dialog confirmWithCancel:msg.
  1611         ^ Dialog confirmWithCancel:msg.
  1612     ] ifFalse:[
  1612     ] ifFalse:[
  1613         ^ Dialog confirm:msg.
  1613         ^ Dialog confirm:msg.
  1619     "
  1619     "
  1620 !
  1620 !
  1621 
  1621 
  1622 confirm:msg withCancel:aBoolean default:default
  1622 confirm:msg withCancel:aBoolean default:default
  1623     "launch a Dialog, which allows user to enter yes, no and optionally: cancel.
  1623     "launch a Dialog, which allows user to enter yes, no and optionally: cancel.
  1624      return true for 'yes', false for 'no', nil for 'cancel'"
  1624      Return true for 'yes', false for 'no', nil for 'cancel'"
  1625 
  1625 
  1626     aBoolean ifTrue:[
  1626     aBoolean ifTrue:[
  1627         ^ Dialog confirmWithCancel:msg default:default.
  1627         ^ Dialog confirmWithCancel:msg default:default.
  1628     ] ifFalse:[
  1628     ] ifFalse:[
  1629         ^ Dialog confirm:msg default:default.
  1629         ^ Dialog confirm:msg default:default.
  1635     "
  1635     "
  1636 !
  1636 !
  1637 
  1637 
  1638 confirm:aString yesLabel:yesText
  1638 confirm:aString yesLabel:yesText
  1639     "launch a Dialog, which allows user to enter yes or no.
  1639     "launch a Dialog, which allows user to enter yes or no.
  1640      return true for yes, false for no.
  1640      Return true for yes, false for no.
  1641      The yes button's label is defined by yesText."
  1641      The yes button's label is defined by yesText."
  1642 
  1642 
  1643     ^ self confirm:aString title:nil yesLabel:yesText noLabel:nil
  1643     ^ self confirm:aString title:nil yesLabel:yesText noLabel:nil
  1644 
  1644 
  1645     " 
  1645     " 
  1649     "
  1649     "
  1650 
  1650 
  1651     "Created: / 04-09-2006 / 11:18:50 / cg"
  1651     "Created: / 04-09-2006 / 11:18:50 / cg"
  1652 !
  1652 !
  1653 
  1653 
       
  1654 confirm:aString yesLabel:yesText initialAnswer:what
       
  1655     "launch a Dialog, which allows user to enter yes or no.
       
  1656      Return true for yes, false for no.
       
  1657      The yes button's label is defined by yesText."
       
  1658 
       
  1659     ^ self confirm:aString title:nil yesLabel:yesText noLabel:nil initialAnswer:what
       
  1660 
       
  1661     " 
       
  1662      Dialog 
       
  1663         confirm:'really ?' 
       
  1664         yesLabel:'Oh well' 
       
  1665         initialAnswer:false
       
  1666     "
       
  1667 
       
  1668     "Created: 21.2.1996 / 01:10:14 / cg"
       
  1669     "Modified: 8.3.1996 / 21:15:06 / cg"
       
  1670 !
       
  1671 
  1654 confirm:aString yesLabel:yesText noLabel:noText
  1672 confirm:aString yesLabel:yesText noLabel:noText
  1655     "launch a Dialog, which allows user to enter yes or no.
  1673     "launch a Dialog, which allows user to enter yes or no.
  1656      return true for yes, false for no.
  1674      Return true for yes, false for no.
  1657      The yes/no buttons' labels are defined by yesText/noText."
  1675      The yes/no buttons' labels are defined by yesText/noText."
  1658 
  1676 
  1659     ^ self confirm:aString title:nil yesLabel:yesText noLabel:noText
  1677     ^ self confirm:aString title:nil yesLabel:yesText noLabel:noText
  1660 
  1678 
  1661     " 
  1679     " 
  1669     "Modified: / 04-09-2006 / 11:19:00 / cg"
  1687     "Modified: / 04-09-2006 / 11:19:00 / cg"
  1670 !
  1688 !
  1671 
  1689 
  1672 confirm:aString yesLabel:yesText noLabel:noText initialAnswer:what
  1690 confirm:aString yesLabel:yesText noLabel:noText initialAnswer:what
  1673     "launch a Dialog, which allows user to enter yes or no.
  1691     "launch a Dialog, which allows user to enter yes or no.
  1674      return true for yes, false for no.
  1692      Return true for yes, false for no.
  1675      The yes/no buttons labels are defined by yesText/noText."
  1693      The yes/no buttons labels are defined by yesText/noText."
  1676 
  1694 
  1677     ^ self confirm:aString title:nil yesLabel:yesText noLabel:noText initialAnswer:what
  1695     ^ self confirm:aString title:nil yesLabel:yesText noLabel:noText initialAnswer:what
  1678 
  1696 
  1679     " 
  1697     " 
  4710          onCancel:nil       
  4728          onCancel:nil       
  4711     "
  4729     "
  4712 
  4730 
  4713     "Created: 27.1.1996 / 14:31:45 / cg"
  4731     "Created: 27.1.1996 / 14:31:45 / cg"
  4714     "Modified: 29.5.1996 / 14:28:59 / cg"
  4732     "Modified: 29.5.1996 / 14:28:59 / cg"
       
  4733 !
       
  4734 
       
  4735 request:aString title:windowTitle
       
  4736     "launch a Dialog, which allows user to enter a string."
       
  4737 
       
  4738     ^ self
       
  4739         request:aString 
       
  4740         displayAt:nil 
       
  4741         centered:(ForceModalBoxesToOpenAtCenter ? false) 
       
  4742         action:nil 
       
  4743         initialAnswer:nil 
       
  4744         okLabel:nil 
       
  4745         cancelLabel:nil 
       
  4746         title:windowTitle 
       
  4747         onCancel:''
       
  4748         list:nil
       
  4749         initialSelection:nil
       
  4750 
       
  4751     "
       
  4752      at topLeft (centering is suppressed, to make the box fully visible)    
       
  4753          Dialog 
       
  4754             request:'enter a string:'
       
  4755             displayAt:0@0
       
  4756             centered:true
       
  4757             action:[:result | result printNewline]
       
  4758             initialAnswer:'the default'
       
  4759             onCancel:#foo
       
  4760 
       
  4761      centered around 200@200:
       
  4762 
       
  4763          Dialog 
       
  4764             request:'enter a string:'
       
  4765             displayAt:200@200
       
  4766             centered:true
       
  4767             action:[:result | result printNewline]
       
  4768             initialAnswer:'the default'
       
  4769             onCancel:#foo
       
  4770 
       
  4771      topLeft of box at 200@200:
       
  4772 
       
  4773          Dialog 
       
  4774             request:'enter a string:'
       
  4775             displayAt:200@200
       
  4776             centered:false 
       
  4777             action:[:result | result printNewline]
       
  4778             initialAnswer:'the default'
       
  4779             onCancel:#foo
       
  4780 
       
  4781      under mouse pointer:
       
  4782 
       
  4783          Dialog 
       
  4784             request:'enter a string:'
       
  4785             displayAt:nil
       
  4786             centered:false 
       
  4787             action:[:result | result printNewline]
       
  4788             initialAnswer:'the default'
       
  4789             onCancel:#foo
       
  4790 
       
  4791      centered on the screen:
       
  4792 
       
  4793          Dialog 
       
  4794             request:'enter a string:'
       
  4795             displayAt:nil
       
  4796             centered:true 
       
  4797             action:[:result | result printNewline]
       
  4798             initialAnswer:'the default'
       
  4799             onCancel:#foo
       
  4800     "
       
  4801 
       
  4802     "Created: 7.12.1995 / 23:14:10 / cg"
       
  4803     "Modified: 29.5.1996 / 14:24:39 / cg"
  4715 !
  4804 !
  4716 
  4805 
  4717 request:aString title:titleString initialAnswer:initial
  4806 request:aString title:titleString initialAnswer:initial
  4718     "launch a Dialog, which allows user to enter something.
  4807     "launch a Dialog, which allows user to enter something.
  4719      Return the entered string (may be empty string) or nil (if cancel was pressed)"
  4808      Return the entered string (may be empty string) or nil (if cancel was pressed)"
  6170      ^ Smalltalk classNamed:className
  6259      ^ Smalltalk classNamed:className
  6171 
  6260 
  6172     "
  6261     "
  6173      Dialog 
  6262      Dialog 
  6174          requestClass:'Enter a class:'
  6263          requestClass:'Enter a class:'
       
  6264          list:(View withAllSubclasses copy sortBySelector:#name)
  6175          okLabel:'OK'
  6265          okLabel:'OK'
  6176          initialAnswer:'Arr'        
  6266          initialAnswer:'Arr'        
  6177     "
  6267     "
  6178 
  6268 
  6179     "Created: / 12-01-2008 / 23:02:28 / cg"
  6269     "Created: / 12-01-2008 / 23:02:28 / cg"
  9795     "Modified: 9.2.1996 / 21:46:40 / cg"
  9885     "Modified: 9.2.1996 / 21:46:40 / cg"
  9796 ! !
  9886 ! !
  9797 
  9887 
  9798 !DialogBox methodsFor:'private'!
  9888 !DialogBox methodsFor:'private'!
  9799 
  9889 
       
  9890 assignKeyboardFocusToFirstInputField
       
  9891     |field|
       
  9892 
       
  9893     (inputFieldGroup notNil 
       
  9894       and:[(field := inputFieldGroup currentField) notNil
       
  9895       and:[field shown]]) ifTrue:[
       
  9896         self assignKeyboardFocusTo:field.
       
  9897         ^ self  "/ disabled - the focus might have already been changed
       
  9898                 "/ explicitly to another field
       
  9899     ].
       
  9900     ^ super assignKeyboardFocusToFirstInputField
       
  9901 !
       
  9902 
  9800 basicAddComponent:aComponent 
  9903 basicAddComponent:aComponent 
  9801     "add a component, dont change its size"
  9904     "add a component, dont change its size"
  9802 
  9905 
  9803     addedComponents isNil ifTrue:[
  9906     addedComponents isNil ifTrue:[
  9804         addedComponents := OrderedCollection new.
  9907         addedComponents := OrderedCollection new.
 10145 ! !
 10248 ! !
 10146 
 10249 
 10147 !DialogBox class methodsFor:'documentation'!
 10250 !DialogBox class methodsFor:'documentation'!
 10148 
 10251 
 10149 version
 10252 version
 10150     ^ '$Header: /cvs/stx/stx/libwidg/DialogBox.st,v 1.354 2014-05-06 19:44:25 cg Exp $'
 10253     ^ '$Header: /cvs/stx/stx/libwidg/DialogBox.st,v 1.359 2014-07-03 16:37:48 cg Exp $'
 10151 !
 10254 !
 10152 
 10255 
 10153 version_CVS
 10256 version_CVS
 10154     ^ '$Header: /cvs/stx/stx/libwidg/DialogBox.st,v 1.354 2014-05-06 19:44:25 cg Exp $'
 10257     ^ '$Header: /cvs/stx/stx/libwidg/DialogBox.st,v 1.359 2014-07-03 16:37:48 cg Exp $'
 10155 ! !
 10258 ! !
 10156 
 10259 
 10157 
 10260 
 10158 DialogBox initialize!
 10261 DialogBox initialize!