Skip to content
Permalink
Browse files

Merge pull request #729 from jecisc/728-Deprecate-asSpAdapter

728-Deprecate-asSpAdapter
  • Loading branch information...
jecisc committed Aug 13, 2019
2 parents 005eded + 9501ae6 commit cb5f47ca0a1aca9c49c2e86c8ee1ab842ff23f37
@@ -1,13 +1,5 @@
Extension { #name : #Morph }

{ #category : #'*Spec2-Adapters-Morphic' }
Morph >> asSpAdapter [

^ (SpBindings value
adapterClass: #GenericAdapter)
morph: self
]

{ #category : #'*Spec2-Adapters-Morphic' }
Morph >> spEnsureLayoutAndAddMorph: aMorph [

@@ -14,10 +14,10 @@ Class {

{ #category : #specs }
SpWorldPresenter class >> defaultSpec [
<spec>

self setUpWorld.
^ self currentWorld asSpAdapter
^ SpMorphPresenter new
morph: self currentWorld;
yourself
]

{ #category : #private }
@@ -46,8 +46,9 @@ SpWorldPresenter >> addPresenterIn: container withSpecLayout: aSpec [

{ #category : #factory }
SpWorldPresenter >> buildWidget [

^ self currentWorld asSpAdapter
^ SpMorphPresenter new
morph: self currentWorld;
yourself
]

{ #category : #private }
@@ -1,5 +1,13 @@
Extension { #name : #Morph }

{ #category : #'*Spec2-Deprecated' }
Morph >> asSpAdapter [
self deprecated: 'Instead of #asSpAdapter you should use a SpMorphPresenter'.
^ (SpBindings value
adapterClass: #GenericAdapter)
morph: self
]

{ #category : #'*Spec2-Deprecated' }
Morph >> spSetModal: aSystemWindow [
|area mySysWin keyboardFocus|
@@ -6,9 +6,16 @@ Be aware that when you use this, you broke Spec plateform independency and force
Class {
#name : #SpMorphicGenericAdapter,
#superclass : #SpAbstractMorphicAdapter,
#category : #'Spec2-Adapters-Morphic-Base'
#category : #'Spec2-Deprecated'
}

{ #category : #deprecation }
SpMorphicGenericAdapter class >> isDeprecated [
"You should use #SpMorphPresenter instead of #asSpAdapter."

^ true
]

{ #category : #'instance creation' }
SpMorphicGenericAdapter class >> morph: morph [

@@ -20,14 +20,16 @@ Class {

{ #category : #specs }
SpDropListExample class >> defaultSpec [
^ SpColumnLayout composed
newRow: [ :r |
r
^ SpBoxLayout newVertical
add:
(SpBoxLayout newHorizontal
add: #uniformDropList;
add: #heterogeneousDropList ]
add: #heterogeneousDropList;
yourself)
height: self toolbarHeight;
newRow: [ :r | r add: #disabledDropList ] height: self toolbarHeight;
newRow: [ :r | r add: #container ] yourself
add: #disabledDropList height: self toolbarHeight;
add: #container;
yourself
]

{ #category : #example }
@@ -45,60 +47,54 @@ SpDropListExample class >> title [

{ #category : #accessing }
SpDropListExample >> container [
^ container
]

^ container asSpAdapter
{ #category : #initialization }
SpDropListExample >> containerMorph [
^ container morph
]

{ #category : #accessing }
SpDropListExample >> disabledDropList [

^ disabledDropList
]

{ #category : #accessing }
SpDropListExample >> heterogeneousDropList [

^ heterogeneousDropList.
^ heterogeneousDropList
]

{ #category : #initialization }
SpDropListExample >> initialize [
SpDropListExample >> initializeWidgets [
uniformDropList := self newDropList.
heterogeneousDropList := self newDropList.
container := self newMorph.
disabledDropList := self newDropList.

container := PanelMorph new.
container morph: PanelMorph new.
self instantiateMorphs.

container
self containerMorph
changeTableLayout;
listDirection: #bottomToLeft.

super initialize.
]

{ #category : #initialization }
SpDropListExample >> initializeWidgets [
uniformDropList := self newDropList.
heterogeneousDropList := self newDropList.
(disabledDropList := self newDropList)
disabledDropList
items: #('Disabled' 'Two' 'Three');
displayBlock: [ :each | each ];
disable.

uniformDropList
items:
{morph1.
morph2.
morph3};
items: {morph1 . morph2 . morph3};
displayBlock: [ :m | m color name capitalized , ' morph' ];
iconBlock: [ :e | self iconNamed: #testGreenIcon ];
whenSelectedItemChangedDo: [ :m |
container removeAllMorphs.
container addMorph: m ].
self containerMorph
removeAllMorphs;
addMorph: m ].

heterogeneousDropList
addItemLabeled: 'Open workspace'
do: [ Smalltalk tools workspace open ]
icon: (self iconNamed: #smallOkIcon);
addItemLabeled: 'Inspect current morph'
do: [ uniformDropList selectedItem inspect ]
icon: (self iconNamed: #testRedIcon).
addItemLabeled: 'Open workspace' do: [ Smalltalk tools workspace open ] icon: (self iconNamed: #smallOkIcon);
addItemLabeled: 'Inspect current morph' do: [ uniformDropList selectedItem inspect ] icon: (self iconNamed: #testRedIcon).

"If this is uncommented, it will fire the action of the first item, which is not what we want:
heterogeneousDropList setSelectedIndex: 1.
@@ -60,19 +60,23 @@ SpScrollSyncExample >> defaultSpecLayout [
{ #category : #initialization }
SpScrollSyncExample >> initialize [
super initialize.
sideRuler := (Morph new
color: Color yellow;
extent: 50 @ 500;
useGradientFill;
hResizing: #spaceFill;
vResizing: #spaceFill;
yourself) asSpAdapter.
currentVerticalScrollPosition := 0
]

{ #category : #initialization }
SpScrollSyncExample >> initializeWidgets [
text := self newText.
sideRuler := self newMorph.

sideRuler
morph:
(Morph new
color: Color yellow;
extent: 50 @ 500;
useGradientFill;
hResizing: #spaceFill;
vResizing: #spaceFill;
yourself).

text whenScrollValueChangedDo: [ :newPosition | self syncMorphPosition ].
text text: self loremIpsum

0 comments on commit cb5f47c

Please sign in to comment.
You can’t perform that action at this time.