Re: Cocoa Text System - Temporarily Disabling Layout

2010-09-26 Thread Jonathan Dann

On 24 Sep 2010, at 18:13, Ross Carter wrote:

 
 Yeah I have line numbers views set up in all of this too, for which I have 
 to set the width before I set the strings of the text views so you don't see 
 the views resizing on first load if the line numbers aren't wide enough to 
 accommodate the number of lines in the new string. Resizing the line numbers 
 shrinks the available width for the text views and then everything lays out 
 again.
 
 You might want to take a look at the WWDC 2010 session that Aki gave on Cocoa 
 text. He showed how to do line numbering by subclassing NSGlyphGenerator.

Thanks Ross. Implementing the line numbers isn't an issue per se, but another 
way of implementing them may be useful to me anyway.

Much appreciated,

Jonathan___

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 arch...@mail-archive.com


Re: Cocoa Text System - Temporarily Disabling Layout

2010-09-26 Thread Jonathan Dann

On 24 Sep 2010, at 19:59, Martin Wierschin wrote:

 when I resize the window and need to adjust the frames of both scroll 
 views, calling -[NSTextView setFrame:] results in the layout manager 
 invalidating and ensuring layout for the newly visible character range.
 
 Why not just turn off text view width/height tracking for the container 
 during the resize? That should let the layout manager use the existing 
 layout information (ie: for the stale container size).
 
 Because that's just moving the problem further down the line. When I finally 
 update the text container size for the first text view it will begin to 
 layout before I've reached the next line of my code where I can fix the size 
 of the second view.
 
 My next suggestion would be to subclass NSLayoutManager and override methods 
 that handle invalidation, eg:
 
   - (void) textContainerChangedGeometry:(NSTextContainer*)tc ;
   - (void) invalidateLayoutForCharacterRange:(NSRange)charRng 
 isSoft:(BOOL)isSoft actualCharacterRange:(NSRange*)charRngPtr ;
   - (void) invalidateLayoutForCharacterRange:(NSRange)charRng 
 actualCharacterRange:(NSRange*)charRngPtr ;
 
 When your resize starts, set some flag on your subclass that makes all those 
 methods no-ops. When you've finished resizing both text systems, clear your 
 flag and re-invalidate as necessary.

I'll take another look at this, I seem to remember finding some layout 
backtrace that bypassed these, but it's been a long time so I'm probably 
mistaken.

 But really, I might ask you why your own code is so delicate that it needs 
 both layout systems to be in some perfectly matched state at all times. 
 Surely your code could have a flag that tells it layout is not yet synced up, 
 and ancillary tasks should be avoided/delayed until a stable state is 
 established.

Always a good question. In Kaleidoscope (one way) we display the diff between 
two text views by creating gaps (by offsetting the proposed line fragment rects 
for specific lines) in the other text view. For example, a deleted line would 
cause a gap in the text view on the right, and an inserted line causes a a gap 
in the text view on the left. The equal lines are then positioned at the same 
y-ordinate in each text view. This requires (when considering wrapped text) the 
text views to be the same width. When resizing, the I have to account for odd 
or even window widths (not in itself a problem) but also support the cases 
where the text views are scrolled to the top such that they layout their 
strings while resizing, and when the text system delays relayout (when scrolled 
far down) until the views aren't resizing any more. Therefore to layout out 
line x in the left text view all lines above x in the right text view also need 
to be laid out so I can know whether, and how much, to increase the y-origin of 
line x by.

What will make this easier is to have, as you rightly suggest some flag so I 
can better control when to/not to layout. The problem, since the text system 
tries to layout upon resizing the text view in a lot of cases, is finding all 
the right places to put this flag.

 
 The other state change you explicitly touch upon is editing the text. If 
 you bracket all your changes to the text storage with begin/end editing 
 calls, you shouldn't trigger layout until all your changes are finished 
 (unless you're also inadvertently triggering layout in other ways).
 
 I'll see how that fits in with setting the 2 strings that are dependent on 
 each other. It may be a nice workaround.
 
 Just be careful that you don't trigger layout while the text storage has an 
 edit open, eg:
 
   [textStorage beginEditing];
   [textStorage deleteCharactersInRange:someRange];
   [layoutManager ensureLayoutForCharacterRange:NSMakeRange(0, 
 [textStorage length])];
   [textStorage endEditing];
 
 The layout system isn't tolerant of that. It used to just throw out-of-bounds 
 exceptions, though now it seems to give you exceptions with nice explanations 
 of what you've done wrong.

That's a good one to keep an eye out for.

Thank you very much. I really appreciate having some fresh eyes on the problem.

Jonathan

___

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 arch...@mail-archive.com


Re: Cocoa Text System - Temporarily Disabling Layout

2010-09-26 Thread Jonathan Dann

On 25 Sep 2010, at 01:23, Douglas Davidson wrote:

 
 On Sep 23, 2010, at 7:54 AM, Jonathan Dann wrote:
 
 In our app, Kaleidoscope, I have 2 text views side-by-side. In one 
 configuration the layout of the text in each text view is dependent both on 
 regions of layout in the sibling text view, and the model objects which 
 represent the the insert, equal and deleted regions of the diff.
 
 The problem I've had to continuously hack around is that NSTextView, in 
 conjunction with NSLayoutManager, is rather eager to get the text to 
 re-layout. For example, when I resize the window and need to adjust the 
 frames of both scroll views, calling -[NSTextView setFrame:] results in the 
 layout manager invalidating and ensuring layout for the newly visible 
 character range.
 
 I'd like to know if anybody has had any experience/luck with completely 
 disabling the automatic layout that the text system does in response to 
 these changes in state?
 
 You can look at the source to TextEdit for an example of removing the layout 
 manager(s) from the text storage and then re-adding them, to prevent layout 
 from occurring for a certain period.  This would probably not be appropriate 
 if you want to retain any layout information across this transition, but if 
 all the text needs to be laid out again anyway, it could be useful.
 
 Douglas Davidson

Thanks Douglas,

This sounds really promising, I'll have a go this week :)

I really appreciate your input.

Jonathan

(Reposted as I forgot to hit reply-all, 
sorry.)___

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 arch...@mail-archive.com


Re: Cocoa Text System - Temporarily Disabling Layout

2010-09-24 Thread Jonathan Dann

On 23 Sep 2010, at 23:12, Ross Carter wrote:

 Maybe, to disable layout, set the textview's textContainer to nil, then 
 restore it to enable layout?

Hi Ross,

I'll give it a go. I think tricks like that may help in some of the cases I 
have.

Thanks,

Jon

___

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 arch...@mail-archive.com


Re: Cocoa Text System - Temporarily Disabling Layout

2010-09-24 Thread Jonathan Dann

On 23 Sep 2010, at 23:46, Martin Wierschin wrote:

 The problem I've had to continuously hack around is that NSTextView, in 
 conjunction with NSLayoutManager, is rather eager to get the text to 
 re-layout.
 
 Maybe, to disable layout, set the textview's textContainer to nil, then 
 restore it to enable layout?
 
 That's one idea, though I wouldn't be surprised if other things go weird as a 
 result.
 
 Personally I'd try to work with the text system in a way it expects. For 
 example:
 
 when I resize the window and need to adjust the frames of both scroll 
 views, calling -[NSTextView setFrame:] results in the layout manager 
 invalidating and ensuring layout for the newly visible character range.
 
 Why not just turn off text view width/height tracking for the container 
 during the resize? That should let the layout manager use the existing layout 
 information (ie: for the stale container size).

Because that's just moving the problem further down the line. When I finally 
update the text container size for the first text view it will begin to layout 
before I've reached the next line of my code where I can fix the size of the 
second view.

The hacky fix for such things is to force the text views (or containers) to be 
the same size in the first call -[NSLayoutManager layoutParagraphAtPoint] or 
something thereabouts, but the underlying problem (the automatic layout) keeps 
rearing it's ugly head in other situations.

 
 The other state change you explicitly touch upon is editing the text. If 
 you bracket all your changes to the text storage with begin/end editing 
 calls, you shouldn't trigger layout until all your changes are finished 
 (unless you're also inadvertently triggering layout in other ways).

I'll see how that fits in with setting the 2 strings that are dependent on each 
other. It may be a nice workaround.

 
 Are there any other scenarios where you trigger layout before you're ready?

Yeah I have line numbers views set up in all of this too, for which I have to 
set the width before I set the strings of the text views so you don't see the 
views resizing on first load if the line numbers aren't wide enough to 
accommodate the number of lines in the new string. Resizing the line numbers 
shrinks the available width for the text views and then everything lays out 
again.

It's, all in all, a very complex setup :)

Thanks,

Jonathan

___

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 arch...@mail-archive.com


Cocoa Text System - Temporarily Disabling Layout

2010-09-23 Thread Jonathan Dann
Hi all,

In our app, Kaleidoscope, I have 2 text views side-by-side. In one 
configuration the layout of the text in each text view is dependent both on 
regions of layout in the sibling text view, and the model objects which 
represent the the insert, equal and deleted regions of the diff.

The problem I've had to continuously hack around is that NSTextView, in 
conjunction with NSLayoutManager, is rather eager to get the text to re-layout. 
For example, when I resize the window and need to adjust the frames of both 
scroll views, calling -[NSTextView setFrame:] results in the layout manager 
invalidating and ensuring layout for the newly visible character range.

I'd like to know if anybody has had any experience/luck with completely 
disabling the automatic layout that the text system does in response to these 
changes in state?

In psuedocode, I'd like to be able to:

[(textViewA or layoutManagerA) disableLayout]
[(textViewB or layoutManagerB) disableLayout]

// set frames, strings, and other state the text views need in order to 
re-layout correctly

[(textViewA or layoutManagerA) enableLayout] // note that this doesn't *cause* 
layout.
[(textViewB or layoutManagerB) enableLayout]

[(textViewA or layoutManagerA) performLayout] // this may result in layout in 
textViewB
[(textViewB or layoutManagerB) performLayout] // just for completeness

If there's any combination of layout manager and text view methods to override 
and return nil, 0, NSZeroRect etc., while I set up all the state that would be 
great. Obviously, -[NSLayoutManager setAllowsBackgroundLayout:] is a no-go as 
that only governs if the text system will layout when the run loop is idle. My 
problems stem from the synchronous layout the text system performs, because, 
from the perspective of layout, it was designed to exist in isolation.

Thanks,

Jonathan___

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 arch...@mail-archive.com


Re: cool way to call super?

2010-09-23 Thread Jonathan Dann

On 23 Sep 2010, at 16:45, Matt Neuburg wrote:

 Is there a cool dynamic Cocoa way to call super with the same parameters
 that came to me? I guess what I'm looking for is a pre-configured invocation
 of the current command where I can just change the target to super. No big
 deal, but I just wondered, since Cocoa is cool and dynamic. m.

No, but you can easily write an NSProxy subclass that doesn't invoke the 
method, but returns you the runtime-generated NSInvocation by reference. i.e

NSInvocation *invocation;
[[object invocationProxy:invocation] 
do:thing:with:any:number:of:args:you:want:];

Then get the objc_super struct using the invocation's target and its class and 
use libffi (http://sourceware.org/libffi/) to construct the argument list from 
the invocation and call objc_msgSendSuper() yourself.

Maybe.

I've not done the latter part, but I'm sure it would be possible. I feel a 
weekend project coming on.

Jonathan___

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 arch...@mail-archive.com


Re: Constructive Criticism

2009-10-07 Thread Jonathan Dann




- (id) init {
if(self == [super init]){
Year = 0;
orignalYear = 0;
}
return (self);
}


In addition to the other comments regarding calling super, you don't  
need to initialize instance variables to values like 0, 0.0, NO, nil,  
NULL. The runtime will do that for you. Note, that it doesn't do the  
same for local variables.


Jonathan

http://madebysofa.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 arch...@mail-archive.com


Re: Newbie query re multithreading

2009-08-18 Thread Jonathan Dann
FWIW you can't always be sure that NSOperationQueue will be using a  
thread per operation. The number of active operations (I explicitly  
don't say threads here) depends on system contention.  Are your  
operations dependent on each other or using shared resources?  Are you  
setting -[NSOperationQueue maxConcurrentOperationCount:] ? If each  
operation is independent then simply throw as many as you like at the  
queue without setting the maxConcurrentOperationCount.


You may even find that NSOperationQueue/NSOperation allows you to  
split up your calculations into smaller chunks than 1 per CPU (or  
effective cores).


Can you post some example code that can shed some more light on what  
you're doing?


Jonathan

http://madebysofa.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 arch...@mail-archive.com


Re: Making NSTextView not wrap lines

2009-07-30 Thread Jonathan Dann

From the archives:

http://www.cocoabuilder.com/archive/message/cocoa/2008/5/23/207981

On 28 Jul 2009, at 18:11, Peter Mulholland wrote:


Hello cocoa-dev,

Basically, i'm trying to do a little debug console. I'm using the  
NSTextView in NSScrollView from Interface Builder.


I've got a Print member in my window's controller class which  
basically does:


[TextView setString:[[TextView string]  
stringByAppendingString:newString]];


What I want is for the horizontal size of the NSTextView part to  
expand to the length of the string. I'm guessing NSTextView already  
knows about \n and how to make a suitable rectangular area out of a  
string.


I've set the Text View portion to be horizontally and vertically  
resizeable. I've also made sure it's only autosizing vertically, so  
that the Scroll View will show a horizontal scroll bar.


By default, it doesnt work. I add text with Print, and it always  
wraps. If I size my window (which resizes the ScrollView) wide  
enough, the text goes onto one line. When i size it smaller, the  
horizontal scroll bar appears as expected.


I have tried calling sizeToFit after the setString, but it doesn't  
do anything.


This is probably a really simple job, but i'm out of ideas! I'm just  
starting with Cocoa, really.


--
Best regards,
Peter  mailto:darkmat...@blueyonder.co.uk

___

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/j.p.dann%40gmail.com

This email sent to j.p.d...@gmail.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 arch...@mail-archive.com


Re: Persistent store removal throwing invalidated NSManagedObject exceptions

2009-04-01 Thread Jonathan Dann


On 1 Apr 2009, at 11:20, Drew McCormack wrote:

I've setup a temporary managed object context to export data to an  
external XML file (persistent store). When I remove the persistent  
store from the context, I am getting errors like this:




[...]

This has been included to remove the object as a KVO observer, and  
refresh a lazy property, but actually, the notification also arises  
when I just use this


-(void)removeCollectionsObject:(KnowledgeCollection *)anObject {
   [self willChangeValueForKey:@collections];
   [[self primitiveValueForKey:@collections] removeObject:anObject];
   [self didChangeValueForKey:@collections];
}

If I remove the method altogether, the exception does not get raised.

So I'm confused, because I would have thought that the implementation
above would be pretty much the same as what Core Data would do  
internally if the method is not included. Apparently it is doing  
other things to

avoid the exception, but what?


Hi Drew,

When writing a custom to-many accessor in an NSManagedObject subclass,  
you need to invoke the correct KVO -will/didChange methods


These are:

-[NSManagedObject willChangeValueForKey:withSetMutation:usingObjects:]
-[NSManagedObject didChangeValueForKey:withSetMutation:usingObjects:]

So your method should change to:

-(void)removeCollectionsObject:(KnowledgeCollection *)anObject {
   NSSet *removedObjects = [[NSSet alloc] initWithObjects:anObject  
count:1];
   [self willChangeValueForKey:@collections  
withSetMutation:NSKeyValueMinusSetMutation usingObjects:removedObjects];

   [[self primitiveValueForKey:@collections] removeObject:anObject];
   [self didChangeValueForKey:@collections  
withSetMutation:NSKeyValueMinusSetMutation usingObjects:removedObjects];

   [removedObjects release];
}

Hope this helps, there's a full example in the programming guide:

http://developer.apple.com/DOCUMENTATION/Cocoa/Conceptual/CoreData/Articles/cdAccessorMethods.html#/ 
/apple_ref/doc/uid/TP40002154-SW6


Jonathan

http://espresso-served-here.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 arch...@mail-archive.com


Re: Persistent store removal throwing invalidated NSManagedObject exceptions

2009-04-01 Thread Jonathan Dann

Thanks Jonathan. You're absolutely right.

However, when I made the appropriate changes, I have the same issue:  
with my new custom remove... accessor, I get the exception, and  
without the custom accessor, there is no exception. So something  
strange is still going on.


Here is the new accessor for good measure:

-(void)removeCollectionsObject:(KnowledgeCollection *)anObject {
NSSet *removedObjects = [[NSSet alloc] initWithObjects:anObject  
count:1];
[self willChangeValueForKey:@collections  
withSetMutation:NSKeyValueMinusSetMutation  
usingObjects:removedObjects];
[[self primitiveValueForKey:@collections]  
removeObject:anObject];
[self didChangeValueForKey:@collections  
withSetMutation:NSKeyValueMinusSetMutation  
usingObjects:removedObjects];

[removedObjects release];
}

Drew


Have you tried declaring your own -primitiveCollections and - 
setPrimitiveCollections: methods like in the example code (not that  
I'm sure that's the issue at all.


Can you post more of your model so I can get the bigger picture,  
please? Particularly how the CollectionGroup managed object fits in.


Jonathan

http://espresso-served-here.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 arch...@mail-archive.com


Re: Moving a window offscreen

2009-03-07 Thread Jonathan Dann


On 7 Mar 2009, at 05:50, Michael Ash wrote:

On Fri, Mar 6, 2009 at 1:38 PM, Jonathan Dann j.p.d...@gmail.com  
wrote:

Hi All,

In my application I want to create an image of a document window as a
preview prior to displaying the window to the user. To obtain the  
CGImage of
a displayed window is simple enough using the CGWindow API as shown  
below:


- (CGImageRef)CGImage;
{
   return CGWindowListCreateImage(CGRectNull,
kCGWindowListOptionIncludingWindow, [self windowNumber],
kCGWindowImageDefault);
}

The problem comes when trying to display the window initially at a  
far-off
position so I can create the image and the move the window onto the  
screen.


Setting the origin of the window to a point with large +ve or -ve  
ordinates
causes the window to appear at the edge of the main screen, partly  
shown.


Has anybody any experience with either a) rendering an entire  
window into a

bitmap instead of to the screen, or b) moving the window offscreen
completely? If b) is possible, would the above code work for such a  
window?


If you create the window with the defer flag set to NO, then the
NSWindow object will get a window server window even when it's not
actually ordered onto the screen. I *believe* that you will then be
able to capture it without ever displaying it so that it's visible to
the user, simply by not sending it an orderFront: or any similar
message.

As an alternative, use -dataWithPDFInsideRect: to generate an image.
This technique tends to be rather slow, though.

Mike



Thanks Mike,

I'll give that a go and let you know. I may run into an issue with all  
the views not being added and positioned in the window properly as  
I've loading my view from nib using view controllers. We'll see!


Appreciate it,

Jonathan

http://espresso-served-here.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 arch...@mail-archive.com


Re: Moving a window offscreen

2009-03-07 Thread Jonathan Dann

On 7 Mar 2009, at 10:20, Jean-Daniel Dupas wrote:



Le 7 mars 09 à 05:50, Michael Ash a écrit :

On Fri, Mar 6, 2009 at 1:38 PM, Jonathan Dann j.p.d...@gmail.com  
wrote:

Hi All,

In my application I want to create an image of a document window  
as a
preview prior to displaying the window to the user. To obtain the  
CGImage of
a displayed window is simple enough using the CGWindow API as  
shown below:


- (CGImageRef)CGImage;
{
  return CGWindowListCreateImage(CGRectNull,
kCGWindowListOptionIncludingWindow, [self windowNumber],
kCGWindowImageDefault);
}

The problem comes when trying to display the window initially at a  
far-off
position so I can create the image and the move the window onto  
the screen.


Setting the origin of the window to a point with large +ve or -ve  
ordinates
causes the window to appear at the edge of the main screen, partly  
shown.


Has anybody any experience with either a) rendering an entire  
window into a

bitmap instead of to the screen, or b) moving the window offscreen
completely? If b) is possible, would the above code work for such  
a window?


If you create the window with the defer flag set to NO, then the
NSWindow object will get a window server window even when it's not
actually ordered onto the screen. I *believe* that you will then be
able to capture it without ever displaying it so that it's visible to
the user, simply by not sending it an orderFront: or any similar
message.

As an alternative, use -dataWithPDFInsideRect: to generate an image.
This technique tends to be rather slow, though.



Has this technic some benefit over locking focus on the window  
content view and using  - [NSBitmapImageRep  
initWithFocusedViewRect:] ?



If I locked focus on the content view, I'm not sure I'd get the title  
bar too. Am I wrong in thinking this?


Thanks for your time,

Jonathan

http://espresso-served-here.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 arch...@mail-archive.com


Re: Moving a window offscreen

2009-03-07 Thread Jonathan Dann


On 7 Mar 2009, at 11:14, Paul Sanders wrote:


Which technique?  The Quartz technique will get you the full window,
including the titlebar.  The -dataWithPDFInsideRect: gets you PDF  
data
instead of a bitmap.  Neither of which is advantageous when you  
want a

bitmap image of the contents of a window.


If you are using Core Animation, you might try setting the opacity  
of the
window's layer to 0.  (Forgive me is this is complete rubbish as I  
only have

a vague idea of what I am talking about).



No problem! Thanks for taking the time to suggest something.

Unfortunately my window isn't layer-backed or layer-hosting. If it  
were, then trying to capture any bitmap data would likely respect the  
opacity setting and I'd get a transparent image.


All suggestions are appreciated though, thanks.

Jonathan

http://espresso-served-here.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 arch...@mail-archive.com


Re: Moving a window offscreen

2009-03-07 Thread Jonathan Dann


On 7 Mar 2009, at 11:00, Kyle Sluder wrote:


On Sat, Mar 7, 2009 at 4:20 AM, Jean-Daniel Dupas
devli...@shadowlab.org wrote:
Has this technic some benefit over locking focus on the window  
content view

and using  - [NSBitmapImageRep initWithFocusedViewRect:] ?


Which technique?  The Quartz technique will get you the full window,
including the titlebar.  The -dataWithPDFInsideRect: gets you PDF data
instead of a bitmap.  Neither of which is advantageous when you want a
bitmap image of the contents of a window.

--Kyle Sluder



Yeah I really need the title bar too.

Thanks Kyle,

Jonathan

http://espresso-served-here.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 arch...@mail-archive.com


Re: Moving a window offscreen

2009-03-07 Thread Jonathan Dann


On 7 Mar 2009, at 12:20, Jean-Daniel Dupas wrote:



Le 7 mars 09 à 12:11, Jonathan Dann a écrit :


On 7 Mar 2009, at 10:20, Jean-Daniel Dupas wrote:



Le 7 mars 09 à 05:50, Michael Ash a écrit :

On Fri, Mar 6, 2009 at 1:38 PM, Jonathan Dann  
j.p.d...@gmail.com wrote:

Hi All,

In my application I want to create an image of a document window  
as a
preview prior to displaying the window to the user. To obtain  
the CGImage of
a displayed window is simple enough using the CGWindow API as  
shown below:


- (CGImageRef)CGImage;
{
return CGWindowListCreateImage(CGRectNull,
kCGWindowListOptionIncludingWindow, [self windowNumber],
kCGWindowImageDefault);
}

The problem comes when trying to display the window initially at  
a far-off
position so I can create the image and the move the window onto  
the screen.


Setting the origin of the window to a point with large +ve or - 
ve ordinates
causes the window to appear at the edge of the main screen,  
partly shown.


Has anybody any experience with either a) rendering an entire  
window into a

bitmap instead of to the screen, or b) moving the window offscreen
completely? If b) is possible, would the above code work for  
such a window?


If you create the window with the defer flag set to NO, then the
NSWindow object will get a window server window even when it's not
actually ordered onto the screen. I *believe* that you will then be
able to capture it without ever displaying it so that it's  
visible to

the user, simply by not sending it an orderFront: or any similar
message.

As an alternative, use -dataWithPDFInsideRect: to generate an  
image.

This technique tends to be rather slow, though.



Has this technic some benefit over locking focus on the window  
content view and using  - [NSBitmapImageRep  
initWithFocusedViewRect:] ?



If I locked focus on the content view, I'm not sure I'd get the  
title bar too. Am I wrong in thinking this?


Thanks for your time,

Jonathan


No, you won't. That's the draw back, but my question was more about  
the pro of using dataWithPDFInsideRect: to generate an image instead  
of [NSBitmapImageRep initWithFocusedViewRect:].


I get you, for me I need to then draw the window image into a CALayer,  
so I'd have to create a CGImage from the PDF data. I don't know how  
quick it would be. For me speed isn't really an issue as long at it  
works and I can get the whole window.


Thanks,

Jonathan

http://espresso-served-here.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 arch...@mail-archive.com


Moving a window offscreen

2009-03-06 Thread Jonathan Dann

Hi All,

In my application I want to create an image of a document window as a  
preview prior to displaying the window to the user. To obtain the  
CGImage of a displayed window is simple enough using the CGWindow API  
as shown below:


- (CGImageRef)CGImage;
{
	return CGWindowListCreateImage(CGRectNull,  
kCGWindowListOptionIncludingWindow, [self windowNumber],  
kCGWindowImageDefault);

}

The problem comes when trying to display the window initially at a far- 
off position so I can create the image and the move the window onto  
the screen.


Setting the origin of the window to a point with large +ve or -ve  
ordinates causes the window to appear at the edge of the main screen,  
partly shown.


Has anybody any experience with either a) rendering an entire window  
into a bitmap instead of to the screen, or b) moving the window  
offscreen completely? If b) is possible, would the above code work for  
such a window?


Thanks for your help,

Jonathan

http://espresso-served-here.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 arch...@mail-archive.com


Re: CGPoint wrapper?

2008-10-23 Thread Jonathan Dann
If you're targeting Leopard then you can use the NS_BUILD_32_LIKE_64  
flag and use NSRect/Point/Size and CGRect/Point/Size interchangeably  
without the cast or the inline conversion functions. Here's a how-to http://theocacao.com/document.page/552


Jonathan

http://espresso-served-here.com

On 23 Oct 2008, at 09:06, Ken Ferry wrote:


On Wed, Oct 22, 2008 at 9:09 PM, Graff [EMAIL PROTECTED] wrote:


On Oct 22, 2008, at 5:49 PM, DKJ wrote:

Is there some straightforward way of wrapping a CGPoint so I can put
it in an NSArray? I don't want to use a C array because I want to  
have
fast enumeration available. Or should I just write a simple  
NSPoint -

CGPoint conversion method?



NSPoint and CGPoint are structs that are essentially the same.  You  
can

convert between them with a simple cast:

NSPoint point = *(NSPoint *)myCGPoint;


http://developer.apple.com/documentation/Cocoa/Conceptual/CocoaDrawingGuide/QuartzOpenGL/chapter_10_section_2.html





You can also use the function NSPointFromCGPoint() which does the  
exact

same thing for you:

NSPoint point = NSPointFromCGPoint(myCGPoint);

(Declared in NSGeometry.h)



The function is actually implemented a bit better than the cast  
above, in

that the function does not violate strict aliasing[1].

-Ken

[1]:
http://www.cellperformance.com/mike_acton/2006/06/understanding_strict_aliasing.html
___

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/j.p.dann%40gmail.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/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Using Core Animation to animate view properties?

2008-10-23 Thread Jonathan Dann

Hi Jim,

I've been having major problems with working with non-layer-baked  
views to coordinate the animation of their positions.  Some of the  
caveats I've come across (note that I haven't used -setWantsLayer: on  
any of the views as it's unnecessary for animating the frame of an  
NSView with the -animator proxy):


1) Using -setWantsLayer: on a custom view can cause problems if you  
set it to YES in -initWithFrame: and then later create the view in IB,  
which by default sets it to NO after -initWithFrame: and just before  
you get an -awakeFromNib.


2) If you call [[self animator] setFrame:newFrame]; and then ask the  
view for it's frame, you DON'T get the toValue as one would be used to  
after using CALayers. This makes co-ordination of views very  
difficult. The value you get is the fromValue.


3) From what I've found, calling [[self animationForKey:@frameOrigin/ 
Size] setDelegate:self]; will cause you to receive - 
animationDidStop:finished: calls from a *bunch* of CABasicAnimation  
objects, none of which are the same object you got from - 
animationForKey:.


3)a) As soon as you set viewA as the delegate of an animation, and  
then do the same for viewB, viewA will no longer get the delegate calls.


5) I haven't found a way to detect an in-flight animation, if you  
solve it, please let me know as it would make life a lot easier for me.


If you (or anyone else) disagrees with me on these points, I'd love to  
hear from you. I've been battling with this for a while now.


Jonathan

http://espresso-served-here.com

On 22 Oct 2008, at 20:13, Jim Correia wrote:


On Oct 22, 2008, at 12:54 PM, Matt Long wrote:

1. If you want to know whether an animation is still running, just  
check to see if it is still in the animations dictionary in the  
layer. A call like this would do it:


[...]

How you apply this to view properties, I'm not sure, but this is  
how you do these things with layers. Hope that helps.


I'm trying to animation a non-layer *view* property. My view isn't  
actually layer backed.


I'm still curious how to detect an in-flight animation.

The documentation suggests I can abort the in-flight animation by  
setting the target value inside of a zero duration animation  
context. This isn't working in my sample app. After I review the  
code, I'll post a link to it here.


Jim

___

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/j.p.dann%40gmail.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/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Semi-transparent, blurred NSWindow background?

2008-08-26 Thread Jonathan Dann


On 26 Aug 2008, at 00:52, Graham Cox wrote:



On 26 Aug 2008, at 8:00 am, Jonathan Dann wrote:

Using the private APIs / the method that Rob showed is perfectly  
fast.


I'd really like this made easier too, so I filed an enhancement  
request rdar://6174287



Is it possible to file a de-enhancement request? ;-)



Nice, I usually resist writing LOL, but that did make me LOL!

Am I the only one mystified by the attraction of this particular  
effect? It burns CPU/GPU time like there's no tomorrow for no  
apparent benefit to the usability of the UI. The original idea of  
semi-transparent windows seems a good one - you can still read some  
of the content behind which can enhance usability when you need a  
quick reminder of what's there without having to activate the  
window. For example there are times when you have no choice but to  
retype something you can see in one window and enter it in a field  
in another (admittedly these times have got a lot rarer with static  
text being often selectable/copyable, but it still happens).


With blurring, the ability to do that has been wiped out in a lot of  
cases. Why? What's the metaphor for a blurring window? Frosted  
glass? How many windows in the real world use frosted glass? Not  
many in proportion to transparent glass, that's for sure. When I  
first saw Vista I chuckled at the widespread use of the blurring  
effect because it seemed like those guys had introduced some  
gratuitous eye-candy without getting in any way why they'd done it.  
I was sorry to see that the joke was on us in Leopard. Leopard's  
blurring is subtler than Vista's, so let's be grateful for small  
mercies - but I do think we ought to be debating why we have this at  
all.


A public API for this would mean that every man and his dog will be  
adding blurring because it's cool without thinking about what it  
*means*. It's going to be the brushed metal of the next few OS revs  
I fear.




I know what you mean.  It's a very fine line to tread when working on  
a GUI app, but I'm not convinced that *absolutely* everything has to  
mean something, just the overwhelming majority.  I think in this case  
its one of those things that does add a nice touch to the UI, if used  
very sparingly.  In the case of a contextual menu I think that  
transparency would be wrong as the user is trying to read the menu  
text and too much of the masked (for example) text view below would be  
distracting.  I quite like the subtlety of the blurring, and come to  
think of it, it may imply that the view that blurs is a transient  
one.  I don't keep menus open for long enough for the CPU usage to be  
an issue, and I don't think many would.


As always, I'm open to a rebuke! :)

Take care,

Jonathan

http://espresso-served-here.com

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: Semi-transparent, blurred NSWindow background?

2008-08-25 Thread Jonathan Dann


On 25 Aug 2008, at 16:58, Tim Andersson wrote:



24 aug 2008 kl. 23.20 skrev Jonathan Dann:



On 24 Aug 2008, at 17:45, Tim Andersson wrote:

YMMV but I'd start with a window as shown in this sample code

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

and then replace the view with a custom view, and apply a CI filter  
as shown here


http://www.kickingbear.com/blog/?m=200803

Hope this helps, let me know how you get on if that's ok?

Jonathan

http://espresso-served-here.com


I'm not getting on very well.. I don't understand how I'm supposed  
to apply the CIFilter to my custom view. What is the concept of  
applying the filter? For example, the concept of applying a CIFilter  
to a CIImage is roughly: Create a CIContext which will draw the  
image, create an CIImage, apply the CIFilter and draw the image  
using the CIContext.


Many thanks,
Tim Andersson



That sounds right to me.

It seems that you will have to make a transparent custom view and a  
transparent window.  From there you make the view the content view of  
your transparent window.  When it comes to drawing your transparent  
view you need to draw into CGLayers.  As demonstrated in the sample  
code on http://www.kickingbear.com/blog/?m=200803 draw your view first  
into a GCLayer, see -lockFocusOnViewLayer.  Then lock focus on your  
own custom view's mask layer and fill the bounds of your view with  
[NSColor whiteColor].  Then you have the job of post processing what  
you just filled (the mask image).


The steps in the application of a CIIFilter to an image are described  
here:


http://developer.apple.com/documentation/GraphicsImaging/Conceptual/CoreImaging/ci_tasks/chapter_3_section_5.html#/ 
/apple_ref/doc/uid/TP30001185-CH203-BAJDDCEE


which I won't re-hash 'cos I'm not confident enough with CoreImage not  
to butcher it.  But have a look at the sample code on the kickingbear  
blog, the application is carried out in the -[KBPostProcessedTableView  
applyPostProcess] methods.  Which creates a CIFilter with  
CIBlendWithMask, and draws the output image into a CIContext.


Hope that's a little clearer.

Jonathan

http://espresso-served-here.com



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: Semi-transparent, blurred NSWindow background?

2008-08-25 Thread Jonathan Dann


On 25 Aug 2008, at 21:51, Seth Willits wrote:


On Aug 25, 2008, at 1:33 PM, Ricky Sharp wrote:

There isn't a particularly fast way to do this, although I have  
experimented with it a bit in the past. You can use the CGWindow  
API to read the contents under your window and apply a blur to  
them using Core Image directly or indirectly via Core Animation,  
but in either case you'll see the Window Server spending  
considerably more CPU time as it has to re-render the contents  
under your window. You could fake it by updating the image rarely  
but there isn't a particularly good way to completely mitigate the  
CPU usage.


Hmm... it's very hard to tell, but I believe there must be a fast  
way that already exists.


I'm sure he meant a fast *public* way to do it.

Using the private APIs / the method that Rob showed is perfectly fast.


I'd really like this made easier too, so I filed an enhancement  
request rdar://6174287


Jonathan

http://espresso-served-here.com



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: UTI Example

2008-08-23 Thread Jonathan Dann

Reposted due to 25KB size limit. Sorry.

On 23 Aug 2008, at 06:42, Adam Thorsen wrote:
Are there any examples of using the UTI API to determine the UTI  
given a path to a file?


Thanks,
-Adam


In my app I have a singleton UTI controller class that has an NSArray  
property of UTIs supported by my application.  There's also a  
dictionary that maps the Core Data entities that I use to represent  
each file type at runtime.  Here are the methods of my UTI controller,  
hope they help. I've replaced most of the string constants with  
external declarations already but a couple are still constant  
strings.  They show how to use -[NSWorkspace type:conformsToType:] and  
-[NSWorkspace typeOfFile:error:]


As for your info.plist file, and exported and imported declarations,  
there's a good article here:


http://developer.apple.com/documentation/Carbon/Conceptual/understanding_utis/understand_utis_conc/chapter_2_section_4.html

- (id)init;
{
if (![super init])
return nil;
	self.supportedUTIs = [NSArray arrayWithObjects:(NSString  
*)kUTTypePlainText 
,kUTTypeTex,kUTTypeTeXShopTex,kUTTypeBib,kUTTypeBibDeskBib,(NSString  
*)kUTTypePDF,(NSString *)kUTTypeImage,kUTTypeEPS,nil];
	self.utiEntityNameMap = [NSDictionary dictionaryWithObjects:[NSArray  
arrayWithObjects:ESTexFileEntityName 
,ESTexFileEntityName 
,ESTexFileEntityName 
,@BibTexFile 
,@BibTexFile 
,ESPDFFileEntityName,ESImageFileEntityName,@EPSFile,nil]  
forKeys:self.supportedUTIs];

return self;
}

- (NSString *)isSupportedUTI:(NSString *)uti error:(NSError  
**)errorPointer;

{
for (NSString *supportedUTI in self.supportedUTIs)
		if ([[NSWorkspace sharedWorkspace] type:uti  
conformsToType:supportedUTI])

return supportedUTI;
if (errorPointer != NULL)
		*errorPointer = [NSError errorWithDomain:ESScribblerErrorDomain  
code:ESUnsupportedUTIErrorCode userInfo:[NSDictionary  
dictionaryWithObjectsAndKeys:NSLocalizedString 
(@,@),NSLocalizedDescriptionKey 
,NSLocalizedString 
(@,@),NSLocalizedRecoverySuggestionErrorKey 
,uti,ESUnsupportedUTIErrorKey,nil]];

return nil;
}

- (NSString *)isSupportedFile:(NSString *)filepath error:(NSError  
**)errorPointer;

{
	NSString *uti = [[NSWorkspace sharedWorkspace] typeOfFile:filepath  
error:errorPointer];

if (!uti)
return nil;
return [self isSupportedUTI:uti error:errorPointer];
}

- (NSString *)entityNameForFile:(NSString *)filepath error:(NSError  
**)errorPointer;

{
	NSString *supportedUTI = [self isSupportedFile:filepath  
error:errorPointer];

if (!supportedUTI)
return nil;
	return [self.utiEntityNameMap valueForKey:supportedUTI]; // leave  
this error as nil, if we've got this far then we can determine the UTI

}

/*
 Maps the UTIs for the files and create a dictionary of entity name  
values and filepath keys. All errros are put into an NSDictionary. It  
is guaranteed to return a dictionary, so clients must inspect both the  
errors dictionary and the count of the returned dictionary.
 This method can't reasonably return nil as the presence of errors  
does not preclude the presence of supported files. To return nil if  
there are errors is too simplistic.

 */
- (NSDictionary *)entityMapForFiles:(NSArray *)filepaths errors: 
(NSDictionary **)dictionaryPtr;

{   
	NSMutableDictionary *mutableErrorsDictionary = [NSMutableDictionary  
dictionary];
	NSMutableDictionary *mutableEntityMap = [NSMutableDictionary  
dictionary];

for (NSString *filepath in filepaths) {
NSError *entityError = nil;
		NSString *entityName = [self entityNameForFile:filepath  
error:entityError];

if (!entityName)
[mutableErrorsDictionary setObject:entityError 
forKey:filepath];
else
[mutableEntityMap setObject:entityName forKey:filepath];
}

if ([mutableErrorsDictionary count] != 0  dictionaryPtr != NULL)
*dictionaryPtr = [[mutableErrorsDictionary copy] autorelease];
return [[mutableEntityMap copy] autorelease];
}

Jonathan

http://espresso-served-here.com

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: reloading an NSTreeController

2008-08-05 Thread Jonathan Dann


On 4 Aug 2008, at 14:04, Gerriet M. Denkmann wrote:



On 3 Aug 2008, at 16:53, Jonathan Dann wrote:


On 3 Aug 2008, at 04:35, Gerriet M. Denkmann wrote:


On 3 Aug 2008, at 05:51, Jonathan Dann wrote:


On 1 Aug 2008, at 14:04, Gerriet M. Denkmann wrote:

But all disclosure triangels are now closed. Is there some way  
to reopen them to the previous state?
I have the strong feeling that I will have to handle this  
myself. Ok. So be it.


It's a common problem.  Can I point you here:

http://www.cocoabuilder.com/archive/message/cocoa/2008/2/23/199705


Thank you very much for this link. You provide there a very clever  
solution, but, as you aptly put in your posting: It uses  
NSTreeNode and -representedObject, so is 10.5 only.
But alas!, I need Tiger 10.4.11. (And am reluctant to use private  
methods which you hint at in your posting).


Ah, sorry about that, I didn't realise.  What you can do is have a  
look at


http://www.wilshipley.com/blog/2006/04/pimp-my-code-part-10-whining-about.html

Wil gives a few category methods like -objectAtIndexPath:  You can  
(maybe) get the index path the _NSArrayControllerTreeNode and then  
get your real object, in which you have an isExpanded flag.


I had a look at this. It seems that to get the real object one has  
to recursively search the whole tree.


You're right, it's a shame these methods aren't available out of the  
box.




In my case it seems to be much simpler just to forget about  
NSTreeController and use the good old DataSource.
This is not a question about premature optimization (the trees in my  
case are quite small) but just a disgust about the silly design of  
the 10.4 NSTreeController.


Thanks for your help!

Kind regards,

Gerriet.



Not a problem, sometimes it is easier to use a datasource rather than  
battle for ages to patch up other code.  Do what works for you.


Glad to be of help.

Jonathan

http://espresso-served-here.com



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: reloading an NSTreeController

2008-08-03 Thread Jonathan Dann


On 3 Aug 2008, at 04:35, Gerriet M. Denkmann wrote:



On 3 Aug 2008, at 05:51, Jonathan Dann wrote:



On 1 Aug 2008, at 14:04, Gerriet M. Denkmann wrote:

But all disclosure triangels are now closed. Is there some way to  
reopen them to the previous state?
I have the strong feeling that I will have to handle this myself.  
Ok. So be it.


It's a common problem.  Can I point you here:

http://www.cocoabuilder.com/archive/message/cocoa/2008/2/23/199705


Thank you very much for this link. You provide there a very clever  
solution, but, as you aptly put in your posting: It uses NSTreeNode  
and -representedObject, so is 10.5 only.
But alas!, I need Tiger 10.4.11. (And am reluctant to use private  
methods which you hint at in your psoting).


Kind regards,

Gerriet.



Ah, sorry about that, I didn't realise.  What you can do is have a  
look at


http://www.wilshipley.com/blog/2006/04/pimp-my-code-part-10-whining-about.html

Wil gives a few category methods like -objectAtIndexPath:  You can  
(maybe) get the index path the _NSArrayControllerTreeNode and then get  
your real object, in which you have an isExpanded flag.


HTH,

Jonathan

http://espresso-served-here.com

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: reloading an NSTreeController

2008-08-02 Thread Jonathan Dann


On 1 Aug 2008, at 14:04, Gerriet M. Denkmann wrote:

But all disclosure triangels are now closed. Is there some way to  
reopen them to the previous state?
I have the strong feeling that I will have to handle this myself.  
Ok. So be it.


It's a common problem.  Can I point you here:

http://www.cocoabuilder.com/archive/message/cocoa/2008/2/23/199705



int numberOfRows = [ outlineView numberOfRows ];
for( int row = 0; row  numberOfRows; row++ )
{
		id item = [ outlineView itemAtRow: row ];	//	 
_NSArrayControllerTreeNode

BOOL isExpanded = [ outlineView isItemExpanded: item ];
if (isExpanded)
{
NSString *key = [ item valueForKey: @Key ]; --- does 
not work.
};
};

The objects in myContentArray are key value coding-compliant for the  
key Key.


But I get the error message: [_NSArrayControllerTreeNode 0x3f1fd0  
valueForUndefinedKey:]: this class is not key value coding-compliant  
for the key Key.



This will not work as in the line:

NSString *key = [ item valueForKey: @Key ];

you're effectively doing this:

NSString *key = [item Key];

which clearly won't work as whatever class your 'item' is doesn't have  
a method with the signature: Key.  For this to work you'd need -Key  
(and then likely -setKey:) in your class.  I'd have another look at  
the documentation on KVC.


http://developer.apple.com/documentation/Cocoa/Conceptual/KeyValueCoding/KeyValueCoding.html

If, for example I were to have the class:

@interface MyClass : NSObject {
NSArray *myArray;
}
- (void)setMyArray:(NSArray *)newValue;
- (NSArray *)myArray;
@end

Then I could safely do this:

MyClass *item = [[[MyClass alloc] init] autorelease];
NSArray *anArray = [item valueForKey:@myArray];

or
NSString *key = @myArray;
MyClass *item = [[[MyClass alloc] init] autorelease];
NSArray *anArray = [item valueForKey:key];


Having said all this, isn't _NSArrayControllerTreeNode private, with  
all the caveats that apply to using private classes.  You're not  
guaranteed that instances of this class with respond to *anything*.


Hope this helps,

Jonathan

http://espresso-served-here.com



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: NSOutlineView with Multiple Core Data Entities

2008-07-25 Thread Jonathan Dann


On 25 Jul 2008, at 17:21, Garrett Bjerkhoel wrote:

I have a NSOutlineView hooked up to a NSTreeController, which has  
multiple entities inside of it. I would like to know how to set it  
up having each entity having its own group. I have downloaded  
Jonathan Dann's example, which compiles but freezes. I can see how  
his Core Data model works, but I already have mine set.


Haha! That's great, sorry about that. I'm interested to know where it  
freezes, can you tell me more so I can fix it, please!


Can you explain what you model looks like in a little more detail, and  
what you mean by each entity having its own group.  Do you want a  
single group node entity or multiple group nodes as well as multiple  
child node entities?


Do I need to have both of my entities have a parent entity in which  
my NSTreeController reads from that one parent entity?




If I understand you correctly, the general concept it to have a single  
abstract TreeNode entity.  This is the entity that the tree  
controller concerns itself with, you then can make as many concrete  
entities as you like that inherit from your abstract one.


Jonathan

www.espresso-served-here.com

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: Drawing a drop-shadow around a view

2008-07-25 Thread Jonathan Dann
How odd I came across this yesterday on my travels! The site for this  
source is


http://www.bergdesign.com/missing_cocoa_docs/nsclipview.html

Jonathan

www.espresso-served-here.com

On 25 Jul 2008, at 11:13, Ian Jackson wrote:


Hi Graham,

if I understand your question, then I wanted to do something like  
this a while back. I got something off the internet, though I can't  
remember where.  Here's the source that I incorporated into my code.  
It's been ages since I added it in, so I can't remember whether this  
takes care of everything or not. I think it does.


Ian.

P.S. if anyone recognises this code as theirs, then I apologise.

SEDrawingClipView.m


On 25/07/2008, at 1:43 PM, Graham Cox wrote:

I have a view embedded in a NSScrollView. When the view is small  
there's a large expanse of grey visible. I'd like to draw a drop- 
shadow around the view in this situation to help it stand out  
slightly from the background. What's a good approach to do this?



tia,

cheers, Graham


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: NSOutlineView with Multiple Core Data Entities

2008-07-25 Thread Jonathan Dann
Ah yeah, that bug is intentional!  The model uses an abstract TreeNode  
entity, which the tree controller is set to; however when you want  
concrete LeafNode and GroupNode entities (or sub-entities thereof) you  
need to create your own -add: methods so you can insert the correct  
entity into the tree.  As the tree controller has its entity set to  
TreeNode (abstract, so it can work will all sub-entity types), when  
calling -add: and addChild: it simply tries to insert an abstract  
entity.  Only the GroupNode responds to -isSpecialGroup, hence the  
exception.


I put those buttons, linked to -add: and -addChild:, in the project to  
emphasise that these no longer work when you want a non-trivial tree  
structure with multiple entities in the same tree.


What I do for the case you want is have an -insertGroupNode: method  
which creates the correct entity and inserts it into the tree at the  
index path you want.  For the default groups I do that in code,  
setting their -displayNames and setting -isSpecialGroup to YES so that  
the NSOutlineView delegate method -outlineView:isGroupItem: can  
interrogate the all the GroupNodes and will draw it in the correct way  
(like MAILBOXES, etc) when -isSpecialGroup returns YES.


In a shipping app I'd bracket such calls (when you don't know what  
type of node your dealing with) with a -respondsToSelector: or - 
isKindOfClass: call.


Sorry for the confusion. Hope this clears it up.

Jonathan

www.espresso-served-here.com

On 25 Jul 2008, at 21:30, Garrett Bjerkhoel wrote:

Here is a rough sketch of my datamodel. If you like I can take a  
screenshot and post a link to it.

Client
---Project
Todo
Writeoff
---Item

By each entity having its own group, I am refering to say Mail.app  
how it has MAILBOXES, then REMINDERS, or in iTunes DEVICES,  
and LIBRARY. My intention was to have multiple group nodes as well  
as multiple child nodes.


On regards to your project, here you go:
Once it loads, nothing is clickable :(

In the debugger, this is what it says:
2008-07-25 12:35:01.031 SortedTree[1526:10b] *** -[ESTreeNode  
isSpecialGroup]: unrecognized selector sent to instance 0x133d20


On Jul 25, 2008, at 12:33 PM, Jonathan Dann wrote:



On 25 Jul 2008, at 17:21, Garrett Bjerkhoel wrote:

I have a NSOutlineView hooked up to a NSTreeController, which has  
multiple entities inside of it. I would like to know how to set it  
up having each entity having its own group. I have downloaded  
Jonathan Dann's example, which compiles but freezes. I can see how  
his Core Data model works, but I already have mine set.


Haha! That's great, sorry about that. I'm interested to know where  
it freezes, can you tell me more so I can fix it, please!


Can you explain what you model looks like in a little more detail,  
and what you mean by each entity having its own group.  Do you want  
a single group node entity or multiple group nodes as well as  
multiple child node entities?


Do I need to have both of my entities have a parent entity in  
which my NSTreeController reads from that one parent entity?




If I understand you correctly, the general concept it to have a  
single abstract TreeNode entity.  This is the entity that the  
tree controller concerns itself with, you then can make as many  
concrete entities as you like that inherit from your abstract one.


Jonathan

www.espresso-served-here.com






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: Flip animation like dashboard widgets

2008-07-18 Thread Jonathan Dann

There was an example of this on Cocoa Is My Girlfriend

http://www.cimgf.com/

HTH

Jon

On 18 Jul 2008, at 08:42, chaitanya pandit wrote:

Is there any way to do flip animation like the one with dashboard  
widgets when u click the i to change the settings for the widget.

Can it be done for NSView?

I'd appreciate any help
Thanks.




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: NSViewController Binding Problem continued

2008-07-18 Thread Jonathan Dann

Hi Ivy,

You can bind the representedObject in NIB, I do it all the time.  My  
rO is an NSPersistentDocument subclass, which is set immediately after  
the view controller is -init-ed.  The bindings in the nib are only set  
up after -loadView is called, which occurs after something in your app  
asks for the -view.  So as long as the rO is not nil when -loadView is  
called then it should bind properly.  Granted though I haven't tried  
it with an NSController subclass as the rO.


Have you tried binding it in code during -awakeFromNib?

Jonathan

www.espresso-served-here.com



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: NSViewController Binding Problem continued

2008-07-18 Thread Jonathan Dann

Hi Ivy,

Can you tell us what the bound object the table receives is?  If you  
could call this method (which, in its current state, would go in an  
NSTableView subclass) somewhere:


- (NSArrayController *)arrayController;
{
	return [[[self tableColumnWithIdentifier:@myColumn]  
infoForBinding:NSValueBinding] valueForKey:NSObservedObjectKey];	

}

then print the results to the console.  Calling it at the end of  
awakeFromNib: with a -performSelector:withObject:afterDelay: (not  
necessary but just to be sure!) should do the trick.  Is what you get  
back an array controller?


Jonathan

www.espresso-served-here.com



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: Duplicate rows appearing in outlineview after creating new Entity in moc, why?

2008-07-17 Thread Jonathan Dann
Yeah come to think of it I saw this behaviour when adopting the  
mediator pattern in my app.  In the NSPersistentDoc tutorial you can  
create a Dept. object just using NSObjectController, then bind your  
array contorller's contentSet binding to the object controller's  
dept.employees keypath (or whatever they recommend).I tried to do  
the same but with NSTreeController and had the same problems.


I'd file a bug if I were you.  I now populate my tree controller by  
binding it only to the MOC, and the problem disappears.  So even  
though I have my Dept. object, which has a bunch of employees in a to  
many relationship I still fetch the tree data direct from the  
context.  This approach may not work for what you describe as  the  
tree you view seems to depend on another selection.


Jon

On 17 Jul 2008, at 00:34, Sean McBride wrote:


Jon,

Thanks for your reply.  My fetch predicate was already parent ==  
nil.


I have narrowed this down to the fact that my treecontroller has its
'contentSet' binding set.  If I remove that binding, duplicates no
longer appear.

I have created a very simple test app to illustrate:
http://www.rogue-research.com/vtk/TreeTest.zip

It's a master-detail interface.  The master is a tableview/
arraycontroller on the left, the detail is an outlineview/ 
treecontroller

on the right.  The treecontroller's 'contentSet' binding is bound to
'arrayController.selection.someRelationship'.

If someone would care to try:
- launch the app
- click 'Add Family'
- click 'New Folder'
- expand the folder's disclosure triangle
- (keep the folder selected)
- click 'New Person'

The new person appears both in the folder and at the root of the
outlineview.  Remove the contentSet binding and the problem goes away.
It's only 50 lines of code.  I don't get it.

Cheers,

Sean


On 7/16/08 1:44 PM, Jonathan Dann said:


The duplicate problem is likely fixed by giving the tee controller a
fetch predicate in IB. Set the predicate to something like
parent==nil. This will obviously depend on what you've called your
'parent' property.

I've blogged about doing this with drag and drop in core data and  
non-

core data apps.

http://espresso-served-here.com

HTH

Jon

On 15 Jul 2008, at 22:59, Sean McBride [EMAIL PROTECTED]
wrote:


Hi all,

I have an outlineview populated by binding to a treecontroller.  It
displays CoreData entities of type Person.  Person has 'parent'
and
'children' relationships.  Displaying everything works fine.

Now the outlineview must support drops.  In my windowcontroller, I
implement outlineView:acceptDrop:item:childIndex: and look for my
custom
pasteboard type.  If it's there, I need to create a new Person
entity.  How should I do this?

I have tried:
a) [myTreeController add:nil];

b) Person* person = [myTreeController newObject];
  [person setParent:...];

c) Person* person = [NSEntityDescription
insertNewObjectForEntityForName:@Person
inManagedObjectContext:moc];
  [person setParent:...];

In all cases, the outlineview shows 2 of the new person.  The
problem is
not on the model side, since if I close and reopen the window,  
only 1

new person is there.

Thanks,

--

Sean McBride, B. Eng [EMAIL PROTECTED]
Rogue Researchwww.rogue-research.com
Mac Software Developer  Montréal, Québec, Canada


___

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/j.p.dann 
%40gmail.com


This email sent to [EMAIL PROTECTED]







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: Where's the best place for addObserver and removeObserver

2008-07-17 Thread Jonathan Dann

Hi Joan,

As Keary says, removing in -dealloc is probably not the best thing to  
do as there are a few cases that this can bite you, like if your  
window controller retains the view controllers, and -dealloc is called  
on the window controller, which would proceed to release its  
collection of view controllers.  In this case you get console logs a- 
plenty informing you that the window controller is being deallocated  
while observers are still registered with it.


What I do is get all the view controllers to conform to a formal  
protocol called DetailViewController.  The protocol has two methods  
that the conforming parties must implement, - 
becomeDetailViewController: and -resignDetailViewController: (the  
names are a result of my master/detail view setup in my app).  In  
these methods the receiver can setup and tear-down both bindings and  
observations.


So when I swap a view in or out I have a single - 
swapDetailViewWithView: method in my windowController that wraps the  
call to the window's content view -replaceSubview:withView (I think  
that's the name) with calls to the current and potential detail view  
controllers -resign... and -become..., respectively.


HTH,

Jonathan

www.espresso-served-here.com

On 17 Jul 2008, at 16:34, Keary Suska wrote:


I don't think it matters when you *start* observing, as long the the
observed objects are guaranteed to exist. awakeFromNib is a perfect  
place if

you expect the observation to last the lifetime of the nib objects.

I will say that removing observation in dealloc is a dangerous  
endeavor. It
works if you can guarantee that the observer will be deallocated  
*before*
the observed. This guarantee is difficult if not impossible in a nib- 
loaded

situation, AFAIK.

I believe that the bindings mechanism, however, has ways to deal  
with these
issues in a nib-loaded situation (and generally as well). That might  
be an

avenue to pursue.


When bindings are set up in nib, Apple takes care of it (with private  
stuff), but programmatic bindings have to be unboud manually.



HTH,

Keary Suska
Esoteritech, Inc.
Demystifying technology for your home or business




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: Duplicate rows appearing in outlineview after creating new Entity in moc, why?

2008-07-16 Thread Jonathan Dann
The duplicate problem is likely fixed by giving the tee controller a  
fetch predicate in IB. Set the predicate to something like  
parent==nil. This will obviously depend on what you've called your  
'parent' property.


I've blogged about doing this with drag and drop in core data and non- 
core data apps.


http://espresso-served-here.com

HTH

Jon

On 15 Jul 2008, at 22:59, Sean McBride [EMAIL PROTECTED]  
wrote:



Hi all,

I have an outlineview populated by binding to a treecontroller.  It
displays CoreData entities of type Person.  Person has 'parent'  
and

'children' relationships.  Displaying everything works fine.

Now the outlineview must support drops.  In my windowcontroller, I
implement outlineView:acceptDrop:item:childIndex: and look for my  
custom

pasteboard type.  If it's there, I need to create a new Person
entity.  How should I do this?

I have tried:
a) [myTreeController add:nil];

b) Person* person = [myTreeController newObject];
   [person setParent:...];

c) Person* person = [NSEntityDescription
 insertNewObjectForEntityForName:@Person
 inManagedObjectContext:moc];
   [person setParent:...];

In all cases, the outlineview shows 2 of the new person.  The  
problem is

not on the model side, since if I close and reopen the window, only 1
new person is there.

Thanks,

--

Sean McBride, B. Eng [EMAIL PROTECTED]
Rogue Researchwww.rogue-research.com
Mac Software Developer  Montréal, Québec, Canada


___

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/j.p.dann%40gmail.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/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Rounded NSWindow corners?

2008-07-14 Thread Jonathan Dann
Have a look and see if the window is textured or not, it a window  
setting in IB.  Non-textured windows have no bottom border by  
default.  Its in the AppKit release notes


http://developer.apple.com/releasenotes/Cocoa/AppKit.html

under the NSWindow heading.

Often this is used in conjunction with the  - 
setContentBorderThickness:forEdge: and - 
setAutorecalculatesContentBorderThickness:flag forEdge:edge methods to  
give a window that iCal/iTunes etc look.


HTH

Jon

On 14 Jul 2008, at 20:47, Chad Harrison wrote:

My main window in IB has a square bottom both when I edit it in  
IB, and when I simulate the interface. But in my compiled app, it  
has the rounded bottom like in the 10.5 Finder and iTunes. Why is  
there this inconsistency between windows?


+Chad
___

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/j.p.dann%40gmail.com

This email sent to [EMAIL PROTECTED]




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: Responder Chain Patching

2008-07-14 Thread Jonathan Dann

Have you seen this

http://katidev.com/blog/2008/04/17/nsviewcontroller-the-new-c-in-mvc-pt-2-of-3/

and this thread

http://www.cocoabuilder.com/archive/message/cocoa/2008/3/19/201743

All of this is covered, with automatic insertion of view controllers  
into the responder chain.


If you want to set up the view controller as the next responder of the  
view (not done in the above) then you might be better with this code  
(thanks, Ali Lalani)



#import MyViewController.h


@implementation MyViewController
- (void)loadView;
{
[super loadView];

[[self view] addObserver:self forKeyPath:@nextResponder  
options:0 context:NULL];

}

- (void)dealloc;
{
[[self view] removeObserver:self forKeyPath:@nextResponder];
[super dealloc];
}
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject: 
(id)object change:(NSDictionary *)change context:(void *)context

{
if ([keyPath isEqualToString:@nextResponder])
{
// when we get called due to setting next responder as  
ourselves we ignore it (could also unobserve right before and re- 
observe right after...)

if ([[self view] nextResponder] != self)
{
[self setNextResponder:[[self view] nextResponder]];
[[self view] setNextResponder:self];
}
}
else
{
[super observeValueForKeyPath:keyPath ofObject:object  
change:change context:context];

}
}
@end



In this way the view controller will 'jump' in whenever the view's  
nextResponder is set.


HTH

Jon



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: Mini Popup Window (Like iCal)

2008-07-11 Thread Jonathan Dann


On 10 Jul 2008, at 19:33, Seth Willits wrote:



Has anyone created a custom window like the event info editor in  
iCal in 10.5? There's a few things I'm not sure how to do:


1) Drawing the window background gradient is pretty straightforward,  
but creating the thin border on the window is not. I'm concerned  
about not being getting it thin enough. Any tips on that?


2) The zoom-in effect. I'm going to go out on a limb here and say  
that this is probably done using private methods. The only public  
way I can think of to do it would be to grab an image of my window  
using the CGWindow API while the window is still hidden, then scale  
that in an overlay window for the effect.



I can come up with solutions for both of these, but I was hoping  
someone might have some better ideas or experience.



I'm working on one at the moment.  This may help you on your way

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

just draw whatever you want in -drawRect:, like a rounded rect or  
something.


The arrow is harder.  There's a window with an arrow on Matt Gemmell's  
site http://mattgemmell.com/ but that uses an NSColor with a pattern  
image to fill the window background and that seems mess up with core  
animation, which can't cache the drawn window prior to animation.


HTH

Jon

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: Widgets for HUD

2008-06-29 Thread Jonathan Dann


On 27 Jun 2008, at 20:48, Erik Verbruggen wrote:

I know this has been asked before on this list (somewhere earlier  
this year), but I couldn't find the posting back. So sorry for  
repeating the question, but I'd like to use the HUD of Leopard and  
with fitting widgets. Somebody mentioned something on tweaking the  
look/colours and somebody else mentioned a 3th party widget set. Can  
somebody point me to that widget set or to best practices around  
this topic?


Thanks,
Erik.


There's a great framework which is being made into a IB plugin. Its  
called BGHUDAppKit


Look here
www.binarymethod.com

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: Passing CGImageSourceRef to IKImageView

2008-06-18 Thread Jonathan Dann

Thanks Douglas,

Nice to know I'm not going mad!

Jon

On 16 Jun 2008, at 17:51, douglas a. welton wrote:


Jonathan,

I don't think you missed anything.  I do believe that documentation  
is somewhat misleading for this class.


I was in the same situation as you, so I simply decided to get a  
CGImageRef (with the associated CGImageProperties) from my  
CGImageSourceRef object and use the -(void)setImage:imageProperties:  
method to set my image.


regards,

douglas

PS:  This issue has been discussed on the Quartz list, but at this  
moment Apple Lists archives are doing something funky and I can't  
find the reference for you.


On Jun 16, 2008, at 7:05 AM, Jonathan Dann wrote:


Hi Guys,

I was just looking at passing a CGImageSourceRef to an IKImageView,  
the documentation says you can, but there's not method that accepts  
it as a parameter.  Is this just a feature that isn't present in  
the release?  Are there release notes that this would be in as  
Image Kit isn't in the App Kit release note.


Thanks,

Jon






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]

Passing CGImageSourceRef to IKImageView

2008-06-16 Thread Jonathan Dann

Hi Guys,

I was just looking at passing a CGImageSourceRef to an IKImageView,  
the documentation says you can, but there's not method that accepts it  
as a parameter.  Is this just a feature that isn't present in the  
release?  Are there release notes that this would be in as Image Kit  
isn't in the App Kit release note.


Thanks,

Jon

www.espresso-served-here.com

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]

NSSlider responding to superview's drawRect

2008-06-10 Thread Jonathan Dann

Hi All,

This is something that I haven't seen before. I have a custom view  
that inherits from NSView directly and just draws a gradient  
background. In IB I've placed an NSSlider on the view which works  
fine. The problem comes when drawRect in my custom view is invoked, I  
draw the gradient and a 1px line at the top of the view, but the line  
also gets draw just above the NSSlider! logging shows the following


1) resize window - drawRect is called and the line above the slider  
disappears
2) move slider - drawRect is called from my gradient view but with the  
frame of the slider. The line then appears.


Is this a known issue with NSSlider and a custom view or have I missed  
an idiosyncracy of NSControls.


Thanks in adavnce,

Jonathan
___

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: NSSlider responding to superview's drawRect

2008-06-10 Thread Jonathan Dann


On 10 Jun 2008, at 17:05, Ken Ferry wrote:

You're probably filling your gradient into the rect passed in  
drawRect.


That rectangle just represents the dirty part of your view. If you  
had a solid color to draw, you could just fill the rect, but with a  
gradient you will get your gradient, top to bottom, within this  
possibly small rect within your view.


Try drawing the gradient into [self bounds] instead.  This describes  
the location of the entire view in its own coordinate system.



On 10 Jun 2008, at 17:03, Andy Lee wrote:
Check the code that draws the 1-pixel line.  It should be  
calculating coordinates of the line based on the view's bounds  
rectangle, not the rectangle that is passed to drawRect:.


--Andy


Thanks to you both, you're absolutely correct!  Works like a charm now.

I'd like to be able to change the fill of my view depending on whether  
the application is active or not.  The only problem is -drawRect isn't  
called when the application becomes inactive, is there a notification  
I can register for?  In all my NSControl subclassing -drawRect is  
called on both become active and deactivating.


Thanks again for your help, that subtlety has never come to light  
until now.


Jonathan

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: Newbie question:IB, NSView, NSViewController

2008-06-05 Thread Jonathan Dann


On 5 Jun 2008, at 14:46, Johnny Andersson wrote:


To understand what I have problems with, let's suppose that I want  
to put a module consisting of an NSViewController, controlling the  
view with two buttons, which in turn contains a DrawView, on my main  
window. Do I put my DrawViewController in  the root of the  
MainWindow NIB, and if so, how do I specify where the view will end  
up? Or, do I instantiate a a DrawViewController in my DrawView NIB,  
and put a DrawView directly into the main window?


I know I'm not explaining this very well; I don't understand the  
concepts well enough to do that yet. If it helps, here's what I  
would have done if I was using Qt:

1) Create DrawWidget
2) Create FancyDrawWidget (containing the buttons, a DrawWidget and  
connections)
3) Create HandwritingWidget, which contains all the logic + a  
FancyDrawWidget.

4) Plop a HandwritingWidget somewhere on my main window.

I'd be grateful for any help - including help on how to ask the  
right question.


Kind regards,
Johnny


It really depends on the larger architecture of your app on how you  
want to do this.  The reason NSViewController exists is to offload  
view-specific code into a controller for that view (or view hierarchy)  
so that the code does not all go in your app controller or a window  
controller.


With something that was a simple 1 window app with a draw view as a  
subview of the window's content view and the buttons you describe also  
as subviews of the content view then a window controller may do.  As  
you say though if you can encapsulate this better you can ease reusing  
this code.


I've written a sample app and post together with Cathy Shive on (what  
we think) is a good and general way of using NSViewController and the  
extras we've added to make it fit into the MVC paradigm properly, you  
can find it on her blog http://katidev.com  The main way I would set  
this up is to create a view nib with your draw view (or your draw view  
as a subview of some other view) in it an little else (a contextual  
menu too perhaps) and set the file's owner of this draw view nib to an  
instance of NSViewController or a subclass thereof.  All your code to  
control the view is then in the view controller and you have self- 
contained unit.


From here you can instantiate your view controller in your window  
controller and then set the view's position in -awakeFromNib of either  
the view or window controller.  You could also, if you redesign later,  
instantiate your draw view controller during the setup of another view  
controller (or indeed some later time in the application's life) and  
set the draw view as a subview of whatever view this other view  
controller controls!  This way you can set up as complex a controller  
hierarchy as you desire, and changing where the draw view is presented  
in your app boils down to moving the line in which you create your  
draw view controller and moving the view positioning code to somewhere  
else.


This setup is shown in the example code in the second article on  
Cathy's site.  If you have any questions then don't hesitate to ask.   
You can also look at the thread that made us write about all this here


http://www.cocoabuilder.com/archive/message/cocoa/2008/3/19/201743

Hope this helps,

Jon

-- Espresso Served Here -- http://jonathandann.wordpress.com --

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: invoking quicklook via code

2008-06-04 Thread Jonathan Dann

Is it possible to somehow just launch the quicklook window for a
quicktime file?


The quicklook framework is private and therefore should cannot be  
reliably used in an app.  There are a few site out there that give  
example code that calls it though.


You could use NSWorkspace to bring forward a Finder window and then  
*somehow* simulate a spacebar event on the file but I don't know how.   
Sorry.


Jon

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: invoking quicklook via code

2008-06-04 Thread Jonathan Dann


On 4 Jun 2008, at 23:18, Nick Zitzmann wrote:



On Jun 4, 2008, at 3:48 PM, Jonathan Dann wrote:

The quicklook framework is private and therefore should cannot be  
reliably used in an app.  There are a few site out there that give  
example code that calls it though.



Since when was this? QuickLook is not a private framework, and it is  
possible for third-party apps to use it as a client without using  
any private APIs.


What third-party apps can't do is get a QuickLook QuickTime preview,  
which is what the Finder does when looking at QuickTime files. And I  
suspect the Finder is not using QuickLook on QuickTime files, but is  
instead using QuickTime directly.


Yeah sorry, should have been clearer, I was referring to the private  
QuickLookUI framework.


Jon

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: Finding the largest value in an NSTreeController?

2008-05-31 Thread Jonathan Dann
To get all the nodes in the tree I do a depth-first search (10.5  
only). Add the first method in an NSTreeNode category  and the second  
to a category on NSTreeController.


// NSTreeNode_Extensions
- (NSArray *)descendants;
{
NSMutableArray *array = [NSMutableArray array];
for (NSTreeNode *item in [self childNodes]) {
[array addObject:item];
if (![item isLeaf])
[array addObjectsFromArray:[item descendants]];
}
return [[array copy] autorelease];
}

// NSTreeController_Extensions
- (NSArray *)flattenedNodes;
{
NSMutableArray *array = [NSMutableArray array];
for (NSTreeNode *node in [self rootNodes]) {
[array addObject:node];
if (![[node valueForKey:[self leafKeyPath]] boolValue])
[array addObjectsFromArray:[node 
valueForKey:@descendants]];
}
return [[array copy] autorelease];  
}

You then have an NSArray with all of the NSTreeNodes and can just call  
[treeNodesArray valueForKey:@representedObject] to get you model  
objects, and then can do whatever you like.  If you're using Core  
Data, can't you fetch all your managed objects and determine the one  
with the max vaule?


Jon

On 31 May 2008, at 10:35, Rick Mann wrote:

I'd like to find the largest integer value of one of my entity  
fields, stored in an NSTreeController. Is this possible? I'm trying  
to use @max, but getting back null on every variant:


	NSNumber* maxVal = [mItemsController valueForKeyPath:  
@@max.number];


I also tried with arrangedOBjects.

I can't even figure out how to manually iterate the objects. Is  
there a way?


TIA,
--
Rick

___

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/j.p.dann%40gmail.com

This email sent to [EMAIL PROTECTED]




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: Finding the largest value in an NSTreeController?

2008-05-31 Thread Jonathan Dann


On 31 May 2008, at 19:47, Rick Mann wrote:



Jonathan, thank you for the excellent example on working with the  
containers. That will certainly be useful.




You're welcome, but I apologise, I forgot the -rootNodes method that  
one of the tree controller methods I sent you calls! This method  
returns the top-level objects in the tree (NSTreeController.h assures  
me that -arrangedObjects responds to -childNodes, this differs from  
what the docs say).


// NSTreeController_Extensions
- (NSArray *)rootNodes;
{
return [[self arrangedObjects] childNodes];
}

now it'll work!.


On May 31, 2008, at 12:05:58, I. Savant wrote:


1 - Create a fetch request for your desired entity.
2 - Create a sort descriptor for the key whose max value you're  
interested in.

3 - Set the fetch request's sort descriptor to the above.
4 - Create any predicates needed for filtration (ie, whatever you  
may or may not have used in the tree controller).

5 - Set the fetch request's predicate to the above if any.
6 - Execute the fetch request and get the last (or first) object of  
the results (checking for errors, minding the set-versus-array  
gotchas, etc.).



Wow, really? No way to just get at all the items in the tree  
controller with some key path, then use @max?


Think of this this way, only the tree controller knows which objects  
it has in it.  The context and the model objects are ignorant of  
this.  The entity you fetch is that you set in IB for the tree  
controller, so that is *kind of* asking the context, get me the nodes  
in the tree controller, but not exactly as the tree controller itself  
may have a predicate that causes it to fetch only some of those types  
of entities.  The fetch request (if you set the same predicate as the  
you have for the tree controller) will get you your NSSet of objects,  
then you can do whatever you want with the objects.


HTH,

Jon

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: Opening column for edit after adding to tree controller?

2008-05-31 Thread Jonathan Dann


The problem is, I don't know how to determine to which row that  
newly-added object corresponds in the table view. Is there any way?  
I suppose it's the current-selected row, since it's set up to select  
on add. Is there a more elegant way to find out, though (i.e., what  
if adding didn't change the selection).


How does one find the row in the table view corresponding to any  
given instance?




Add this to your category on NSTreeController. It calls the - 
flattendedNodes method I gave you earlier.  You can then get the tree  
node for the whatever you added to the tree and call NSOutlineView's - 
rowForItem:


- (NSTreeNode *)treeNodeForObject:(id)object;
{   
NSTreeNode *treeNode = nil;
for (NSTreeNode *node in [self flattenedNodes]) {
if ([node representedObject] == object) {
treeNode = node;
break;
}
}
return treeNode;
}

For those searching the archives, the previous code examples are in  
this thread:


http://lists.apple.com/archives/cocoa-dev//2008/May/msg03138.html

Jon

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: Finding the largest value in an NSTreeController?

2008-05-31 Thread Jonathan Dann


On 31 May 2008, at 21:43, Rick Mann wrote:


 Can category methods act as KVC properties?



Yep, the -flattenedObjects method I gave you asks the array of tree  
nodes valueForKey:@descendants.  -descendants was the NSTreeNode  
method I posted.


Jon

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: Possible Bug in NSFileManager -moveItemAtPath:toPath:error:

2008-05-31 Thread Jonathan Dann


On 31 May 2008, at 17:37, Torsten Curdt wrote:



On May 31, 2008, at 18:27, Jonathan Dann wrote:


Hi Guys,

Just a quick one.  I would expect renaming a file named HELLO.TXT  
to hello.txt (or another variant where the case of a few letters  
change) with -moveItemAtPath:toPath:error: to be allowed.  As it is  
not (it generates an NSFileWriteUnknownError) is this a bug or just  
me?  If not, is there are more appropriate API for renaming files?


Have you tried:

HELLO.TXT - something
something - hello.txt

Just a thought maybe it's related to the filesystem no being  
case-sensitive.


cheers
--
Torsten


Thanks Torsten that works, just feels like a hack as I have to use  
another method to generate a filename that isn't in the working  
directory.


Jon

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: Possible Bug in NSFileManager -moveItemAtPath:toPath:error:

2008-05-31 Thread Jonathan Dann


On 31 May 2008, at 18:17, Jens Alfke wrote:



On 31 May '08, at 9:27 AM, Jonathan Dann wrote:

Just a quick one.  I would expect renaming a file named HELLO.TXT  
to hello.txt (or another variant where the case of a few letters  
change) with -moveItemAtPath:toPath:error: to be allowed. As it is  
not (it generates an NSFileWriteUnknownError) is this a bug or just  
me?


That ought to work, even on HFS+. (It's not a no-op, because HFS+  
preserves the case of filenames, so getting the directory contents  
will return the name in its new case.)



If not, is there are more appropriate API for renaming files?


Try using the system call rename. (Use man 2 rename to see the  
documentation.)
Call -fileSystemRepresentation on your path strings to convert them  
to appropriate C strings.


—Jens


I'll have a look at that, would that break if my users have non-ascii  
filenames?  I've only worked with NString, which handles Unicode  
transparently.


Thanks Jens,

Jon

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: Possible Bug in NSFileManager -moveItemAtPath:toPath:error:

2008-05-31 Thread Jonathan Dann


On 31 May 2008, at 22:51, stephen joseph butler wrote:

On Sat, May 31, 2008 at 4:35 PM, Jonathan Dann [EMAIL PROTECTED]  
wrote:

On 31 May 2008, at 18:17, Jens Alfke wrote:

Try using the system call rename. (Use man 2 rename to see the
documentation.)
Call -fileSystemRepresentation on your path strings to convert  
them to

appropriate C strings.


I'll have a look at that, would that break if my users have non-ascii
filenames?  I've only worked with NString, which handles Unicode
transparently.


As long as you use fileSystemRepresentation, it always does The Right
Thing w.r.t. Unicode encoding.


Awesome! Thanks for your help.

Jon

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: NSTextView without word wrap?

2008-05-24 Thread Jonathan Dann

You're welcome, but I'd replace this:


const CGFloat LargeNumberForText = 1.0e7;
   [[textView textContainer]  
setContainerSize:NSMakeSize(LargeNumberForText, LargeNumberForText)];


with

[[textView textContainer] setContainerSize:NSMakeSize(FLT_MAX,  
FLT_MAX)];


hey presto 1 less line of code!  FLT_MAX is the largest representable  
floating point number. It *may* insulate you from processor  
differences, but someone would have to confirm to me that this could  
ever be a problem.


Jon

On 24 May 2008, at 02:35, David Carlisle wrote:

Based on your kindly giving me a precise reference I was able to  
remove a few unnecessary statements from my awake from nib.  It now  
reads as follows:


- (void) awakeFromNib {
   const CGFloat LargeNumberForText = 1.0e7;
   [[textView textContainer]  
setContainerSize:NSMakeSize(LargeNumberForText, LargeNumberForText)];

   [[textView textContainer] setWidthTracksTextView:NO];
   [textView setHorizontallyResizable:YES];
}

Thanks,
DC

On May 23, 2008, at 4:08 PM, Jonathan Dann wrote:


Its in SMLViewMenuController.m line -(IBAction)lineWrapTextAction:

Jon

On 23 May 2008, at 22:58, David Carlisle wrote:


Looks interesting.  Thanks.

DC

On May 23, 2008, at 3:37 PM, Jonathan Dann wrote:

You may also like to look at the source code to Smultron by Peter  
Borg.  It's in there but I forget exactly.


http://smultron.sourceforge.net/

Jon

On 23 May 2008, at 21:55, David Carlisle wrote:

I made some guesses at which statements to copy from  
BiScrollAspect.m and came up with the following awakeFromNib.   
I'm not sure which statements are the most relevant, and why,  
but it seems to do what I need.


- (void) awakeFromNib {
const CGFloat LargeNumberForText = 1.0e7;
[[textView textContainer]  
setContainerSize:NSMakeSize(LargeNumberForText,  
LargeNumberForText)];

[[textView textContainer] setWidthTracksTextView:NO];
[[textView textContainer] setHeightTracksTextView:NO];
[textView setAutoresizingMask:NSViewNotSizable];
[textView setMaxSize:NSMakeSize(LargeNumberForText,  
LargeNumberForText)];

[textView setHorizontallyResizable:YES];
[textView setVerticallyResizable:YES];
}

On May 23, 2008, at 12:03 PM, Douglas Davidson wrote:



On May 23, 2008, at 10:33 AM, David Carlisle wrote:

I've spent the last few hours trying to create an NSTextView  
without word wrap.  The BiScrollAspect.m file in the  
textSizingExample project file is no help at all.


No help in that it doesn't do what you want, or no help in that  
you can't get it working in your app, or no help in some other  
way?


Douglas Davidson



___

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/j.p.dann%40gmail.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/davidcar1%40mstarmetro.net

This email sent to [EMAIL PROTECTED]






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]

Core Data, transient properties and saving

2008-05-23 Thread Jonathan Dann

Hi Guys,

Has anyone come across this before? I've looked online and I think I  
know the problem but the solution is evading me!


I have an NSManagedObject that represents a text file, the text itself  
is saved to a text file and the file's attributes are stored in the  
persistent store (much the same way Xcode works).  The file has a non- 
optional, transient property isEdited (default is NO) that gets  
updated to YES when the text is edited and then set to NO when the  
text itself is saved to the locations specified by the file's path  
property.  However if I want to save an individual file and then save  
any changes to the object graph subsequent fetches with the predicate  
@isEdited == YES does not return any other edited files.


So saving the store has turned all my file objects into faults.   
However as all my files are in a source list, after saving one file  
selecting one of the other files I know to be edited and then trying  
to fetch again returns the selected file.  Therefore the fault seems  
to be fired by my tree controller and the isEdited value is correct.


In practice a user will edit multiple files and then save one of them,  
then try to quit the program which tries to fetch any edited files and  
throw up a dialog asking the user to save all the other edited files,  
but as the other edited files are faults the fetch returns no edited  
files and the program quits.


How can I work around this?  I could always walk the tree and ask each  
file if they're edited, but a fetch seems cleaner.


Thanks for any pointers,

Jon

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: Core Data, transient properties and saving

2008-05-23 Thread Jonathan Dann

Thanks for the quick reply Ben and your explanation of what's going on.

I've just re-read the Fetching section of the Core Data Programming  
Guide and its glaring at me not to fetch using transient attributes.


I appreciate your help.

Jon


On 23 May 2008, at 22:32, Ben Trumbull wrote:

As a summary, you can't fetch or sort against transient properties  
reliably.  They don't exist in the persistent store (database).


The in memory filtering will apply your predicate to any dirty  
objects to reconcile unsaved changes with the results from the  
persistent store.



So saving the store has turned all my file objects into faults.


Not exactly, the managed objects are marked clean (not dirty) after  
saving.  Since the objects are no longer dirty, the MOC's filtering  
will not post process them for unsaved changes.


How can I work around this?  I could always walk the tree and ask  
each

file if they're edited, but a fetch seems cleaner.


You should probably keep an NSSet of edited objects.  
Alternatively, you could make it a persistent property and manage  
the consequences of that.

--

-Ben




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: Programmatically get treecontroller selection

2008-05-21 Thread Jonathan Dann


- (void)getSelectedAccount{

NSString *accountName = @Bank;
NSLog(accountName);
	accountName = [[MLoutlineViewController selection]  
valueForKey:@name];

NSLog(accountName);

//get managedObjectContext in preparation for fetch code
moc = [MLappDelegate managedObjectContext];

}


At first glance, try NSTreeController's -selectedObjects and - 
selectedNodes methods rather than -selection. Also, in my experience  
I've not found is necessary to bind the selectionIndexPath(s) to the  
outline view to get it all to work, maybe unbind that as a quick test?


Jon

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: Programmatically get treecontroller selection

2008-05-20 Thread Jonathan Dann

In addition:

So, I guess my question is: how is your NSOutlineView populated?  Do  
you have to NSTableColumn of the NSOutlineView bound to the tree  
controllers @arrangedObjects.name keypath? If this is the case, in  
what way are you giving the tree controller content to work with.


All the best,

Jon

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: Programmatically get treecontroller selection

2008-05-19 Thread Jonathan Dann


On 19 May 2008, at 13:29, Steven Hamilton wrote:

I have a core data master-detail interface that consists of a  
sourcelist on the left and a tableview.


The source list displays object from a core data entity. THe table  
view will be populated by a custom datasource as I have to do some  
data munging on the way from core data to the tableview. My custom  
controller (datasource) is based on NSObject and has the standard  
tableview delegate methods.


The tableview is also populated based on the selected item in the  
source list. So I've setup a notification from the outlineview to  
call a method in my custom controller. This works fine and when I  
execute it I'm trying to get the outlineview's treecontrollers  
selection like so;


NSString *accountName = @default;   //set initial string value
NSLog(accountName); // check logging
object = [MLoutlineViewController selection];	//get selection object  
from treecontroller (proxy of core data entity)
accountName = [object valueForKey:@name];  //get name property  
from object


The object being returned from the selection is always NULL.

Console shows the following;

2008-05-19 22:25:46.990 moolahcoredata[664:10b] Cannot perform  
operation without a managed object context

2008-05-19 22:25:46.996 moolahcoredata[664:10b] default

Now, I know the context error is probably because the outlineview  
starts up with an item selected, probably before core data is  
initialised properly. I've also read that every controller has to  
have the context bound. My controller is based on NSObject, it  
doesn't have bindings and I'd rather do things programmatically just  
now. Do I need to somehow use the context to get the selection? If  
so, how? I know context is needed for adding, fetching etc but to  
get an object from a treecontroller? I don't think so somehow.


A few things here make me think that you haven't got the idea of using  
NSControllers at all.  If you've coded up an NSOutlineView datasource  
then the tree controller has nothing to do with your setup.  Without  
bindings how have you linked the tree controller to the outline view?   
The way its traditionally (and designed to be) used is that the tree  
controller is the outline view's data source.  The tree controller is  
then bound to the managed object context.


There are many tutorials online about how to set this up with and  
without Core Data. Can you clarify your setup please.


Jon



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]

[OT] Wales/South West NSCoder Night (UK)

2008-05-19 Thread Jonathan Dann

Hi Guys,

In follow-up to the last open invite I've had a couple of responses to  
starting an NSCoder night.  The proposed location is to vary between  
Cardiff and Bristol, is anyone from the surrounding areas interested?   
Please contact me off-list.


Look forward to hearing from you.

Jon



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: NSTreeController problems

2008-05-18 Thread Jonathan Dann


On 18 May 2008, at 20:57, Charles Srstka wrote:

Lately, I've been trying to update my stodgy old ways and try to  
incorporate some of the new technologies Cocoa has picked up over  
the years when starting new projects (my main app has had to be  
compatible with older OS X versions, so I haven't had much  
opportunity to jump into the world of bindings prior to now). One of  
these is NSTreeController. Unfortunately, I'm having a bit of  
trouble using figuring out how to do what I want with it.


1. The order of the objects in my (non-Core Data) data model is  
sometimes important, so rather than using the tree controller to add  
objects, I have been adding them manually by calling the appropriate  
-insertObject:inkeyatIndex: methods. Okay, that works pretty well,  
and the objects show up in the NSOutlineView. However, I'd like to  
select the objects after I insert them. Now, I know where these  
objects are in the model, but since the order of the objects in the  
outline view might be different due to the user clicking on one  
column header or another to sort, and since the index paths sent to  
the tree controller's -setSelectedIndexPaths: method seem to be  
based on the interface, not the model, I don't know exactly where  
these objects are in order to select them. NSTreeController appears  
to have no -indexPathForObject: method or anything similar - does  
anyone know a way around this?


	1a. At first I thought that since I am making a sibling to the  
currently selected object, I could just get the parent's index path  
via [[treeController selectionIndexPath]  
indexPathByRemovingLastIndex], then get the node at that index path  
and iterate through its -childNodes until I find the one whose - 
representedObject is the correct model object, but there doesn't  
seem to be any way to get NSTreeController to give the node (or the  
model object, for that matter) for an index path. Does anyone else  
find this a little bizarre


To have an indexPathForObject method you need this:


- (NSArray *)rootNodes;
{
return [[self arrangedObjects] childNodes];
}

// this is a depth-first search
- (NSArray *)flattenedNodes;
{
NSMutableArray *mutableArray = [NSMutableArray array];
for (NSTreeNode *node in [self rootNodes]) {
[mutableArray addObject:node];
if (![[node valueForKey:[self leafKeyPath]] boolValue])
[mutableArray addObjectsFromArray:[node 
valueForKey:@descendants]];
}
return [[mutableArray copy] autorelease];   
}

- (NSTreeNode *)treeNodeForObject:(id)object;
{   
NSTreeNode *treeNode = nil;
for (NSTreeNode *node in [self flattenedNodes]) {
if ([node representedObject] == object) {
treeNode = node;
break;
}
}
return treeNode;
}

- (NSIndexPath *)indexPathToObject:(id)object;
{
return [[self treeNodeForObject:object] indexPath];
}

They're all separate methods as I have quite a few extensions on  
NSTreeController!




2. Okay, so I've got my objects displaying in an NSOutlineView, and  
now I'd like to add a search feature. Rather than eliminating the  
options that don't match, what I want to do is find the object,  
expand all its ancestors in the outline view so it's visible, and  
select it. Finding the model object is easy, and doing the rest  
*would* be easy enough if I weren't using NSTreeController - just  
climb the family tree, use -rowForItem: for each, expand it, and  
then use -rowForItem: to get the object and select it. Of course,  
with NSTreeController we have all these NSTreeNode objects instead  
of the actual objects themselves in the outline view, so - 
rowForItem: won't work. Is there any way to find the rows for the  
various nodes in the family tree of an object without resorting to  
just iterating through every row in the outline view? Any way to get  
the tree node for a given model object?


Now you have a treeNode for object you can as the NSOutlineView to  
expand that item (the NSTreeNode) using -expandItem:


Ive recently written two posts on NSTreeController, the first is non- 
Core Data the second is with core data but the sample project has a  
load of extensions that let you do what you want to do. They're at


http://jonathandann.wordpress.com/2008/04/06/using-nstreecontroller/

and

http://jonathandann.wordpress.com/2008/05/13/nstreecontroller-and-core-data-sorted/

Hope this helps

Jon



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: releasing NSKeyedUnarchiver causes crash

2008-05-18 Thread Jonathan Dann


On 18 May 2008, at 18:04, Markus Spoettl wrote:


On May 18, 2008, at 5:25 AM, Klaus Backert wrote:
- (BOOL)readFromData:(NSData *)data ofType:(NSString *)typeName  
error:(NSError **)outError

{
  *outError = nil;
  NSKeyedUnarchiver *archiver;
  archiver = [[NSKeyedUnarchiver alloc] initForReadingWithData:  
data];


  // release current data
  [tracks release];
  tracks = [archiver decodeObjectForKey: @myobject];
  [tracks retain];




As tracks seems to be an ivar, it would likely be better practice to  
handle your memory management in an accessor, this way you never have  
to remember to write retain and release multiple times:


- (void)setTracks:(id)newTracks;
{
if(tracks == newTracks)
return;
[tracks release];
tracks = [newTracks retain];
}

you can the just call [self setTracks:newValue];

see here:

http://developer.apple.com/documentation/Cocoa/Conceptual/MemoryMgmt/Articles/mmAccessorMethods.html

To avoid writing accessors altogether, use Obj-C 2.0 properties.

http://developer.apple.com/documentation/Cocoa/Conceptual/ObjectiveC/Articles/chapter_5_section_2.html#/ 
/apple_ref/doc/uid/TP30001163-CH17-SW13


Sorry if I've told you things you know already and there was another  
perfectly valid reason for doing what you did.


Jon

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: NSTreeController problems

2008-05-18 Thread Jonathan Dann


On 18 May 2008, at 23:57, Charles Srstka wrote:


On May 18, 2008, at 5:47 PM, Jonathan Dann wrote:

Not any more, the documentation may not have been updated yet.  The  
header for NSTreeController says differently as of 10.5.  It's  
always good to check the docs and the comments in the header file.   
(control double click on the word NSTreeController in your code to  
get to the header). You often find the odd method that's not in the  
docs too. File a radar if you do for any of the classes you use.


Glad to be of service, feel free to ask more.

Jon


Oh sweet, you are indeed correct. The header also mentions a - 
descendantNodeAtIndexPath: method I can send this object that will  
allow me to get the node at a given index path, which was another  
thing I was having trouble doing.


Thanks! :-)

Charles


Yeah that one's really useful. NSTreeController is so much easier to  
use in 10.5 but those extensions to NSTreeController NSTreeNode and  
NSIndexPath make it really simple to use.


You're welcome. These ones I didn't post but I use ALL the time too  
(note they call other methods in the sample project)


//NSTreeNode_Extensions (insipred by Apple's SourceView sample code)
- (NSArray *)descendants;
{
NSMutableArray *array = [NSMutableArray array];
for (NSTreeNode *item in [self childNodes]) {
[array addObject:item];
if (![item isLeaf])
[array addObjectsFromArray:[item descendants]];
}
return [[array copy] autorelease];
}

// NSTreeController_Extensions
- (void)setSelectedNode:(NSTreeNode *)node;
{
[self setSelectionIndexPath:[node indexPath]];
}

- (void)setSelectedObject:(id)object;
{
[self setSelectedNode:[self treeNodeForObject:object]];
}

- (NSArray *)flattenedSelectedNodes;
{
NSMutableArray *mutableArray = [NSMutableArray array];
for (NSTreeNode *treeNode in [self selectedNodes]) {
if (![mutableArray containsObject:treeNode])
[mutableArray addObject:treeNode];
if (![[treeNode valueForKeyPath:[self leafKeyPath]] boolValue]) 
{
			[mutableArray addObjectsFromArray:[treeNode  
valueForKeyPath:@descendants]];

}
}
return [[mutableArray copy] autorelease];
}

- (NSArray *)flattenedSelectedObjects;
{
	return [[self flattenedSelectedNodes]  
valueForKey:@representedObject];

}

- (NSArray *)flattenedSelectedLeafNodes;
{
NSMutableArray *mutableArray = [NSMutableArray array];
for (NSTreeNode *treeNode in [self flattenedSelectedNodes]) {
if ([[treeNode valueForKeyPath:[self leafKeyPath]] boolValue])
[mutableArray addObject:treeNode];
}
return [[mutableArray copy] autorelease];
}

- (NSArray *)flattenedSelectedLeafObjects;
{
	return [[self flattenedSelectedLeafNodes]  
valueForKey:@representedObject];

}

- (NSArray *)flattenedSelectedGroupNodes;
{
NSMutableArray *mutableArray = [NSMutableArray array];
for (NSTreeNode *treeNode in [self flattenedSelectedNodes]) {
if (![[treeNode valueForKeyPath:[self leafKeyPath]] boolValue])
[mutableArray addObject:treeNode];
}
return [[mutableArray copy] autorelease];
}


- (NSArray *)flattenedSelectedGroupObjects;
{
	return [[self flattenedSelectedGroupNodes]  
valueForKey:@representedObject];

}

Jon



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]

Core Data and Run Loops

2008-04-30 Thread Jonathan Dann

Hi All,

I'm now learning Core Data and was working through the persistent  
document tutorial when I hit a snag.


After following the advice in the Adpoting the Mediator Pattern the  
object controller now simply prepares its content and fetches the  
department  object.


I then tried in my windowControllerDidLoadNib method to use the array  
controllers add and insertObject:... methods to populate the context  
after all had loaded but got an exception when _NSStateMarker was sent  
mutableCopyWithZone: which it didnt recognise.  When using  
performSelector:withObject:afterDelay:it worked fine.


I thought that since the add: method and its counterparts were  
deferred until the next run loop anyway I wouldn't have to do this. Is  
there something happening in the background when the controllers set  
up their bindings to the context, meaning they're not set in when  
windowControllerDidLoadNib: is called? I'm sure I read something in  
the core data guide about run loops and performing after delays but I  
may be wrong.


Thanks,

Jon
___

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: Subclassing NSScroller

2008-04-14 Thread Jonathan Dann


On 14 Apr 2008, at 02:12, Chris Hanson wrote:


On Apr 13, 2008, at 3:13 PM, [EMAIL PROTECTED] wrote:


I believe this is a typo in the documentation. The method you want to
override is actually spelled -drawArrow:highlightParts:


In http://www.cocoabuilder.com/archive/message/cocoa/ 
2008/1/26/197320, Troy Stephens responds to Michael Watson's  
mention of that method with:


That method isn't part of NSScroller's published API (note its  
absence

from NSScroller.h).  Therefore it's subject to disappearing without
warning in a future release, and you should avoid any reliance on it
in your code.


Don't rely on anything that isn't API.  If there's something you  
can't do within the API, please file a bug at http://bugreport.apple.com/ 
 and describe what you're trying to create.


 -- Chris



Hi Guys,

Thanks ever so much for your responses on this, I appreciate it.  Can  
I clarify then?


Clearly using undocumented API is a bad road to start on so - 
drawArrow:highlightParts: is out of the question.  So if I override - 
drawRect: (so obvious that I forgot about it), draw the arrows and  
then call -drawKnob etc. I'm then going along the right lines?


Any ideas why passing slimmer frames to -initWithFrame: has no effect  
on the initial scroller width?


Jon

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: HUD-style panel controls?

2008-04-13 Thread Jonathan Dann

In the mean time, there is this.

http://lipidity.com/apple/ilife-controls-hud-windows-and-more

Jon

On Sat, Apr 12, 2008 at 7:21 PM, Michael Watson [EMAIL PROTECTED]  
wrote:
You aren't missing anything. Apple gave us an official HUD panel and  
UI
guidelines surrounding it, and failed to provide any HUD-style  
controls to
go with it. If the idea is to give us something standard, so  
everyone's not

rolling slightly different HUD panels, we should have at least /some/
standard HUD controls.

Please, please file an enhancement request.


--
m-s


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]

Subclassing NSScroller

2008-04-13 Thread Jonathan Dann

Hi All,

I'm trying to re-create the iTunes and HUD window scrollbars for my  
project.  I've managed to get a good looking NSScrollerKnob, and  
NSScrollerKnobSlot using bezier paths and gradients, but now I'm  
moving on to the arrows and the curved ends of the slot.


To get the knob I've overridden -drawKnob and the slot is done by  
overriding -drawKnobSlotInRect:highlight:.  By the same logic I  
thought that -drawArrow:highlight: would allow me to start playing  
with the arrows, but this never gets called.  Has anyone any  
experience with doing this, and changing the width of the whole  
(vertical) bar itself?  Passing arbitrary NSRects to -initWithFrame:  
doesn't seem to have any effect on the size of the scroll bar.


Thanks for your time,

Jon

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: NSTreeController / CoreData still broken in 10.5?

2008-04-09 Thread Jonathan Dann


On 7 Apr 2008, at 23:52, Adam Gerson wrote:


However, I am using CoreData with my TreeController bound to a Managed
Object Context. Can I still supply a contentArray in this situation?

Adam


On Sun, Apr 6, 2008 at 9:36 AM, Jonathan Dann [EMAIL PROTECTED]  
wrote:

Hi Adam,

I've just finished a blog post on this, it's not about using it  
with core

data, but it may help you out.

http://jonathandann.wordpress.com/2008/04/06/using-nstreecontroller/

Hope its useful

Jon

Jonathan P Dann: Trainee Medical Physicist - Homepage - Flickr
contact | [EMAIL PROTECTED] - 07515-352-490 | skype - jonathandann



I'm afraid I'll have to defer to those who know core data better than I.

Sorry

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: Menu Key Equivalents Not Displayed

2008-04-06 Thread Jonathan Dann


On 7 Apr 2008, at 01:16, Michael Ash wrote:


In short, if your shortcut conflicts with an existing one then it
won't show. But if it matches an existing one including in terms of
behavior, then it will show.


Yeah but that wasn't happening, my command-G shortcut was conflicting  
with the Find Next item in the Edit menu so it was not showing on one  
menu (that attached to the NSSegmentedControl), but it was showing on  
the others (the contextual menu in my source list and the menu bar).   
So there does seem to be a bug.


Forgive me if I've misunderstood you,

Jon

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: Source list using bindings?

2008-03-26 Thread Jonathan Dann


On 26 Mar 2008, at 00:45, Hamish Allan wrote:


Hi Jon,

On Tue, Mar 25, 2008 at 9:49 PM, Jonathan Dann [EMAIL PROTECTED]  
wrote:


As of 10.5 it's the Apple-sanctioned way to go!  I've used it for  
ages
now, no problems at all.  The tree node is a proxy for whatever  
'real'

item you add to the tree.


I just wondered why it was NSTreeControllerTreeNode rather than
NSTreeNode. I'm just naturally wary of solutions beginning class-dump
shows...!


You do get a lot of that, it's maybe a contrived example, but many of  
your classes will get replaced at runtime by isa-swizzling to make  
them something like KVONotifyingMyAwesomeClass (I forget the prefix  
Apple adds, just have a look in the debugger).  It'll just be some odd  
implementation detail that will be beyond me!  The 10.5 docs for  
NSTreeController all refer to NSTreeNode.





You can also get the selectedNodes, which returns treeNode objects,  
or

the selectedObjects, which returns the 'real' obejcts that you've
created.


Splendid!


My isGroupItem just compares an NSString *nodeName of the represented
object to a list of strings I want to have as groups, i.e @SOURCES,
@PLAYLISTS, etc.


I just treat everything at the top level as a group item:

- (BOOL)outlineView:(NSOutlineView *)outlineView isGroupItem:(id)item
{
return ([outlineView parentForItem:item] == nil);
}


Thank you for your autosaving advice; I did see your code for that on
the list recently, and it will doubtless be very useful.



You're welcome.

Jon

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]

NSLayoutManager Non-Contiguous Layout

2008-03-26 Thread Jonathan Dann

Hi Guys,

I'm using non-contiguous layout in one of my text views and I keep  
getting this strange drawing error when I scroll quickly just after  
the document has loaded:


http://flickr.com/photos/jonathandann/2364567591/

I have a method that highlights syntax by getting the visible  
character range in the scroll view and setting some temporary  
attributes to the text.  When that is never called, this drawing bug  
(is it invalidation of glyphs?) doesn't happen.  I've tried all the  
different variations on the ensureLayout and placed them everywhere I  
can think of I'm even getting the -didCompleteLayout. method sent  
to my layout manager's delegate.


When this happens if I switch apps I see the view fix the drawing, the  
same happens if I scroll a tiny bit more after I see this.  Calling - 
display and -displayIfNeeded on the textView after setting the  
temporary attributes doesn't work either. Does anybody have any  
experience with this issue, I'm at a loss.


Thanks in advance,

Jonathan

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: Source list using bindings?

2008-03-25 Thread Jonathan Dann



Ah, thanks. I wonder what the purpose of this subclass is and how
fragile this solution?


As of 10.5 it's the Apple-sanctioned way to go!  I've used it for ages  
now, no problems at all.  The tree node is a proxy for whatever 'real'  
item you add to the tree.


You can also get the selectedNodes, which returns treeNode objects, or  
the selectedObjects, which returns the 'real' obejcts that you've  
created.


My isGroupItem just compares an NSString *nodeName of the represented  
object to a list of strings I want to have as groups, i.e @SOURCES,  
@PLAYLISTS, etc.




I'm not convinced I'm going to go the bindings route, as my source
list has non-collapsible groups, and making sure they're expanded and
not selected when the table is first displayed seems as much trouble
as just using a datasource in the first place!



Bindings do make the whole thing a lot easier in the long run, and  
autosaving of the state just needs a bit of trickery:


1) Subclass NSOutlineView and add a method that simply looks at each  
row in turn and sees if the itemAtRow is expanded.


2) Add all the expanded items to an array.

3) Save the array in your data store, along with the whole tree as you  
normally would.


4) On loading, set the outline view's content and then pass the  
'expanded items' array to another method 'expandItemsInArray' in you  
NSOutlineView subclass.


5) This method should start at row 1 and compare all the items in the  
expanded items array to the itemAtRow: if they're the same expand the  
item


6) When you do this, be sure to update the number of rows as each  
expansion of an item causes the number of rows to increase.


This works without fail for me, i posted the code that does this a  
while back, sometime in the last couple of months.


Hope this helps,

Jon

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]

Using CoreAnimation to Show/Hide a SplitView Pane

2008-03-23 Thread Jonathan Dann

Hi All,

I've managed to do the above with NSAnimation, but I'm trying to do  
the same using Core Animation.


AFAIK To hide a split view pane when the user clicks a button, you  
need to set the frame's height/width to zero and move the divider when  
the animation has finished.  When using an implicit animation on the  
view's frame I can't see how to get a notification that the animation  
has ended.  If I do the following:


// horizontal splitView
[[subview animator] setFrame:newFrame];
[splitView setPosition:[splitView maxPossiblePositionOfDividerAtIndex: 
0]  ofDividerAtIndex:0];


the animation is not shown as the divider causes the subview to 'snap'  
shut immediately.  With NSAnimation you can set the delegate and move  
the split view bar in the -animationDidEnd: method.


To do the same with Core Animation I've tried to set up my own  
CABasicAnimation, but I can't get it to work, and the Programming  
Guide isn't clearing up the matter for me.  I've tried this so far:


- (IBAction)hide:(id)sender {
		NSScrollView *scrollView = self.splitView.subviews.secondObject; // - 
secondObject is my own NSArray method and the scrollView is the lower  
of a horizontal two-pane split view;


NSRect toValue = scrollView.frame;
toValue.size.height = 0.0;

	CABasicAnimation *hidePaneAnimation = [CABasicAnimation  
animationWithKeyPath:@position];

[hidePaneAnimation setRemovedOnCompletion:NO];
[hidePaneAnimation setFillMode:kCAFillModeForwards];
[hidePaneAnimation setToValue:[NSValue valueWithRect:toValue]];
	[hidePaneAnimation setFromValue:[NSValue valueWithRect:[scrollView  
frame]]];

[hidePaneAnimation setDelegate:self];
[scrollView setWantsLayer:YES];
[scrollView setLayer:[CALayer layer]];
	[[scrollView layer] addAnimation:hidePaneAnimation  
forKey:@positionAnimation];

}

- (void)animationDidStop:(CAAnimation *)animation finished: 
(BOOL)finished;

{
NSLog(@%p %s %@ Finished: %i,self,__func__,animation,finished);
NSString *keyPath = [(CABasicAnimation *)animation keyPath];
NSLog(@key %@,keyPath);
NSSplitView *splitView = (NSSplitView *)self.view;
CALayer *layer = [splitView.subviews.secondObject layer];
	[layer setValue:[(CABasicAnimation *)animation toValue]  
forKeyPath:keyPath];

[layer removeAnimationForKey:keyPath];
	[splitView setPosition:[splitView maxPossiblePositionOfDividerAtIndex: 
0] ofDividerAtIndex:0];

}

Currently this just causes the pane to snap shut and flicker a  
little.  Can anybody give me a hand with this, please?


Thanks,

Jonathan





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: Correct use of NSViewController

2008-03-21 Thread Jonathan Dann

Hi Cathy and Paul,

Thanks to you both for your help, I'm really starting to get somewhere  
with this now.


I now have a view controller hierarchy that reflects the views in my  
app.  I've defined my own view controller subclass that I use and an  
abstract superclass for the view controllers I use in the app.  To  
this 'ESViewController' class I've added a, parent ivar, a mutable  
children array and a few indexed accessor methods for that.


To add a new view controller to the hierarchy I use -addChild: 
(ESViewController *)vC which has the side-effect of setting the parent  
and (originally) the window controller of the child.  The parent will  
be the view controller that calls -addChild: and the window controller  
of the 'root' view controller of the tree is set when I first make the  
root view controller.


Cathy, your suggestion of adding the window controller to the views  
and their children so I could get the document seemed to work at  
first, but I kept getting a warning when closing my document.  One of  
my children view controllers had an NSObjectController with the  
content binding set to @file's owner.windowController.document,  
which worked fine until I tried to close the document.  I was told  
that the window controller was being deallocated while key-value  
observers were still registered with it, which I assume was the  
NSObjectController further down in the view hierarchy.


I think this has something to do with retains, as the window  
controller was not retained by the view controllers, I couldn't get my  
head around who should retain who as my -dealloc methods look like this:


// ESViewController (inherits from NSViewController and used as  
abstract superclass for all my view controllers)


- (void)dealloc;
{
parent = nil; // non-retained ivar
self.children = nil;
windowController = nil;
[super dealloc];
}

// ESWindowController  (my window controller for my document)
- (void)dealloc
{
	self.rootViewController = nil; // rootViewController is an instance  
of ESSplitViewController which places a split view in the window's  
content view)

[super dealloc];
}

My windowController's -awakeFromNib method set the root view  
controller, which when instantiated created its children, setting  
their window controllers and parents as such


// ESWindowController
- (void)awakeFromNib;
{
	ESSplitViewController *root = [[ESSplitViewController alloc]  
initWithNibName:@SplitView bundle:nil];

[root setWindowController:self];
[self setRootViewController:root];
[root release];
root =  nil;
}

// ESSplitViewController
- (id)initWith..
{
if (![super init])
return nil;
	ESOutlineViewController *oVC = [[ESOutlineViewController alloc]  
initWithNibName:@OutlineView bundle:nil]; // the OutlineView nib has  
the NSObjectController that causes the deallocation grief
	ESTextViewController *tVC = [[ESTextViewController alloc]  
initWithNibName:@TextView bundle:nil];

[self addChild:oVC];
[self addChild:tVC];
[oVC release];
[tVC release];
return self;
}

- (void)addChild:(ESViewController *)child;
{
[child addObject:child];
[child setWindowController:self.windowController];
[child setParent:self];
}

So the way I expected it to work, when deallocating was as follows

windowController gets a -dealloc call
rootViewController gets released and -dealloc'd
childrenViewControllers get released and -dealloc'd
at the end of all this the control returns to the windowController's - 
dealloc method which proceeds to call [super dealloc];


Some amount of logging later showed me that my windowController was  
calling super before the children began their dealloc methods, which  
leads me to assume that maybe the unbinding of the NSObjectController  
couldn't happen as the windowController to which it was bound was  
already gone.


So this boils down to a couple of ideas

Why could the window controller complete it's deallocation before the  
children view controllers have, when they are definitely not retained  
elsewhere?
Should the view controllers have retained the window controller and/or  
their parent (instinct leads me to think this would cause retain  
cycles as the window controller will not call -dealloc as it is  
retained by view controllers which it needs to release first).


I later changed this code with Paul's suggestion of using the  
represented object as a pointer to my document subclass and all this  
went away.  The -addChild method now sets the represented object of  
the child to that of its parent instead of the window controller.  Am  
I right in thinking that because of the document architecture the  
document cannot be deallocated until the window controller is, so  
deallocating the window controller removes the binding before the  
document receives -dealloc.  In that case, if I did wish to bind  
something 

Re: Correct use of NSViewController

2008-03-20 Thread Jonathan Dann



Hi Cathy,

Thanks again for your advice. I've got it working now and I'm almost  
back I where I was before refactoring, I'm now running into a bindings  
problem.


Before using the view controllers I had put 2 tree controllers in my  
window controller's nib, 2 outline views were then bound to these and  
the tree controllers themselves got their content from an object  
controller that was bound to the the keypath [(Window Controller) 
File's Owner].document. So the object controller was a proxy for my  
document and the tree controllers had shorter keypath to traverse to  
get to the array they needed in my document subclass.


Now when I do this I have the tree controllers and the document proxy  
object controller in my view controller's nib. The only way I can see  
to getting to the document is using the keypath


[File's Owner].view.window.windowController.document

However this does not work, seems convoluted, and I get the following:

KVO autonotifying only supports -setKey: methods that return void.  
Autonotifying will not be done for invocations of -[NSSplitView  
_setWindow:]


So my view controller needs to know about its 'owning' document  
somehow and I can't see how to get it.


Have you run into this. I'm not sure getting the current document from  
the document controller will work as that will change ad the user  
opens more documents.


Thanks again,

Jon

P.S. Out of interest, what do you develop?
___

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]


Correct use of NSViewController

2008-03-19 Thread Jonathan Dann

Hi guys,

I've ended up with a bloated window controller in my document based  
app and want to refactor my code using done view controllers.  My  
question is really about design.


If I have a split view with which contains a split view (like mail)  
then should I have a controller for the large split view which will  
then contain an ivar that points to a controller for the smaller split  
view?  As a subview of one of the split views I would then have a text  
view that itself needs a view controller, so it seems like I'll he  
ending up with a heirarchy of view controllers that reflects the view  
heirarchy itself. This seems like I'm gong about this the wrong way ad  
would end up with a spaghetti code.


Can anyone give mr a few hints as to how this should he fine properly?

Thanks,

Jon
___

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: Correct use of NSViewController

2008-03-19 Thread Jonathan Dann

Hi Cathy,

Thanks for the comprehensive answer to my question, I wanted to make  
sure that I wasn't committing heresy by going down the 'tree of view  
controllers' road before jumping in and refactoring all my code.  I  
was hoping to set it up so I could forget about most of the memory  
management as I'm replacing views all over the place at runtime.


Out of interest, when I add my main split view, I then have to set its  
size to fit my document window's content view.  As this task is view- 
related it seems like it the split view's NSViewController should  
handle the size calculation and placing of the view in the correct  
place in the window.  I allocate and instantiate my view controller in  
my NSWindowController subclass, then set the split view as a subview  
of the content view and then  in the -awakeFromNib of the view  
controller I get the split view's superview's (the content view's)  
frame, doing my resiing from there.


Would you do the same, as this seems to encapsulate the logic  
properly, or would you just set it all in the window controller?


Thanks again, you've been really helpful.

Jonathan

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: Core Animation Choppyness

2008-03-11 Thread Jonathan Dann


On 10 Mar 2008, at 22:40, Scott Anguish wrote:

if you stop the animation of the replaceSubview... is that no longer  
choppy?  This is one of the most expensive animations possible.


That fixed it, looks great now!  It was a flickering NSPopUpButton  
that was causing me grief.



also, are all your boundaries integral?


I assume they are as I've just created a bunch of custom views in IB  
and set their frames there.  Would there be a better way?  If they  
can't be resized by the user, is it worth calculating their values on  
startup and just caching them, even though I calculate the new frame  
before the animation?


Thanks very much Scott,

Jon

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: How to get the name of a method at runtime?

2008-03-09 Thread Jonathan Dann


I think maybe you missed the existence of _cmd. Both self (this  
object) and
_cmd (this selector) are passed as implicit arguments to every  
Objective-C

method.


You can also call __func__ from within a method call, I use this often,

NSLog(@%p %s,self,__func__); // Thanks James Bucanek

Jon

___

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]


10.5.2 release notes?

2008-03-06 Thread Jonathan Dann

Hi Guys,

Does anyone know if there are some release notes specific for 10.5.2?   
I remember reading on some blog that there was an NSTreeController  
bugfix.  I can't seem to be able to find any details on Google other  
than these


http://docs.info.apple.com/article.html?artnum=307109

which have no mention of it.

Thanks,

Jon

Jonathan P Dann: Trainee Medical Physicist - Homepage - Flickr
contact | [EMAIL PROTECTED] - 07515-352-490 | skype - jonathandann

___

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: Localise between different versions of English

2008-03-05 Thread Jonathan Dann


On 5 Mar 2008, at 17:25, Christopher Nebel wrote:


On Mar 4, 2008, at 9:36 PM, Jens Alfke wrote:


On 4 Mar '08, at 3:23 PM, Sean McBride wrote:


There's also Canadian English (en_CA), and perhaps others too...


The ISO is in the process of adding en_LOL for Lolcat, aka Kitteh  
or Cat Pidgin[1]. (If you don't think there's a need for this,  
consider what HTTP Language: header value should be used by  
daringfurball.org or icanhascheezburger.com.)


I presume Jens was joking, but for a chuckle, go to Google web  
search, hit Preferences and check out the Interface Language  
preference.  There are lots of real ones (be careful experimenting,  
you may have trouble getting back to English!), but a few fakes as  
well.  LOLcat is, regrettably, not one of them, but they do have  
Klingon, Hacker (notice what Hacker is when written natively), and  
my personal favorite, Elmer Fudd.



--Chris N.



Even Leopard (and Tiger, not sure about further back) has Klingon  
(tlhlngan Hol)!  Don't know about the ISO code for it though.


Jon

___

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: regexkit [Using NSPredicate to parse strings]

2008-03-04 Thread Jonathan Dann


On 4 Mar 2008, at 17:50, Jens Alfke wrote:



On 4 Mar '08, at 3:25 AM, Jonathan Dann wrote:

That is a seriously good framework, and the documentation is great  
too.


My only issue with regexkit is that it uses PCRE instead of ICU.

PCRE has to be compiled into the library, making it larger (whereas  
ICU is already built into the OS.)


PCRE is also, last I checked, less I18N-savvy than ICU. This has  
given me grief in the past; I used PRCE-based regex code in a  
project 3 years ago, and as soon as the Japanese and Korean testers  
started working with it, they found that the app's text searching  
didn't work correctly for them. (In a nutshell, PCRE's notion of  
alphabetic characters and word breaks only works for Roman  
writing systems.)


Unfortunately I don't know of a comparable Cocoa regex library that  
uses ICU. (NSPredicate does, but its support for regexes is very  
limited, as already discussed in this thread.)


—Jens


Thanks for the heads-up Jens, that will probably be an issue for me in  
the future, I'm going to localise my app for as many languages as I  
can so I'll have to find out how a few non-Roman-typing users will be  
using it and if it will affect them.


I'm most-likely going to have to support many text-encodings.  Say if  
I'm writing a document in Jaspanese (Mac OS), will I have to convert  
that to UTF-8 before the methods of something like RegexKit would  
work?  Any caveats you know of that I need to be aware of? I'm  
learning by doing.


Thanks for taking the time to mention the PCRE thing, I appreciate it,

Jon

___

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: Best place to remove observer for NSViewBoundsDidChangeNotification

2008-03-04 Thread Jonathan Dann


On 25 Feb 2008, at 23:30, Jonathan Dann wrote:



On 25 Feb 2008, at 23:15, Jerry Krinock wrote:

I presume that sending a notification to a deallocced object causes  
a crash?


Invariably! ;)

Oh, yes, it will bite you.  Says so right in the documentation of - 
[NSDocument close].


Funny how I read that so many times last week when overriding - 
canCloseDocument: but then forget immediately.


When I had a problem like this one time I ended my -dealloc like  
this:


  [super dealloc] ;
  self = nil ;
}


I'll try it, just looking for a 'clean' implementation, so I  
unregister at the right point.


Just for completeness,

I found that I was registering for the notifications of a view in my  
NSDocument's -init method, not in the -windowDidLoadNib.  Therefore  
the object: argument of -addObserver:selector:name:object: was nil,  
thus I was getting *all* notifications.  Moving the registration to - 
windowDidLoadNib: sorted it all as the object I wanted to watch was  
instantiated.


Jon

___

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]


Using NSPredicate to parse strings

2008-03-03 Thread Jonathan Dann

Hi Guys,

I'm trying to find a way to use NSPredicate to search an NSString for  
all occurrences of a string and return them to me. Ideally I need the  
returned strings ranges too.


Is this possible? I can get is to tell me that a regex match is found  
using a predicate with the format @SELF MATCHES %@,myRegex and  
evaluating my plain text document string, but now I'm stuck.


Any help would be grand, thanks.

Jonathan Dann
___

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: Using NSPredicate to parse strings

2008-03-03 Thread Jonathan Dann


On 3 Mar 2008, at 16:16, Mike Abdullah [EMAIL PROTECTED]  
wrote:


Jonathon, you'll have much better luck with NSScanner. It's designed  
for exactly what you want.


Mike.












Thanks Mike, just tried it and it works quite well.  Any way of using  
NSScanner directly with regex? Not sure if its really necessary for my  
code but would probably be very useful, alternatively I'll just use  
NSPredicate to avoid scanning for stuff that isn't there.


Much appreciated,

Jon
___

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: [NSOutlineView] How to know an item is expanded if its parent item is not?

2008-03-02 Thread Jonathan Dann


On 1 Mar 2008, at 23:02, Stéphane Sudre wrote:


There seems to be a missing method in NSOutlineView.

You can know an item is expanded only if its parent is expanded (so  
that the item itself is visible).


This is problematic if you want to cache the current list of  
expanded items. Instead of just iterating through the item hierarchy  
when needed, you would need to use the notifications sent when an  
item is about to be disclosed or closed.


This is a bit strange if you consider that NSOutlineView probably  
caches this information in _expandSet or _expandSetToExpandItemsInto  
so that it can remember to expand the children of an item if needed.


An I missing something and is there a way to know which items are  
expanded (either visible or not)?


For what it's worth, I haven't found a way to do this either, would be  
really great if this can be cracked.  I had to manually track all the  
NSOutlineViewItemDidExpand (and the Collapse) notifications.


Jon___

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]


Best place to remove observer for NSViewBoundsDidChangeNotification

2008-02-25 Thread Jonathan Dann

Hi Guys,

I have a document-based non-GC app in which I register my document  
instance to receive an NSViewBoundsDidChangeNotification for my  
[[mainTextView enclosingScrollView] contentView].


On dealloc, the document calls [[NSNotificationCenter defaultCenter]  
removeObserver:self], but these notifications still get sent to the  
dealloc'd instance when the window itself closes.  I think this is  
something to do with the notification being sent/received in a delayed  
manner, am I right?


I've now overridden NSDocument's -close method to remove self from  
observing these notifications before calling [super close] (which  
works fine) but I was wondering if there was a better, more  
conventional place to put these -removeObserver: calls.  I'm not sure  
if this makes sense but are there any view-related methods that get  
called when a document/window closes that would be the best place to  
de-register for observations of view notifications? Could what I've  
done bite me if, for example, for some reason -close does not get  
called?


Thanks,

Jon
___

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: NSOutlineView autosaving of expanded/collapsed state

2008-02-25 Thread Jonathan Dann


On 24 Feb 2008, at 22:45, Ralph Manns wrote:



Am 24.02.2008 um 23:37 schrieb Jonathan Dann:

Hi Jon,

thanks for your response and providing your code. Works great.

Ralph.


You're welcome!

Jon
___

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]