View subclass:#ComboBoxView
instanceVariableNames:'enterField pullDownButton list'
classVariableNames:''
poolDictionaries:''
category:'Views-Interactors'
!
!ComboBoxView class methodsFor:'documentation'!
documentation
"
a first attempt in a comboBox implementation.
Not yet finished.
"
!
examples
"
|top b|
top := StandardSystemView new.
top extent:(300 @ 200).
b := ComboBoxView in:top.
b origin:(0.0 @ 0.0) corner:(1.0 @ 0.0).
b bottomInset:(b preferredExtent y negated).
b list:#('hello' 'world' 'this' 'is' 'st/x').
top open.
model operation:
|model top b|
model := 'foo' asValue.
top := StandardSystemView new.
top extent:(300 @ 200).
b := ComboBoxView in:top.
b origin:(0.0 @ 0.0) corner:(1.0 @ 0.0).
b bottomInset:(b preferredExtent y negated).
b list:#('hello' 'world' 'this' 'is' 'st/x').
b model:model.
top openModal.
model inspect.
"
! !
!ComboBoxView class methodsFor:'defaults'!
buttonForm
|form|
form := Form fromFile:'ComboDn_win.xbm'.
^ form on:Display
! !
!ComboBoxView methodsFor:'accessing-contents'!
list:aList
list := aList
"Created: 9.2.1996 / 00:51:25 / cg"
"Modified: 9.2.1996 / 00:51:56 / cg"
! !
!ComboBoxView methodsFor:'accessing-mvc'!
action:aBlock
enterField action:aBlock
"Created: 9.2.1996 / 01:44:20 / cg"
!
model
^ enterField model
"Created: 9.2.1996 / 00:50:18 / cg"
!
model:aModel
enterField model:aModel.
"Created: 9.2.1996 / 00:50:12 / cg"
! !
!ComboBoxView methodsFor:'initialization'!
initialize
|ext|
super initialize.
"/ borderWidth := 0.
enterField := EditField in:self.
enterField origin:0.0@0.0 corner:1.0@1.0.
enterField model:('' asValue).
pullDownButton := Toggle in:self.
pullDownButton label:(self class buttonForm).
ext := pullDownButton preferredExtent.
pullDownButton origin:1.0@0.0 corner:1.0@1.0.
pullDownButton leftInset:(ext x negated).
enterField rightInset:(ext x).
pullDownButton pressAction:[self pullMenu].
pullDownButton releaseAction:[self hideMenu].
self height:enterField preferredExtent y + ViewSpacing.
"
all of my input goes to the enterfield
"
self delegate:(KeyboardForwarder toView:enterField).
"
|b|
b := ComboBoxView new.
b list:#('hello' 'world' 'this' 'is' 'st/x').
b open
"
"Created: 9.2.1996 / 00:05:24 / cg"
"Modified: 9.2.1996 / 01:07:10 / cg"
! !
!ComboBoxView methodsFor:'queries'!
preferredExtent
|pref1 pref2|
pref1 := enterField preferredExtent.
pref2 := pullDownButton preferredExtent.
^ (pref1 x + pref2 x) @ (pref1 y max:pref2 y)
"Created: 9.2.1996 / 01:08:47 / cg"
! !
!ComboBoxView methodsFor:'user interaction'!
entryChanged:what
enterField contents:what.
enterField accept.
pullDownButton turnOff.
"Created: 9.2.1996 / 01:06:01 / cg"
"Modified: 9.2.1996 / 01:42:38 / cg"
!
pullMenu
|m org|
m := PopUpMenu
labels:list
selectors:#entryChanged:
args:list
receiver:self.
Transcript showCr:m menuView width.
Transcript showCr:m width.
m menuView resize.
m menuView width:(self width).
m menuView sizeFixed:true.
m hideOnRelease:false.
org := device translatePoint:(0 @ self height)
from:(self id)
to:(device rootView id).
m showAt:org.
pullDownButton turnOff.
"Created: 9.2.1996 / 00:36:49 / cg"
"Modified: 9.2.1996 / 02:02:54 / cg"
! !
!ComboBoxView class methodsFor:'documentation'!
version
^ '$Header: /cvs/stx/stx/libwidg2/ComboBoxView.st,v 1.1 1996-02-09 01:09:28 cg Exp $'
! !