List Info

Thread: Drawing with NSCell or NSView and reducing -drawRect: clutter?




Drawing with NSCell or NSView and reducing -drawRect: clutter?
country flaguser name
United Kingdom
2007-08-20 19:01:32
Hello,

(please see below for the reasoning behind these questions)

1) Can I tell an NSCell to draw paths?

2) Is it a good idea to reduce clutter in -drawRect: by
using simple  
helper objects to draw? I would find this aesthetically more
pleasing  
compared to just adding methods to the NSView subclass. As
for the  
former, I can have a one-to-one relationship between custom
drawing  
objects and model objects (see below for more details about
this).  
i.e. a model object is drawn using a corresponding drawing
object.

 From reading the docs it seems that NSCell is a way to do
simple  
drawing inside a parent NSView. However, it seems to centre
around  
drawing images and text.

What I'm actually doing is trying to draw the axis of a
graph. I have  
a simple model object that describes the axis (tic marks
along an  
axis) and just want a graphical representation of it, e.g. a
line  
with the tic marks at appropriate intervals. Have a look
here for the  
model class, http://w
ww.boyfarrell.com/code/chocplot/doc/

I was hoping to have a simple drawing class that I can
initialise  
with my axis model, such that it will draw in the
appropriate place  
on my NSView.

Cheers,

Dan.




_______________________________________________
Discuss-gnustep mailing list
Discuss-gnustepgnu.org
http://lists.gnu.org/mailman/listinfo/discuss-gnustep

Re: Drawing with NSCell or NSView and reducing -drawRect: clutter?
country flaguser name
Germany
2007-08-21 04:28:11
Daniel J Farrell wrote:
> Hello,
> 
> (please see below for the reasoning behind these
questions)
> 
> 1) Can I tell an NSCell to draw paths?
>
You don't need to tell the NSCell, just draw the path inside
its
drawInteriorWithFrame:inView: method. Here the view
(actually an
NSControl subclass) already has been set as the current
drawing target.

> 2) Is it a good idea to reduce clutter in -drawRect: by
using simple
> helper objects to draw? I would find this aesthetically
more pleasing
> compared to just adding methods to the NSView subclass.
As for the
> former, I can have a one-to-one relationship between
custom drawing
> objects and model objects (see below for more details
about this). i.e.
> a model object is drawn using a corresponding drawing
object.
> 
Nice, this surely works with GNUstep, but we don't have any
special
support for it.

> From reading the docs it seems that NSCell is a way to
do simple drawing
> inside a parent NSView. However, it seems to centre
around drawing
> images and text.
> 
If you don't use the border functionality and you don't need
multiple
drawing targets at once, then there isn't much difference
for you
between using an NSView or an NSCell.

> What I'm actually doing is trying to draw the axis of a
graph. I have a
> simple model object that describes the axis (tic marks
along an axis)
> and just want a graphical representation of it, e.g. a
line with the tic
> marks at appropriate intervals. Have a look here for
the model class,
> http://w
ww.boyfarrell.com/code/chocplot/doc/
> 
> I was hoping to have a simple drawing class that I can
initialise with
> my axis model, such that it will draw in the
appropriate place on my
> NSView.
> 
No, there isn't any class for this in GNUstep, the closest
we have got
is NSRulerView. Perhaps you could have a look there.

Fred


_______________________________________________
Discuss-gnustep mailing list
Discuss-gnustepgnu.org
http://lists.gnu.org/mailman/listinfo/discuss-gnustep

Re: Drawing with NSCell or NSView and reducing -drawRect: clutter?
country flaguser name
United Kingdom
2007-08-21 05:07:08
Hi,

Thanks for you the advice Fred and hns. It clear what I have
to do now.

Cheers,

Dan.

On 21 Aug 2007, at 10:28, Fred Kiefer wrote:

> Daniel J Farrell wrote:
>> Hello,
>>
>> (please see below for the reasoning behind these
questions)
>>
>> 1) Can I tell an NSCell to draw paths?
>>
> You don't need to tell the NSCell, just draw the path
inside its
> drawInteriorWithFrame:inView: method. Here the view
(actually an
> NSControl subclass) already has been set as the current
drawing  
> target.
>
>> 2) Is it a good idea to reduce clutter in
-drawRect: by using simple
>> helper objects to draw? I would find this
aesthetically more pleasing
>> compared to just adding methods to the NSView
subclass. As for the
>> former, I can have a one-to-one relationship
between custom drawing
>> objects and model objects (see below for more
details about this).  
>> i.e.
>> a model object is drawn using a corresponding
drawing object.
>>
> Nice, this surely works with GNUstep, but we don't have
any special
> support for it.
>
>> From reading the docs it seems that NSCell is a way
to do simple  
>> drawing
>> inside a parent NSView. However, it seems to centre
around drawing
>> images and text.
>>
> If you don't use the border functionality and you don't
need multiple
> drawing targets at once, then there isn't much
difference for you
> between using an NSView or an NSCell.
>
>> What I'm actually doing is trying to draw the axis
of a graph. I  
>> have a
>> simple model object that describes the axis (tic
marks along an axis)
>> and just want a graphical representation of it,
e.g. a line with  
>> the tic
>> marks at appropriate intervals. Have a look here
for the model class,
>> http://w
ww.boyfarrell.com/code/chocplot/doc/
>>
>> I was hoping to have a simple drawing class that I
can initialise  
>> with
>> my axis model, such that it will draw in the
appropriate place on my
>> NSView.
>>
> No, there isn't any class for this in GNUstep, the
closest we have got
> is NSRulerView. Perhaps you could have a look there.
>
> Fred



_______________________________________________
Discuss-gnustep mailing list
Discuss-gnustepgnu.org
http://lists.gnu.org/mailman/listinfo/discuss-gnustep

[1-3]

about | contact  Other archives ( Real Estate discussion Medical topics )