On Mon, Dec 8, 2008 at 12:57 AM, Chris Hiszpanski <[EMAIL PROTECTED]> wrote:

> I'm trying to write a very simple oscilloscope in Cocoa as a shell tool that
> continuously reads samples via standard input and draws them as a waveform
> in a window. I do _not_ want a menu bar (i.e. an application), just one
> window that disappears when the parent shell tool receives the interrupt
> signal.
...
> - How can I create a window without creating a full fledge application (i.e.
> without creating an instance of NSApplication)?

  So ... you want a GUI application without a GUI? That makes little sense.

> - What is the difference between a Cocoa Shell Tool and a Cocoa Application?
> Can a Cocoa Shell Tool draw GUI objects, or is it restricted to text in the
> shell?

  A "Cocoa Shell Tool" is usually linked only against the Foundation
framework (sans all the GUI goodness of AppKit, which means it's also
sans all the reasonably-convenient drawing and animation stuff). It
also has no link to the window server so it can't create or 'have'
windows.

> - How can I read standard input? With the NSFileHandle class? I see
> fileHandleWithStandardInput is a class method there, but not an instance
> method...

  Have you searched the archives? The documentation? This comes up
fairly often and is pretty well documented.

> - How can I draw an oscilloscope type "animation"? With the drawRect method
> of my own class that inherits from NSView? Or is there a more appropriate
> method?

  "How do I write a program?" -- your question is about this vague. If
you accept that in order to make use of NSView, windows, and the GUI
in general, you must create an actual application, then you should
start by reading all the documentation ("Cocoa Drawing Guide" and
"View Programming Guide" are good places to start), then ask more
specific questions.

  To answer your -drawRect:/NSView subclass method: "It depends." If
you desire kick-ass graphics (really nice animations and effects) you
probably want to look into layer-backed views. If you just want a
basic plot that changes in realtime (ie, not necessarily an
"animation" but just a continuously-updating plot), then you can
probably get away with just using a view subclass and handling the
drawing in -drawRect:, updating only when new data comes in (or
regularly updating at an interval, fired by a timer).

--
I.S.
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to