Thread View: comp.sys.next.programmer
3 messages
3 total messages
Started by John W. Wooten
Thu, 13 Aug 1992 20:45
lots of objects to display
Author: John W. Wooten
Date: Thu, 13 Aug 1992 20:45
Date: Thu, 13 Aug 1992 20:45
20 lines
1068 bytes
1068 bytes
I have an app in which I have a lot of elements, which may have many different geometrical shapes, but are subclassed from a general element object which is a subclass of View. As I build them, they are stored in a list. I want them to be drawn in a View (myView) in myWindow. Each element subclass has a drawSelf method and each instance has it, of course. When my controller does a [myView display], the background appears, but does each element have to be individually sent a [myElement drawSelf]? It then seems that they each have to be a subView of the original View. Somehow it should be simpler than this, so I think I'm missing something. -- ----------------- J. W. Wooten
Re: lots of objects to display
Author: Robert D. Nicholson
Date: Fri, 14 Aug 1992 07:02
Date: Fri, 14 Aug 1992 07:02
54 lines
2300 bytes
2300 bytes
woo@ornl.gov(John W. Wooten) writes:
>I have an app in which I have a lot of elements, which may have
>many different geometrical shapes, but are subclassed from a general
>element object which is a subclass of View. As I build them, they are
>stored in a list.
>I want them to be drawn in a View (myView) in myWindow. Each element
>subclass has a drawSelf method and each instance has it, of course.
>When my controller does a [myView display], the background appears, but
>does each element have to be individually sent a [myElement drawSelf]?
>It then seems that they each have to be a subView of the original View.
>Somehow it should be simpler than this, so I think I'm missing
>something.
>--
>-----------------
>J. W. Wooten
Well, {myView display] will only send display to myView and myView's subviews
which have been set up via view's addSubview. Thus you should create a
allGraphicsPerform method and have it send a display to each element in the list.
Actually you can pass the method you wish to have executed as a parameter and
thus generalise even further.
Check out Summer NeXTWORLD , 1992 in Charles L. Perkins Article on Composition
makeSquaresPerform:
The code looks like
- makeSquaresPerform:(SEL) aMessage {
return [[self viewList] makeObjectsPerform:aMessage];
}
If you wish to set up something that uses parameter passing. then you
could try this.
- makeSquaresPerform:(SEL) aMessage with: anObject {
return [[self viewList] makeObjectsPerform:aMessage with: anObject];
}
Basically its makes use of behaviour already in List.
replace [self viewList] with your list's reference or method
to retrieve its reference.
Hope this helps.
This code assumes that all your objects will perform "aMessage" perhaps
it might be worthwhile to check using Object's respondsTo: first.
Re: lots of objects to display
Author: Subrata Sircar
Date: Fri, 14 Aug 1992 22:01
Date: Fri, 14 Aug 1992 22:01
20 lines
1510 bytes
1510 bytes
ede978e@monu6.cc.monash.edu.au (Robert D. Nicholson) writes: >woo@ornl.gov(John W. Wooten) writes: >>I want them [list of varying elements] to be drawn in a View (myView) in >>myWindow. Each element subclass has a drawSelf method and each instance >>has it, of course. [Robert Nicholson's suggestion deleted, because it is essentially the same as my own] Or you could do it the way draw does it; when the myView is called on to draw itself, it sends the draw method to the entire list. Check out GraphicView, in the Draw example source code. All the elements are subclasses of Graphic. -- Subrata Sircar | ssircar@canon.com | Prophet & SPAMIT Charter Member Canon Information Systems and I do not speak for each other on all things. "I wish people wouldn't instantly assume that I am an idiot." (Valentine) "A restaurant is a whorehouse that does food instead of sex." (Roger Lustig)
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads