Created
May 21, 2016 18:56
-
-
Save nicoknoll/17234879dc4f445861520db8e5846b05 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PluggableListMorph subclass: #STweetPluggableListMorph | |
instanceVariableNames: '' | |
classVariableNames: '' | |
poolDictionaries: '' | |
category: 'Project08-Core' | |
listItemHeight | |
"This should be cleaned up. The list should get spaced by this | |
parameter. " | |
^ 100 | |
------- | |
Object subclass: #STweetList | |
instanceVariableNames: 'list selectedIndex' | |
classVariableNames: '' | |
poolDictionaries: '' | |
category: 'Project08-Core' | |
getListMorph | |
| aListMorph | | |
aListMorph := STweetPluggableListMorph | |
on: self | |
list: #list | |
selected: #listIndex | |
changeSelected: #listIndex: | |
menu: #listMenu:. | |
"I am the model that has a list to display" | |
"This is how the morph gets the list from me" | |
"This is how the morph knows which item to highlight" | |
"This is how the morph informs me of a user selection" | |
"This is how the morph requests a menu for the list" | |
aListMorph color: Color white. | |
^ aListMorph | |
initialize | |
list := #('bla' 'bla' ) | |
asSortedCollection: [:a :b | a = b]. | |
selectedIndex := 1 | |
list | |
^ list | |
listIndex | |
^ selectedIndex | |
listIndex: anInteger | |
selectedIndex := anInteger. | |
self changed: #listIndex | |
listMenu: aMenu | |
| targetClass differentMenu className | | |
className := list | |
at: selectedIndex | |
ifAbsent: [^ aMenu | |
add: 'nothing selected' | |
target: self | |
selector: #beep]. | |
targetClass := Smalltalk | |
at: className | |
ifAbsent: [^ aMenu | |
add: 'that class is history!!' | |
target: self | |
selector: #beep]. | |
differentMenu := DumberMenuMorph new. | |
"avoid the retargeting business" | |
differentMenu | |
add: 'browse' | |
target: targetClass | |
selector: #browse; | |
add: 'inspect' | |
target: targetClass | |
selector: #inspect; | |
add: 'explore' | |
target: targetClass | |
selector: #explore. | |
^ differentMenu | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment