DialogBox.st
changeset 381 49fc4e7d81b7
parent 374 39a735c9a1c7
child 414 1435ecc200a9
equal deleted inserted replaced
380:6eb402d01ae0 381:49fc4e7d81b7
  2521     "
  2521     "
  2522 
  2522 
  2523     "Modified: 9.2.1996 / 21:36:16 / cg"
  2523     "Modified: 9.2.1996 / 21:36:16 / cg"
  2524 !
  2524 !
  2525 
  2525 
       
  2526 addListBoxOn:aModel
       
  2527     "add a selectionInListView to the box"
       
  2528 
       
  2529     ^ self addListBoxOn:aModel withNumberOfLines:nil
       
  2530 
       
  2531     "
       
  2532      |dialog model listView|
       
  2533 
       
  2534      model := SelectionInList new.
       
  2535      model list:#('one' 'two' 'three' 'four').
       
  2536      model selectionIndex:2.
       
  2537 
       
  2538      dialog := DialogBox new.
       
  2539      (dialog addTextLabel:'select any') adjust:#left.
       
  2540 
       
  2541      listView := dialog addListBoxOn:model.
       
  2542 
       
  2543      dialog addAbortButton; addOkButton.
       
  2544      dialog open.
       
  2545 
       
  2546      dialog accepted ifTrue:[Transcript show:'selection is:'; showCr:model selection].
       
  2547     "
       
  2548 
       
  2549     "Modified: 22.2.1996 / 15:40:54 / cg"
       
  2550 !
       
  2551 
       
  2552 addListBoxOn:aModel withNumberOfLines:numLines
       
  2553     "add a selectionInListView to the box.
       
  2554      The list has numLines (if nonNil) number of lines shown."
       
  2555 
       
  2556     |l scr h|
       
  2557 
       
  2558     l := SelectionInListView new.
       
  2559     l model:aModel.
       
  2560     l doubleClickAction:[:name | self okPressed].
       
  2561     scr := ScrollableView forView:l.
       
  2562 
       
  2563     numLines notNil ifTrue:[
       
  2564         h := l heightForLines:numLines.
       
  2565     ] ifFalse:[
       
  2566         h := l preferredExtent y
       
  2567     ].
       
  2568     self addComponent:scr withHeight:h.
       
  2569     ^ l
       
  2570 
       
  2571     "
       
  2572      |dialog model listView|
       
  2573 
       
  2574      model := SelectionInList new.
       
  2575      model list:#('one' 'two' 'three' 'four').
       
  2576      model selectionIndex:2.
       
  2577 
       
  2578      dialog := DialogBox new.
       
  2579      (dialog addTextLabel:'select any') adjust:#left.
       
  2580 
       
  2581      listView := dialog addListBoxOn:model withNumberOfLines:3.
       
  2582 
       
  2583      dialog addAbortButton; addOkButton.
       
  2584      dialog open.
       
  2585 
       
  2586      dialog accepted ifTrue:[Transcript show:'selection is:'; showCr:model selection].
       
  2587     "
       
  2588 
       
  2589     "Created: 22.2.1996 / 15:40:07 / cg"
       
  2590     "Modified: 22.2.1996 / 15:41:25 / cg"
       
  2591 !
       
  2592 
  2526 addOkButton
  2593 addOkButton
  2527     "create an okButton - to be sent from redefined initialize
  2594     "create an okButton - to be sent from redefined initialize
  2528      methods in subclasses or when creating a box programmatically.
  2595      methods in subclasses or when creating a box programmatically.
  2529      Returns the button."
  2596      Returns the button."
  2530 
  2597 
  3427 ! !
  3494 ! !
  3428 
  3495 
  3429 !DialogBox class methodsFor:'documentation'!
  3496 !DialogBox class methodsFor:'documentation'!
  3430 
  3497 
  3431 version
  3498 version
  3432     ^ '$Header: /cvs/stx/stx/libwidg/DialogBox.st,v 1.45 1996-02-21 00:37:00 cg Exp $'
  3499     ^ '$Header: /cvs/stx/stx/libwidg/DialogBox.st,v 1.46 1996-02-22 20:43:54 cg Exp $'
  3433 ! !
  3500 ! !