84 lines
2.1 KiB
Smalltalk
84 lines
2.1 KiB
Smalltalk
Class {
|
|
#name : #GrafoscopioNewTextInputModel,
|
|
#superclass : #SpDynamicPresenter,
|
|
#instVars : [
|
|
'#body',
|
|
'#model => SpObservableSlot',
|
|
'#onModifyNodeLocationDo'
|
|
],
|
|
#category : #'Grafoscopio-New-UI'
|
|
}
|
|
|
|
{ #category : #specs }
|
|
GrafoscopioNewTextInputModel class >> defaultSpec [
|
|
^ SpBoxLayout newVertical
|
|
add: #body height: 300;
|
|
yourself
|
|
]
|
|
|
|
{ #category : #API }
|
|
GrafoscopioNewTextInputModel >> content: aGrafoscopioNodeContent [
|
|
self layout: (self createLayoutFor: aGrafoscopioNodeContent).
|
|
body text: (aGrafoscopioNodeContent ifNil: [ '' ])
|
|
]
|
|
|
|
{ #category : #API }
|
|
GrafoscopioNewTextInputModel >> createLayoutFor: aGrafoscopioNodeContent [
|
|
^ SpBoxLayout newVertical
|
|
add: #body
|
|
height: (self heightFor: aGrafoscopioNodeContent)
|
|
]
|
|
|
|
{ #category : #'as yet unclassified' }
|
|
GrafoscopioNewTextInputModel >> heightFor: aGrafoscopioNodeContent [
|
|
^ aGrafoscopioNodeContent
|
|
ifNil: [ 100 ]
|
|
ifNotNil: [ (aGrafoscopioNodeContent asString lines size * self class toolbarHeight) max: 100 ]
|
|
]
|
|
|
|
{ #category : #initialization }
|
|
GrafoscopioNewTextInputModel >> informModification [
|
|
onModifyNodeLocationDo
|
|
ifNotNil: [ onModifyNodeLocationDo cull: self ]
|
|
]
|
|
|
|
{ #category : #initialization }
|
|
GrafoscopioNewTextInputModel >> initialize [
|
|
super initialize.
|
|
]
|
|
|
|
{ #category : #initialization }
|
|
GrafoscopioNewTextInputModel >> initializePrivateAnnouncements [
|
|
super initializePrivateAnnouncements.
|
|
self property: #model whenChangedDo: [ self modelChanged ]
|
|
]
|
|
|
|
{ #category : #initialization }
|
|
GrafoscopioNewTextInputModel >> initializeWidgets [
|
|
body := self newTextComponent.
|
|
|
|
]
|
|
|
|
{ #category : #initialization }
|
|
GrafoscopioNewTextInputModel >> model: aModel [
|
|
model := aModel
|
|
]
|
|
|
|
{ #category : #initialization }
|
|
GrafoscopioNewTextInputModel >> modelChanged [
|
|
self content: model text.
|
|
]
|
|
|
|
{ #category : #initialization }
|
|
GrafoscopioNewTextInputModel >> newTextComponent [
|
|
^ self newTextInput whenTextChangedDo: [
|
|
model text: body text.
|
|
self informModification ];
|
|
yourself
|
|
]
|
|
|
|
{ #category : #initialization }
|
|
GrafoscopioNewTextInputModel >> onModifyNodeLocationDo: aBlock [
|
|
onModifyNodeLocationDo := aBlock
|
|
]
|