DialogBox.st
changeset 2080 620d5ac7dee5
parent 2079 80dcc5d0caac
child 2106 40b0e35b3dbc
equal deleted inserted replaced
2079:80dcc5d0caac 2080:620d5ac7dee5
  2264         onCancel:cancelValue 
  2264         onCancel:cancelValue 
  2265         list:nil
  2265         list:nil
  2266 
  2266 
  2267 !
  2267 !
  2268 
  2268 
  2269 request:aString displayAt:aPoint centered:centered action:resultAction initialAnswer:initial okLabel:okLabel cancelLabel:cancelLabel title:titleString onCancel:cancelValue list:listToSelectFrom
  2269 request:aString displayAt:aPoint centered:centered action:resultAction 
       
  2270 initialAnswer:initial okLabel:okLabel cancelLabel:cancelLabel title:titleString 
       
  2271 onCancel:cancelValue list:listToSelectFrom
  2270     "launch a Dialog, which allows user to enter a string.
  2272     "launch a Dialog, which allows user to enter a string.
  2271      The dialogs window is titled titleString, or the default (if nil).
  2273      The dialogs window is titled titleString, or the default (if nil).
  2272      If aPoint is nonNil, the box is shown there, optionally centered around it.
  2274      If aPoint is nonNil, the box is shown there, optionally centered around it.
  2273      If it is nil, it is shown at the current pointer position or at the 
  2275      If it is nil, it is shown at the current pointer position or at the 
  2274      screen center (if centered is true).
  2276      screen center (if centered is true).
  2275      The ok-button is labelled okLabel (or the default, ifNil),
  2277      The ok-button is labelled okLabel (or the default, ifNil),
  2276      the cancel-button is labelled cancelLabel (or the default, ifNil).
  2278      the cancel-button is labelled cancelLabel (or the default, ifNil).
  2277      Return the string or the value of cancelValue (if cancel was pressed)"
  2279      Return the string or the value of cancelValue (if cancel was pressed)"
  2278 
  2280 
  2279     |box|
  2281     ^ self
  2280 
  2282         request:aString 
  2281     listToSelectFrom isNil ifTrue:[
  2283         displayAt:aPoint 
  2282         box := EnterBox title:aString.
  2284         centered:centered 
  2283     ] ifFalse:[
  2285         action:resultAction 
  2284         box := EnterBoxWithList title:aString.
  2286         initialAnswer:initial 
  2285         box list:listToSelectFrom.
  2287         okLabel:okLabel 
  2286     ].
  2288         cancelLabel:cancelLabel 
  2287     box initialText:initial printString.
  2289         title:titleString 
  2288     box abortAction:[:val | box destroy. ^ cancelValue value].
  2290         onCancel:cancelValue 
  2289     okLabel notNil ifTrue:[
  2291         list:listToSelectFrom 
  2290         box okText:okLabel.
  2292         initialSelection:nil
  2291     ].
       
  2292     cancelLabel notNil ifTrue:[
       
  2293         box abortText:cancelLabel 
       
  2294     ].
       
  2295     resultAction isNil ifTrue:[
       
  2296         box action:[:val | box destroy. ^ val]
       
  2297     ] ifFalse:[
       
  2298         box action:[:val | box destroy. ^ resultAction value:val]
       
  2299     ].
       
  2300     titleString notNil ifTrue:[
       
  2301         box label:titleString
       
  2302     ].
       
  2303 
       
  2304     aPoint notNil ifTrue:[
       
  2305         box showAt:aPoint center:centered
       
  2306     ] ifFalse:[
       
  2307         centered ifTrue:[
       
  2308             box showAtCenter
       
  2309         ] ifFalse:[
       
  2310             box showAtPointer
       
  2311         ]
       
  2312     ].
       
  2313     box destroy. 
       
  2314     ^ cancelValue value.
       
  2315 
  2293 
  2316     "
  2294     "
  2317      centered around 200@200:
  2295      centered around 200@200:
  2318 
  2296 
  2319          Dialog 
  2297          Dialog 
  2370 
  2348 
  2371     "Created: / 29.5.1996 / 14:35:04 / cg"
  2349     "Created: / 29.5.1996 / 14:35:04 / cg"
  2372     "Modified: / 5.5.1999 / 10:50:22 / cg"
  2350     "Modified: / 5.5.1999 / 10:50:22 / cg"
  2373 !
  2351 !
  2374 
  2352 
       
  2353 request:aString displayAt:aPoint centered:centered action:resultAction 
       
  2354 initialAnswer:initial okLabel:okLabel cancelLabel:cancelLabel title:titleString 
       
  2355 onCancel:cancelValue list:listToSelectFrom initialSelection:anInterval
       
  2356     "launch a Dialog, which allows user to enter a string.
       
  2357      The dialogs window is titled titleString, or the default (if nil).
       
  2358      If aPoint is nonNil, the box is shown there, optionally centered around it.
       
  2359      If it is nil, it is shown at the current pointer position or at the 
       
  2360      screen center (if centered is true).
       
  2361      The ok-button is labelled okLabel (or the default, ifNil),
       
  2362      the cancel-button is labelled cancelLabel (or the default, ifNil).
       
  2363      Return the string or the value of cancelValue (if cancel was pressed)"
       
  2364 
       
  2365     |box|
       
  2366 
       
  2367     listToSelectFrom isNil ifTrue:[
       
  2368         box := EnterBox title:aString.
       
  2369     ] ifFalse:[
       
  2370         box := EnterBoxWithList title:aString.
       
  2371         box list:listToSelectFrom.
       
  2372     ].
       
  2373     box initialText:initial printString.
       
  2374     anInterval notNil ifTrue:[
       
  2375         box selectFrom:anInterval start to:anInterval stop.
       
  2376     ].
       
  2377     box abortAction:[:val | box destroy. ^ cancelValue value].
       
  2378     okLabel notNil ifTrue:[
       
  2379         box okText:okLabel.
       
  2380     ].
       
  2381     cancelLabel notNil ifTrue:[
       
  2382         box abortText:cancelLabel 
       
  2383     ].
       
  2384     resultAction isNil ifTrue:[
       
  2385         box action:[:val | box destroy. ^ val]
       
  2386     ] ifFalse:[
       
  2387         box action:[:val | box destroy. ^ resultAction value:val]
       
  2388     ].
       
  2389     titleString notNil ifTrue:[
       
  2390         box label:titleString
       
  2391     ].
       
  2392 
       
  2393     aPoint notNil ifTrue:[
       
  2394         box showAt:aPoint center:centered
       
  2395     ] ifFalse:[
       
  2396         centered ifTrue:[
       
  2397             box showAtCenter
       
  2398         ] ifFalse:[
       
  2399             box showAtPointer
       
  2400         ]
       
  2401     ].
       
  2402     box destroy. 
       
  2403     ^ cancelValue value.
       
  2404 
       
  2405     "
       
  2406      centered around 200@200:
       
  2407 
       
  2408          Dialog 
       
  2409             request:'enter a string:'
       
  2410             displayAt:200@200
       
  2411             centered:true
       
  2412             action:[:result | result printNewline]
       
  2413             initialAnswer:'the default'
       
  2414             okLabel:'yes'
       
  2415             cancelLabel:'no'
       
  2416             title:'foo'
       
  2417             onCancel:#foo
       
  2418 
       
  2419      under mouse pointer:
       
  2420 
       
  2421          Dialog 
       
  2422             request:'enter a string:'
       
  2423             displayAt:nil
       
  2424             centered:false 
       
  2425             action:[:result | result printNewline]
       
  2426             initialAnswer:'the default'
       
  2427             okLabel:'yes'
       
  2428             cancelLabel:'no'
       
  2429             title:'foo'
       
  2430             onCancel:#foo
       
  2431 
       
  2432      centered on the screen:
       
  2433 
       
  2434          Dialog 
       
  2435             request:'enter a string:'
       
  2436             displayAt:nil
       
  2437             centered:true 
       
  2438             action:[:result | result printNewline]
       
  2439             initialAnswer:'the default'
       
  2440             okLabel:'yes'
       
  2441             cancelLabel:'no'
       
  2442             title:'foo'
       
  2443             onCancel:#foo
       
  2444 
       
  2445      with a list:
       
  2446 
       
  2447          Dialog 
       
  2448             request:'enter a string:'
       
  2449             displayAt:nil
       
  2450             centered:true 
       
  2451             action:[:result | result printNewline]
       
  2452             initialAnswer:'the default'
       
  2453             okLabel:'yes'
       
  2454             cancelLabel:'no'
       
  2455             title:'foo'
       
  2456             onCancel:#foo
       
  2457             list:#(foo bar baz)
       
  2458     "
       
  2459 
       
  2460     "Created: / 29.5.1996 / 14:35:04 / cg"
       
  2461     "Modified: / 5.5.1999 / 10:50:22 / cg"
       
  2462 !
       
  2463 
  2375 request:aString displayAt:aPoint centered:centered action:resultAction initialAnswer:initial onCancel:cancelValue
  2464 request:aString displayAt:aPoint centered:centered action:resultAction initialAnswer:initial onCancel:cancelValue
  2376     "launch a Dialog, which allows user to enter a string.
  2465     "launch a Dialog, which allows user to enter a string.
  2377      If aPoint is nonNil, the box is shown there, optionally centered.
  2466      If aPoint is nonNil, the box is shown there, optionally centered.
  2378      If it is nil, it is shown at the current pointer position or at the screen center.
  2467      If it is nil, it is shown at the current pointer position or at the screen center.
  2379      Return the string or the value of cancelValue (if cancel was pressed)"
  2468      Return the string or the value of cancelValue (if cancel was pressed)"
  2480 
  2569 
  2481     "
  2570     "
  2482      Dialog 
  2571      Dialog 
  2483 	 request:'enter a string:' 
  2572 	 request:'enter a string:' 
  2484 	 initialAnswer:'the default'  
  2573 	 initialAnswer:'the default'  
       
  2574     "
       
  2575 
       
  2576     "Modified: 29.5.1996 / 14:30:05 / cg"
       
  2577 !
       
  2578 
       
  2579 request:aString initialAnswer:initial initialSelection:anInterval
       
  2580     "launch a Dialog, which allows user to enter something.
       
  2581      Return the entered string (may be empty string) or nil (if cancel was pressed)"
       
  2582 
       
  2583     ^ self 
       
  2584         request:aString 
       
  2585         displayAt:nil 
       
  2586         centered:false 
       
  2587         action:nil 
       
  2588         initialAnswer:initial 
       
  2589         okLabel:nil 
       
  2590         cancelLabel:nil 
       
  2591         title:nil 
       
  2592         onCancel:'' 
       
  2593         list:nil 
       
  2594         initialSelection:anInterval
       
  2595 
       
  2596     "
       
  2597      Dialog 
       
  2598          request:'enter a string:' 
       
  2599          initialAnswer:'the default'
       
  2600          initialSelection:(1 to:3)
  2485     "
  2601     "
  2486 
  2602 
  2487     "Modified: 29.5.1996 / 14:30:05 / cg"
  2603     "Modified: 29.5.1996 / 14:30:05 / cg"
  2488 !
  2604 !
  2489 
  2605 
  6090 ! !
  6206 ! !
  6091 
  6207 
  6092 !DialogBox class methodsFor:'documentation'!
  6208 !DialogBox class methodsFor:'documentation'!
  6093 
  6209 
  6094 version
  6210 version
  6095     ^ '$Header: /cvs/stx/stx/libwidg/DialogBox.st,v 1.138 1999-12-09 20:11:28 cg Exp $'
  6211     ^ '$Header: /cvs/stx/stx/libwidg/DialogBox.st,v 1.139 1999-12-09 22:50:49 cg Exp $'
  6096 ! !
  6212 ! !
  6097 DialogBox initialize!
  6213 DialogBox initialize!