Re: Graphics seen when volume is modified.

2008-05-03 Thread Jean-Daniel Dupas
And after that, you can either uses NSImage but it's not really nice,  
or create a NSView subclass to do your drawing.


I had to do this myself and want to share some knowledge.

Actually, the notification windows is 161 points wide, and 156 points  
high (with 1 point = 1 pixel when use scale factor = 1) without shadow.
This is a rounded rect with a radius of 25 pixels, filled using a  
black color with alpha set to 0.15.

And the window frame origin is center for x, and 140 points for y.

[[NSColor colorWithCalibratedWhite:0 alpha:0.15] setFill];
[[NSBezierPath bezierPathWithRoundedRect:NSMakeRect(0, 0, 161, 156)   
xRadius:25 yRadius:25] fill];


Le 3 mai 08 à 04:19, Jamie Phelps a écrit :

You might also check out the RoundedFloatingPanel code from Matt  
Gemmell: http://mattgemmell.com/source about 60% of the way down.


JP

On May 2, 2008, at 3:38 AM, John Clayton wrote:


Hi All,

Does anyone know of some code that mimics the graphics that are  
displayed by Apple when one modifies the system volume?   
Specifically the grey box + white shadowed text that pops up  
briefly.  I want to do something similar in my app, so any kind of  
guiding code would be useful.


Any info about the box or code that emulates this would be useful,

Thanks!

--
John Clayton
http://www.coderage-software.com/



___

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/jrphelps%40mac.com

This email sent to [EMAIL PROTECTED]


___

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/devlists%40shadowlab.org

This email sent to [EMAIL PROTECTED]



___

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]


Re: Saving/restoring PDFAnnotationTextWidget stringValues with PDFKit 10.5

2008-05-03 Thread Antonio Nunes

On May 3, 2008, at 6:54 AM, Joel Norvell wrote:


If you use PDFKit 10.5 to save and then restore a pdf file, are
PDFAnnotationTextWidget stringValues preserved?  (These are the text  
fields

that you enter in PDF forms.)


They are not preserved. If you are saving data into your own file  
format you can can query the widgets at saving time and write them out  
explicitly. Then restore them when the file is read back in, after the  
PDF pages have been restored.


António

-
Accepting others as they are
brings a wonderful freedom
to your own mind.

--The Peace Formula
-




___

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]


scriptability of button in interface?

2008-05-03 Thread Patrick J. Collins
Hi everyone,

I was just curious--  Does anyone know off the top of their head how one makes
a button's action in an xcode project accessible via applescript?

In otherwords, say your main window has a button named "start".

How do you make it so that an end user could write their own applescript and do
something like:

"Tell application 'patrick's app' to start"

?

I am assuming there is something in interface builder that you need to do to
accomplish this, but I just don't know what it is.

Thank you!

Patrick J. Collins
http://collinatorstudios.com

___

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]


NSImageView blocking drag

2008-05-03 Thread Gordon Apple
I have a custom view that contains a (covering) NSImageView.  The latter
is disabled.  I want the custom view to handle all drag operations.  This
works fine as long as I don't drag in a type (e.g., NSFilenamesPboardType)
that NSImageView directly supports.  setAllowsCutCopyPaste:NO for the
NSImageView does not help.  The drop never gets to the custom view (yes, it
registers the types) but is simply rejected by the disabled NSImageView.  My
custom view's dragOperationForDraggingInfo never gets called in such case.
If I squeeze down the NSImageView and drag directly to the exposed custom
view, it works fine.

Shouldn't disabling the NSImageView make it effectively invisible for
all such operations?  Bug report time?

___

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]


Re: Loading a .nib?

2008-05-03 Thread Uli Kusterer

Am 03.05.2008 um 03:19 schrieb Graham Cox:
One thing to clarify about Carbon vs. Cocoa - while Cocoa itself is  
unavailable, you can of course use Core Foundation. However  
everything in Carbon is lower level and generally more work than  
Cocoa, so be prepared ;-)



 Cocoa unavailable? What? You can mix-and-match Carbon and Cocoa in  
the same application. Call NSApplicationLoad(), catch Cocoa exceptions  
so they don't get thrown into Carbon code and vice versa (if you're  
using longjmp or throwing C++ exceptions), and you can essentially  
have Cocoa and Carbon windows in the same app.


Cheers,
-- Uli Kusterer
"The Witnesses of TeachText are everywhere..."
http://www.zathras.de





___

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]


Re: Loading a .nib?

2008-05-03 Thread Uli Kusterer

Am 03.05.2008 um 05:58 schrieb Michael Ash:

ObjC gets set up simply by linking to it, so that happens without any
intervention. Foundation can be used with no additional setup as well.
AppKit requires that you initialize it by calling NSApplicationLoad()
before using it for anything else. Fortunately the call can be made
multiple times without harm, so you don't have to worry about anyone
else doing it too.



 One more thing to note: If you want to use NSImage, make sure you've  
created a Cocoa window once. [[[NSWindow alloc] init...] release] is  
enough. That's probably fixed in Leopard, but I haven't checked yet...


Cheers,
-- Uli Kusterer
"The Witnesses of TeachText are everywhere..."
http://www.zathras.de





___

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]


Re: scriptability of button in interface?

2008-05-03 Thread Uli Kusterer

Am 03.05.2008 um 12:09 schrieb Patrick J. Collins:
I am assuming there is something in interface builder that you need  
to do to

accomplish this, but I just don't know what it is.



 No, not in IB. AppleScript in general doesn't script the UI, but  
rather what is the controller layer in a Cocoa app. So, what you need  
to do is create a scripting definition (.sdef and stuff like that)  
that maps AppleScript command names to methods on your controller  
object. http://developer.apple.com has some nice documentation on  
making Cocoa applications scriptable this way, using NSScriptCommand  
where you need to add your own commands that don't have objects  
associated with them.


Cheers,
-- Uli Kusterer
"The Witnesses of TeachText are everywhere..."
http://www.zathras.de





___

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]


Re: drawing in a separate thread

2008-05-03 Thread Duncan


On May 3, 2008, at 5:00 AM, Graham Cox <[EMAIL PROTECTED]> wrote:

One thing I realised after the previous posting is that the  
performance hit I'm seeing is because unlike the usual drawRect:  
case, I wasn't doing any clipping to the update area, so the entire  
view was getting repainted rather than just some small part of it -  
adding a clipRect: call substantially improved things.


However it also made me realise that just doing the drawing on a  
second thread is not enough - my graphics code makes quite a bit of  
use of the view's -needsToDrawRect: method, which of course when  
it's called by the thread is just not going to be valid, as  
drawRect: has been and gone. I'm not sure how to tackle this - it  
would seem I'd have to cache the result of - 
getRectsBeingDrawn:count: each time I queue a draw from the main  
thread and somehow make these rects available to clients of the view  
when they are drawn from the second thread (by overriding  
needsToDrawRect: for example). This seems complicated and somewhat  
hackish - or I redesign the drawing code to have these rects passed  
down as a parameter for every draw, which is equally awkward.


If you're going to do your drawing in a separate thread, you'll need  
to remember WHAT to draw. I wouldn't call it "hackish", I'd call it  
the cost of doing business that way.


If you implement a job queue, add the list of dirty rectangles to each  
job object. -drawRect would be where you'd add your jobs to the queue.  
It cold call getRectsBeingDrawn:count to get the list of dirty rects,  
then add that list to the job object. Then when the worker thread  
picks up a job, it would get the list of dirty rectangles from the job  
object instead of calling getRectsBeingDrawn:count. That should be  
pretty straightforward.


One thing you may face with rendering in a separate thread: At some  
point, you may need to wait for rendering to complete before your app  
can go on to it's next task. Say, for example, you need to show the  
user the results of their changes, then ask them what to do next. In  
that case, you'd need a way to wait until drawing completes. You could  
add something like a flushRendering call (much like glFlush in OpenGL)  
that wold block until all the rendering jobs were completely, or  
waitUntilJobComplete, which could wait until a specific rendering job  
was complete





I'm not yet convinced that drawing on a second thread will really  
give any benefit, so I'm reluctant to change things dramatically to  
allow it when I may end up abandoning the whole idea.


Be useful to hear from anyone who's done something like this to a)  
convince me it's worth it and b) hear about any solutions to the  
update rects issue.



Using a separate thread for time-consuming drawing does make the user  
experience much better. My app does OpenGL rendering of large, complex  
3D fractals, and I ended up pulling out the drawing code into a  
separate thread. That's even hairier than what you're trying to do,  
because I use NSOpenGLViews, and they are not particularly well set up  
for multi-threaded use.


What I do is to display a progress bar at the bottom of my 3D view  
window. As rendering progresses, I update the progress bar. I return  
control to the user immediately, so I avoid the spinning wait cursor.  
If the user then does something that invalidates the current rendering  
task, I set a "terminate rendering" flag and wait for the rendering  
thread to stop, then submit a new rendering job.



Duncan C
___

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]


Re: drawing in a separate thread

2008-05-03 Thread Jean-Daniel Dupas


Le 3 mai 08 à 13:36, Duncan a écrit :



On May 3, 2008, at 5:00 AM, Graham Cox <[EMAIL PROTECTED]> wrote:

One thing I realised after the previous posting is that the  
performance hit I'm seeing is because unlike the usual drawRect:  
case, I wasn't doing any clipping to the update area, so the entire  
view was getting repainted rather than just some small part of it -  
adding a clipRect: call substantially improved things.


However it also made me realise that just doing the drawing on a  
second thread is not enough - my graphics code makes quite a bit of  
use of the view's -needsToDrawRect: method, which of course when  
it's called by the thread is just not going to be valid, as  
drawRect: has been and gone. I'm not sure how to tackle this - it  
would seem I'd have to cache the result of - 
getRectsBeingDrawn:count: each time I queue a draw from the main  
thread and somehow make these rects available to clients of the  
view when they are drawn from the second thread (by overriding  
needsToDrawRect: for example). This seems complicated and somewhat  
hackish - or I redesign the drawing code to have these rects passed  
down as a parameter for every draw, which is equally awkward.


If you're going to do your drawing in a separate thread, you'll need  
to remember WHAT to draw. I wouldn't call it "hackish", I'd call it  
the cost of doing business that way.


If you implement a job queue, add the list of dirty rectangles to  
each job object. -drawRect would be where you'd add your jobs to the  
queue. It cold call getRectsBeingDrawn:count to get the list of  
dirty rects, then add that list to the job object. Then when the  
worker thread picks up a job, it would get the list of dirty  
rectangles from the job object instead of calling  
getRectsBeingDrawn:count. That should be pretty straightforward.


One thing you may face with rendering in a separate thread: At some  
point, you may need to wait for rendering to complete before your  
app can go on to it's next task. Say, for example, you need to show  
the user the results of their changes, then ask them what to do  
next. In that case, you'd need a way to wait until drawing  
completes. You could add something like a flushRendering call (much  
like glFlush in OpenGL) that wold block until all the rendering jobs  
were completely, or waitUntilJobComplete, which could wait until a  
specific rendering job was complet


In fact, glFlush() is asynchonous and do not block until the end of  
the rendering. glFlush() only pushs the command on the renderer queue  
and returns.
If you want to wait the end of the rendering, you must use glFinish().  
( http://developer.apple.com/qa/qa2004/qa1158.html )



I'm not yet convinced that drawing on a second thread will really  
give any benefit, so I'm reluctant to change things dramatically to  
allow it when I may end up abandoning the whole idea.


Be useful to hear from anyone who's done something like this to a)  
convince me it's worth it and b) hear about any solutions to the  
update rects issue.



Using a separate thread for time-consuming drawing does make the  
user experience much better. My app does OpenGL rendering of large,  
complex 3D fractals, and I ended up pulling out the drawing code  
into a separate thread. That's even hairier than what you're trying  
to do, because I use NSOpenGLViews, and they are not particularly  
well set up for multi-threaded use.


What I do is to display a progress bar at the bottom of my 3D view  
window. As rendering progresses, I update the progress bar. I return  
control to the user immediately, so I avoid the spinning wait  
cursor. If the user then does something that invalidates the current  
rendering task, I set a "terminate rendering" flag and wait for the  
rendering thread to stop, then submit a new rendering job.


Duncan C



NSOpenGLViews is probably the only view that support multi-threading  
out of the box. There is a lots of sample codes on ADC that draw in  
OpenGL view from many threads. (All CoreVideo samples for example).
There is only two things you have to do. In your GLView subclass,  
synchronize the -update message - (void)update { @synchronize(self)  
{ [super update]; } } and in your drawing method lock your gl context  
to be sure that only one thread access it to draw at a time.




___

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]


Update NSMenuItem while displaying

2008-05-03 Thread Jere Gmail
I have a NSMenuItem int a NSStatusBarItem that displays the remaining
time of a timer. It is only updated when I'm not viewing the menu.
When I click in the menu, I can see in the debug console that no there
are no calls to the timer loop function.
How can I solve it?

-- 
http://zon7blog.wordpress.com/
And again we fall.
___

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]


Re: Update NSMenuItem while displaying

2008-05-03 Thread Ricky Sharp


On May 3, 2008, at 7:31 AM, Jere Gmail wrote:


I have a NSMenuItem int a NSStatusBarItem that displays the remaining
time of a timer. It is only updated when I'm not viewing the menu.
When I click in the menu, I can see in the debug console that no there
are no calls to the timer loop function.
How can I solve it?



When you're adding your timer to the run loop, I think you've only  
specified the NSDefaultRunLoopMode.  In addition to that, add the  
timer with a second mode of NSEventTrackingRunLoopMode.


See addTimer:forMode:


If using 10.5 and later, there appears to be a new mode  
(NSRunLoopCommonModes).  I have not used that myself, but check the  
docs to see if it may apply to you.


___
Ricky A. Sharp mailto:[EMAIL PROTECTED]
Instant Interactive(tm)   http://www.instantinteractive.com

___

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]


Re: drawing in a separate thread

2008-05-03 Thread Graham Cox


On 3 May 2008, at 9:36 pm, Duncan wrote:

If you're going to do your drawing in a separate thread, you'll need  
to remember WHAT to draw. I wouldn't call it "hackish", I'd call it  
the cost of doing business that way.


If you implement a job queue, add the list of dirty rectangles to  
each job object. -drawRect would be where you'd add your jobs to the  
queue. It cold call getRectsBeingDrawn:count to get the list of  
dirty rects, then add that list to the job object. Then when the  
worker thread picks up a job, it would get the list of dirty  
rectangles from the job object instead of calling  
getRectsBeingDrawn:count. That should be pretty straightforward.


This is pretty much what I've done. When the need to draw is flagged,  
it copies the rects from getRectsBeingDrawn: and saves them in the  
invocation which is queued. When the thread invokes drawing, it passes  
the rects back to the view which now overrides needsToDrawRect: and  
uses these saved rects to figure out what needs to draw. Lower level  
drawing code is none the wiser.


That's all working pretty well as such now, performance seems as least  
on a par with synchronous drawing, possibly better though I've yet to  
measure it.


Now another issue rears its head ;-)

Consider the user dragging an object. Because drawRect: returns  
quickly now, the user is able to move the object beyond the update  
area before the thread gets a chance to draw it - so I'm seeing edges  
of objects are being clipped out during fast motion. I can't think of  
any way around this at the moment - any ideas? (I tried triggering the  
draw thread on a setNeedsDisplayInRect: but that's much worse - it  
queues so many updates it has an eerie slo-mo effect! It catches up  
eventually, but it's clearly not a solution).



G.
___

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]


Implementing fast enumeration

2008-05-03 Thread Ben
I have been reading the documentation for implementing the  
NSFastEnumeration protocol and am having some difficulties following it.


For completeness, here is the protocol method:
- (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState  
*)state objects:(id *)stackbuf count:(NSUInteger)len;


typedef struct {
unsigned long state;
id *itemsPtr;
unsigned long *mutationsPtr;
unsigned long extra[5]; } NSFastEnumerationState;

I have a C array where the elements within it can be converted into  
multiple objects. Say I have 5 objects. Do I provide them all in one  
go and return the total number? Or just one per call and return the  
number remaining?


Also, should the objects be returned by reference in the stackbuf  
variable, or in the itemsPtr field of the state structure?


Apologies if these are basic questions, but I got decidedly lost  
trying to follow the docs.


Ben.
___

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]


Re: Implementing fast enumeration

2008-05-03 Thread Thomas Backman

Hmm, your previous message/thread made it and has two answers.

Regards,
Thomas

On May 2, 2008, at 10:41 AM, Ben wrote:

I have been reading the documentation for implementing the  
NSFastEnumeration protocol and am having some difficulties following  
it.


For completeness, here is the protocol method:
- (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState  
*)state objects:(id *)stackbuf count:(NSUInteger)len;


typedef struct {
unsigned long state;
id *itemsPtr;
unsigned long *mutationsPtr;
unsigned long extra[5]; } NSFastEnumerationState;

I have a C array where the elements within it can be converted into  
multiple objects. Say I have 5 objects. Do I provide them all in one  
go and return the total number? Or just one per call and return the  
number remaining?


Also, should the objects be returned by reference in the stackbuf  
variable, or in the itemsPtr field of the state structure?


Apologies if these are basic questions, but I got decidedly lost  
trying to follow the docs.


Ben.
___

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/serenity 
%40exscape.org


This email sent to [EMAIL PROTECTED]


___

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]


Re: drawing in a separate thread

2008-05-03 Thread Jean-Daniel Dupas


Le 3 mai 08 à 14:52, Graham Cox a écrit :



On 3 May 2008, at 9:36 pm, Duncan wrote:

If you're going to do your drawing in a separate thread, you'll  
need to remember WHAT to draw. I wouldn't call it "hackish", I'd  
call it the cost of doing business that way.


If you implement a job queue, add the list of dirty rectangles to  
each job object. -drawRect would be where you'd add your jobs to  
the queue. It cold call getRectsBeingDrawn:count to get the list of  
dirty rects, then add that list to the job object. Then when the  
worker thread picks up a job, it would get the list of dirty  
rectangles from the job object instead of calling  
getRectsBeingDrawn:count. That should be pretty straightforward.


This is pretty much what I've done. When the need to draw is  
flagged, it copies the rects from getRectsBeingDrawn: and saves them  
in the invocation which is queued. When the thread invokes drawing,  
it passes the rects back to the view which now overrides  
needsToDrawRect: and uses these saved rects to figure out what needs  
to draw. Lower level drawing code is none the wiser.


That's all working pretty well as such now, performance seems as  
least on a par with synchronous drawing, possibly better though I've  
yet to measure it.


Now another issue rears its head ;-)

Consider the user dragging an object. Because drawRect: returns  
quickly now, the user is able to move the object beyond the update  
area before the thread gets a chance to draw it - so I'm seeing  
edges of objects are being clipped out during fast motion. I can't  
think of any way around this at the moment - any ideas? (I tried  
triggering the draw thread on a setNeedsDisplayInRect: but that's  
much worse - it queues so many updates it has an eerie slo-mo  
effect! It catches up eventually, but it's clearly not a solution).



G.


Why not merging your drawing invocation instead of queuing them.
Each time a drawRect is called on your view, get the rects that need  
to be refreshed, and add them to a single array of rect.
One each loop, the drawing thread will picks all rects in the list and  
draw the view one time. Like this, if there is overlapping rects in  
the queue it will refresh them only once.



___

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]


Re: drawing in a separate thread

2008-05-03 Thread Graham Cox
Cocoa already coalesces updates in this way, so when drawRect: is  
called, the list of rects is the merged list.


I does raise a question though - is there a way to get, at any point  
in time, the list of merged rects needing update from a view *at that  
point* - in other words, outside of a drawRect: call, can I found out  
what has been marked for update so far? That would be useful.


G.




On 3 May 2008, at 11:22 pm, Jean-Daniel Dupas wrote:


Why not merging your drawing invocation instead of queuing them.
Each time a drawRect is called on your view, get the rects that need  
to be refreshed, and add them to a single array of rect.
One each loop, the drawing thread will picks all rects in the list  
and draw the view one time. Like this, if there is overlapping rects  
in the queue it will refresh them only once.


___

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]


dockMenu bug?

2008-05-03 Thread slasktrattenator
Hi,

I'm having this problem where I cannot hide menu items in my dock
menu. [menuItem setHidden:YES] does nothing, nor does checking the
"Hidden" checkbox in IB. The dock menu itself is created in IB and
connected to NSApp's dockMenu outlet. Is this a bug or am I missing
something?

I know I can just as easily create the menu at runtime in NSApp's
applicationDockMenu: delegate method, and do the filtering there, just
curious to know why it behaves this way, and if there's a workaround.

Thanks.
___

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]


Re: drawing in a separate thread

2008-05-03 Thread Ricky Sharp


On May 3, 2008, at 8:30 AM, Graham Cox wrote:

Cocoa already coalesces updates in this way, so when drawRect: is  
called, the list of rects is the merged list.


I does raise a question though - is there a way to get, at any point  
in time, the list of merged rects needing update from a view *at  
that point* - in other words, outside of a drawRect: call, can I  
found out what has been marked for update so far? That would be  
useful.



You may have to step down to CoreGraphics (CG) APIs.  Perhaps  
CGWaitForScreenRefreshRects or some other API would be helpful?


___
Ricky A. Sharp mailto:[EMAIL PROTECTED]
Instant Interactive(tm)   http://www.instantinteractive.com

___

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]


Re: drawing in a separate thread

2008-05-03 Thread Jean-Daniel Dupas


Le 3 mai 08 à 15:30, Graham Cox a écrit :

Cocoa already coalesces updates in this way, so when drawRect: is  
called, the list of rects is the merged list.


Cocoa already do this for synchronous drawing, and after each  
drawRect: call it resets the list. If the drawRect: method is call  
faster than what the background thread can process, the Cocoa effort  
to coalesce updates is lost.



I does raise a question though - is there a way to get, at any point  
in time, the list of merged rects needing update from a view *at  
that point* - in other words, outside of a drawRect: call, can I  
found out what has been marked for update so far? That would be  
useful.


G.




Even if such API exists, it will be useless with multi-threading, as a  
view assume that after a drawRect: call, all rects that was marked for  
update are now updated. And so, the "dirty rects" list will not be  
synchronize with the real state of the view.



___

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]


Re: drawing in a separate thread

2008-05-03 Thread Graham Cox


On 3 May 2008, at 11:55 pm, Jean-Daniel Dupas wrote:



Le 3 mai 08 à 15:30, Graham Cox a écrit :

Cocoa already coalesces updates in this way, so when drawRect: is  
called, the list of rects is the merged list.


Cocoa already do this for synchronous drawing, and after each  
drawRect: call it resets the list. If the drawRect: method is call  
faster than what the background thread can process, the Cocoa effort  
to coalesce updates is lost.


Ah, OK, I see what you were saying - I should keep clumping together  
new dirty rects as they are marked until the *thread* has dealt with  
them. Might be a good idea - though to be honest sounds like it could  
be computationally complex. Even just splitting up two overlapping  
rects (in a question a couple of weeks ago) was a bit of a head- 
scratcher - this sounds ten times worse ;-)


Even if such API exists, it will be useless with multi-threading, as  
a view assume that after a drawRect: call, all rects that was marked  
for update are now updated. And so, the "dirty rects" list will not  
be synchronize with the real state of the view.


I agree, the update rects would be stale by the time the thread gets  
around to using them. That's already the problem I'm having with  
moving objects losing their edges when dragging. But with such an API  
the *thread* could grab those rects just before drawing at least  
minimising the "time to become stale" which would reduce if not  
eliminate the problem.


I still see no theoretical way around this basic problem with dirty  
rects being generated on one thread and being updated on another (if  
the dirty rects are changing rapidly, which they are much of the time).


One thing that would dramatically improve drawing times is if NSShadow  
wasn't so dog-slow. That's part of the *real* problem I'm having :(


Frankly I'm about ready to give up on this - seems more trouble than  
it's worth.


G.___

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]


Converting XML to NSDictionary

2008-05-03 Thread Mr. Gecko

How would I convert XML to NSDictionary so I can read it.
Here is an example of how my XML file looks like



	http://www.example.com/file1"; size="522656" name="File  
Number 1"/>
	http://www.example.com/file1"; size="4533" name="File  
Number 2"/>



___

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]


Re: Text attachment not deleted from NSTextView

2008-05-03 Thread Luong Dang
I added a button to manually refresh the NSTextView, but things don't  
change at all.


On 2-May-08, at 4:24 AM, Stéphane Sudre wrote:



On May 1, 2008, at 11:19 PM, Luong Dang wrote:

It's from the keyboard. Basically, I just hit the Delete key.

I also noticed that in Interface Builder's test mode, I can drag  
the file into the NSTextView and it will delete the image just fine.


If you then force a refresh of the text view with  
setNeedsDisplay:YES for instance, is the image still visible?





___

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]


Re: dockMenu bug?

2008-05-03 Thread Jens Alfke


On 3 May '08, at 6:44 AM, [EMAIL PROTECTED] wrote:


I'm having this problem where I cannot hide menu items in my dock
menu. [menuItem setHidden:YES] does nothing, nor does checking the
"Hidden" checkbox in IB. The dock menu itself is created in IB and
connected to NSApp's dockMenu outlet. Is this a bug or am I missing
something?


"Bug", I guess; really, the dock menu doesn't support all the  
functionality of a real NSMenu, since it's implemented differently —  
the NSMenu object is just a proxy, and the actual menu is managed by  
the Dock process. (I believe the app sends IPC messages to the Dock  
process telling it what menu items to show, and the Dock sends back  
IPC messages when the user chooses an item.)


—Jens

smime.p7s
Description: S/MIME cryptographic signature
___

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]

Re: Converting XML to NSDictionary

2008-05-03 Thread Jens Alfke


On 3 May '08, at 8:01 AM, Mr. Gecko wrote:


How would I convert XML to NSDictionary so I can read it.


We already answered this yesterday: NSXMLDocument. It doesn't convert  
it literally into an NSDictionary, but it's a tree of NSXMLElement  
objects that you can use in much the same way. Please read the  
documentation for those classes, try using them, and if you have  
specific questions afterwards, ask them.


—Jens

smime.p7s
Description: S/MIME cryptographic signature
___

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]

Re: Converting XML to NSDictionary

2008-05-03 Thread Jean-Daniel Dupas


Le 3 mai 08 à 17:01, Mr. Gecko a écrit :


How would I convert XML to NSDictionary so I can read it.
Here is an example of how my XML file looks like



	http://www.example.com/file1"; size="522656" name="File  
Number 1"/>
	http://www.example.com/file1"; size="4533" name="File  
Number 2"/>





Maybe the Uli's UKXMLPersistence class do what you want: 
http://www.zathras.de/angelweb/sourcecode.htm

But as Jens Alfke said, using NSXMLDocument is right too.


___

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]


Re: dockMenu bug?

2008-05-03 Thread slasktrattenator
Thanks Jens. Sounds to me we don't need the quotation marks round "bug".

On Sat, May 3, 2008 at 5:46 PM, Jens Alfke <[EMAIL PROTECTED]> wrote:
>
>  On 3 May '08, at 6:44 AM, [EMAIL PROTECTED] wrote:
>
>
> > I'm having this problem where I cannot hide menu items in my dock
> > menu. [menuItem setHidden:YES] does nothing, nor does checking the
> > "Hidden" checkbox in IB. The dock menu itself is created in IB and
> > connected to NSApp's dockMenu outlet. Is this a bug or am I missing
> > something?
> >
>
>  "Bug", I guess; really, the dock menu doesn't support all the functionality
> of a real NSMenu, since it's implemented differently — the NSMenu object is
> just a proxy, and the actual menu is managed by the Dock process. (I believe
> the app sends IPC messages to the Dock process telling it what menu items to
> show, and the Dock sends back IPC messages when the user chooses an item.)
>
>  —Jens
___

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]


NSPopupButton displaying extra item when model changed

2008-05-03 Thread Johnny Lundy

Hello all,

Thanks for your previous help. I'm trying to firm up my understanding  
of NSPopupButton. I wrote a test project modeled after Kevin Wojniak's  
example here:


http://forums.macrumors.com/showthread.php?p=4839485  , post #7,  
referencing matt neuburg's example.


One NSPopupButton
One NSArrayController (popupController)
One NSObject (popup) whose Class is set to "Popup"

You know how everyone always says "All I am trying to do is..." ?  
Well, I just want to get the popup's selection in my Model so I can  
use the value in my code.


Bindings:
PopupButton bound to NSArrayController "popupController":
Content: popupController.arrangedObjects.type
Content Values: popupController.arrangedObjects.type
Selected Object: popup.selectedType

Bindings for popupController:
Content: popup.gameTypes

The little bit of code is below. Two classes, although I don't  
understand why Kevin made the second class (my class "GameType").


PROBLEM: The popup is loaded from the model array through the  
controller. No problem. When I call my "changeArray" method, though,  
the popup's display adds a fourth element, which isn't in the actual  
model array. The model object "selectedType" correctly updates when  
the popup's selection is changed.


- Do I need this extra class and this loop that populates the array  
"gameTypes?" It works, and just binding the controller to the  
"popupArray" by itself does not work. I don't get this.


- Is instantiating the NSObject "popup" in IB and setting its class to  
the class in which my ivars are declared the correct way to provide  
the controller layer with access to the Model layer?


Thanks


//Popup.h***
#import 
@interface Popup : NSObject
{
//Make an NSString instance variable and and two arrays for the popup
NSMutableArray *gameTypes;
NSArray *popupArray;
NSString *selectedType;
}
- (void) changeArray;
@property (readwrite, copy) NSArray *popupArray;
@property (readwrite, retain) NSMutableArray *gameTypes;
@property (readwrite, copy) NSString *selectedType;
@end

//Popup.m*
#import "GameType.h"
@implementation Popup: NSObject
@synthesize popupArray, gameTypes, selectedType;
- (id) init
{
self = [super init];
return self;
}
- (void) awakeFromNib
{
	[self setPopupArray: [NSArray arrayWithObjects:@"C9", @"F11",  
@"Other", nil]];

gameTypes = [NSMutableArray array];
for (NSString *theType in popupArray)
{
GameType *gameTypeObject = [[[GameType alloc] init] 
autorelease];
gameTypeObject.type = theType;
[gameTypes addObject:gameTypeObject];
}
self.gameTypes = gameTypes;
}

- (void) changeArray //From the "method" binding of an NSButton in the  
nib file

{
	self.selectedType=@"Deathy"; //This adds a fourth item to the popup's  
list, rather than renaming the selected item.

}
@end

//  GameType.h**
//  TestPopup

#import 
@interface GameType : NSObject
{
NSString *type;
}
@property (readwrite, retain) NSString *type;
@end

//  GameType.m *
//  TestPopup
#import "GameType.h"
@implementation GameType
@synthesize type;
@end
___

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]


Re: NSImageView blocking drag -- solved

2008-05-03 Thread Gordon Apple
That post was in the middle of the night when I couldn't sleep.  I
researched the archives this  morning and found the solution.  I added an
outlet in my controller to the NSImageView and in awakeFromNib called
unregisterDraggedTypes for the NSImageView.  Problem solved.  However, I
still think that this should be the default behavior for a disabled view.


> 
>   I have a custom view that contains a (covering) NSImageView.  The latter
> is disabled.  I want the custom view to handle all drag operations.  This
> works fine as long as I don't drag in a type (e.g., NSFilenamesPboardType)
> that NSImageView directly supports.  setAllowsCutCopyPaste:NO for the
> NSImageView does not help.  The drop never gets to the custom view (yes, it
> registers the types) but is simply rejected by the disabled NSImageView.  My
> custom view's dragOperationForDraggingInfo never gets called in such case.
> If I squeeze down the NSImageView and drag directly to the exposed custom
> view, it works fine.
> 
>   Shouldn't disabling the NSImageView make it effectively invisible for
> all such operations?  Bug report time?
> 

___

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]


Reading XML

2008-05-03 Thread Mr. Gecko

Ok I have been searching for hours.
Here is exact details.
I have an xml file on the web for files and I use it for flash I don't  
want to make an xml plist on the web because I don't want to have two  
sources.

I need to read it in cocoa here is the layout of the cocoa file.



	http://www.example.com/file1"; size="522656" name="File  
Number 1"/>
	http://www.example.com/file2"; size="4533" name="File  
Number 2"/>



I heard about NSXMLDocument but I got no exact way to read objects in  
it.

I want to beable to just do something like this.
NSXML *xml = [NSXML initWithXMLData:[NSData dataWithContentsOfUrl: 
[NSURL URLWithString:@"http://www.example.com/xmlfile.xml";]]];

NSArray *data = [xml elementsForName:@"files"];
NSDictionary *stuff = [data objectAtIndex:0]
NSLog(@"Url is [EMAIL PROTECTED] is [EMAIL PROTECTED] is %@", [stuff  
objectForKey:@"url"], [stuff objectForKey:@"size"], [stuff  
objectForKey:@"name"]);


Is there any like framework that will let you do that?
Is there an example for how to read xml?
Is there a tutorial?

Thanks,
Mr. Gecko
___

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]


Re: Saving/restoring PDFAnnotationTextWidget stringValues with PDFKit 10.5

2008-05-03 Thread Joel Norvell
Dear Antonio,

Thank you very much for clarifying this!  And CONGRATULATIONS on your new
PDFClerk Pro 3.0 "rewritten from the ground up to take advantage of Mac OS X
10.5's many improvements"!

Best regards,
Joel

--- Antonio Nunes <[EMAIL PROTECTED]> wrote:

> On May 3, 2008, at 6:54 AM, Joel Norvell wrote:
> 
> > If you use PDFKit 10.5 to save and then restore a pdf file, are
> > PDFAnnotationTextWidget stringValues preserved?  (These are the text  
> > fields that you enter in PDF forms.)
> 
> They are not preserved. If you are saving data into your own file  
> format you can can query the widgets at saving time and write them out  
> explicitly. Then restore them when the file is read back in, after the  
> PDF pages have been restored.
> 
> António
> 
> -
> Accepting others as they are
> brings a wonderful freedom
> to your own mind.
> 
> --The Peace Formula
> -
> 




  

Be a better friend, newshound, and 
know-it-all with Yahoo! Mobile.  Try it now.  
http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ
___

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]


Re: Reading XML

2008-05-03 Thread John Calsbeek
NSXMLElement represents a single element, not an NSDictionary. Just  
purge the word "NSDictionary" from your mind, and start reading:








___

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]


Real time video analysis app under Cocoa

2008-05-03 Thread Yreaction JP

Hi there

I have a few questions about what way should I choose for develop an  
real time video analysis app. I already have a solid knowledge of  
image analysis and objetive c aswell. The basic idea to start with  
this is an app that get a real time video signal and pass a set of  
filters (thresholding, segmentation) that count or discount an object  
(e.a Beans) and shows the number of the current count.


Im not really sure what core video offers, but as fair i understand  
while reading the guide, Do i need to think something like the next  
workflow?


iSight Signal - Core Video - Buffer - vImage (convolutions to each  
frame?) -  Core Video (Compose an output video with a eliptical color  
around the bean?) - Results?


Thanks in advance.
___

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]


Re: Converting XML to NSDictionary

2008-05-03 Thread Hal Mueller
Also see this sample code using libxml2, should there be some reason  
you can't use NSXMLDocument:


http://inessential.com/?comments=1&postid=3489

Hal

___

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]


most efficient way to string CIFilters together?

2008-05-03 Thread Josh Burnett
In a photography app, I'm chaining a series of CIFilters together to  
process the image.  I'm able to do the chain just fine, but I'm only  
using a few filters at the moment.  As I increase the length of this  
chain, am I going to run into performance issues?  Here's my code:


exposureFilter   = [CIFilter filterWithName: @"CIExposureAdjust"
keysAndValues:
@"inputImage", inputImage,
@"inputEV", [NSNumber numberWithFloat: exposureValue],
nil];
outputImage = [exposureFilter valueForKey: @"outputImage"];
[exposureFilter retain];

zoomFilter   = [CIFilter filterWithName: @"CILanczosScaleTransform"
keysAndValues:
@"inputImage", outputImage,
@"inputScale", [NSNumber numberWithFloat: mappedZoom],
@"inputAspectRatio", [NSNumber numberWithFloat: 1.0],
nil];
outputImage = [zoomFilter valueForKey: @"outputImage"];
[zoomFilter retain];


Obviously, it's easy to continue to add to this chain.  Is this the  
most efficient way to string multiple filters together?  I can  
probably use Quartz Composer to create a single image unit that does  
all of the processing.  Would that be any more efficient, or would it  
be essentially the same result?


Thanks,

Josh
___

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]


Re: Loading a .nib?

2008-05-03 Thread Chris Hanson

On May 2, 2008, at 5:37 PM, Graham Cox wrote:

is a Carbon app, so there is no Cocoa runtime available. You can use  
a nib, but it has to be a Carbon one, so the functions you need to  
look at are in the HIView family of Carbon functions.


It doesn't matter what Carbon app you're writing a plug-in for, you  
can use Cocoa.


You just need to ensure NSApplicationLoad() is called.  You can call  
it yourself in your plug-in before you try to use Cocoa:





The Objective-C runtime, the Cocoa frameworks, etc. will be pulled in  
as a side-effect of loading a plug-in that's linked against them.   
They aren't required to be linked from the main executable.


The only tricky thing you'll need to manage is if the main executable  
*unloads* plug-ins.  You have to ensure your plug-in is unloadable in  
that case, which can be subtle with Cocoa code.  For example, you'll  
want to pass -fno-constant-cfstrings to the compiler, and use  
CFSTR("foo") instead of @"foo" for string constants, to ensure that  
they're created at runtime rather than memory-mapped from your plug-in.


  -- Chris

___

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]


Re: most efficient way to string CIFilters together?

2008-05-03 Thread Jean-Daniel Dupas


Le 3 mai 08 à 20:06, Josh Burnett a écrit :

In a photography app, I'm chaining a series of CIFilters together to  
process the image.  I'm able to do the chain just fine, but I'm only  
using a few filters at the moment.  As I increase the length of this  
chain, am I going to run into performance issues?  Here's my code:


exposureFilter   = [CIFilter filterWithName: @"CIExposureAdjust"
keysAndValues:
@"inputImage", inputImage,
@"inputEV", [NSNumber numberWithFloat: exposureValue],
nil];
outputImage = [exposureFilter valueForKey: @"outputImage"];
[exposureFilter retain];

zoomFilter   = [CIFilter filterWithName: @"CILanczosScaleTransform"
keysAndValues:
@"inputImage", outputImage,
@"inputScale", [NSNumber numberWithFloat: mappedZoom],
@"inputAspectRatio", [NSNumber numberWithFloat: 1.0],
nil];
outputImage = [zoomFilter valueForKey: @"outputImage"];
[zoomFilter retain];


Obviously, it's easy to continue to add to this chain.  Is this the  
most efficient way to string multiple filters together?  I can  
probably use Quartz Composer to create a single image unit that does  
all of the processing.  Would that be any more efficient, or would  
it be essentially the same result?


Thanks,

Josh


On Mac OS 10.5, there is a class designed to create and store filter  
chain (CIFilterGenerator). You may have a look at it.
You also have to know that the filter is not computed when you call  
[valueForKey:@"outputImage"] but when you try to access the final  
outputImage content (to display it for example). Even if this is not  
obvious as you have to create a new image instance for each filter,  
Core Image optimize the image processing. So creating a single image  
unit would probably not be more efficient.


___

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]


Re: Real time video analysis app under Cocoa

2008-05-03 Thread Jean-Daniel Dupas


Le 3 mai 08 à 19:49, Yreaction JP a écrit :


Hi there

I have a few questions about what way should I choose for develop an  
real time video analysis app. I already have a solid knowledge of  
image analysis and objetive c aswell. The basic idea to start with  
this is an app that get a real time video signal and pass a set of  
filters (thresholding, segmentation) that count or discount an  
object (e.a Beans) and shows the number of the current count.


Im not really sure what core video offers, but as fair i understand  
while reading the guide, Do i need to think something like the next  
workflow?


iSight Signal - Core Video - Buffer - vImage (convolutions to each  
frame?) -  Core Video (Compose an output video with a eliptical  
color around the bean?) - Results?


Thanks in advance.


This sample may give you a start:

http://developer.apple.com/samplecode/CIColorTracking/index.html

It processes movie from a file and not from an iSight, but it show you  
how to analyse and update frames from a running movie.
There is also a bunch of sample on the ADC site that show how to  
capture and analyse an iSight signal.


The processing path may be

iSight (or any other CVImageBuffer source) -> Core Image (-[CIImage  
initWithCVImageBuffer:]) -> Image processing -> -[CIContext  
drawImage:] (using an OpenGL View for example).



___

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]


XML Attributes

2008-05-03 Thread Mr. Gecko
Ok I was able to one of the childs from my xml file now what I am  
asking is how to get the attributes from it

I uses this
NSXMLDocument *xml = [[NSXMLDocument alloc] initWithData:[NSData  
dataWithContentsOfURL:[NSURL URLWithString:@"http://www.example.com/xmlfile.xml 
"]] options:NSXMLDocumentTidyXML error:NULL];

NSXMLNode *nodes = [xml rootElement];
NSXMLNode *node = [[nodes childAtIndex:1] childAtIndex:0];
to get this
http://www.example.com/file1"; size="522656" name="File  
Number 1">
so now how do I get an attribute from it such as url, or name.  I saw  
in NSXMLElement documentation that it had an attribute thing but I  
can't figure out how to convert the node to NSXMLElement to get the  
attribute.


Thanks for any help,
Mr. Gecko
___

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]


Re: XML Attributes

2008-05-03 Thread Mr. Gecko

Thanks it works
here is my updated code
NSXMLDocument *xml = [[NSXMLDocument alloc] initWithData:[NSData  
dataWithContentsOfURL:[NSURL URLWithString:@"http://www.example.com/xmlfile.xml 
"]] options:NSXMLDocumentTidyXML error:NULL];

NSXMLNode *node = [xml rootElement];
NSString *name = [[(NSXMLElement *)[[node childAtIndex:1] childAtIndex: 
0] attributeForName:@"name"] stringValue];

On May 3, 2008, at 3:54 PM, John Calsbeek wrote:

I believe what you've got is an NSXMLElement (you can see this using  
the -kind method). You just need to cast it as one:


NSXMLElement *node = (NSXMLElement *)[[nodes childAtIndex:1]  
childAtIndex:0];


___

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]


Re: NSArrayController issue

2008-05-03 Thread Hamish Allan
On Thu, May 1, 2008 at 10:09 PM, Måns Severin <[EMAIL PROTECTED]> wrote:

>  Is there some kind of delegate / observer method of the NSArrayController
> to see when it is done changing selection?

You could register for KVO notifications on NSArrayController's
selectedObjects or similar.

Hamish
___

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]


HTTP Headers

2008-05-03 Thread Jeremy

Hello,

Is there an easy way within Obj-C to read HTTP headers, to write HTTP  
headers, and to send HTTP headers? As this will be the easiest way for  
me to authenticate for an XML API I am using, and to read http status  
codes (if the action was completed - or the error).


Jeremy
"For a long time it puzzled me how something so expensive, so leading  
edge, could be so useless, and then it occurred to me that a computer  
is a stupid machine with the ability to do incredibly smart things,  
while computer programmers are smart people with the ability to do  
incredibly stupid things. They are, in short, a perfect match." - Bill  
Bryson



___

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]


Re: Real time video analysis app under Cocoa

2008-05-03 Thread Andrew Farmer

On 03 May 08, at 10:49, Yreaction JP wrote:
I have a few questions about what way should I choose for develop an  
real time video analysis app. I already have a solid knowledge of  
image analysis and objetive c aswell. The basic idea to start with  
this is an app that get a real time video signal and pass a set of  
filters (thresholding, segmentation) that count or discount an  
object (e.a Beans) and shows the number of the current count.


Im not really sure what core video offers, but as fair i understand  
while reading the guide, Do i need to think something like the next  
workflow?


iSight Signal - Core Video - Buffer - vImage (convolutions to each  
frame?) -  Core Video (Compose an output video with a eliptical  
color around the bean?) - Results?


My understanding is that Core Video is primarily intended for  
processing video to be displayed on screen. You should probably take a  
look at the OpenCV computer vision library - it's much better suited  
to this sort of image analysis.

___

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]


Newbie Question: Controls not redrawing on changes

2008-05-03 Thread Christopher Kempke
I'm attempting to convert my "Modern Carbon"/Windows GDI+ application  
framework to Cocoa for 64-bit support, and am paradoxically finding  
the "easy" things hard and the "hard" things easy.  My latest case in  
point:   My controls (checkboxes) aren't redrawing when they change  
state, and default buttons in the same dialog are drawn in blue but  
not throbbing.When I click on the check box, it's changing state  
(as determined by a call to [theControl state], but not redrawing on  
screen.This is all programatic; not using Interface Builder.


Here's some random clips from my code.   The Windows for my (modal)  
dialog are are created by:


			theWindow = [[NSWindow alloc]  
initWithContentRect:*(NSRect*)&platRect styleMask:winStyleMask  &~  
(NSClosableWindowMask | NSMiniaturizableWindowMask |  
NSResizableWindowMask) backing:NSBackingStoreRetained defer:YES];

[theWindow setLevel: NSModalPanelWindowLevel];


I create the checkbox with:

case kAOControlCheckbox:
ctl = [[NSButton alloc] init];
[(NSButton*)ctl setButtonType:NSSwitchButton];
[(NSButton*)ctl setTitle:(NSString*)title];
SetPlatformCheckOrRadioValue(ctl, initValue);
break;

Ad add it to the parent view:

[parent addSubview:ctl];
[ctl setFrame:*(NSRect*)&nrect];
if (![ctl isEnabled])
[ctl setEnabled:YES];

Then I draw the window with:

[iWindow makeKeyAndOrderFront:nil];

And run it as a modal dialog with:

[NSApp runModalForWindow:iWindow];

(The app itself is launched with [NSApp run]; )

This draws my dialog correctly, including all the controls.  But the  
buttons don't visibly respond when the mouse is held down on them,  
default buttons are blue but don't throb, and checkboxes change  
programatic state but not visible state when clicked.   If buttons are  
hooked to action targets, they're getting called when the button is  
clicked.   I discovered by accident that when drawing a custom view  
elsewhere in the dialog that if I included:


[[NSGraphicsContext currentContext] flushGraphics];

in the drawRect: method of the view, that all the controls would  
update when that view did (triggered by a mousedown handler in just  
that custom view).   But the description of both flushGraphics and 	 
[NSButton setState] seem to indicate that it should be happening  
automatically.


I've turned off all assignments of actions and targets, thinking I was  
"stealing" some event the system needed, but no go.   I don't have  
mouseAnything: handlers on the checkboxes; in fact, I'm not even  
subclassing them.


I'm guessing I've missed a step, something that provides the context  
flush and the throb heartbeat.   Anyone care to take pity on me?


--Christopher Kempke


___

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]


Proxy Window of another

2008-05-03 Thread Daniel Rampanelli


Hi,
I was thinking wheter it is possible to create a sort of "proxy"  
window which displays the content of another. Of course, the further  
step would be to also pass events from the proxied window to the  
source one. Is this even possible?


Thanks in advance,
Daniel
___

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]


Re: HTTP Headers

2008-05-03 Thread Uli Kusterer


Am 03.05.2008 um 23:35 schrieb Jeremy:
Is there an easy way within Obj-C to read HTTP headers, to write  
HTTP headers, and to send HTTP headers? As this will be the easiest  
way for me to authenticate for an XML API I am using, and to read  
http status codes (if the action was completed - or the error).



NSURLRequest and NSURLHandle (or was it NSURLConnection?) let you do  
that. Anyway, a search for NSURL at http://developer.apple.com should  
provide the right name for the APIs involved. You essentially pass in  
a dictionary with the header name as the key and the header content as  
the value. Of course that means that you can't easily have several  
headers with the same name (like it'd be done for an SMTP server), but  
for most uses it works.


There might even be sample code for doing HTTP GET or POST requests at 
http://cocoadev.com

Cheers,
-- Uli Kusterer
"The Witnesses of TeachText are everywhere..."
http://www.zathras.de





___

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]


Re: HTTP Headers

2008-05-03 Thread Jeremy

So... Using

[NSURLRequest HTTPBody]; will return what is returned. I don't see any  
way to build and send HTTP headers.


Jeremy
"For a long time it puzzled me how something so expensive, so leading  
edge, could be so useless, and then it occurred to me that a computer  
is a stupid machine with the ability to do incredibly smart things,  
while computer programmers are smart people with the ability to do  
incredibly stupid things. They are, in short, a perfect match." - Bill  
Bryson



On May 3, 2008, at 5:52 PM, Uli Kusterer wrote:



Am 03.05.2008 um 23:35 schrieb Jeremy:
Is there an easy way within Obj-C to read HTTP headers, to write  
HTTP headers, and to send HTTP headers? As this will be the easiest  
way for me to authenticate for an XML API I am using, and to read  
http status codes (if the action was completed - or the error).



NSURLRequest and NSURLHandle (or was it NSURLConnection?) let you do  
that. Anyway, a search for NSURL at http://developer.apple.com  
should provide the right name for the APIs involved. You essentially  
pass in a dictionary with the header name as the key and the header  
content as the value. Of course that means that you can't easily  
have several headers with the same name (like it'd be done for an  
SMTP server), but for most uses it works.


There might even be sample code for doing HTTP GET or POST requests  
at http://cocoadev.com


Cheers,
-- Uli Kusterer
"The Witnesses of TeachText are everywhere..."
http://www.zathras.de







___

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]


Re: Newbie Question: Controls not redrawing on changes

2008-05-03 Thread Nathan Kinsinger

On May 3, 2008, at 3:42 PM, Christopher Kempke wrote:

Then I draw the window with:

[iWindow makeKeyAndOrderFront:nil];

And run it as a modal dialog with:

[NSApp runModalForWindow:iWindow];


The docs for runModalForWindow: explicitly say not to send  
makeKeyAndOrderFront: to the window. I'm guessing that the window is  
in the normal run loop and not the modal run loop.  
makeKeyAndOrderFront: will show the window and make it key.


--Nathan
___

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]


Re: HTTP Headers

2008-05-03 Thread Kyle Sluder
On Sat, May 3, 2008 at 6:05 PM, Jeremy <[EMAIL PROTECTED]> wrote:
> So... Using
>
>  [NSURLRequest HTTPBody]; will return what is returned. I don't see any way
> to build and send HTTP headers.

NSMutableURLRequest has all of that.

--Kyle Sluder
___

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]


Re: Newbie Question: Controls not redrawing on changes

2008-05-03 Thread Michael Ash
On Sat, May 3, 2008 at 5:42 PM, Christopher Kempke
<[EMAIL PROTECTED]> wrote:
>  Here's some random clips from my code.   The Windows for my (modal) dialog
> are are created by:
>
> theWindow = [[NSWindow alloc]
> initWithContentRect:*(NSRect*)&platRect styleMask:winStyleMask  &~
> (NSClosableWindowMask | NSMiniaturizableWindowMask | NSResizableWindowMask)
> backing:NSBackingStoreRetained defer:YES];

You should basically never use any backing store type other than
NSBackingStoreBuffered. The other types exist for extremely
specialized uses and they don't play well with nearly anything. I
wouldn't be surprised if Cocoa controls assumed they were in a
buffered window and this was the cause of your problem.

I know that you're stuck doing it this way due to the nature of what
you're creating, but the reason you're finding the easy things hard is
because the easy way is to use IB. Although you probably can't use it
for what you're doing, some practice sessions with IB or some
compare-and-contrast between the objects IB produces and the objects
you're producing yourself would help reveal the problem in this sort
of situation.

Mike
___

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]


Re: Proxy Window of another

2008-05-03 Thread Jean-Daniel Dupas


Le 3 mai 08 à 23:45, Daniel Rampanelli a écrit :



Hi,
I was thinking wheter it is possible to create a sort of "proxy"  
window which displays the content of another. Of course, the further  
step would be to also pass events from the proxied window to the  
source one. Is this even possible?


Thanks in advance,
Daniel


Override the -[NSWindow  sendEvent:] method and pass the event  
parameter to the target window sendEvent: method.




___

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]


Re: Proxy Window of another

2008-05-03 Thread Jean-Daniel Dupas


Le 4 mai 08 à 00:30, Jean-Daniel Dupas a écrit :



Le 3 mai 08 à 23:45, Daniel Rampanelli a écrit :



Hi,
I was thinking wheter it is possible to create a sort of "proxy"  
window which displays the content of another. Of course, the  
further step would be to also pass events from the proxied window  
to the source one. Is this even possible?


Thanks in advance,
Daniel


Override the -[NSWindow  sendEvent:] method and pass the event  
parameter to the target window sendEvent: method.


Sorry, I miss the first part. I don't think you can copy the content  
of a Window into another one.  What are you trying to do ?


___

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]


List Running apps and windows

2008-05-03 Thread Jere Gmail
I want to list all the running apps and their windows.
Running apps is easy with [ws launchedApplications] but I cant find a
way for listing their windows.
I have tried NSWindowList(win_count,arr_win)  but then
[[NSApplication sharedApplication] windowWithWindowNumber:arr_win[i]]
in a bucle will give me no info on windows from other apps.
Can anyone help? Thanks

-- 
http://zon7blog.wordpress.com/
And again we fall.
___

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]


Re: Implementing fast enumeration

2008-05-03 Thread Ben


On 3 May 2008, at 02:43, Adam R. Maxwell wrote:



On May 2, 2008, at 12:18 PM, Ben wrote:


Re-sending as this did not seem to get make it to the list.

I have been reading the documentation for implementing the  
NSFastEnumeration protocol and am having some difficulties  
following it.


[...]

Apologies if these are basic questions, but I got decidedly lost  
trying to follow the docs.


I also got lost in the docs (I should file a bug one of these  
days).  Anyway, take a look at CFArray.c from Apple's CF source,  
specifically the _CFArrayFastEnumeration function.  Having that for  
an example really helped.


hth,
Adam


Thanks for that pointer, I'll spend some time digging through it. I  
also found your FVPriorityQueue code in the Bibdesk repository  
(mentioning it here to help others). Re-designing my class using a  
system closer to those two files looks like it will provide faster and  
neater code too.


Also it would appear that my original post has turned up a day late.  
Sorry about the extra noise.


Ben.
___

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]


Re: Newbie Question: Controls not redrawing on changes

2008-05-03 Thread Christopher Kempke
Thanks for the tip, but no go.  It actually makes the behavior worse:  
now the modal dialog is still drawn, but never becomes active (the  
title bar never gets dark, and the previously visible (document)  
window never deactivates, although the dialog is drawn on top), and  
the default button doesn't even turn blue.


--Christopher Kempke

On May 3, 2008, at 3:10 PM, Nathan Kinsinger wrote:


On May 3, 2008, at 3:42 PM, Christopher Kempke wrote:

Then I draw the window with:

[iWindow makeKeyAndOrderFront:nil];

And run it as a modal dialog with:

[NSApp runModalForWindow:iWindow];


The docs for runModalForWindow: explicitly say not to send  
makeKeyAndOrderFront: to the window. I'm guessing that the window is  
in the normal run loop and not the modal run loop.  
makeKeyAndOrderFront: will show the window and make it key.


--Nathan



___

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]


Re: List Running apps and windows

2008-05-03 Thread Steve Christensen

On May 3, 2008, at 3:52 PM, Jere Gmail wrote:


I want to list all the running apps and their windows.
Running apps is easy with [ws launchedApplications] but I cant find a
way for listing their windows.
I have tried NSWindowList(win_count,arr_win)  but then
[[NSApplication sharedApplication] windowWithWindowNumber:arr_win[i]]
in a bucle will give me no info on windows from other apps.
Can anyone help? Thanks


Each application has its own private address space, so including  
another app's windows in your app's window list doesn't make sense.  
The only way to find out about other app's windows is to have the  
user enable accessibility in System Preferences. This has already  
been discussed in detail here and on other lists. You might try doing  
a search to see what's already been said.


___

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]


Re: List Running apps and windows

2008-05-03 Thread Jean-Daniel Dupas


Le 4 mai 08 à 01:09, Steve Christensen a écrit :


On May 3, 2008, at 3:52 PM, Jere Gmail wrote:


I want to list all the running apps and their windows.
Running apps is easy with [ws launchedApplications] but I cant find a
way for listing their windows.
I have tried NSWindowList(win_count,arr_win)  but then
[[NSApplication sharedApplication] windowWithWindowNumber:arr_win[i]]
in a bucle will give me no info on windows from other apps.
Can anyone help? Thanks


Each application has its own private address space, so including  
another app's windows in your app's window list doesn't make sense.  
The only way to find out about other app's windows is to have the  
user enable accessibility in System Preferences. This has already  
been discussed in detail here and on other lists. You might try  
doing a search to see what's already been said.




In fact, this is no longer true on Leopard. Window are always in there  
own space, but you can list all windows and even create image for each  
window on screen.


http://developer.apple.com/samplecode/SonOfGrab/

And it make sense to inlude other app window in an a list, else tools  
like the GrabFS would not exists.


___

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]


Re: Proxy Window of another

2008-05-03 Thread Uli Kusterer

Am 03.05.2008 um 23:45 schrieb Daniel Rampanelli:
I was thinking wheter it is possible to create a sort of "proxy"  
window which displays the content of another. Of course, the further  
step would be to also pass events from the proxied window to the  
source one. Is this even possible?



 What are you trying to do?

 Usually, "content" translates to "model", "display" generally  
translates to "view", so according to the Model-View-Controller  
paradigm, you could create another instance of your controller that  
has its own copy of the views, but points at the same model, instead  
of forwarding events.


 That's one of the advantages of Cocoa's MVC design: If you separate  
the view and the model code, you can easily have several windows  
showing the same data. It's also more flexible than just duplicating a  
window and forwarding its contents, because it can be scrolled to a  
different location, can have a different toolbar collapse state, can  
be a different size etc.


Cheers,
-- Uli Kusterer
"The Witnesses of TeachText are everywhere..."
http://www.zathras.de





___

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]


Event loop in a secondary thread? Nibless Cocoa?

2008-05-03 Thread Bruce Sherwood
I'm new to (modern) Mac programming. There seem to be two major 
show-stoppers to what I need to do, and I'd be grateful to be told how 
to get around these seemingly impenetrable barriers. I posted a similar 
question on the carbon-dev list and got some useful advice, and now I'm 
asking the advice of the Cocoa community.


Visual is a 3D graphics module for Python; the combination is called 
VPython (see vpython.org). Visual, which is written in multithreaded 
C++, can be imported dynamically at any time in a Python program. Visual 
then has to start up an event loop to make a window and process events.


First, it appears impossible to start either a Cocoa or Carbon event 
loop from a secondary thread, which I think I need to do in the Visual 
situation. We're not building an application, we're building an 
importable module. (In tests we ran, we ran into similar problems with 
PyObjC.)


Second, I don't see any way to access a Nib file in this situation. I 
think my event loop has to be implemented in a nibless way. I'm not 
building a free-standing bundled application. After a fair amount of 
blood on the floor (since there is no or wrong or out-of-date 
documentation on how to do this with Carbon, and/or the things 
recommended turn out to be deprecated when tried), I did succeed in 
making a nibless Carbon proof of concept.


I found a series of articles on nibless Cocoa, but these articles assume 
far more knowledge than I currently have, and the scheme seems to depend 
on undocumented tricks and kludges that are unlikely to be stable:


http://lapcatsoftware.com/blog/2007/07/10/working-without-a-nib-part-5-open-recent-menu

Is there an approved way to work with Cocoa without a Nib file? Or 
equivalently is there a way to specify a location where the Nib file can 
be found? Visual won't be a bundled application, so presumably the Nib 
file won't be found in a standard place.


Bruce Sherwood

P.S. Until now the Mac version of Visual has been built on GTKmm and 
requires Fink and X11, which makes VPython difficult to install for 
nonexpert Mac users. We very much want a native-mode version of Visual.



___

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]


Re: Event loop in a secondary thread? Nibless Cocoa?

2008-05-03 Thread John C. Randolph


On May 3, 2008, at 4:35 PM, Bruce Sherwood wrote:

 We very much want a native-mode version of Visual.


If you want a native app, then don't fight the framework.  Rolling  
your own event system, and doing away with nib files is not a project  
for someone new to the platform, and once you have experience with  
Cocoa, you'll know better than to reinvent the wheel.


-jcr
___

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]


Re: Event loop in a secondary thread? Nibless Cocoa?

2008-05-03 Thread B.J. Buchalter


On May 3, 2008, at 9:55 PM, John C. Randolph wrote:



On May 3, 2008, at 4:35 PM, Bruce Sherwood wrote:

We very much want a native-mode version of Visual.


If you want a native app, then don't fight the framework.  Rolling  
your own event system, and doing away with nib files is not a  
project for someone new to the platform, and once you have  
experience with Cocoa, you'll know better than to reinvent the wheel.


That's not really a helpful response to his question. He is not trying  
to fight the framwork, but his code is something that is loaded by  
python -- he is not the shell app. So his requirements are a bit  
different that a standard app.


Not that I have any answers for him...

B.J. Buchalter
Metric Halo
http://www.mhlabs.com



___

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]


Re: Event loop in a secondary thread? Nibless Cocoa?

2008-05-03 Thread Bruce Sherwood
I couldn't agree more. But the issue is that I'm NOT building an 
application. I'm trying to build a Python module, to be imported 
dynamically by a running Python program. Here the app is Python, which 
processes a script (program) written by a user, which at some point 
imports the Visual module.


The primary thread is Python, executing statements in the user's script. 
Secondary threads are the GUI thread and an OpenGL rendering thread.


The way Visual works is that about 30 times per second a rendering 
thread runs, with the Python thread blocked, and a 3D OpenGL scene is 
rendered and handed to the graphics card to refresh the screen. Because 
the rendering uses the current attributes of objects in the scene, and 
the Python computational thread can continually update those attributes, 
the effect is that the user can concentrate on the calculations, and a 
real-time navigable 3D scene is created as a side effect of those 
calculations.


I SO want not to invent some new wheel! But I need advice on how to use 
existing wheels in the face of two seemingly forbidding challenges: How 
to run the GUI in a secondary thread, and how to dispense with a nib 
file (or be able to point to it in a non-standard, non-bundled location).


Bruce Sherwood

John C. Randolph wrote:


On May 3, 2008, at 4:35 PM, Bruce Sherwood wrote:

 We very much want a native-mode version of Visual.


If you want a native app, then don't fight the framework.  Rolling your 
own event system, and doing away with nib files is not a project for 
someone new to the platform, and once you have experience with Cocoa, 
you'll know better than to reinvent the wheel.


-jcr

___

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]


Re: Event loop in a secondary thread? Nibless Cocoa?

2008-05-03 Thread Jens Alfke


On 3 May '08, at 4:35 PM, Bruce Sherwood wrote:

Visual, which is written in multithreaded C++, can be imported  
dynamically at any time in a Python program. Visual then has to  
start up an event loop to make a window and process events.


Oh boy, this is a flashback. You've got the exact same issues we had  
when we brought up Java on OS X back in 2000. The process starts out  
GUI-less (just an invocation of /usr/bin/python, in your case) and has  
to acquire a windowserver connection, event loop, menus, all that stuff.


This is pretty tricky stuff, or it was back then, and we had the  
advantage of being able to use or create private APIs. But more of  
that stuff might be public now. (Wasn't there some discussion on this  
list recently of upgrading a command-line process to a GUI?)


IIRC, you don't have to start the event loop on the process's main  
thread, but whatever thread you create the WindowServer connection on  
becomes the de facto GUI thread, on which the main event loop will run.


I don't see any problem with loading nibs. You just have to find them  
— presumably you'd put them next to wherever you put your code.


—Jens

smime.p7s
Description: S/MIME cryptographic signature
___

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]

Re: Event loop in a secondary thread? Nibless Cocoa?

2008-05-03 Thread Bruce Sherwood
Thanks! I'm really glad to hear that this is a known problem, and that 
there are solutions, even if it is "pretty tricky stuff". Can you or 
someone else point me to a sample piece of code that could get me started?


Indeed, the nib file (if there is one) would be right next to the Visual 
module (in site-packages/visual). But initial reading of documentation, 
or at least of examples, made it look like you say something like 
"LoadNib", with no option to say where to get it, because the assumption 
is that the nib file is in a standard place in the app's bundle. Is 
there some kind of nib-loading procedure that takes a file location as 
an argument? I don't have anything against nib files in principle; I 
just don't know how to find them when my software isn't an app.


Bruce Sherwood

Jens Alfke wrote:


On 3 May '08, at 4:35 PM, Bruce Sherwood wrote:

Visual, which is written in multithreaded C++, can be imported 
dynamically at any time in a Python program. Visual then has to start 
up an event loop to make a window and process events.


Oh boy, this is a flashback. You've got the exact same issues we had 
when we brought up Java on OS X back in 2000. The process starts out 
GUI-less (just an invocation of /usr/bin/python, in your case) and has 
to acquire a windowserver connection, event loop, menus, all that stuff.


This is pretty tricky stuff, or it was back then, and we had the 
advantage of being able to use or create private APIs. But more of that 
stuff might be public now. (Wasn't there some discussion on this list 
recently of upgrading a command-line process to a GUI?)


IIRC, you don't have to start the event loop on the process's main 
thread, but whatever thread you create the WindowServer connection on 
becomes the de facto GUI thread, on which the main event loop will run.


I don't see any problem with loading nibs. You just have to find them — 
presumably you'd put them next to wherever you put your code.


—Jens

___

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]


Re: XML Attributes

2008-05-03 Thread Jens Alfke


On 3 May '08, at 1:43 PM, Mr. Gecko wrote:


NSXMLNode *nodes = [xml rootElement];
NSXMLNode *node = [[nodes childAtIndex:1] childAtIndex:0];
to get this
http://www.example.com/file1"; size="522656" name="File  
Number 1">
so now how do I get an attribute from it such as url, or name.  I  
saw in NSXMLElement documentation that it had an attribute thing but  
I can't figure out how to convert the node to NSXMLElement to get  
the attribute.


The nodes are elements. Change "NSXMLNode" to "NSXMLElement" in your  
code (adding a type-cast if necessary), and then call - 
attributeForName:.


If you want to learn XPath syntax (google it for lots of tutorials)  
you can do all of this stuff with one or two lines of code, using - 
nodesForXPath:error:; but XPath has its own learning curve.


—Jens

smime.p7s
Description: S/MIME cryptographic signature
___

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]

Re: Event loop in a secondary thread? Nibless Cocoa?

2008-05-03 Thread Jens Alfke


On 3 May '08, at 8:13 PM, Bruce Sherwood wrote:

Thanks! I'm really glad to hear that this is a known problem, and  
that there are solutions, even if it is "pretty tricky stuff". Can  
you or someone else point me to a sample piece of code that could  
get me started?


I'm not sure, actually. Check the last few weeks of list archives; I  
remember a thread whose subject was something relevant about promoting  
a command-line process.


Indeed, the nib file (if there is one) would be right next to the  
Visual module (in site-packages/visual). But initial reading of  
documentation, or at least of examples, made it look like you say  
something like "LoadNib", with no option to say where to get it,  
because the assumption is that the nib file is in a standard place  
in the app's bundle. Is there some kind of nib-loading procedure  
that takes a file location as an argument? I don't have anything  
against nib files in principle; I just don't know how to find them  
when my software isn't an app.


I can't speak for the Carbon nib APIs, but look at the NSBundle method
+ (BOOL)loadNibFile:(NSString *)fileName externalNameTable: 
(NSDictionary *)contextwithZone:(NSZone *)zone


The fileName parameter is an absolute path.

—Jens



smime.p7s
Description: S/MIME cryptographic signature
___

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]

Re: Event loop in a secondary thread? Nibless Cocoa?

2008-05-03 Thread Kyle Sluder
On Sat, May 3, 2008 at 11:13 PM, Bruce Sherwood <[EMAIL PROTECTED]> wrote:
>  Indeed, the nib file (if there is one) would be right next to the Visual
> module (in site-packages/visual). But initial reading of documentation, or
> at least of examples, made it look like you say something like "LoadNib",
> with no option to say where to get it, because the assumption is that the
> nib file is in a standard place in the app's bundle. Is there some kind of
> nib-loading procedure that takes a file location as an argument? I don't
> have anything against nib files in principle; I just don't know how to find
> them when my software isn't an app.

PyObjC has special support for nib files.  Not too familiar with it
myself, but look into PyObjCTools.NibClassBuilder.

--Kyle Sluder
___

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]


Re: Newbie Question: Controls not redrawing on changes

2008-05-03 Thread Kyle Sluder
On Sat, May 3, 2008 at 7:08 PM, Christopher Kempke
<[EMAIL PROTECTED]> wrote:
> Thanks for the tip, but no go.  It actually makes the behavior worse: now
> the modal dialog is still drawn, but never becomes active (the title bar
> never gets dark, and the previously visible (document) window never
> deactivates, although the dialog is drawn on top), and the default button
> doesn't even turn blue.

Take a look at -[NSPanel setWorksWhenModal:].  You should be using an
NSPanel, not an NSWindow, and must send it this message before doing
-[NSApplication runModalForWindow:].  Read this document, entitled
"How Modal Windows Work," for more information.
http://developer.apple.com/documentation/Cocoa/Conceptual/WinPanel/Concepts/UsingModalWindows.html#//apple_ref/doc/uid/2223

--Kyle Sluder
___

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]