ListView, registering view resources

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

ListView, registering view resources

Hasko Heinecke
When I execute the following code in 4.01, I get a notifier because a
commctrl message failed:

    ListPresenter addView: ListView asResource: 'test'

As a result, the view resource is sort of added to the ResourceManager, but
it doesn't really work.

Actually, I'm creating a subclass of ListView that allows editing any list
cell in report mode, not just the first one. However, the error doesn't seem
to be in my code as it also happens with ListView itself.

Hasko


Reply | Threaded
Open this post in threaded view
|

Re: ListView, registering view resources

Bill Schwab
Hasko,

> When I execute the following code in 4.01, I get a notifier because a
> commctrl message failed:
>
>     ListPresenter addView: ListView asResource: 'test'
>
> As a result, the view resource is sort of added to the ResourceManager,
but
> it doesn't really work.
>
> Actually, I'm creating a subclass of ListView that allows editing any list
> cell in report mode, not just the first one. However, the error doesn't
seem
> to be in my code as it also happens with ListView itself.

ListPresenter probably is the presenter class you want to use, but, try
specifying your new subclass rather than ListView.  No promises though :)

Have a good one,

Bill

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


Reply | Threaded
Open this post in threaded view
|

Re: ListView, registering view resources

Hasko Heinecke
Bill Schwab <[hidden email]> wrote in response to my question:
> > When I execute the following code in 4.01, I get a notifier because a
> > commctrl message failed:
> >
> >     ListPresenter addView: ListView asResource: 'test'
[...]
> > Actually, I'm creating a subclass of ListView that allows editing any
list
> > cell in report mode, not just the first one. However, the error doesn't
> seem
> > to be in my code as it also happens with ListView itself.
>
> ListPresenter probably is the presenter class you want to use, but, try
> specifying your new subclass rather than ListView.  No promises though :)

I'm not sure I understand. Do you mean I should write

    ListPresenter addView: MyListView asResource: 'test'

I did that, and got the error I described. I just noticed that the same
error happens with the original ListView class, so the error is not in my
code. However, I already wrote this in my previous post, so maybe I
misunderstood your point.

By the way, there is no new subclass of ListPresenter - all the logic is
handled in the new ListView subclass. It's all passing Windows messages to
and fro...

Hasko


Reply | Threaded
Open this post in threaded view
|

Re: ListView, registering view resources

Ian Bartholomew
Hasko,

> I did that, and got the error I described. I just noticed that the same
> error happens with the original ListView class, so the error is not in my
> code. However, I already wrote this in my previous post, so maybe I
> misunderstood your point.

This has been reported in the newsgroup before (Christopher Demers on 24
July 2000 at 23:40) but appears to have slipped through the OA bug fix list.

A temporary fix is just to comment out the code in ListView>>state (between
the last comment and the return statement) while you create the resource. I
think it's just caused by the API method needing the ListView to be created
"properly", as part of an open view, rather than just for the
ResourceManager.  Commenting out this short section will not affect anything
as it is only used to remember when the ListViewColumns are rearranged by
dragging the headers - something that won't have happened while the
ViewResource is being created.

Hopefully OA will address it is the next patch?

Ian


Reply | Threaded
Open this post in threaded view
|

Re: ListView, registering view resources

Andy Bower
Folks,

> > I did that, and got the error I described. I just noticed that the same
> > error happens with the original ListView class, so the error is not in
my
> > code. However, I already wrote this in my previous post, so maybe I
> > misunderstood your point.
>
> This has been reported in the newsgroup before (Christopher Demers on 24
> July 2000 at 23:40) but appears to have slipped through the OA bug fix
list.
>
> A temporary fix is just to comment out the code in ListView>>state
(between
> the last comment and the return statement) while you create the resource.
I
> think it's just caused by the API method needing the ListView to be
created
> "properly", as part of an open view, rather than just for the
> ResourceManager.  Commenting out this short section will not affect
anything
> as it is only used to remember when the ListViewColumns are rearranged by
> dragging the headers - something that won't have happened while the
> ViewResource is being created.
>
> Hopefully OA will address it is the next patch?

I think the correct fix is to the View>>makeResource:inClass: method as
follows. The problem appears to be caused by the fact that a ListView
control does not behave correctly when it is made a child of the desktop.
The solution chosen is to create a temporary shell view to act as the parent
for all view being instantiated to add to the resource manager. This is now
recorded as defect #186 and the fix should appear in 4.01.2. In the meantime
can you verify that the following does address the problem for you:

View>>makeResource: aStringName inClass: aClass
    "Private - Save and instance of the receiver as a default writable
ViewResource
    called aString owned by aClass."

    | resID view shell |
    shell := ShellView new create.
    view := shell addSubView: self new.
    (resID := ResourceIdentifier class: aClass name: aStringName)
        assign: (ViewResource defaultWritable);
        save: view.
    shell destroy.
    ^resID

Best Regards,

Andy Bower
Dolphin Support
http://www.object-arts.com

---
Visit the Dolphin Smalltalk WikiWeb
http://www.object-arts.com/wiki/html/Dolphin/FrontPage.htm
---


Reply | Threaded
Open this post in threaded view
|

Re: ListView, registering view resources

Christopher J. Demers
In reply to this post by Hasko Heinecke
Hasko Heinecke <[hidden email]> wrote in message
news:3ae2be55$[hidden email]...
>
> Actually, I'm creating a subclass of ListView that allows editing any list
> cell in report mode, not just the first one. However, the error doesn't
seem
> to be in my code as it also happens with ListView itself.
>

I was trying to do something similar some time ago.  I decided not to
subclass the view after all, but rather to subclass ListPresenter.  I would
then dynamically create or move a textbox to the new text entry position.  I
did some experiments with this approach and decided I was not really happy
with it.

I decided that I wanted more control over the whole thing, so I created an
emulated ListEditView.  I create a column of StaticText views and a column
of TextEdit views inside a ScrollDecorator.  This seems to work fairly well
for what I need.

If you want to see my code I have my new ListEditView here:
http://www.mitchellscientific.com/smalltalk/ and I even out up my old
ListPresenter subclass based code here:
http://www.mitchellscientific.com/smalltalk/ListEditPresenterOLD.cls .
Please note that the old code may look pretty bad, it was very experimental
stuff, and I never refined it.

Hopefully some of this code is of use to you.  I would also be interested in
knowing how you end up approaching a listEdit control.

Chris


Reply | Threaded
Open this post in threaded view
|

Re: ListView, registering view resources

Hasko Heinecke
In reply to this post by Andy Bower
Andy Bower <[hidden email]> wrote:
> I think the correct fix is to the View>>makeResource:inClass: method as
> follows.
[...]
> This is now
> recorded as defect #186 and the fix should appear in 4.01.2. In the
meantime
> can you verify that the following does address the problem for you:

> View>>makeResource: aStringName inClass: aClass
>     "Private - Save and instance of the receiver as a default writable
> ViewResource
>     called aString owned by aClass."
>
>     | resID view shell |
>     shell := ShellView new create.
>     view := shell addSubView: self new.
>     (resID := ResourceIdentifier class: aClass name: aStringName)
>         assign: (ViewResource defaultWritable);
>         save: view.
>     shell destroy.
>     ^resID

Yes, with that fix adding a ListView resources works perfectly. Thanks a
lot!

BTW, there's a related bug in ListView that I reported to you erlier this
week: In ListView>>publishedAspectsOfInstances the class ListViewColumn is
directly referenced by name in an aspect string. This should really use the
class returned by #columnClass to allow subclassing of ListViewColumn. As a
result, #columnClass must become a class method. Will that be fixed in
4.01.2 as well?

Thanks again and have a nice day. (It's 6 a.m. here now...)

Hasko


Reply | Threaded
Open this post in threaded view
|

Re: ListView, registering view resources

Andy Bower
Hasko,

> BTW, there's a related bug in ListView that I reported to you erlier this
> week: In ListView>>publishedAspectsOfInstances the class ListViewColumn is
> directly referenced by name in an aspect string. This should really use
the
> class returned by #columnClass to allow subclassing of ListViewColumn. As
a
> result, #columnClass must become a class method. Will that be fixed in
> 4.01.2 as well?

This has now been entered as an enhancement #190 and will be fixed for
4.01.2.

Best Regards,

Andy Bower
Dolphin Support
http://www.object-arts.com

---
Visit the Dolphin Smalltalk WikiWeb
http://www.object-arts.com/wiki/html/Dolphin/FrontPage.htm
---


Reply | Threaded
Open this post in threaded view
|

Re: ListView, registering view resources

Andy Bower
Hask,

> > BTW, there's a related bug in ListView that I reported to you erlier
this
> > week: In ListView>>publishedAspectsOfInstances the class ListViewColumn
is
> > directly referenced by name in an aspect string. This should really use
> the
> > class returned by #columnClass to allow subclassing of ListViewColumn.
As
> a
> > result, #columnClass must become a class method. Will that be fixed in
> > 4.01.2 as well?
>
> This has now been entered as an enhancement #190 and will be fixed for
> 4.01.2.

The fix I've chosen for this is to add the published aspect for the column
selection to an instance side #publishedAspects method (rather than by
creating a class side #columnClass method). The reason for this is to ensure
that if the instance side #columnClass method was ever overidden by a
subclass then the publish aspects would still be correct. The attached ST
file demonstrates the patch; let me know if this addresses your problem.

Best Regards,

Andy Bower
Dolphin Support
http://www.object-arts.com

---
Visit the Dolphin Smalltalk WikiWeb
http://www.object-arts.com/wiki/html/Dolphin/FrontPage.htm
---
























begin 666 ListView column class patch.st
M#0HA3&ES=%9I97<@;65T:&]D<T9O<B$-"@T*<'5B;&ES:&5D07-P96-T<PT*
M"2)!;G-W97(@82 \4V5T/B!O9B!T:&4@87-P96-T<R!P=6)L:7-H960@8GD@
M=&AI<R!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