From: Sophia Drossopoulou <scd@doc.ic.ac.uk>
Newsgroups: comp.lang.smalltalk
Subject: mysterious buffering and MVC in Objectworks\Smalltalk version 4.1
Date: 5 Oct 1992 16:13:22 GMT
Organization: Department of Computing, Imperial College, LONDON, UK
Distribution: world
NNTP-Posting-Host: alice-mac-145.doc.ic.ac.uk
X-UserAgent: Nuntius v1.1.1d11
X-XXMessage-ID: <A6F628519D020D91@alice-mac-145.doc.ic.ac.uk>
X-XXDate: Mon, 5 Oct 92 15:13:53 GMT

"I am trying to use the model-view-controller approach on
Objectworks\Smalltalk version 4.1, to
obtain monitors on objects which would diaplay any changes to their
state, even their intermediate 
state. However, it seems that some buffering goes on at the level of the
windows, and only the final 
state is displayed. Can anybody help me, please?

Here follows a simple code which demonstrates the problem. "


Model subclass: #Something
	instanceVariableNames: 'text '
	classVariableNames: ''
	poolDictionaries: ''
	category: 'Experiment'!


!Something methodsFor: 'initialization'!

initializeWith: aText 
	"initialization is separate from text: because the latter alaso calls
	self changed:.... which  requires  an active view and window"

	text := aText! !

!Something methodsFor: 'access'!

text
	Transcript show: 'at', (Time dateAndTimeNow printString), 'the value of
text is ', text.
	Transcript cr.
	^ text!

text: aText
	text := aText.
	self changed: #text! !
"-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "!
"Now I execute the following text  (ie I highlight it in a workspace and
<do it>)
that is,  I create an instance of something (ASomething),  create a view
on it (AView), and insert this view
into a window (AWindow), and then change the <text> contents of
ASomething"

	"ASomething, AWindow, AView, AComposite are global variables"
	Transcript show: '************* start  testViews ***********'.
	Transcript cr.
	
	ASomething  :=  Something new initializeWith: 'first'.
	AView := TextView
				on: ASomething
				aspect: #text
				change: #text:
				menu: nil
				initialSelection: (ASomething text).
	AComposite := CompositePart new.
	AComposite add: (LookPreferences edgeDecorator on: AView)
		in: (0 @ 0 extent: 0.3 @ 0.3).
	AWindow := ScheduledWindow new label: ' testing views'.
	AWindow minimumSize: 600 @ 600.
	AWindow component: AComposite.
	AWindow open.
	 
	DelayTime :=5.
	(Delay forSeconds: DelayTime) wait.
	ASomething text: 'second'.
	(Delay forSeconds: DelayTime) wait.
	ASomething text: 'third'.
	
	Transcript show: '************* end of testViews ***********'.
	Transcript cr.

"then, I  obtain the following output on the System Transcipt

************* start  testViews ***********
at#(5 October 1992 8:15:43 am )the value of text is first
at#(5 October 1992 8:15:43 am )the value of text is first
at#(5 October 1992 8:15:49 am )the value of text is second
at#(5 October 1992 8:15:54 am )the value of text is third
************* end of testViews ***********

which is as expected. It also proves, that any time tha value of <text>
is modified, the view *was*
notified, and the model *was* interrogated - as it should be.
But I expected that the window would display 'first', then, five seconds
later it would display
'second' and again five seconds later 'third'. Instaed, the window only
displays third at the end.

Furthermore, if I  define a class method, <testViews>, which essentlially
does the same as the
text from my worspace: 

Something class
	instanceVariableNames: ''!


!Something class methodsFor: 'testing Views'!

testViews
	|  aView aSomething composite window  delayTime |

	Transcript show: '************* start  testViews ***********'.
	Transcript cr.
	composite := CompositePart new.
	aSomething  :=  Something new initializeWith: 'first'.
	aView := TextView
				on: aSomething
				aspect: #text
				change: #text:
				menu: nil
				initialSelection: (aSomething text).
	composite add: (LookPreferences edgeDecorator on: aView)
		in: (0 @ 0.35 extent: 0.6 @ 0.85).
	window := ScheduledWindow new label: ' testing buffering '.
	window minimumSize: 400 @ 300.
	window component: composite.
	window open.

	delayTime := 5.
	(Delay forSeconds: delayTime) wait.
	aSomething text: 'second'.
	(Delay forSeconds: delayTime) wait.
	aSomething text: 'third'.
	
	Transcript show: '************* end of testViews ***********'.
	Transcript cr.! !

"then even more mysterious buffering takes place: When I execute
<Something testViews> then 
the window appears, but it does not display any text!


Could anybody tell me
	a) how do I avoid this bufering of the intermediate values of <text>
	b) how do I make the window display the view in the case of <testView>
	c) TextView provides facilities for scrolling/accepting/deleting etc. I
just want to have some text
		displayed. Therefore it looks as an overkill. What kind of view could I
use instead? 

Furthermore, does there exist any more extensive documentation about the
various classes
of the MVC approach  in the Objectworks\Smalltalk version 4.1, other than
the user's guide?


Many thanks,

Sophia Drossopoulou
Imperial College, LONDON
email: scd@doc.ic.ac.uk"
Xref: sparky comp.lang.smalltalk:2035 comp.lang.eiffel:1233 comp.object:3845