Re: NSBezierPath
Re: NSBezierPath
- Subject: Re: NSBezierPath
- From: Daniel Todd Currie <email@hidden>
- Date: Mon, 1 Dec 2003 21:07:17 -0800
Since my view does not resize, this is of little concern to me... are
there other reasons I might want to use drawRect:? It seems to me that
it is easier the way i have done it, not having to use a subclass and
having access to instance variables, etc.
I'm not sure what you mean by "redrawing the background". There do not
seem to be any methods dealing with backgrounds in NSView, and I have
never drawn a background, let alone redrawn one. Could you perhaps be
more specific regarding the actual methods that I might use to do as
you suggest? thanks much
On 2003 Dec 01, at 19:31, Public Look wrote:
Do all of your drawing in drawRect: There are lots of good reasons,
but chief among them is that it is the best way for automatic redraw
to happen (for example if the window is resized).
If you want to draw animation (changing graphics) you must erase
previous drawing. You can do this by redrawing the background. You
can draw the background in an image ond only redraw the image (or part
of the image) if you want.
On Dec 1, 2003, at 9:37 PM, Daniel Todd Currie wrote:
This all works fine now, but I'm unsure of how to remove the line.
Since the strokeLineFromPoint:toPoint: method is a class method which
returns void, I don't have an object that i can release. The only
thing resembling what I need would require setting up GStates, which
I assume is not what I want to do, as system performance is rather
critical in my app. In case it matters, I am not calling this method
from the gaugeView's drawRect method. Thanks for your help.
// D
On 2003 Dec 01, at 03:49, Louis C. Sacha wrote:
Hello...
I would add to the previous comments by James Chen about locking the
focus before drawing, that this depends on how your
drawNeedleForError: method is being called. If you only call this
method from inside GaugeView's drawRect: method, then the focus has
already been taken care of for you automatically. If you are calling
this method from outside the GaugeView's drawRect: method or any
other object is calling this method on your gaugeView instance, then
you definitely need to do as he said and lock/unlock focus properly.
Also, you might want to change the
gaugeRect = [gaugeView frame];
call to
gaugeRect = [gaugeView bounds];
A view's frame represents its position and size in it's superview, a
view's bounds represents the rect used internally for drawing its
content.
Anyway, the following code isn't working (at all). This is
currently just a test method that should simply draw a line from
the bottom left corner to the top right corner. gaugeView is
declared in my .h file and is linked to an NSQuickDrawView in IB.
I have verified that the output of the NSLog is appropriate. Any
help would be appreciated; TIA!
Finally, you might want to verify that you have added your gaugeView
to the NIB file correctly in Interface Builder. I may be
misunderstanding what you are trying to say above, but it doesn't
sound right to me. If your GaugeView class is a subclass of NSView,
then you need to drag an NSView to your window (it looks like a
shaded rectangle, which I believe says "Custom View" on it). Then
either drag the GaugeView.h file onto Interface Builder, or choose
the "Classes" tab in the shelf that displays the objects in the nib
file and then select "Read Files" from the "Classes" menu in the
main menubar and choose your GaugeView.h file. After that, click on
the custom View that you dragged to the window earlier and then
choose the "Custom Class" tab on the Inspector panel. Select
GaugeView in the list of classes displayed. You'll also need to make
whatever connections to the gaugeView from the objects that you need
to send commands from.
Hope that helps,
Louis
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.