Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

AHelloWorld experiment gone awry

94 views
Skip to first unread message

Pewing

unread,
May 9, 2012, 3:26:06 AM5/9/12
to
Hi All,
Your basic newbie here trying to learn how to use Dolphin
SmallTalk. The other day I watched the Better Hello World video and
wrote the application and what do you know it worked (yippie)! So
then I thought, "I wondered if I can do this on a Scrollable window'.
After some research I found that you need a "ScrollingDecorator View"
dropped on the SHELL view, then a "ContainerView" dropped on the
"ScrollingDecorator View" and then finally my "TextPresenterStatic
View" dropped on the "ContainerView". After making the necassary
change to the name field just like in the video. Sure enough it
worked' Hello Worled on a scrollable window. Yahoo! time break out the
Sparkling water.
Then I tried to repeat the same experiment with the scrolling window,
but instead I tried to over ride the onViewOpened method and use the
createIn:on: message.
Exp: tp := TextPresenter createIn: self on: (self model value) .

Well that didn't worked , the Hello Worled is on the Shell view, and
is covered up by the "ScrollingDecorator View" and the "ContainerView
". What I can't seem to do is associate the TextPresenter View to the
Container View of my Scrollable window. Would anyone care to help me
make my experiment a success so I can get the champagne out.

Pewing

unread,
May 9, 2012, 3:18:08 AM5/9/12
to
Hi All,
I'm your basic newbie here trying to learn how to use Dolphin SmallTalk. The other day I watched the Better Hello World video and wrote the application and what do you know it worked (yippie)! So then I thought, "I wondered if I can do this on a Scrollable window'. After some research I found that you need a "ScrollingDecorator View" dropped on the SHELL view, then a "ContainerView" dropped on the "ScrollingDecorator View" and then finally my "TextPresenterStatic View" dropped on the "ContainerView". After making the necassary change to the name field just like in the video. Sure enough it worked' Hello Worled on a scrollable window. Yahoo! time break out the Sparkling water.

Andy Bower

unread,
May 9, 2012, 6:44:11 AM5/9/12
to
Pewing,

Could you wrap up your code in a package and include the text of the PAC
file here (or put it on Dropbox). It's difficult to see what might be
wrong without seeing all the code.

One thing occurs to me though; you ALWAYS need to supersend
#onViewOpened if you override it. Make sure that you've done that.

Best regards

Andy Bower

Pewing

unread,
May 9, 2012, 9:52:27 PM5/9/12
to
On Wednesday, May 9, 2012 4:44:11 AM UTC-6, Andy Bower wrote:
> Pewing,
>
> Could you wrap up your code in a package and include the text of the PAC
> file here (or put it on Dropbox). It's difficult to see what might be
> wrong without seeing all the code.
>
> One thing occurs to me though; you ALWAYS need to supersend
> #onViewOpened if you override it. Make sure that you've done that.
>
> Best regards
>
> Andy Bower
>
-------------------------

Hi Andy
Here is the code that I created essentially it is the Better Hello World video, but instead I am trying to display it on a scrollable window and use the createIn:On: method. what I am trying to accomplish is developing different techniques for manipulating Views and Presenters. I suppose writing the LOC game on a scrollable window would be the same thing.

Peter
--------------------------
| package |
package := Package name: 'TestWin2'.
package paxVersion: 1;
basicComment: ''.


package classNames
add: #TestWinShell2;
yourself.

package binaryGlobalNames: (Set new
yourself).

package globalAliases: (Set new
yourself).

package setPrerequisites: (IdentitySet new
add: '..\Dolphin\Base\Dolphin';
add: '..\Dolphin\MVP\Base\Dolphin MVP Base';
add: '..\Dolphin\MVP\Views\Scrollbars\Dolphin Scrollbars';
add: '..\Dolphin\MVP\Presenters\Text\Dolphin Text Presenter';
yourself).

package!

"Class Definitions"!

Shell subclass: #TestWinShell2
instanceVariableNames: 'tp'
classVariableNames: ''
poolDictionaries: ''
classInstanceVariableNames: ''!

"Global Aliases"!


"Loose Methods"!

"End of package definition"!

"Source Globals"!

"Classes"!

TestWinShell2 guid: (GUID fromString: '{224CA88B-F1BE-4457-A53E-7CE540FBB5D8}')!
TestWinShell2 comment: ''!
!TestWinShell2 categoriesForClass!Unclassified! !
!TestWinShell2 methodsFor!

onViewOpened
super onViewOpened.

tp:= TextPresenter createIn:self on: (self model).
! !
!TestWinShell2 categoriesFor: #onViewOpened!public! !

!TestWinShell2 class methodsFor!

defaultModel
^ 'Super Hello World' asValue.!

resource_Default_view
"Answer the literal data from which the 'Default view' resource can be reconstituted.
DO NOT EDIT OR RECATEGORIZE THIS METHOD.

If you wish to modify this resource evaluate:
ViewComposer openOn: (ResourceIdentifier class: self selector: #resource_Default_view)
"

^#(#'!!STL' 3 788558 10 ##(Smalltalk.STBViewProxy) 8 ##(Smalltalk.ShellView) 98 27 0 0 98 2 27131905 131073 416 0 524550 ##(Smalltalk.ColorRef) 8 4278190080 0 551 0 0 0 416 788230 ##(Smalltalk.BorderLayout) 1 1 0 0 0 0 0 234 256 98 0 0 0 0 0 0 1 0 0 0 0 1 0 0 983302 ##(Smalltalk.MessageSequence) 202 208 98 2 721670 ##(Smalltalk.MessageSend) 8 #createAt:extent: 98 2 328198 ##(Smalltalk.Point) 3839 21 722 1681 1231 416 658 8 #updateMenuBar 576 416 983302 ##(Smalltalk.WINDOWPLACEMENT) 8 #[44 0 0 0 0 0 0 0 0 0 0 0 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 57 7 0 0 10 0 0 0 129 10 0 0 113 2 0 0] 98 1 410 8 ##(Smalltalk.ScrollingDecorator) 98 18 0 416 98 2 8 1143996416 131073 864 0 0 0 7 0 0 0 864 1573190 1 ##(Smalltalk.ScrollingDecoratorLayout) 16 234 256 576 0 722 1 1 16 722 17 17 594 202 208 98 1 658 688 98 2 722 1 1 722 1649 1155 864 802 8 #[44 0 0 0 0 0 0 0 1 0 0 0 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 0 0 0 0 0 0 0 0 56 3 0 0 65 2 0 0] 98 1 410 8 ##(Smalltalk.ContainerView) 98 15 0 864 98 2 8 1140850688 131073 1184 0 0 0 7 0 0 0 1184 0 234 256 576 0 594 202 208 98 1 658 688 98 2 722 1 1 722 3649 2555 1184 802 8 #[44 0 0 0 0 0 0 0 1 0 0 0 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 0 0 0 0 0 0 0 0 32 7 0 0 253 4 0 0] 98 0 722 193 193 0 27 1440 0 27 1440 0 27 )! !
!TestWinShell2 class categoriesFor: #defaultModel!public! !
!TestWinShell2 class categoriesFor: #resource_Default_view!public!resources-views! !

"Binary Globals"!

Andy Bower

unread,
May 15, 2012, 4:47:47 AM5/15/12
to
Pewing,

I took a look at your code and it is essentially working as far as it
goes. The issue is why the text view doesn't appear as a child of the
scrolling decorator.

The reason is because you haven't told it to and really there isn't an
easy way to do this. Why? I hear you ask.

Well, you are trying to dynamically create a presenter at runtime and
attach it to a particular view in the hierarchy. However, MVP is built
on the premise that really a presenter shouldn't know about the view
hierarchy it is attached to. This allows alternative views to be
substituted in future without breaking anything. Now I know we don't
always obey this rule and sometimes allow a presenter to talk to its
attached views but really this is frowned upon.

The result is that, if you create a presenter dynamically at runtime,
the only views that can really be guaranteed to be there are the ones
for the presenter itself and its parent presenter. For this reason the
new presenter (in this case your TextPresenter) must always be placed as
a child of the fixed parent (in this case your TestWinShell2). This is
why it doesn't appear inside the scrolling decorator.

So you have two choices:

1) Build your view statically (i.e. using the View Composer). Place the
TextView inside your ScrollingDecorator's container and create a
matching presenter inside TextWinShell2>>createComponents. This is the
normal way to create presenters and views.

2) If you really want to create your text view dynamically at runtime
then you need to have a subpresenter as a place holder for the container
inside your ScrollingDecorator. Then you can use #createIn:on: to create
your new presenter as a child of the placeholder.

Sounds a bit complicated but it's not really. I've modified your example
to demonstrate this. You can download the modified package here:

http://dl.dropbox.com/u/2242074/ObjectArts%20Downloads/TestWin2.pac

HTH

Best regards

Andy Bower

Pewing

unread,
May 16, 2012, 12:52:37 AM5/16/12
to
Hi Andy

Totally cool, thanks a lot I know it may seem trivial but every tidbit of information I gather on how to use Dolphin Smalltalk. The more confident I become on using it and shortening the learning curve. Secondly, is there or have you ever considered a web page where we can swap and exchange programs, I've written a couple of games already and would be pleased to share them with the community. One is a FireWorks program I thought might be good for when you release 6.2, also have a Planet program which is also fun. If you google Atari SpinWheel you can get an Idea of the kind of work I have done.

I've got about 50 more questions to ask, but right now I'm going to get that champagne out and enjoy.
Peter






On Tuesday, May 15, 2012 2:47:47 AM UTC-6, Andy Bower wrote:
> Pewing,
>
0 new messages