discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


From: Daniel J Farrell
Subject: Re: Drawing with NSCell or NSView and reducing -drawRect: clutter?
Date: Tue, 21 Aug 2007 11:07:08 +0100

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://www.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





reply via email to

[Prev in Thread] Current Thread [Next in Thread]