Difference between reference view and a copy

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|

Difference between reference view and a copy

Yar Hwee Boon-3
Hi

Was wondering what is the difference between a reference view and a copy  
(normal?) view. Why is it that when I create a copy of TextPresenter it  
works as expected using the fairly simple code below, whereas a reference  
view will not? Same goes for a presenter subclass made of container views  
and other presenters. When do I use a reference and when a copy? Thanks.

SomeShell>>model: aModel
...
test2Presenter model: (['abcdef'] aspectValue: #value).
...

SomeShell>>createComponents
...
test2Presenter := self add: TextPresenter new name: 'test2'.

...


--
Regards
Hwee Boon
MotionObj


Reply | Threaded
Open this post in threaded view
|

Re: Difference between reference view and a copy

Schwab,Wilhelm K
> Was wondering what is the difference between a reference view and a
> copy  (normal?) view.

Pasting a reference view is equivalent to asking that, each time your
view is opened, it will load the latest copy of the referenced resource.
  If you want to get the benefit of changes to component views without
needing to edit your view, then a reference view is a good choice.  In
contrast, if you want current settings to apply regardless of what
cosmetic changes might appear in the next patch level, then you would
paste a copy.

Your example of sending #aspectValue: to a block is a little unusual.
When it fails, is it because of sending #value: (trying to set the
value)?  Unless I am missing something, consider that your problem might
be a result of your example, and not a failing of reference views in
general.

If you continue to have trouble, you can define #selfOrReferee in View
(answer self) and ReferenceView (answer self referee).  I have these
methods lurking in my image, but they are no widely used, and it is even
possible that I no longer need them.  Both Dolphin and my code have
improved since I first added them.  My advice is to try to solve your
problem w/o #selfOrReferee.

Does that help?

Have a good one,

Bill

--
Wilhelm K. Schwab, Ph.D.
[hidden email]


Reply | Threaded
Open this post in threaded view
|

Re: Difference between reference view and a copy

Schwab,Wilhelm K
In reply to this post by Yar Hwee Boon-3
> SomeShell>>model: aModel
> ...
> test2Presenter model: (['abcdef'] aspectValue: #value).

Another thought: try

    test2Presenter model:'abcdef' asValue.

Have a good one,

Bill


--
Wilhelm K. Schwab, Ph.D.
[hidden email]


Reply | Threaded
Open this post in threaded view
|

Re: Difference between reference view and a copy

Yar Hwee Boon-3
In reply to this post by Schwab,Wilhelm K
On Wed, 30 Jun 2004 15:28:28 -0500, Bill Schwab <[hidden email]>  
wrote:

> Your example of sending #aspectValue: to a block is a little unusual.  
> When it fails, is it because of sending #value: (trying to set the  
> value)?  Unless I am missing something, consider that your problem might  
> be a result of your example, and not a failing of reference views in  
> general.

Ah.. I supposed my example was abit weird, anyway my point of using

test2Presenter model: (['abcdef'] aspectValue: #value)

is that it should (i think) display the text 'abcdef' by letting  
#getContentsBlock send #value to that block (I just wanted to simulate a  
model of my own while keeping the example simple, guess it backfired :)).  
Indeed #value: will not work, but that doesn't matter, because I was just  
checking if 'abcdef' would appear. I have tried your suggestion in the  
other post for using

test2Presenter model:'abcdef' asValue.

doesn't work too.

>
> If you continue to have trouble, you can define #selfOrReferee in View  
> (answer self) and ReferenceView (answer self referee).

I tried defining the 2 #selfOrReferee methods, don't seem to work either.

> My advice is to try to solve your problem w/o #selfOrReferee.

Agreed. There seems to be some subtle difference that I'm not  
understanding about reference views (or I just completely missed the  
point..)

> Does that help?

Not so far.. but thanks for the suggestions.


--
Regards
Hwee Boon
MotionObj


Reply | Threaded
Open this post in threaded view
|

Re: Difference between reference view and a copy

Yar Hwee Boon-3
On Thu, 01 Jul 2004 10:57:13 +0800, Yar Hwee Boon <[hidden email]>  
wrote:

> test2Presenter model:'abcdef' asValue.

After some further testing, I realised that this doesn't work when I am  
using a reference view PLUS the shell is created as a popup using a method  
I defined as:

        toolShell := MyShellUsingReferenceView showAsPopupFor: someOtherShell.

Shell class>>showAsPopupFor: parentShell
        | shell |
        shell := self create.
        shell view bePopupFor: parentShell view.
        shell showShell.
        ^shell.

However, the reference view works properly if I do the following instead:

        toolShell := MyShellUsingReferenceView show.
        toolShell view bePopupFor: self view.


Is #showAsPopupFor implemented incorrectly? The second way works, but I  
think there is some flickering due to the child window/view(?) being  
destroyed and recreated.

--
Regards
Hwee Boon
MotionObj


Reply | Threaded
Open this post in threaded view
|

Re: Difference between reference view and a copy

Yar Hwee Boon-3
On Mon, 05 Jul 2004 12:38:06 +0800, Yar Hwee Boon <[hidden email]>  
wrote:

> toolShell := MyShellUsingReferenceView showAsPopupFor: someOtherShell.
>
> Shell class>>showAsPopupFor: parentShell
> | shell |
> shell := self create.
> shell view bePopupFor: parentShell view.
> shell showShell.
> ^shell.
>
> However, the reference view works properly if I do the following instead:
>
> toolShell := MyShellUsingReferenceView show.
> toolShell view bePopupFor: self view.

Let me correct myself, the reference view does not work in both of the  
cases above. As long as I replace a copy of the view with a reference view  
PLUS I make the the shell be created as a popup of another, the reference  
view does not work, anyone has any idea why?

--
Regards
Hwee Boon
MotionObj


Reply | Threaded
Open this post in threaded view
|

Re: Difference between reference view and a copy

Pieter Emmelot-2
Yar Hwee Boon wrote:

> On Mon, 05 Jul 2004 12:38:06 +0800, Yar Hwee Boon <[hidden email]>  
> wrote:
>
>>     toolShell := MyShellUsingReferenceView showAsPopupFor:
>> someOtherShell.
>>
>> Shell class>>showAsPopupFor: parentShell
>>     | shell |
>>     shell := self create.
>>     shell view bePopupFor: parentShell view.
>>     shell showShell.
>>     ^shell.
>>
>> However, the reference view works properly if I do the following instead:
>>
>>     toolShell := MyShellUsingReferenceView show.
>>     toolShell view bePopupFor: self view.
>
>
> Let me correct myself, the reference view does not work in both of the  
> cases above. As long as I replace a copy of the view with a reference
> view  PLUS I make the the shell be created as a popup of another, the
> reference  view does not work, anyone has any idea why?

I use the code below (modeled after ResourceBrowser
class>>showAsToolboxFor:at:) to open small windows aligned to buttons in
a parent view.
Maybe it helps.
Good luck, Pieter


Presenter class>>popupFor: parentView
        "Creates an instance of the receiver attached to parentView. Do not
show the view yet."

        | popupView presenter |
        popupView := (self loadViewResource: 'Default view' inContext: View
desktop) bePopupFor: parentView.
        popupView font: parentView actualFont. "this is a hack, for some reason
the default font isn't found and we have to set it explicitly"
        presenter := self new.
        presenter view: popupView.
        presenter onViewOpened.
        ^presenter


Reply | Threaded
Open this post in threaded view
|

Re: Difference between reference view and a copy

Yar Hwee Boon-3
On Mon, 05 Jul 2004 10:09:33 +0200, Pieter Emmelot  
<[hidden email]> wrote:

> I use the code below (modeled after ResourceBrowser  
> class>>showAsToolboxFor:at:) to open small windows aligned to buttons in  
> a parent view.
> Maybe it helps.
> Good luck, Pieter

Thanks, it works! Regarding your comment about the hack to "inherit" the  
font, its working without that hack on my 5.1.4 image though.

--
Regards
Hwee Boon
MotionObj


Reply | Threaded
Open this post in threaded view
|

Re: Difference between reference view and a copy

Pieter Emmelot-2
Yar Hwee Boon wrote:

> On Mon, 05 Jul 2004 10:09:33 +0200, Pieter Emmelot  
> <[hidden email]> wrote:
>
>> I use the code below (modeled after ResourceBrowser  
>> class>>showAsToolboxFor:at:) to open small windows aligned to buttons
>> in  a parent view.
>> Maybe it helps.
>> Good luck, Pieter
>
>
> Thanks, it works! Regarding your comment about the hack to "inherit"
> the  font, its working without that hack on my 5.1.4 image though.
>
Hmm, maybe you've set the font of the presenter you're popping-up in the
ViewComposer?
If I leave font=nil (meaning: use font of parent view) and comment the
hack out I get a windows 3.0 style font in the popup...


Reply | Threaded
Open this post in threaded view
|

Re: Difference between reference view and a copy

Yar Hwee Boon-3
On Tue, 06 Jul 2004 11:08:25 +0200, Pieter Emmelot  
<[hidden email]> wrote:

> Yar Hwee Boon wrote:
>>   Thanks, it works! Regarding your comment about the hack to "inherit"  
>> the  font, its working without that hack on my 5.1.4 image though.
>>
> Hmm, maybe you've set the font of the presenter you're popping-up in the  
> ViewComposer?
> If I leave font=nil (meaning: use font of parent view) and comment the  
> hack out I get a windows 3.0 style font in the popup...

Nope, I left both the fonts for the parent Shell and child Shell at the  
default nil. And if i set the parent Shell font to Times New Roman pt12  
bold italics, leaving the child Shell as nil, upon popup I do see Times  
New Roman in my child shell without the hack in place. Inspecting  
(childShell popupView font) does give a nil. Btw, I'm using XP Pro with  
themes off. Any difference in platform?

--
Regards
Hwee Boon
MotionObj


Reply | Threaded
Open this post in threaded view
|

Re: Difference between reference view and a copy

Pieter Emmelot-2
Yar Hwee Boon wrote:

> On Tue, 06 Jul 2004 11:08:25 +0200, Pieter Emmelot  
> <[hidden email]> wrote:
>
>> Yar Hwee Boon wrote:
>>
>>>   Thanks, it works! Regarding your comment about the hack to
>>> "inherit"  the  font, its working without that hack on my 5.1.4 image
>>> though.
>>>
>> Hmm, maybe you've set the font of the presenter you're popping-up in
>> the  ViewComposer?
>> If I leave font=nil (meaning: use font of parent view) and comment
>> the  hack out I get a windows 3.0 style font in the popup...
>
>
> Nope, I left both the fonts for the parent Shell and child Shell at the  
> default nil. And if i set the parent Shell font to Times New Roman pt12  
> bold italics, leaving the child Shell as nil, upon popup I do see Times  
> New Roman in my child shell without the hack in place. Inspecting  
> (childShell popupView font) does give a nil. Btw, I'm using XP Pro with  
> themes off. Any difference in platform?
>
Yep, I'm using Win2k.
I'll add your observations in the comment and leave it for that rainy day...
Thanks for the feedback.
  - Pieter