Re: NSWindowController, bindings and Garbage Collection

2009-02-24 Thread Nikita Zhuk

I think I've found a workaround for this problem.

It seems that the model object is accessed from the GC thread's  
finalize only when the keyPath to which a value is bound contains at  
least three components. For example, if a value in the window is bound  
to "model.name" property, my model isn't touched from GC thread's  
finalize. If keypath is "model.subModel.name", methods of my model are  
called from GC thread's finalize.


So the workaround seems to be to use keypaths with only two components.



On 24.2.2009, at 22.22, Nikita Zhuk wrote:

I'm running a Cocoa application with Garbage Collection enabled,  
linking against 10.5 SDK. My application has a NSWindowController  
subclass which instantiates a window from a nib file (- 
[NSWindowController initWithWindowNibName:]) and acts as the File's  
owner of that nib. The window in the nib has several controls with  
values bound to properties of a model object, which is accessible  
through the File's owner. The model object assumes that all method  
calls made to retrieve its values are made in the main thread - it  
has assertions which verify that this is the case.


Under manually managed memory this works as expected - all bound  
values are fetched from the model object on the main thread and  
file's owner is deallocated after the window is closed. When the  
application is compiled and run with GC, file's owner is collected  
(finalize is run), but after a while NSBinder instance accesses my  
model class from a subthread, causing the "main thread only"  
assertion of my model class to fail with the following stack trace:


#2	0xa3aa in -[MyModelObject mainThreadOnlyMethod:] at  
MyModelObject.m:123

#3  0x936ebf6b in _NSGetUsingKeyValueGetter
#4  0x936eba07 in -[NSObject(NSKeyValueCoding) valueForKey:]
#5	0x9376aa01 in -[NSKeyValueNestedProperty  
object:didRemoveObservance:]
#6	0x93749c43 in -[NSObject(NSKeyValueObserverRegistration)  
_removeObserver:forProperty:]
#7	0x937499e4 in -[NSObject(NSKeyValueObserverRegistration)  
removeObserver:forKeyPath:]
#8	0x9376aa21 in -[NSKeyValueNestedProperty  
object:didRemoveObservance:]
#9	0x93749c43 in -[NSObject(NSKeyValueObserverRegistration)  
_removeObserver:forProperty:]
#10	0x937499e4 in -[NSObject(NSKeyValueObserverRegistration)  
removeObserver:forKeyPath:]

#11 0x93b3f690 in -[NSBinder _updateObservingRegistration:]
#12	0x93b85d0f in -[NSBinder  
releaseConnectionWithSynchronizePeerBinders:]

#13 0x93d288c8 in -[NSBinder finalize]
#14 0x933546b6 in finalizeOneObject
#15 0x91488dab in foreach_block_do
#16 0x9335487b in batchFinalize
#17 0x93354b42 in batchFinalizeOnTwoThreads
#18 0x91489f0e in auto_collect_internal
#19 0x9148ab8f in auto_collection_thread
#20 0x9559a095 in _pthread_start
#21 0x95599f52 in thread_start

There have been a similar problem reported earlier when using Core  
Data, bindings and GC [1]. The problem seem to be the same. How this  
could be prevented or worked around? My model objects must remain  
main-thread-only. Would the "NSObjectController as a file file's  
owner" pattern [2] help here?


[1] http://www.mail-archive.com/cocoa-dev@lists.apple.com/ 
msg17346.html

[2] http://www.borkware.com/quickies/do-search?search=nsobjectcontroller



___

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/nikita.zhuk%40karppinen.fi

This email sent to nikita.z...@karppinen.fi



___

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: plug-in

2009-02-24 Thread XiaoGang Li
Thanks very much. It is what I need. You are so nice.

2009/2/25 Karolis Ramanauskas 

> if this is the file you are talking about, I had no problem downloading it.
> Here I uploaded it to my site:
>
> http://strangeinversion.com/Paper2002.dmg.sit
>
> If it's something else, let me know...
> ___
>
> 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/andrew.macdev%40gmail.com
>
> This email sent to andrew.mac...@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


Binding an OutlineView and/or its TableColumn to a TreeController

2009-02-24 Thread Stuart Malin
I have a data model that is bound to a TreeController. The  
TreeController manages an OutlineView.


When I first implemented this, I bound the TableColumn backing the  
OutlineView to the TreeController (the TableColumn's Value property to  
the TreeController's arrangedObjects with a Model Key Path for the  
property I want displayed).  This worked fine -- even though I did not  
bind the OutlineView in any way to the Tree Controller. In some sample  
code I have been looking at, the Content property and the Selected  
Index Paths property of the OutlineView are bound to the  
TreeController (arrangedObjects and selectedIndexPaths, respectivel);  
this is in addition to the TableColumn's bindings.  I am not sure  
what, if any, functionality I am losing by *not* binding the  
OutlineView as well. (It seems to work just fine, expanding and  
collapsing tree nodes).


Question 1: Is it necessary to bind both the OutlineView and the  
TableColumn?



I can also make this work in the converse: binding the OutLineView's  
Content property and *not* binding the TableColum's Value. Well,  
almost works as no data is actually displayed. But that is overcome  
because (for other reasons) I use a custom cell for the TableColumn.  
I've got a controller that is the delegate for the OutlineView, and it  
implements:


- (void)outlineView:(NSOutlineView *)outlineView
willDisplayCell:(NSCell*)cell
 forTableColumn:(NSTableColumn *)tableColumn
   item:(id)item

When this delegate method is invoked, I call -setStringValue on the  
cell (with data gotten from the represented item), thereby setting its  
value, which is properly displayed.


Question 2: is this a valid approach (that is, bind only the  
OutlineView's Content property and supply the text via the delegate  
method)? I ask because while this does work, I don't know what gotchas  
may be lurking that I have not yet stumbled upon.




___

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: Stop edit session with a NSTextField

2009-02-24 Thread Patrick Mau

Hi Eric

I was going through your last messages on this list, because I'm  
working on a similar problem.
Reading through the code snippets you showed here, it isn't clear to  
me how your controls are being created.


Are you creating a subclass of NSControl and afterwards add your GUI  
elements as sub-views programatically?
I could not figure out if you use one NSControl with NSCell's, sorry  
if I missed it.


[snip]


Unfortunately, it does not work either.

If anyone has any further ideas on how to correctly end an editing  
session of a NSTextField, I am interested.


To summarize the proposed and failed solutions:

*** [[[self view] window] endEditingFor:nil];

Pressing return or pressing the tab key will not end the editing  
session


As far as I understand, TAB will focus the next control using the  
responder chain.
It is not really remove the editor, because you could TAB back to your  
control/cell

and still have the same state for editing.



*** [[[self view] window] makeFirstResponder:[self view]];

Pressing return will allow the editing session to end, but pressing  
the tab key will not.


I would suggest you write a small debug function to output the  
responder chain.
Call it after all your elements are setup and again after you started  
editing.



*** NSTextView *fieldEditor = [[aNotification userInfo]  
objectForKey:@"NSFieldEditor"];

   NSView *v = fieldEditor;
   while ( v && ( [v superview] != [aNotification object] ) )
   v = [v superview];
   [v removeFromSuperview];

Pressing return or pressing the tab key will not end the editing  
session


It works for me using one NSView only drawing NSCell objects.
But it was only a hack I tried to remove the field editor.

What happens when you NSLog all views you traverse on your way up?
Could you send the output?


The editing session was started with:

[textField selectText:nil]; 


This is a complete NSTexyField added as a subview to your NSControl,  
not a NSTextFieldCell?
Could you tell a bit more about how your abjects are created/setup, if  
you don't mind?


I'm asking because I work on a similar problem, implementing one
NSView class drawing multiple (editable) NSCell objects.

Regards
Patrick
___

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: Adding text to NSImage using lockFocus/unlockFocus not working

2009-02-24 Thread Graham Cox


On 25/02/2009, at 4:04 PM, ashish_tiw...@persistent.co.in wrote:



Hi Graham,

I tried what you have suggested still only images are shown with  
titles.



I'm not clear what the problem is - what did you expect to see?


- (NSString*)   imageSubtitle
{
NSDictionary* attribs = [image imageAttributes];

int w, h;

w = [[attribs objectForKey:@"PixelWidth"] intValue];
h = [[attribs objectForKey:@"PixelHeight"] intValue];

return [NSString stringWithFormat:@"%d x %d", w, h];
}



This won't work - NSImage doesn't have a method called - 
imageAttributes. In my code the attributes are retrieved using [self  
imageAttributes], and that method looks like this:


- (NSDictionary*)   imageAttributes
{
	// returns the image's attributes dictionary using CGImageSource to  
read the file's header. This is fast as the image

// itself isn't loaded.

NSURL*url = [NSURL fileURLWithPath:mPath];
	CGImageSourceRef  srcRef = CGImageSourceCreateWithURL((CFURLRef) url,  
NULL );
	NSDictionary*	  imgProps = (NSDictionary*)  
CGImageSourceCopyPropertiesAtIndex( srcRef, 0, NULL);


CFRelease(srcRef);

//NSLog(@"attributes for '%@': %@", mPath, imgProps );

return [imgProps autorelease];
}


I suspect your method is asserting when it's called due to the  
unimplemented method and that is stopping the browser view working  
properly. Check your console output.




--Graham


___

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: plug-in

2009-02-24 Thread Karolis Ramanauskas
if this is the file you are talking about, I had no problem downloading it.
Here I uploaded it to my site:

http://strangeinversion.com/Paper2002.dmg.sit

If it's something else, let me know...
___

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: Adding text to NSImage using lockFocus/unlockFocus not working

2009-02-24 Thread ashish_tiwari

Hi Graham,

I tried what you have suggested still only images are shown with titles.
May be there is something wrong with my other code segments. Please have a
look at my code if you can spot anything wrong. I suspect
imageBrowser:itemAtIndex: should have different implementation.

My AppController looks like this:
/**/
#import "AppController.h"

@implementation AppController
- (void)awakeFromNib
{
data = [[NSMutableArray alloc] init]; //array of IKBBrowserItem objects
[browserView setContentResizingMask:NSViewHeightSizable];

[browserView setDelegate:self];
[browserView setDataSource:self];

[self setDataWithPath:@"/Users/ashisht/Desktop/pics"];
[browserView reloadData];

}
- (NSUInteger) numberOfItemsInImageBrowser:(IKImageBrowserView *) aBrowser
{
return [data count];
}

- (id) imageBrowser:(IKImageBrowserView *) aBrowser
itemAtIndex:(NSUInteger)index
{
return [data objectAtIndex:index];
}
/**/

Where as my datasource items look like this:

/**/

@implementation IKBBrowserItem

@synthesize image;
@synthesize mPath;

- (id)initWithImage:(NSImage*)anImage imageID:(NSString*)anPath
{
if (self = [super init]) {
image = [anImage copy];
mPath = [anPath  copy];
}
return self;
}

- (void)dealloc
{
[image release];
[mPath release];
[super dealloc];
}

#pragma mark -
#pragma mark Required Methods IKImageBrowserItem Informal Protocol
- (NSString *) imageUID
{
return mPath;
}
- (NSString *) imageRepresentationType
{
return IKImageBrowserPathRepresentationType
/*IKImageBrowserNSImageRepresentationType*/;
}
- (id) imageRepresentation
{
return mPath;
}

#pragma mark -
#pragma mark Optional Methods IKImageBrowserItem Informal Protocol
- (NSString*) imageTitle
{
return [[mPath lastPathComponent] stringByDeletingPathExtension];
}
- (NSString*)   imageSubtitle
{
NSDictionary* attribs = [image imageAttributes];

int w, h;

w = [[attribs objectForKey:@"PixelWidth"] intValue];
h = [[attribs objectForKey:@"PixelHeight"] intValue];

return [NSString stringWithFormat:@"%d x %d", w, h];
}

/**/
>
> On 24/02/2009, at 9:50 PM, Ashish Tiwari wrote:
>
>> I am trying to get finder icon view like behavior in my
>> application.  Using
>> IKImageBrowserView I am able to show icons for contents of a
>> directory but I
>> also need file/directory name below those icons. For this I am
>> trying to
>> insert NString into NSImage but text is now showing up in
>> IKImageBrowserView.
>
>
> IKImageBrowserVIew has a much better way to handle this specific
> labelling requirement.
>
> The objects it stores should implement the informal protocol for -
> imageTitle and -imageSubtitle, and the view will draw those strings
> below the icons for you.
>
> Here are the methods I have in a simple custom object I use - I think
> I originally got this from one of Apple's samples though I'm afraid I
> forgot exactly which one. It simply provides the browser with the path
> to each image.
>
> --Graham
>
>
>
> //
> -
> //  imageRepresentationType:
> //
> //  Set up the image browser to use a path representation.
> //
> -
> - (NSString*) imageRepresentationType
> {
>   return IKImageBrowserPathRepresentationType;
> }
>
> //
> -
> //  imageRepresentation:
> //
> //  Give the path representation to the image browser.
> //
> -
> - (id)imageRepresentation
> {
>   return mPath;
> }
>
> //
> -
> //  imageUID:
> //
> //  Use the absolute file path as the identifier.
> //
> -
> - (NSString*) imageUID
> {
>  return mPath;
> }
>
>
> - (NSString*) imageTitle
> {
>   return [[mPath lastPathComponent] stringByDeletingPathExtension];
> }
>
>
> - (NSString*) imageSubtitle
> {
>   NSDictionary* attribs = [self imageAttributes];
>
>   int w, h;
>
>   w = [[attribs objectForKey:@"PixelWidth"] intValue];
>   h = [[attribs objectForKey:@"PixelHeight"] intValue];
>
>   return [NSString stringWithFormat:@"%d x %d", w, h];
> }
>
>


___

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 Subscript

Re: Strange NSManagedObjectContextObjectsDidChangeNotification behavior

2009-02-24 Thread Karolis Ramanauskas
OK, I managed to replicate my problem in this example project:
http://strangeinversion.com/weird.zip

If you are interested download it, only 44KB. It contains two core data
entities: BigBagOfFruit and Fruit.

1. Run the program
2. Add a bag
3. Now add some fruit in it ;)
4. Move your mouse around the window and look at your console:
NSManagedObjectContextObjectsDidChangeNotification get called all the
time...
5. Go to fruit class, comment out: [self setName:@"Banana"];
6. Repeat 1 through 4, problem is gone.

That's what I noticed in my program, whenever there is ANY SETTER within the
draw method that is called from MyView's drawRect, I get this behavior.

Any thoughts?
Thanks a lot.
___

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


plug-in

2009-02-24 Thread XiaoGang Li
Hi, List
 I want to develop an application which should have a plug-in
architecture, in order to give a way for third party to extend new feature
without touching the source code of my main application.
So, I have read the document <>, and then I also have read the artical written by Rainer Brockerhoff
<>, you can touch it here: --
http://cocoadevcentral.com/articles/68.php--. And more. I have reviewed
the Sample code supplied by ADC : BundleLoader.

   But at last, I decide to adopt the code from Rainer Brockerhoff, which
also have detailed description about every code line. But I can not access
the link address which is supplied in this article,
http://www.brockerhoff.net/pap.html.
   I need to download his source code to have a deeply study, and then maybe
I can integrate it to my application because of similiar functionality.
  So, my question is that does anyone have downloaded this pieces of code
already? can you share it with me? Thanks ahead.

AndrewLi
2009-02-25
___

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: do i need to create autorelease pool?

2009-02-24 Thread Peter N Lewis
I know what autorelease pools are and how they work so my question 
isn't about that.


In my iPhone app I create a NSTimer to run at 60fps, in it I update 
a bunch of stuff and draw opengl.


Currently I have:
-(void) timerLoop {
// create autorelease pool in case anything needs it
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];

// release pool
[pool release];
}

Do I need this autorelease pool here or does UIApplicationMain 
manage that for every call of timerLoop?


No, you don't need an auto release pool, the run loop handles that:

From the NSAutoreleasePool doicumentation:
The Application Kit creates an autorelease pool on the main thread 
at the beginning of every cycle of the event loop, and drains it at 
the end, thereby releasing any autoreleased objects generated while 
processing an event.


This is assuming iPhone or Leopard, I believe the NSAutoreleasePool 
creation was required for older versions of Mac OS X.


Enjoy,
   Peter.

--
 Run macros from your iPhone with Keyboard Maestro Control!
   or take a break with Aragom Space War for your iPhone

Keyboard Maestro  Macros for your Mac
Aragom Space War  Don't get killed!
   
___

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


OmniObjectMeter is now free

2009-02-24 Thread Ken Case
OmniObjectMeter tracks every retain, release, and autorelease in your  
application, and helps you pair them up to find zombies and leaks.   
We've been selling it for years, but today we've decided to release it  
as freeware (along with OmniWeb, OmniDiskSweeper, and OmniDazzle) as  
we focus our development efforts on our major products (OmniGraffle,  
OmniFocus, OmniPlan, and OmniOutliner).


You'll find it at .

Enjoy!
Ken

P.S. -- We also recently posted updated versions of our open source  
Omni frameworks to github, including OmniDataObjects (our CoreData- 
like implementation which works on both Mac and iPhone).  For more  
information, see .

___

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: Strange NSManagedObjectContextObjectsDidChangeNotification behavior

2009-02-24 Thread Dave Fernandes


On Feb 24, 2009, at 6:41 PM, Jerry Krinock wrote:


But, just a warning.  I originally had this grand plan which may be  
similar to yours -- I was going to simply observe  
NSManagedObjectContextObjectsDidChangeNotification, decode whatever  
happened as I just advised you to do, and then implement all my  
business logic in that observer.  But it got to be more and more  
painful.  The deal-breaker was last week when I learned that - 
[NSManagedObject changedValues] continues to include changed keys  
that had already been noted in previous notifications, until the  
document is saved.  So I would decode the same change repeatedly.   
With that discovery, I decided to bite the bullet and use KVO for  
most of the changes instead of  
NSManagedObjectContextObjectsDidChangeNotification.


I can't say I have the ideal solution, and I am also using KVO, but  
one might want to heed Ben Trumbull's warning before going down this  
path...


Complex KVO observer actions need to be carefully constrained. If  
they simply grow organically, then it's pretty easy to fall into  
the trap of observers creating side effects that trigger other  
observers that cascade to yet more observers.  This (a) makes  
your code impossible to understand, since no one ever  
intentionally designed their app that way from the beginning, and  
(b) sucks for performance.


It's often easier to understand, and much faster, to use  
NSNotificationCenter to defer and coalesce observations for a  
batch operation like operating upon 2000 objects.  One way to  
achieve this with the array controller is to remove all the  
objects from the controller, do your batch operation, and then  
add them back







It turned out to be not so bad, after I invented (or maybe re- 
invented -- someone will correct me) a little idea which I call  
"class observers", implemented it in my NSManagedObject subclass,  
and made all my managed object classes a subclass of this.  Each  
subsubclass (i.e. Employee, Recipe, whatever) overrides  
+classObservers, providing a dictionary of "observer dictionaries",  
each one giving a keyPath, observer, options and context.  Whenever  
an instance object of this subsubclass is created, it has all these  
"class observers" set automatically (during -awakeFromInsert or - 
awakeFromFetch), and whenever it's destroyed (-didBecomeFault in  
Core-Data-speak), these observers are removed.  So I'm not afraid  
of forgetting to remove observers any more.  Let me know if you  
want the code for this.


I'm only just getting familiar with the idiosyncrasies of Leopard,  
however, in Tiger didBecomeFault might be called many times, but  
awakeFromInsert or awakeFromFetch was only called once for the  
lifetime of the MOC (not the lifetime of the object). Thus, if you  
delete the object, and then undo that action, your observers will be  
removed by didBecomeFault and not added back since awakeFromFetch is  
not called again.


Dave
___

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: Alternative to NSWorkspace iconForFileType for icons?

2009-02-24 Thread Ken Thomases

On Feb 24, 2009, at 5:57 PM, Kevin Walzer wrote:

As I read it, the iconForFileType and related methods form  
NSWorkspace returns an NSImage. I don't want an NSImage. I want the  
path to the 'icns' file that the iconForFileType NSImage is based on.


What makes you think that all icons come from free-standing icns files?


Am I missing something in Cocoa here? Can anyone suggest an  
alternative API/class/method to me?


I don't believe the API you're looking for exists.  My first thought  
was to check Launch Services, but the icon-related stuff in there is  
documented as no longer being used.  After that, I checked Icon  
Services.  There are functions there to obtain an IconRef for a given  
item in the file system, but there doesn't appear to be a way to  
obtain a reference to the file that that icon comes from, if there is  
even such a file.


Regards,
Ken

___

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


do i need to create autorelease pool?

2009-02-24 Thread Memo Akten
I know what autorelease pools are and how they work so my question  
isn't about that.


In my iPhone app I create a NSTimer to run at 60fps, in it I update a  
bunch of stuff and draw opengl.


Currently I have:
-(void) timerLoop {
// create autorelease pool in case anything needs it
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];

// release pool
[pool release];
}

Do I need this autorelease pool here or does UIApplicationMain manage  
that for every call of timerLoop?

___

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: Help with sheets, NSArrayController & NSTableView (all working together) ...

2009-02-24 Thread Ken Thomases

On Feb 24, 2009, at 4:59 PM, Mic Pringle wrote:


If I hook up a button to the add selector of the NSArrayController it
works as you'd expect and the new instances populate the table (using
default data).

I have looked for delegate methods in both NSArrayController and
NSTableView to see if I can get notification of when a new instance is
created so that I can then use that to pop up the sheet, but to no
avail.

Can anyone help and point me in the right direction of how to do  
this ?


Have you considered not having the button target the add: selector of  
the array controller?  Instead have it target a method of your own  
design on the coordinating controller for the window.  Then you can  
have it do whatever you like, including dropping down a sheet to  
collect the information for the new object, creating that new object,  
and inserting it into the to-many relationship.


Cheers,
Ken

___

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: NSDate And Super Class

2009-02-24 Thread Andy Lee

On Feb 24, 2009, at 8:25 PM, Richard Good wrote:

-(DateTest*)init{
[super init];
aDate =[NSDate date];
return self;
}


Wait a minute.  I just figured out you're saying the *debugger* says  
datesubClass.aDate is out of scope, not the compiler as I thought.   
The reason is that you're not retaining aDate in the init method.  It  
gets deallocated prematurely and the pointer is invalid, hence "out of  
scope".  Try


aDate = [[NSDate date] retain];

If it's unclear why you need to do this, you need to study memory  
management -- it's a prominent chapter in the docs, you should be able  
to find it, plus it's linked to many, many times in the list archives.


There are other coding issues: init methods should return id, and they  
should check the result of [super init].  There's a chapter on  
"writing initializers" or some such -- look for that too.


--Andy

___

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: NSDate And Super Class

2009-02-24 Thread Andy Lee

On Feb 24, 2009, at 8:25 PM, Richard Good wrote:

Instance var creation
DatesubClass* datesubClass = [[DatesubClass alloc]init];
At this point the datesubClass.aDate Instance variable is "out of  
scope"


Your code works for me, verbatim, so there's something you're not  
showing us that's causing the problem.


The line above creates an instance, not an instance var.  It doesn't  
reference anything called aDate.  Can you show more context?  What is  
the exact line the compiler is barfing on?  Better yet, the whole  
method containing that line?


--Andy

___

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 oneself to /Applications (or ~/Applications)

2009-02-24 Thread Michael Ash
On Tue, Feb 24, 2009 at 12:34 AM, Tommy Nordgren
 wrote:
>
> On Feb 24, 2009, at 3:34 AM, Shawn Erickson wrote:
>
>> On Mon, Feb 23, 2009 at 6:22 PM, Tommy Nordgren
>>  wrote:
>>>
>>> The following code will test if you are running from the DMG:
>>>
>>> NSString * volName = @"Mother";
>>> NSString * appName = @"MyApp.app";
>>>
>>> if ([[[NSBundle mainBundle] bundlePath] isEqualTo: [ NSString
>>> stringWithFormat:@"/Volumes/%@/%@",volName,appName]) {
>>>
>>>      //Here you can show an alert telling the user to to copy the app to
>>> the applications folder
>>>
>>> }
>>
>> If a disk image it mounted a second time (can happen in a few ways) it
>> won't be at /Volumes/Mother/... but at /Volumes/Mounter 1/... Also you
>> can mount disk images in location other then under /Volumes/...
>>
>> If you really want to check this you should utilize
>> DiskImages.framework (IIRC) or possibly use "hdutil info -plist" and
>> look for your disk image and its current mount location. Then compare
>> that to your bundles location.
>>
>> -Shawn
>
>        Unfortunately, the DiskImages framework is private (no headers)
> Getting the output of hdiutil is a little awkward since the NSDictionary
> class has no method to initialize from a pipe.

It is precisely three method calls to go from an NSPipe to an
NSDictionary. If that qualifies as "a little awkward" then I must add
a bit extra to my usual despair for humanity.

Mike
___

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

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

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

This email sent to arch...@mail-archive.com


Re: [Q] What causes an NSArrayController to know that an entity was inserted via a different window?

2009-02-24 Thread Michael Ash
On Tue, Feb 24, 2009 at 3:37 PM, Jon C. Munson II  wrote:
> In the method,
> -(void)managedObjectContextUpdatedNotification:(NSNotification *)notif, the
> notif contains userInfo.  [userInfo valueForKey:] returns an NSSet.  This
> set has a -description, which returns a string formatted as a property list.
> And there's where the documentation ends.  In the debugger console, printing
> out that description gives an "array dump," so I can see what is in the
> description.
>
> My current solution is to call -rangeOfString on that description to look
> for the data specific to the entity in which I'm interested (the name of the
> entity in my case).  That works pretty well.  As the userInfo description
> isn't too big (small entities), this works fine.  However, I'm not convinced
> this is the best way to get at that data.

It's good that you're not convinced, because it's not the best way. In
fact, I believe it could very well be the absolute worst way possible.

What happens if the description of one of the other objects just
happens to look like the description for yours? Disaster.

You know that you have an NSSet. The documentation for NSSet will tell
you how to inspect it to discover the presence or absence of an object
within it, without going through such a crazy roundabout process.

Mike
___

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

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

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

This email sent to arch...@mail-archive.com


Re: Metrics for a NSTextField

2009-02-24 Thread Martin Wierschin

Hi Eric,

NSTextView *fieldEditor = (NSTextView*)[[self window]  
fieldEditor:YES forObject:self];	
NSRect usedRect = [[fieldEditor layoutManager]  
usedRectForTextContainer:[fieldEditor textContainer]];


But the used rect returned is empty and [self stringValue] does  
contain a string of > 0 characters.


If you check the documentation for the "usedRectForTextContainer:"  
method, it does not trigger any layout. So you'll want to first call  
something like "ensureLayoutForTextContainer:" before asking your  
question.


~Martin

___

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: Editing a multi-line NSTextField as a single line

2009-02-24 Thread Martin Wierschin
When editing, I would like the editor which appears to edit this  
text on just a single line and not do any wrapping.


I was able to accomplish this by doing:

  [[textField cell] setLineBreakMode:NSLineBreakByClipping];

before I start the edit session.

However, I am curious (because I think it would help me understand  
how the system works) how I could alter currentEditor to accomplish  
the same thing.


Offhand I would guess one or both of the following:

1. The NSTextContainer for the current editor has been expanded to  
infinite size.
2. The NSParagraphStyle applied to the editor's NSTextStorage has had  
its line break mode changed.


~Martin
___

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


NSDate And Super Class

2009-02-24 Thread Richard Good
I clearly don't understand how inheritance works for Objective C, at  
least not with the NSDate type.  When I create a super class with an  
NSDate type as an instance variable and then instantiate a subclass of  
the superclass,  I get an "out of Scope" error for the NSDate instance  
variable.

What am I doing wrong?

Here is an example of my class hierarchy:
Super Class:

DateTest.h
#import 
@interface DateTest : NSObject {
NSDate* aDate;
}
@property (nonatomic,retain)NSDate*  aDate;
@end

DateTest.m
#import "DateTest.h"
@implementation DateTest
@synthesize aDate;
-(DateTest*)init{
[super init];
aDate =[NSDate date];
return self;
}
@end

Sub Class:
 DatesubClass.h
#import 
#import "DateTest.h"

@interface DatesubClass : DateTest {
NSString*   testStr;

}
@property (nonatomic,copy)  NSString* testStr;
@end
SubClass DatesubClass.m
#import "DatesubClass.h"
@implementation DatesubClass
@synthesize testStr;

-(DatesubClass*)init{
[super init];
testStr= @"Test";
return self;
}
@end

Instance var creation
DatesubClass* datesubClass = [[DatesubClass alloc]init];
At this point the datesubClass.aDate Instance variable is "out of scope"



Richard Good

___

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


Core Data Relationships

2009-02-24 Thread Walker Argendeli

I apologize beforehand for the beginner-level of this question.
I'm getting started with core data, and I've gone through several  
tutorials.
Let's say I have 2 entities: an Item, and a Kind.  Each Item has 1  
Kind, and each Kind has multiple Items.  The Item might have an  
attribute, Title, and a relationship to Kind, and Kind might have an  
attribute, Title, and a To-Many relationship to Item (inverse).
It seems that in all the examples, a NSPopUpButton is used, with  
Content, Content Values, and Selected Object being bindings.
What if I wanted to have say, an NSTextCell where you could enter a  
Kind.  I haven't decided whether you would be forced to enter a kind  
that is already in the Kinds array, or could just type anything.

Anyways, what bindings would I want to use to accomplish this.
Thanks,

- Walker Argendeli

___

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


Alternative to NSWorkspace iconForFileType for icons?

2009-02-24 Thread Kevin Walzer
I'm trying to implement some command-line functionality that will 
retrieve the path to the icon for a specified file type, and I'm having 
trouble locating the correct API in Cocoa.


As I read it, the iconForFileType and related methods form NSWorkspace 
returns an NSImage. I don't want an NSImage. I want the path to the 
'icns' file that the iconForFileType NSImage is based on.


Looking through various docs, I see that the 'lsregister -dump' command 
seems to have the functionality I want, but the output of that command 
is a swamp.


Am I missing something in Cocoa here? Can anyone suggest an alternative 
API/class/method to me?


--
Kevin Walzer
Code by Kevin
http://www.codebykevin.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: Responding to view controller memory warnings (was Re: Outlets / IBOutlet declarations)

2009-02-24 Thread Jonathan Hess


On Feb 20, 2009, at 1:05 AM, Alexander Spohr wrote:



Am 20.02.2009 um 04:18 schrieb mmalc Crawford:



On Feb 19, 2009, at 12:34 PM, mmalc Crawford wrote:

See also updated: 




The Doc states:
You should therefore also set outlet variables to nil in dealloc:

- (void)dealloc {
// release outlets and set outlet variables to nil
[anOutlet release], anOutlet = nil;
[super dealloc];
}

why not just use

[self setAnOutlet = nil];
or
self.anOutlet = nil;

Any danger in this? (except a bad implementation of setAnOutlet:)



Any of the standard arguments about not calling setters in dealloc and  
init would apply. For example, if you were subclassed, and your  
subclass had an override of one of your setters, and you called it  
from dealloc you'd be calling one of their methods after they'd called  
[super dealloc]. Or, you might later implement side-effects for one of  
your setters not thinking about the called-from-dealloc-case and  
introduce a subtle bug into your own code.


Jon Hess



atze

___

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/jhess%40apple.com

This email sent to jh...@apple.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: Strange NSManagedObjectContextObjectsDidChangeNotification behavior

2009-02-24 Thread Jerry Krinock


On 2009 Feb 24, at 10:25, Karolis Ramanauskas wrote:

Weird behavior: After adding a few objects whenever I move a mouse  
over the

NSTableViews (or more accurately NSScrollViews enclosing them), the
NSManagedObjectContextObjectsDidChangeNotification is triggered!  
Actually it

gets triggered by more than that, but I'm not doing anything to change
NSManagedObjectContext. Why would simply moving a mouse over certain  
areas

of the before mentioned views trigger that event to fire?


I don't know Karolis, but you can find out yourself and tell us by  
adding some NSLogs to your notification-observer's selector method...


- (void)myChangeObserver:(NSNotification*)n {
NSSet* insertedObjects = [[n userInfo]  
objectForKey:NSInsertedObjectsKey] ;
NSSet* deletedObjects = [[n userInfo]  
objectForKey:NSDeletedObjectsKey] ;
NSSet* updatedObjects = [[n userInfo]  
objectForKey:NSUpdatedObjectsKey] ;


NSLog(@"inserted: %@", insertedObjects) ;
NSLog(@"deleted: %@", deletedObjects) ;
NSLog(@"updated: %@", updatedObjects) ;

...
}

Theoretically, you can also use that information to filter out changes  
that you're not interested in.


But, just a warning.  I originally had this grand plan which may be  
similar to yours -- I was going to simply observe  
NSManagedObjectContextObjectsDidChangeNotification, decode whatever  
happened as I just advised you to do, and then implement all my  
business logic in that observer.  But it got to be more and more  
painful.  The deal-breaker was last week when I learned that - 
[NSManagedObject changedValues] continues to include changed keys that  
had already been noted in previous notifications, until the document  
is saved.  So I would decode the same change repeatedly.  With that  
discovery, I decided to bite the bullet and use KVO for most of the  
changes instead of NSManagedObjectContextObjectsDidChangeNotification.


It turned out to be not so bad, after I invented (or maybe re-invented  
-- someone will correct me) a little idea which I call "class  
observers", implemented it in my NSManagedObject subclass, and made  
all my managed object classes a subclass of this.  Each subsubclass  
(i.e. Employee, Recipe, whatever) overrides +classObservers, providing  
a dictionary of "observer dictionaries", each one giving a keyPath,  
observer, options and context.  Whenever an instance object of this  
subsubclass is created, it has all these "class observers" set  
automatically (during -awakeFromInsert or -awakeFromFetch), and  
whenever it's destroyed (-didBecomeFault in Core-Data-speak), these  
observers are removed.  So I'm not afraid of forgetting to remove  
observers any more.  Let me know if you want the code for this.


___

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: Stop edit session with a NSTextField

2009-02-24 Thread Eric Gorr


On Feb 24, 2009, at 5:47 PM, Eric Gorr wrote:



On Feb 23, 2009, at 11:35 AM, Eric Gorr wrote:



On Feb 23, 2009, at 11:01 AM, Patrick Mau wrote:



On 23.02.2009, at 16:50, Eric Gorr wrote:



I am not sure I understand this.

Are you are saying is that you looked for the NSTextView being  
used as the field editor for the NSTextField and then removed the  
NSTextView from it's superview?


I tried this:

id fieldEditor = [[aNotification userInfo]  
objectForKey:@"NSFieldEditor"];

[fieldEditor removeFromSuperview];

Unfortunately, it didn't work.


Yes. The superview of the fieldeditor is some clipping view (I  
forgot the class).


ah, ok. Makes more sense now.

In any case, the solution to my problem turned out to be not so  
bad. I simply did the following:


[[[self view] window] makeFirstResponder:[self view]];

Basically, told the window to make someone else the first  
responder. This seemed to work.


I do find it odd that I could not tell the field editor to resign  
as first responder.


Unfortunately, this solution isn't complete.

If one presses the tab key, I see my controlTextDidEndEditing  
getting called which does successfully set the first responder  
elsewhere, but the field editor steals first responder status back -  
something which you probably already knew.


I will try your solution and see if I can get it to work.


Unfortunately, it does not work either.

If anyone has any further ideas on how to correctly end an editing  
session of a NSTextField, I am interested.


To summarize the proposed and failed solutions:



*** [[[self view] window] endEditingFor:nil];

Pressing return or pressing the tab key will not end the editing session



*** [[[self view] window] makeFirstResponder:[self view]];

Pressing return will allow the editing session to end, but pressing  
the tab key will not




*** NSTextView *fieldEditor = [[aNotification userInfo]  
objectForKey:@"NSFieldEditor"];

NSView *v = fieldEditor;
while ( v && ( [v superview] != [aNotification object] ) )
v = [v superview];
[v removeFromSuperview];

Pressing return or pressing the tab key will not end the editing session


The editing session was started with:

[textField selectText:nil]; 
NSTextView  *currentEditor  = (NSTextView*)[textField currentEditor];
NSPoint windowLocation  = [theEvent locationInWindow];
NSPoint		screenLocation	= [[self window]  
convertBaseToScreen:windowLocation];
NSUInteger	characterIndex	= [currentEditor  
characterIndexForPoint:screenLocation];
[currentEditor setSelectedRange:NSMakeRange( characterIndex + 1,  
0 )];			


NOTE: normally, the NSTextField is not editable and is drawn as a  
static text string



___

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


Help with sheets, NSArrayController & NSTableView (all working together) ...

2009-02-24 Thread Mic Pringle
Hi,

I hoping someone can point me in the right direction on this as I'm
really struggling to get it all to work.

I have a class which holds two NSString properties, an NSImage
property and an NSPredicate property.

I have an array that holds instances of this class, and an
NSArrayController hooked up to that array.

I have a NSTableView with a custom cell, which displays the image,
name (1st NSString property) and description (2nd NSString property)
for each instance of the class in the NSArrayController.

So, because the custom cell draws its data as it does, I cannot simply
allow the end user to edit in cell so have disabled that
functionality.

Would I would like to do is to pop up a sheet that has a form on it to
edit the new instance of the class just added by clicking the button
linked to the add selector, but this is what I can't figure out how to
do ?

If I hook up a button to the add selector of the NSArrayController it
works as you'd expect and the new instances populate the table (using
default data).

I have looked for delegate methods in both NSArrayController and
NSTableView to see if I can get notification of when a new instance is
created so that I can then use that to pop up the sheet, but to no
avail.

Can anyone help and point me in the right direction of how to do this ?

Thanks,

-Mic
___

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: Stop edit session with a NSTextField

2009-02-24 Thread Eric Gorr


On Feb 23, 2009, at 11:35 AM, Eric Gorr wrote:



On Feb 23, 2009, at 11:01 AM, Patrick Mau wrote:



On 23.02.2009, at 16:50, Eric Gorr wrote:



I am not sure I understand this.

Are you are saying is that you looked for the NSTextView being  
used as the field editor for the NSTextField and then removed the  
NSTextView from it's superview?


I tried this:

id fieldEditor = [[aNotification userInfo]  
objectForKey:@"NSFieldEditor"];

[fieldEditor removeFromSuperview];

Unfortunately, it didn't work.


Yes. The superview of the fieldeditor is some clipping view (I  
forgot the class).


ah, ok. Makes more sense now.

In any case, the solution to my problem turned out to be not so bad.  
I simply did the following:


[[[self view] window] makeFirstResponder:[self view]];

Basically, told the window to make someone else the first responder.  
This seemed to work.


I do find it odd that I could not tell the field editor to resign as  
first responder.


Unfortunately, this solution isn't complete.

If one presses the tab key, I see my controlTextDidEndEditing getting  
called which does successfully set the first responder elsewhere, but  
the field editor steals first responder status back - something which  
you probably already knew.


I will try your solution and see if I can get it to work.

 
 
___


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: [Q] What causes an NSArrayController to know that an entity was inserted via a different window?

2009-02-24 Thread mmalc Crawford


On Feb 24, 2009, at 12:37 PM, Jon C. Munson II wrote:

I do have one question, an answer to which I could not readily find  
in the

dox.

[...]
So, my question is, what is the preferred/best method to access the  
property
list to return the name of the entity that had an insertion, update,  
or

delete?




mmalc

___

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: How to center a custom NSView in a NSScrollView

2009-02-24 Thread Andrew Farmer

On 24 Feb 09, at 13:46, Meik Schuetz wrote:
If the visible area (NSScrollView) is GREATER than the fixed size of  
the custom NSView, the custom NSView should be positioned centered  
in the NSScrollView, otherwise, the default behaviour of the scroll  
view should apply. I just want to avoid that the custom NSView stays  
at the bottom left (or top left) corner of the NSScrollView, when  
there's enough space to center it horizontally and vertically.


The "corner-pinning" behavior you're seeing exists in NSClipView  
(which is a component of scroll views). To override it, you'll need to  
create a subclass of NSClipView -  has details on one approach.

___

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: Drawing a badge in an OutlineView column cell: but width changes on expanding

2009-02-24 Thread Stuart Malin


On Feb 24, 2009, at 11:48 AM, Corbin Dunn wrote:


I've just published a blog that has screen shots of these states:
http://stuartmalin.blogspot.com/2009/02/troubles-with-cocoa-custom.html



Your table column's width is changing automatically (because you  
have setAutoresizesOutlineColumn:YES), but your view is set to not  
show horizontal scrollers, so it is clipping. Either:

1. Turn on horizontal scrollers (auto hidden is okay)
2. Turn off setAutoresizesOutlineColumn


#2 works for me (conceptually, and in practice).
Corbin: Thanks so much for dealing with what is my lack of knowledge/ 
experience.


___

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: Drawing a badge in an OutlineView column cell: but width changes on expanding

2009-02-24 Thread Corbin Dunn


I've just published a blog that has screen shots of these states:
http://stuartmalin.blogspot.com/2009/02/troubles-with-cocoa- 
custom.html




Your table column's width is changing automatically (because you have  
setAutoresizesOutlineColumn:YES), but your view is set to not show  
horizontal scrollers, so it is clipping. Either:

1. Turn on horizontal scrollers (auto hidden is okay)
2. Turn off setAutoresizesOutlineColumn

corbin


___

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: How to center a custom NSView in a NSScrollView

2009-02-24 Thread Meik Schuetz

Hi Ben,
thanks for you answer and my apologies for answering with that delay.


I've already tried with a custom NSClipView, as explained here:

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


This is the standard way to do this.

After working some time on other subjects, I tried the solution with  
the NSClipView again. The custom NSView is still drawn at the bottom  
left corner of the scroll view, and I've got no idea why. What I try  
to archive is the following:


The question is, how can I center a custom NSView in a  
NSScrollView, if

the visible width and/or height is greater than the fixed size of the
NSScrollView?


What does centering mean if the view’s size is larger than that of the
scroll view?

If the visible area (NSScrollView) is GREATER than the fixed size of  
the custom NSView, the custom NSView should be positioned centered in  
the NSScrollView, otherwise, the default behaviour of the scroll view  
should apply. I just want to avoid that the custom NSView stays at the  
bottom left (or top left) corner of the NSScrollView, when there's  
enough space to center it horizontally and vertically.


Thanks for any more information about this subject.

Best regards
Meik

___

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: Drawing a badge in an OutlineView column cell: but width changes on expanding

2009-02-24 Thread Stuart Malin


On Feb 24, 2009, at 10:51 AM, Corbin Dunn wrote:



On Feb 24, 2009, at 12:38 PM, Stuart Malin wrote:

I have been reading various blogs, tried to search CocoaBuilder,  
and have ben looking at the code in Apple's PhotoSearch sample, but  
am not clear about the best way to handle this situation:


I have an NSOutlineView for which I have set a custom cell (sub  
class of NSTextViewCell) in order to draw a badge on the right side  
of the cell.


I have overridden drawInteriorWithFrame:controlView: to do my  
drawing there.  It seems to me that when a row that has descendent  
nodes is expanded, the width of the hierarchically containing cells  
(lower level value) are made wider (by the same amount as the  
indentation). Both the indented cells (by their indentation) and  
the higher order cells (by the increased cell width) now have their  
right side pushed partway out of the viewable area of the column.  
So, I can't determine the x position of the badge based upon the  
width of the cell (a hierarchically outer cell with no indent has  
an increased width, yet to calculate a proper x coordinate, the  
cell would need to know that  some other table items are expanded;  
how could it "know" this?)


My best idea so far is to determine the position based on the table  
column's width, and take into account the indent level. But I  
suspect there are any of a number of ways to handle this, and so am  
looking for guidance on a best practice from those with experience.

TIA.


You should just draw the badge in -drawInteriorWithFrame, and  
everything should work provided you are right-aligning it with the  
frame passed to you. What does your code look like? Maybe it has  
some errors/problems.


Thanks for replying so quickly, Corbin.  My code for drawing the badge  
is relatively straightforward. But... to get a handle on the problem,  
I am not presently drawing it. I have greatly simplified my code, and  
all ll I do now is:


1) in the -init for the cell, I set -setBordered So I can see the size  
of the cell.


- (id) init {
self = [super init];
if (self != nil) {
[self setLineBreakMode:NSLineBreakByTruncatingTail];
[self setBordered:YES];

2) and I have trivialized -drawInteriorWithFrame

- (void)drawInteriorWithFrame:(NSRect)cellFrame inView: 
(NSView*)controlView

{
[super drawInteriorWithFrame:cellFrame inView:controlView];
return;

3) When I run, I get what I consider to be weird behavior:

a) When the app first starts and displays, the borders of the level 0  
entries (none are expanded) are completely visible.
b) when I expand a level 0 item, the borders for all cells (level 0  
and level 1) are no longer visible on the right side.
c) the OutlineView is in a splitter. If I move the splitter to expand  
the outline view's width, when I release, the right side of the cell  
borders are all visible (both level 0 and level 1 items), and are  
nearly flush to the right side of the column. Nice.
d) If I then collapse the expanded item, all of the cells borders are  
visible, but the cell width is noticeably smaller than the column's  
width.


I've just published a blog that has screen shots of these states:
http://stuartmalin.blogspot.com/2009/02/troubles-with-cocoa-custom.html

So, what I am seeing is that the cell's width fluctuates  
inconsistently with respect to the column's width, sometimes being  
nicely bound to the column's right side, sometimes extending beyond,  
and sometimes being too short.


I am on Leopard 10.5.6 using Xcode 3.1.1; Target: Base SDK = Mac OS 10.5




___

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: Drawing a badge in an OutlineView column cell: but width changes on expanding

2009-02-24 Thread Corbin Dunn


On Feb 24, 2009, at 12:38 PM, Stuart Malin wrote:

I have been reading various blogs, tried to search CocoaBuilder, and  
have ben looking at the code in Apple's PhotoSearch sample, but am  
not clear about the best way to handle this situation:


I have an NSOutlineView for which I have set a custom cell (sub  
class of NSTextViewCell) in order to draw a badge on the right side  
of the cell.


I have overridden drawInteriorWithFrame:controlView: to do my  
drawing there.  It seems to me that when a row that has descendent  
nodes is expanded, the width of the hierarchically containing cells  
(lower level value) are made wider (by the same amount as the  
indentation). Both the indented cells (by their indentation) and the  
higher order cells (by the increased cell width) now have their  
right side pushed partway out of the viewable area of the column.  
So, I can't determine the x position of the badge based upon the  
width of the cell (a hierarchically outer cell with no indent has an  
increased width, yet to calculate a proper x coordinate, the cell  
would need to know that  some other table items are expanded; how  
could it "know" this?)


My best idea so far is to determine the position based on the table  
column's width, and take into account the indent level. But I  
suspect there are any of a number of ways to handle this, and so am  
looking for guidance on a best practice from those with experience.

TIA.


You should just draw the badge in -drawInteriorWithFrame, and  
everything should work provided you are right-aligning it with the  
frame passed to you. What does your code look like? Maybe it has some  
errors/problems.


.corbin


___

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: [Q] What causes an NSArrayController to know that an entity was inserted via a different window?

2009-02-24 Thread Jon C. Munson II
> >
> > [[NSNotificationCenter defaultCenter] addObserver:self
> > selector:@selector(managedObjectContextUpdatedNotification:)
> > name:NSManagedObjectContextObjectsDidChangeNotification
> > object:[self managedObjectContext]];
> >

[Jon C. Munson II] This is the method I ended up implementing in my custom
view class.  I realized, after some thought, attempting to get my array
controller subclass to cause the view to change was actually stupid and a
violation of good programming methodology.  Thus, registering as an observer
for this notification in my custom view class allowed my view to get
notified when the MOC changed, which is what I needed.

Now, I only need to know if a specific entity in that MOC changed
(inserted/updated/deleted), so I added some processing to handle that.

I do have one question, an answer to which I could not readily find in the
dox.

In the method,
-(void)managedObjectContextUpdatedNotification:(NSNotification *)notif, the
notif contains userInfo.  [userInfo valueForKey:] returns an NSSet.  This
set has a -description, which returns a string formatted as a property list.
And there's where the documentation ends.  In the debugger console, printing
out that description gives an "array dump," so I can see what is in the
description.

My current solution is to call -rangeOfString on that description to look
for the data specific to the entity in which I'm interested (the name of the
entity in my case).  That works pretty well.  As the userInfo description
isn't too big (small entities), this works fine.  However, I'm not convinced
this is the best way to get at that data.  

So, I'd like to know how to access the properties in that list.  I couldn't
find documentation that shows what properties are actually in that list, and
I couldn't find a reference to a "property list" object in the dox (I saw
CFPreferences, but that didn't seem right).  

So, my question is, what is the preferred/best method to access the property
list to return the name of the entity that had an insertion, update, or
delete?

Thanks!

Peace, Love, and Light,

/s/ Jon C. Munson II

___

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


Drawing a badge in an OutlineView column cell: but width changes on expanding

2009-02-24 Thread Stuart Malin
I have been reading various blogs, tried to search CocoaBuilder, and  
have ben looking at the code in Apple's PhotoSearch sample, but am not  
clear about the best way to handle this situation:


I have an NSOutlineView for which I have set a custom cell (sub class  
of NSTextViewCell) in order to draw a badge on the right side of the  
cell.


I have overridden drawInteriorWithFrame:controlView: to do my drawing  
there.  It seems to me that when a row that has descendent nodes is  
expanded, the width of the hierarchically containing cells (lower  
level value) are made wider (by the same amount as the indentation).  
Both the indented cells (by their indentation) and the higher order  
cells (by the increased cell width) now have their right side pushed  
partway out of the viewable area of the column. So, I can't determine  
the x position of the badge based upon the width of the cell (a  
hierarchically outer cell with no indent has an increased width, yet  
to calculate a proper x coordinate, the cell would need to know that   
some other table items are expanded; how could it "know" this?)


My best idea so far is to determine the position based on the table  
column's width, and take into account the indent level. But I suspect  
there are any of a number of ways to handle this, and so am looking  
for guidance on a best practice from those with experience.

TIA.



___

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


NSWindowController, bindings and Garbage Collection

2009-02-24 Thread Nikita Zhuk
I'm running a Cocoa application with Garbage Collection enabled,  
linking against 10.5 SDK. My application has a NSWindowController  
subclass which instantiates a window from a nib file (- 
[NSWindowController initWithWindowNibName:]) and acts as the File's  
owner of that nib. The window in the nib has several controls with  
values bound to properties of a model object, which is accessible  
through the File's owner. The model object assumes that all method  
calls made to retrieve its values are made in the main thread - it has  
assertions which verify that this is the case.


Under manually managed memory this works as expected - all bound  
values are fetched from the model object on the main thread and file's  
owner is deallocated after the window is closed. When the application  
is compiled and run with GC, file's owner is collected (finalize is  
run), but after a while NSBinder instance accesses my model class from  
a subthread, causing the "main thread only" assertion of my model  
class to fail with the following stack trace:


#2	0xa3aa in -[MyModelObject mainThreadOnlyMethod:] at  
MyModelObject.m:123

#3  0x936ebf6b in _NSGetUsingKeyValueGetter
#4  0x936eba07 in -[NSObject(NSKeyValueCoding) valueForKey:]
#5  0x9376aa01 in -[NSKeyValueNestedProperty object:didRemoveObservance:]
#6	0x93749c43 in -[NSObject(NSKeyValueObserverRegistration)  
_removeObserver:forProperty:]
#7	0x937499e4 in -[NSObject(NSKeyValueObserverRegistration)  
removeObserver:forKeyPath:]

#8  0x9376aa21 in -[NSKeyValueNestedProperty object:didRemoveObservance:]
#9	0x93749c43 in -[NSObject(NSKeyValueObserverRegistration)  
_removeObserver:forProperty:]
#10	0x937499e4 in -[NSObject(NSKeyValueObserverRegistration)  
removeObserver:forKeyPath:]

#11 0x93b3f690 in -[NSBinder _updateObservingRegistration:]
#12	0x93b85d0f in -[NSBinder  
releaseConnectionWithSynchronizePeerBinders:]

#13 0x93d288c8 in -[NSBinder finalize]
#14 0x933546b6 in finalizeOneObject
#15 0x91488dab in foreach_block_do
#16 0x9335487b in batchFinalize
#17 0x93354b42 in batchFinalizeOnTwoThreads
#18 0x91489f0e in auto_collect_internal
#19 0x9148ab8f in auto_collection_thread
#20 0x9559a095 in _pthread_start
#21 0x95599f52 in thread_start

There have been a similar problem reported earlier when using Core  
Data, bindings and GC [1]. The problem seem to be the same. How this  
could be prevented or worked around? My model objects must remain main- 
thread-only. Would the "NSObjectController as a file file's owner"  
pattern [2] help here?


[1] http://www.mail-archive.com/cocoa-dev@lists.apple.com/msg17346.html
[2] http://www.borkware.com/quickies/do-search?search=nsobjectcontroller



___

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


[ANN] BWToolkit 1.1 IB Plugin: Codeless Split Views

2009-02-24 Thread Brandon Walkin

Hi all,

I've just released a new version of my IB plugin with a split view  
that requires no programming for common split view functionality.  
Right within Interface Builder, you can specify which subviews should  
resize with the split view, set min and max sizes on subviews, mark a  
subview as "collapsible", and hook a button up to an action on the  
split view which will collapse or expand the collapsible subview with  
Core Animation.


Watch a screencast of the split view in action and read more about it  
here: http://www.brandonwalkin.com/blog/2009/02/24/bwtoolkit-11-codeless-split-views/


If you've never heard of BWToolkit, this webpage outlines all the  
features: http://brandonwalkin.com/bwtoolkit


Cheers,
Brandon
___

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


Metrics for a NSTextField

2009-02-24 Thread Eric Gorr
I am attempting to get some measurements for the text being displayed  
in a NSTextField and am running into trouble.


It looks like all of the measurement methods are related to NSTextView.

I tried asking for a NSTextView for my NSTextField by doing the  
following:



NSTextView *fieldEditor = (NSTextView*)[[self window] fieldEditor:YES  
forObject:self];	

NSLog( @"fieldEditor: %@", fieldEditor );
NSRect usedRect = [[fieldEditor layoutManager]  
usedRectForTextContainer:[fieldEditor textContainer]];
NSLog( @"usedRectForTextContainer: %@, %@",  
NSStringFromRect( usedRect ), [self stringValue] );



But the used rect returned is empty and [self stringValue] does  
contain a string of > 0 characters.



Is there something I am missing or is there an alternative way to get  
the information I am looking for?



___

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: [Q] What causes an NSArrayController to know that an entity was inserted via a different window?

2009-02-24 Thread Jacob Evans

On Feb 24, 2009, at 8:48 AM, Jon C. Munson II wrote:

This is why Hillegass' book was extremely useful to me as I could  
see the concepts put into practice.


Jon, like I.S. mentioned, it seems you need to get a better grasp on  
KVC/KVO concepts. Perhaps a re-read of Chapter 7 of Hillegass' "Cocoa  
Programming For Mac OS X" third edition book might help.


Jacob
___

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


Strange NSManagedObjectContextObjectsDidChangeNotification behavior

2009-02-24 Thread Karolis Ramanauskas
Good day, everyone,

I have a core data document based app. There are two windows for each
document. One is the "Inspector" window with mostly NSTableViews
representing objects and their relationships. Another window consists of a
custom view which draws graphical representation of the objects. In my
custom view I use NSManagedObjectContextObjectsDidChangeNotification
observer to refresh the view whenever there are any changes in the
NSManagedObjectContext.

Weird behavior: After adding a few objects whenever I move a mouse over the
NSTableViews (or more accurately NSScrollViews enclosing them), the
NSManagedObjectContextObjectsDidChangeNotification is triggered! Actually it
gets triggered by more than that, but I'm not doing anything to change
NSManagedObjectContext. Why would simply moving a mouse over certain areas
of the before mentioned views trigger that event to fire? It cause
completely unnecessary refreshes and makes the view flicker more than it
should...

Any help is greatly appreciated!

Thanks,
Karolis
___

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


How can I authenticate using a client certificate with NSURLConnection?

2009-02-24 Thread Richard Frith-Macdonald
I need to connect to a a service where the company running the service  
uses certificate based authentication over SSL.


They have given me a certificate to use when sending requests to their  
server, but I can't find anything in the NSURLConnection or  
NSURLRequest documentation which tells me how to make NSURLConnection  
use that client certificate when connecting to the server.


Have I missed something in the documentation?  Is there any way to do  
it?  Or do I have to abandon Cocoa and use a different API?


___

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: Getting CGImage out of NSBitmapImageRep in 10.4

2009-02-24 Thread David Alter
I removed the use of the NSBitmapImageRep as you suggested and it is working
much better now.
Thanks for the help
-dave


On Tue, Feb 24, 2009 at 10:10 AM, douglas welton <
douglas_wel...@earthlink.net> wrote:

> David,
>
> perhaps I'm missing something simple...  Is there some reason that you are
> using NSBitmapImageRep to handle the jpg file?
>
> why not use CGImageSource to read your jpg file, create a CGImage from the
> CGImageSource, draw the new CGImage into a CGBitmapContext, do your
> additional drawing; and then extract a final CGImage from the
> CGBitmapContext with CGBitmapContextCreateImage?
>
> regards,
>
> douglas
>
>
>
> On Feb 24, 2009, at 12:41 PM, David Alter wrote:
>
>  What I want to do is create the NSBitmapImageRep from a jpg. Draw into the
>> image and extract a CGImageRef out. I need to be able to access
>> the individual pixels of the image. Maybe there is a better way to do
>> this?
>>
>>
>
___

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


IMKit window not reappearing

2009-02-24 Thread Daniel Child
I have a background app (an input method) that has a window associated  
with MainMenu.nib.


The first time the app launches when I select it from the input  
methods list, the window launches. But if I close the window, it seems  
there is no way to get it back.


My current settings in IB are:
- visible at launch
- deferred / buffered

Eventually I want the window to hide on deactivation but have  
deselected that setting since it is not coming back at all. So hide on  
deactivate is unchecked for the time being.


Within app delegate, I've tried to intervene at a number of places,  
including


- (void) applicationDidFinishLaunching: (NSNotification *) not;

This method does not appear to get called when returning from another  
input method, and so is of no use. It only works if you log out and  
log back in. Not a solution.


I also tried a makeKeyAndOrderFront in the App delegeta's  
awakeFromNib, but of course that only helps the first time around too.  
The window does appear the first time. Probably unnecessary anyway  
since in IB it is set to be visible at launch.


If anyone knows where I can gain a foothold to place my call to make  
the window visible, I'd really appreciate it. Thanks.


Daniel

___

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

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

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

This email sent to arch...@mail-archive.com


Re: Getting CGImage out of NSBitmapImageRep in 10.4

2009-02-24 Thread douglas welton

David,

perhaps I'm missing something simple...  Is there some reason that you  
are using NSBitmapImageRep to handle the jpg file?


why not use CGImageSource to read your jpg file, create a CGImage from  
the CGImageSource, draw the new CGImage into a CGBitmapContext, do  
your additional drawing; and then extract a final CGImage from the  
CGBitmapContext with CGBitmapContextCreateImage?


regards,

douglas


On Feb 24, 2009, at 12:41 PM, David Alter wrote:

What I want to do is create the NSBitmapImageRep from a jpg. Draw  
into the

image and extract a CGImageRef out. I need to be able to access
the individual pixels of the image. Maybe there is a better way to  
do this?




___

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: Getting CGImage out of NSBitmapImageRep in 10.4

2009-02-24 Thread David Alter
On Mon, Feb 23, 2009 at 7:42 PM, Michael Ash  wrote:

> On Mon, Feb 23, 2009 at 4:51 PM, David Alter 
> wrote:
> > I need to get a CGImage out of a NSBitmapImageRep. This needs to work in
> > 10.4.
> > I tried doing this by setting the bitmap as the graphics context and then
> > creating the image form the context. This gives me an
> CGBitmapContextCreate:
> > unsupported parameter combination. Here is the code
> >
> > NSGraphicsContext * context = [NSGraphicsContext
> > graphicsContextWithBitmapImageRep:offscreenRep];
> >
> > CGContextRef bitmapContext = (CGContextRef)[context graphicsPort];
> >
> > CGImageRef image = CGBitmapContextCreateImage (bitmapContext);
> >
> > I suspect there is a better way to do this. Does anyone have any
> > suggestions.
>
> Just call CGImageCreate. Most of the parameters can be obtained by
> simply querying the NSBitmapImageRep, and the remainder are not
> terribly difficult to create yourself, being either constants or
> fairly easy to construct.
>
> That should work fine.

As I have progressed with this, I would like to do some additional drawing
in my  NSBitmapImageRep. Is there a way that I can set it as my
NSGraphicsContext. As I noted
earlier NSGraphicsContext graphicsContextWithBitmapImageRep: is giving me an
error.

What I want to do is create the NSBitmapImageRep from a jpg. Draw into the
image and extract a CGImageRef out. I need to be able to access
the individual pixels of the image. Maybe there is a better way to do this?

thanks for the help
-dave
___

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: [Q] What causes an NSArrayController to know that an entity was inserted via a different window?

2009-02-24 Thread I. Savant
On Tue, Feb 24, 2009 at 10:48 AM, Jon C. Munson II  wrote:

> [Jon C. Munson II] With regards to the dox, and I'm not being grumpy or
> "short" when saying this, if, situationally speaking, these things were
> *explicitly* explained (and not just "conceptually" explained), I'd probably
> have a better time of it.
> I'm NOT one of those people who learn well from
> reading technical documentation, particularly if that documentation is
> geared more to conceptions than real-world/practical example.

  Is that truly your argument? There is API reference (the basic nuts
and bolts describing the objects / methods available in the API) and
the conceptual documentation that explains how it is best used (and
the design methodology behind it). This is how the world of software
development works. They are two different reference tools geared for
the two primary necessities when learning a new platform (in the sense
of language+architecture+API). It's a necessary evil you're going to
have to accept because nobody on this list wants to spend time
repeating or pointing to text that directly and clearly answers your
questions (as you asked them, anyway).


> This is why Hillegass' book was extremely useful to me as I could see the 
> concepts put to practice.

  This is essentially a tutorial. It's a third reference tool that's a
helpful addition but not intended to replace the documentation when
you need to understand more than what the tutorial covers (which is
almost always the case in a real project). Since there's no completed
Core Data reference book yet (Pragmatic Bookshelf has a book in
development: http://www.pragprog.com/titles/mzcd/core-data ), there
are only web tutorials, but again: that's not your problem. Your
problem is that you need to go back to the basics of Bindings / KVC /
KVO and learn them in detail because this is the basis of your
problem.

  Essentially, you've watched a video on assembling a lamp from a kit,
screwing in the light bulb, plugging it in, and turning it on. What
you're now trying to do is design your own lamp with more complicated
parts. Well, you need not only to read up on the intricacies of
complicated lighting design (conceptual), but to look up the specs on
each of those parts to see if they work together in the way you're
imagining (API reference). No general lamp assembly tutorial is going
to exist for your particular design and no assembly tutorial is going
to teach you much more than you need to know (for assembly) about all
the parts, how they were selected, why they work together the way they
do, and how you might interchange some of those parts for more
complicated things -- its' beyond the scope of the tutorial. In short,
you STILL have to understand the concepts and frequently reference the
specific components you wish to use. There is quite simply no way
around this.


> That being said, I did think there was some sort of message that
> NSArrayController was responding to.  I had hoped there was a method or
> delegate method one could employ that would get implemented in response to
> whatever message that is, but didn't see one.
>
> Not knowing which/what message to search for prompted the post.
>
> Having said that, and following with what you replied, I found this on the
> 'net (typos not withstanding):
>
> [[NSNotificationCenter defaultCenter] addObserver:self
> selector:@selector(managedObjectContextUpdatedNotification:)
> name:NSManagedObjectContextObjectsDidChangeNotification
> object:[self managedObjectContext]];
>
> Assuming that goes in init, is this the correct message, etc., to be
> listening for?

  No. This is a notification. This has nothing to do with Bindings /
KVC / KVO. You can of course listen for this notification and react to
it, but this is not what NSArrayController is relying on. Again, it's
relying on KVO (because it's "O"bserving the Managed Object Context
(MOC) keypath of either your application delegate (if Core Data
Application) or your persistent document instance (if Core Data
Document-Based Application).

  Again, this is the only Core-Data-related aspect of this use of
Bindings (that it's observing the Core Data MOC, rather than some
other KVC/KVO-compliant key). The MOC says a managed object changed,
so the array controller sees if that change included anything it's
interested in (instances of the entity it's managing) and re-fetches
from the context. That's it.


> Anyway, I do appreciate the time and patience of those on the list who do
> take the time to reply and offer assistance.

  Then please show this by taking the advice we're giving you.
Specifically, despite the fact you find it difficult, read all the
prerequisite documentation anyway. Also refrain from declaring
something is not covered in documentation you clearly did not read
carefully, if at all - it's annoying to those who take the trouble to
point it out to you when it's right before their/our eyes, plain as
day. If you don't *understand* what you're r

Re: Disabled, auto-disappearing placeholder in search field like Safari, Console.app

2009-02-24 Thread Jerry Krinock


On 2009 Feb 24, at 03:57, Andrew Farmer wrote:

This is placeholder text. You can set it with the "placeholder"  
field on text input fields, or programatically using the  
setPlaceholderString on a NSTextFieldCell.


Thank you, Andrew.  Yes, that gives the behavior that I want.

And it takes less code than setting the binding option, which gives  
the weird behavior that, I believe, nobody would want.



___

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: simple memory management question

2009-02-24 Thread Matt Neuburg
On Tue, 24 Feb 2009 07:37:43 -0600, James Cicenia  said:
>Hello -
>
>I have the following snippet:
>
>- (void)stateAction:(id)sender{
> StatePickViewController *spvc = [[StatePickViewController
>alloc]initWithNibName:@"StatePicker" bundle:nil];
> [spvc setMyParentController:self];
> [spvc setDialogView:fruitTypeView];
> [spvc viewWillAppear:TRUE];
> [fruitTypeView addSubview:spvc.view];
>}
>
>
>Now I thought I should put [spvc autorelease] at the end, but then my
>view won't show.
>
>Aren't I supposed to release spvc ? And if not, why not?

It depends on what setMyParentController is doing, doesn't it? If it doesn't
retain it, then no one is retaining it, and when you release it it will
vanish in a puff of smoke, closing everything in this copy of the nib. m.

-- 
matt neuburg, phd = m...@tidbits.com, 
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide - Second Edition!
http://www.tidbits.com/matt/default.html#applescriptthings



___

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: simple memory management question

2009-02-24 Thread Joar Wingfors


On Feb 24, 2009, at 5:37 AM, James Cicenia wrote:


Hello -

I have the following snippet:

- (void)stateAction:(id)sender{
	StatePickViewController *spvc = [[StatePickViewController alloc] 
initWithNibName:@"StatePicker"	bundle:nil];

[spvc setMyParentController:self];
[spvc setDialogView:fruitTypeView];
[spvc viewWillAppear:TRUE]; 
[fruitTypeView addSubview:spvc.view];
}


Now I thought I should put [spvc autorelease] at the end, but then  
my view won't show.


Aren't I supposed to release spvc ? And if not, why not?



If you release it, and if no one else is retaining it, it will be  
deallocated. Is that what you want? If not, you need to figure out who  
would be the logical owner of that view controller, and that owner  
then needs to have a reference (pointer) to the view controller and  
retain it.


j o a r


___

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: [Q] What causes an NSArrayController to know that an entity was inserted via a different window?

2009-02-24 Thread Matt Neuburg
On Tue, 24 Feb 2009 09:16:18 -0500, "Jon C. Munson II" 
said:
>The user adds records on one screen.  On a different screen, there is an
>NSArrayController to which an NSTableView is hooked.  When the records are
>added on the first screen, the tableview (on the other screen) updates
>itself automagically (AFAIK I wrote no code to facilitate that behavior).  I
>have a custom view that is also on that other screen that will need to
>update itself as well to match - it isn't based on that same array
>controller however.
>
>So, my question is, how is the array controller receiving notification of
>the newly added records so that I can, hopefully, do the same with my custom
>view?

Well, it's all about bindings and KVO (key-value-observing), isn't it? I
mean, that's what they do and that's what they're for. m.

-- 
matt neuburg, phd = m...@tidbits.com, 
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide - Second Edition!
http://www.tidbits.com/matt/default.html#applescriptthings



___

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: [Q] What causes an NSArrayController to know that an entity was inserted via a different window?

2009-02-24 Thread mmalc Crawford


On Feb 24, 2009, at 7:48 AM, Jon C. Munson II wrote:

 I'm NOT one of those people who learn well from reading technical  
documentation,


It is truly obnoxious, then, and unhelpful to others, to continue to  
make assertions that various issues are not covered in the  
documentation when they very clearly are.

As ever, your fundamental question is answered in the documentation:




[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(managedObjectContextUpdatedNotification:)
name:NSManagedObjectContextObjectsDidChangeNotification
object:[self managedObjectContext]];



Assuming that goes in init, is this the correct message, etc., to be
listening for?

This is not a message, it's a notification.  Notifications are another  
of those fundamental aspects of Cocoa development with which someone  
starting to use Core Data should be familiar.
See 


mmalc

___

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: [Q] What causes an NSArrayController to know that an entity was inserted via a different window?

2009-02-24 Thread Jon C. Munson II
> 
> > So, my question is, how is the array controller receiving notification
> of
> > the newly added records so that I can, hopefully, do the same with my
> custom
> > view?
> 
>   It's done by having the array controller observe (via KVO, using the
> Bindings mechanism) the managed object context. When it changes, the
> array controller updates itself (by performing a 'fetch'). The only
> thing about this that is specific to Core Data (ie, not part of the
> usual Bindings - and by extension, KVC/KVO) is the fact that the array
> controller is observing the MOC as opposed to some other keypath of
> some other KVC/KVO-compliant object. This is explained
> 

[Jon C. Munson II] With regards to the dox, and I'm not being grumpy or
"short" when saying this, if, situationally speaking, these things were
*explicitly* explained (and not just "conceptually" explained), I'd probably
have a better time of it.  I'm NOT one of those people who learn well from
reading technical documentation, particularly if that documentation is
geared more to conceptions than real-world/practical example.  This is why
Hillegass' book was extremely useful to me as I could see the concepts put
into practice.  I tend to learn best by doing and asking questions.  Not
that I don't read the technical dox - I do in order to attempt to arrive at
the answers myself before "bothering" anyone.  Sometimes I can get answers
out of the dox, when the answers I need are finite to the topic discussed.
However, when they start to cross boundaries (as is this case), then I have
a harder time putting two and two together.  Bottom line is, I don't
necessarily learn easily/readily by reading technical documentation (good
examples are my best friend, me being a more visual/kinesthetic type).  And
yes, that's a pain in my tail that I can't always get the
references/inferences within the documentation.  Guess I'm just not as smart
as some of those on this list in that manner.  

That being said, I did think there was some sort of message that
NSArrayController was responding to.  I had hoped there was a method or
delegate method one could employ that would get implemented in response to
whatever message that is, but didn't see one.

Not knowing which/what message to search for prompted the post.

Having said that, and following with what you replied, I found this on the
'net (typos not withstanding):

[[NSNotificationCenter defaultCenter] addObserver:self
 selector:@selector(managedObjectContextUpdatedNotification:)
 name:NSManagedObjectContextObjectsDidChangeNotification
 object:[self managedObjectContext]];

Assuming that goes in init, is this the correct message, etc., to be
listening for?

I am curious about something though.  Since the array controller providing
data for the table view is my custom subclass of NSArrayController, and it
is obviously responding to that message (provided the above is the correct
message), why is it that there's no method one can override in the
NSArrayController class to implement custom functionality based on the
receipt of the message?  It seems that registering two listeners (if,
indeed, one is registered for the base NSArrayController class) is a little
redundant.

Anyway, I do appreciate the time and patience of those on the list who do
take the time to reply and offer assistance.

Thanks for the help!

___

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


Editing a multi-line NSTextField as a single line

2009-02-24 Thread Eric Gorr

I start an edit session of a NSTextField by doing the following:

[textField selectText:nil]; 
NSTextView  *currentEditor  = (NSTextView*)[textField currentEditor];
NSPoint windowLocation  = [theEvent locationInWindow];
NSPoint		screenLocation	= [[self window]  
convertBaseToScreen:windowLocation];
NSUInteger	characterIndex	= [currentEditor  
characterIndexForPoint:screenLocation];
[currentEditor setSelectedRange:NSMakeRange( characterIndex + 1,  
0 )];			


However, this text field has a line break mode of  
NSLineBreakByWordWrapping and does display two lines of text. When  
editing, I would like the editor which appears to edit this text on  
just a single line and not do any wrapping.


I was able to accomplish this by doing:

  [[textField cell] setLineBreakMode:NSLineBreakByClipping];

before I start the edit session.

However, I am curious (because I think it would help me understand how  
the system works) how I could alter currentEditor to accomplish the  
same thing.


I tried looking at the various classes involved...NSTextView,  
NSTextContainer, and NSLayoutManager, but didn't see anything obvious.


___

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: Capture highlighted menu name

2009-02-24 Thread I. Savant
On Tue, Feb 24, 2009 at 9:50 AM, Graham Cox  wrote:

> There is virtually no API for getting at the menu bar layout metrics, even
> in Carbon (it used to be possible to ferret out some of the info, but I
> think much of that stuff - MBDFs and so on - has long gone).

  I think given this:

>> As I mentioned earlier , it is a screen capture application.  So we want to 
>> capture anything that is
>> on the screen.

  ... he just wants a full-screen capture and doesn't want the actual
menu data. Or maybe I'm just completely misunderstanding the nature of
the request. :-)

--
I.S.
___

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

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

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

This email sent to arch...@mail-archive.com


Re: [Q] What causes an NSArrayController to know that an entity was inserted via a different window?

2009-02-24 Thread I. Savant
On Tue, Feb 24, 2009 at 9:16 AM, Jon C. Munson II  wrote:

> The user adds records on one screen.  On a different screen, there is an
> NSArrayController to which an NSTableView is hooked.  When the records are
> added on the first screen, the tableview (on the other screen) updates
> itself automagically (AFAIK I wrote no code to facilitate that behavior).  I
> have a custom view that is also on that other screen that will need to
> update itself as well to match - it isn't based on that same array
> controller however.

  You might easily dismiss mmalc's sentiment in your other thread as
grumpiness if you weren't paying close attention, but in fact his
observation (and assertion) is spot-on.

  With respect, you are asking *a lot* of questions about an advanced
Cocoa technology that depends on other technologies you clearly
haven't studied yet in any reasonable depth. This "automagic"
operation you're asking about is handled by Cocoa Bindings (collective
term for Key Value Coding and Key Value Observing with the supporting
controller layer including NSArrayController). It is not the same
thing as Core Data and in fact you can use either of these
technologies without ever touching the other (Core Data still uses
KVC/KVO but can be used without the supporting controller layer
Bindings provides), but they are most easily used together unless
you're a sadist. With this in mind, however, you MUST learn the ins
and outs of Bindings (and ITS prerequisites) if you're going to use it
with Core Data in any but the most basic of application architectures.

  In his response, mmalc quoted this (in the Before You Start section
at the beginning of the Core Data Programming Guide):

"Core Data is not an entry-level technology. It leverages many other
Cocoa technologies, including memory management, key-value coding, and
key-value observing. You must understand these technologies to use
Core Data effectively."

  DO NOT IGNORE THIS. Read ALL the prerequisites and MAKE SURE YOU
UNDERSTAND THEM so you are not wasting your own time, let alone asking
the list to repeat the conceptual documentation when you should be
reading it carefully for yourself. The list is a valuable place to
come to ask for clarification when doing your homework, but it is not
a substitute for homework ...


> So, my question is, how is the array controller receiving notification of
> the newly added records so that I can, hopefully, do the same with my custom
> view?

  It's done by having the array controller observe (via KVO, using the
Bindings mechanism) the managed object context. When it changes, the
array controller updates itself (by performing a 'fetch'). The only
thing about this that is specific to Core Data (ie, not part of the
usual Bindings - and by extension, KVC/KVO) is the fact that the array
controller is observing the MOC as opposed to some other keypath of
some other KVC/KVO-compliant object. This is explained

--
I.S.
___

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

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

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

This email sent to arch...@mail-archive.com


Re: Capture highlighted menu name

2009-02-24 Thread Graham Cox


On 25/02/2009, at 1:15 AM, Cauvery K wrote:


Hi There,

Any updates on this guys?

Regards,
Cauvery


Hi There,
[...]



I'm going to ignore the approach you mentioned because it sounds
incredibly painful for what could very well turn out to be a very
simple thing. The problem is that it's hard to tell exactly what
you're trying to do because you didn't explain your goals very well.


We are developing a screen capture application and menu capture is  
one of the features. If you consider the default
Apple object capture, it captures the menu but not along with its  
title.  But we want to capture the menu  along with its title.





Sounds like it would be useful for the standard "window" screen  
capture (cmd-shift-4, spacebar) to grab the menu's title along with  
the menu itself. Currently it treats the menu bar and the pulled down  
menu as two separate targets (which they are in terms of windows, but  
not in terms of the user's perception). Including just the title as a  
"tab" above the menu would be very useful for screenshots for manuals.


Have you tried filing an enhancement request? They do seem to work  
eventually - a screen capture feature I asked for around 10.2 time  
turned up in Leopard (though I've no idea if it was because I asked or  
not, or just because it was an obviously good idea).


There is virtually no API for getting at the menu bar layout metrics,  
even in Carbon (it used to be possible to ferret out some of the info,  
but I think much of that stuff - MBDFs and so on - has long gone). So  
I'd guess that the short-term prospects for a solution are poor. You  
might be able to come up with a way to get the title rect using a  
combination of the -locationForSubmenu: method, the title string  
length, system font metrics, menu bar height, and some fiddle factors.  
Expect it to break in future releases. File another enhancement  
request to get an API for the titleRect to be returned.


--Graham






___

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: Changing the height of a NSTextField for editing

2009-02-24 Thread Eric Gorr
Ah, thank you. I think I knew that bounds and frame had different  
uses...hopefully this time that information will stick.


And, yes, it worked.

On Feb 23, 2009, at 5:14 PM, Nate Weaver wrote:

Try setting the frame of the field/field editor instead (doing unit  
conversions if necessary). When you change the bounds of something  
explicitly, you end up changing the drawing transformation as well  
(see under setBounds: and friends).


This has bitten me in the butt before (recently!).

HTH!


On Feb 23, 2009, at 11:52 AM, Eric Gorr wrote:


Here's a sample application demonstrating the problem:

http://ericgorr.net/cocoadev/label/ItemDevLabel.zip

When I click in the label, I start an editing session. However, the  
height of the label can contain two lines of text. When the editing  
session begins, I would like just a single line of editable text.


I begin editing by doing the following:

[textField selectText:nil]; 
NSTextView  *currentEditor  = (NSTextView*)[textField currentEditor];
NSPoint windowLocation  = [theEvent locationInWindow];
NSPoint		screenLocation	= [[self window]  
convertBaseToScreen:windowLocation];
NSUInteger	characterIndex	= [currentEditor  
characterIndexForPoint:screenLocation];
[currentEditor setSelectedRange:NSMakeRange( characterIndex + 1,  
0 )];			



So, I figured I could simply take currentEditor and change it's  
height:


NSRect  editorBounds = [currentEditor bounds];
NSSize  newEditorSize = editorBounds.size;
newEditorSize.height = 16; // just some smaller value for now
[currentEditor setBoundsSize:newEditorSize];

Unfortunately, that does not work. I find it very odd that the  
height of the control remains the same and the text becomes larger.


Next, I tried altering the height of textField before I started the  
editing session and did:


NSSize  textViewSize = [textView bounds].size;
textViewSize.height = 16;
[textView setBoundsSize:textViewSize];

However, I saw the same behavior as demonstrated in the sample  
application.


Eventually, I would like to allow the user to edit on multiple  
lines, but if I cannot change the height to just a single line, I  
have no expectation that I'd be able to change the height to hold  
multiple lines.



Anyone have any ideas?


___

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/mailist 
%40ericgorr.net


This email sent to mail...@ericgorr.net


___

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: Capture highlighted menu name

2009-02-24 Thread I. Savant
On Tue, Feb 24, 2009 at 9:15 AM, Cauvery K  wrote:

> Any updates on this guys?

  It doesn't appear so, but it's likely because your clarification
answer still didn't clarify things much. See below.


On Thu, Feb 19, 2009 at 12:58 AM, Cauvery K  wrote:

> We are developing a screen capture application and menu capture is one of
> the features. If you consider the default
> Apple object capture, it captures the menu but not along with its title.

  It's not clear what you mean by "the default Apple object capture".
Be specific.


>  But we want to capture the menu  along with its title.
> Guess an example would clear things up. Lets say a user clicks on the 'File'
> menu on  the  Mail application menu bar.  Now the user will be able to see
> the menu items like 'New Message' , 'New Note'etc.  Now we would like to
> capture this File menu along with the menu name  - 'File' in this case (i.e
> File highlighted using the selection color)

  When I use the built-in screen capture shortcuts (particularly,
Cmd-Shift-3 to capture the full screen and write the file to the
desktop), it works as expected. Not only do the menu titles show up,
but the highlighted item appears highlighted in the capture, as
expected.

  What *specific* approach are you taking to capture the screen?

--
I.S.
___

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

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

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

This email sent to arch...@mail-archive.com


[Q] What causes an NSArrayController to know that an entity was inserted via a different window?

2009-02-24 Thread Jon C. Munson II
Namaste!

I'm not sure what to actually title this nor what search terms to use as
preliminary shots-in-the-dark didn't turn up much with the exception of one
possibility.

The situation is this:

The user adds records on one screen.  On a different screen, there is an
NSArrayController to which an NSTableView is hooked.  When the records are
added on the first screen, the tableview (on the other screen) updates
itself automagically (AFAIK I wrote no code to facilitate that behavior).  I
have a custom view that is also on that other screen that will need to
update itself as well to match - it isn't based on that same array
controller however.

So, my question is, how is the array controller receiving notification of
the newly added records so that I can, hopefully, do the same with my custom
view?

Any advice appreciated and many thanks in advance!

Peace, Love, and Light,

/s/ Jon C. Munson II


___

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: Capture highlighted menu name

2009-02-24 Thread Cauvery K


Hi There,

Any updates on this guys?

Regards,
Cauvery


Hi There,
[...]



 I'm going to ignore the approach you mentioned because it sounds
incredibly painful for what could very well turn out to be a very
simple thing. The problem is that it's hard to tell exactly what
you're trying to do because you didn't explain your goals very well.


We are developing a screen capture application and menu capture is  
one of the features. If you consider the default
Apple object capture, it captures the menu but not along with its  
title.  But we want to capture the menu  along with its title.


Guess an example would clear things up. Lets say a user clicks on  
the 'File' menu on  the  Mail application menu bar.  Now the user  
will be able to see the menu items like 'New Message' , 'New  
Note'etc.  Now we would like to capture this File menu along with  
the menu name  - 'File' in this case (i.e File highlighted using the  
selection color)



 You want the *title* of whatever menu item is selected. Do you mean
within your own application or any application at all?


As I mentioned earlier , it is a screen capture application.  So we  
want to capture anything that is

on the screen.

Thank you.

Regards,
Cauvery.



On 18-Feb-09, at 1:00 AM, I. Savant wrote:

On Tue, Feb 17, 2009 at 6:47 AM, Cauvery K  
 wrote:



--
I.S.









---
Robosoft Technologies - Come home to Technology

Disclaimer: This email may contain confidential material. If you were not an 
intended recipient, please notify the sender and delete all copies. Emails to 
and from our network may be logged and monitored. This email and its 
attachments are scanned for virus by our scanners and are believed to be safe. 
However, no warranty is given that this email is free of malicious content or 
virus.
___

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: View with Subviews + Drawing on top of everything

2009-02-24 Thread rajesh
sorry I got confused over the term " lightweight drawing objects  
" :) . I just started with the CA programming guide , its amazing !!!


Thanks Graham.

~Rajesh

On Feb 24, 2009, at 1:57 PM, Graham Cox wrote:



On 24/02/2009, at 11:52 PM, rajesh wrote:

Yes indeed , but I chose such approach is that these subViews have  
lot of stuff to draw within itself



That's irrelevant - you have to do all that drawing, whether it's  
inside an NSView or not.


and not to mention the animations with which they  
appear,disappear,move etc., is pretty much achievable.


You could use Core Animation to use multiple CALayers within a  
single view. There is plenty of good sample code on this - try  
GeekGameBoard for instance.





--Graham






___

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


simple memory management question

2009-02-24 Thread James Cicenia

Hello -

I have the following snippet:

- (void)stateAction:(id)sender{
	StatePickViewController *spvc = [[StatePickViewController  
alloc]initWithNibName:@"StatePicker"	bundle:nil];

[spvc setMyParentController:self];
[spvc setDialogView:fruitTypeView];
[spvc viewWillAppear:TRUE]; 
[fruitTypeView addSubview:spvc.view];
}


Now I thought I should put [spvc autorelease] at the end, but then my  
view won't show.


Aren't I supposed to release spvc ? And if not, why not?

Thanks
James
___

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: Simple way to traverse 2D array?

2009-02-24 Thread Peter N Lewis

At 18:36 -0600 23/2/09, Ashley Perrien wrote:
This is relatively easy if I know how many arrays I'm working with 
(3 in this case) to simply nest the for loops but if I don't know 
how many arrays the primary array has, I can't think of a way to 
nest the loops if I don't know how deeply to nest them. Any 
suggestions on the best way to approach something like this?


You could use a simple recursion, something like this:

void Recurse( NSMutableArray* allresults, NSArray* arrays, int index, 
NSMutableArray* current )

{
  if ( index >= [arrays count] ) {
[allresults addObject:current];
  } else {
for ( id obj in [arrays objectAtIndex:index] ) {
  NSMutableArray* c = [current mutableCopy];
  [c addObject:obj];
  Recurse( allresults, arrays, index+1, c );
  [c release];
}
  }
}

void Doit()
{
  // Initialize the 2D array
  NSMutableArray *arrays = [NSMutableArray array];
  [arrays addObject:[NSArray arrayWithObjects:@"1", @"2", @"3", nil]];
  [arrays addObject:[NSArray arrayWithObjects:@"A", @"B", @"C", @"D", nil]];
  [arrays addObject:[NSArray arrayWithObjects:@"Red", @"White", @"Blue", nil]];

  NSMutableArray *allresults = [NSMutableArray array];
  Recurse( allresults, arrays, 0, [NSMutableArray array] );
   
  NSLog( @"%@", allresults );

}

Enjoy,
   Peter.

--
 Run macros from your iPhone with Keyboard Maestro Control!
   or take a break with Aragom Space War for your iPhone

Keyboard Maestro  Macros for your Mac
Aragom Space War  Don't get killed!
   
___

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: View with Subviews + Drawing on top of everything

2009-02-24 Thread Graham Cox


On 24/02/2009, at 11:52 PM, rajesh wrote:

Yes indeed , but I chose such approach is that these subViews have  
lot of stuff to draw within itself



That's irrelevant - you have to do all that drawing, whether it's  
inside an NSView or not.


and not to mention the animations with which they  
appear,disappear,move etc., is pretty much achievable.


You could use Core Animation to use multiple CALayers within a single  
view. There is plenty of good sample code on this - try GeekGameBoard  
for instance.





--Graham




___

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 oneself to /Applications (or ~/Applications)

2009-02-24 Thread Rainer Brockerhoff
At 03:06 -0800 24/02/09, cocoa-dev-requ...@lists.apple.com wrote:
>From: Tommy Nordgren 
>References: <67c1da73-c3cb-4854-9b46-70c0365d5...@mac.com>
>   <57b2a86d-b87c-486f-8d2e-6291d3f29...@comhem.se>
>   <4b898f01-2234-4d19-8b63-25f4cd275...@webis.net>
>   <15c43c09-ae0d-455e-ae10-5bc8c2714...@comhem.se>
>   
>In-Reply-To: 
>Date: Tue, 24 Feb 2009 04:08:36 +0100
>Message-ID: <8d535551-d24a-47ad-8fa2-2138ca7ec...@comhem.se>
>
>On Feb 24, 2009, at 3:34 AM, Shawn Erickson wrote:
>
>>On Mon, Feb 23, 2009 at 6:22 PM, Tommy Nordgren
>> wrote:
>>>The following code will test if you are running from the DMG:
>>>
>>>NSString * volName = @"Mother";
>>>NSString * appName = @"MyApp.app";
>>>
>>>if ([[[NSBundle mainBundle] bundlePath] isEqualTo: [ NSString
>>>stringWithFormat:@"/Volumes/%@/%@",volName,appName]) {
>>>
>>>  //Here you can show an alert telling the user to to copy the app to
>>>the applications folder
>>>
>>>}
>>
>>If a disk image it mounted a second time (can happen in a few ways) it
>>won't be at /Volumes/Mother/... but at /Volumes/Mounter 1/... Also you
>>can mount disk images in location other then under /Volumes/...
>   It will be /Volumes/Mother 1/...  I've tested.
>This can be handled by using a regexp class for the matching instead of a 
>simple
>equality test.
>   Also, while it's possible to mount a disk image at other places than 
> under Volumes,
>that won't happen when doubleclicking a disk image or it being mounted from 
>Safari

You might want to look at
http://www.brockerhoff.net/src/index.html
scroll down to "PathProps". It's source code I wrote to check volume/device 
parameters for a given path; the original idea was to check whether your app is 
running from a disk image. (Some of the code to find out details for a network 
volume calls deprecated API's; you might want to comment that out.)

In fact, I don't recommend using this code directly; use parts and modify as 
you see fit. For one, if your app is in ~/Applications and the user is using 
FileVault, the home folder _will_ be on a disk image. So you'll also have to 
check if the volume is read-only r not.

It may be useful to also distinguish whether you're running from a generic disk 
image or optical disk, or specifically from _your_ distribution disk image. For 
that, I found it most useful to have a hidden file next to my app on the 
original image. This hidden file has a name like 
".29E04275-96F1-4CF5-9EB5-4ECE6908C460.png" (make your own UUID in the Terminal 
typing "uuidgen"), and doubles as the disk image's hidden background image. 
Then I simply check for the presence of this file.

What action to take depends on what your software does. If you have to install 
a launch agent or setuid/setgid tool, these binaries won't work properly from 
FileVault or on a disk image, so you pretty much have to handle this case.

Personally I avoid installer packages - I've lost data in the past by 
improperly quoted folder paths in installer scripts, and dislike writing shell 
scripts myself. An alternative is to do a one-time check; have a "first run" 
key in your preferences, and if the user is running from the dmg, you offer to 
copy the application.

Previous posts have discussed the problem of "moving" a running application. 
This is actually unnecessary. You can copy your entire application bundle with 
an API like FSPathCopyObjectSync() or one of the Cocoa equivalents, start the 
copy with LaunchServices, quit, and have the copy unmount the disk image.

While I'm not sure I was the first to use the symlink-to-Applications 
technique, I started using it in 2003 (see http://db.tidbits.com/article/8357). 
If you use it, be sure to use a symlink instead of a Finder-generated alias 
file; besides being larger, an alias may contain private data about your home 
system, like the name and creation timestamp of your boot drive.

Downside of the symlink idea is that there's no way to make a generic symlink 
to ~/Applications.

HTH,
-- 
Rainer Brockerhoff  
Belo Horizonte, Brazil
"In the affairs of others even fools are wise
 In their own business even sages err."
Weblog: http://www.brockerhoff.net/bb/viewtopic.php
___

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: View with Subviews + Drawing on top of everything

2009-02-24 Thread rajesh
Yes indeed , but I chose such approach is that these subViews have lot  
of stuff to draw within itself and not to mention the animations with  
which they appear,disappear,move etc., is pretty much achievable.
I don't know if the said things can be done the way you suggested then  
I better start make changes :)


It is something like one of the apple example codes  
( SimpleLayoutView ) has , it has sample with NSBox... I don't think  
its any different If I use NSView instead.


On Feb 24, 2009, at 1:27 PM, Graham Cox wrote:



On 24/02/2009, at 11:15 PM, rajesh wrote:


Need help with drawing (I have done some basic drawings in Cocoa)

Problem:
I have a View which in-turn has subviews(elements) e.g.,  
chocolates ,balloons,roses , etc.,

These elements have complex drawings and are subclasses of NSView.

I place these elements on to the view with some gaps/space in  
between (exposed part of main view), so far good , but I am really  
stuck at a point where I have to draw a line/lines which connect  
all the like elements or something like that.


When I attempt to draw a line joining the elements , line is drawn  
then subViews are placed over it , but I want the other way around.


There should be something fundamental flaw or I am missing the big  
picture.

I know that drawRect: is called first and the subViews are placed.

How should make my code to work as Intended



Subviews are drawn "on top" because conceptually they are in front.

My advice is general: don't (ab)use NSViews like this. I've seen  
quite a few people doing this lately, or trying to, and it's  
actually one of the first things that Apple advise against in the  
drawing guide. Using an entire NSView to act as a moveable graphic  
within a larger view is using a sledgehammer to crack a nut. It's  
very unscalable and will quickly suffer from performance issues.


It's much easier to create lightweight drawing objects that are  
drawn within one view. Apart from being much faster, you can overlay  
lines or other things on top as you wish - it gives you much more  
control.


--Graham




___

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: View with Subviews + Drawing on top of everything

2009-02-24 Thread Graham Cox


On 24/02/2009, at 11:15 PM, rajesh wrote:


Need help with drawing (I have done some basic drawings in Cocoa)

Problem:
I have a View which in-turn has subviews(elements) e.g.,  
chocolates ,balloons,roses , etc.,

These elements have complex drawings and are subclasses of NSView.

I place these elements on to the view with some gaps/space in  
between (exposed part of main view), so far good , but I am really  
stuck at a point where I have to draw a line/lines which connect all  
the like elements or something like that.


When I attempt to draw a line joining the elements , line is drawn  
then subViews are placed over it , but I want the other way around.


There should be something fundamental flaw or I am missing the big  
picture.

I know that drawRect: is called first and the subViews are placed.

How should make my code to work as Intended



Subviews are drawn "on top" because conceptually they are in front.

My advice is general: don't (ab)use NSViews like this. I've seen quite  
a few people doing this lately, or trying to, and it's actually one of  
the first things that Apple advise against in the drawing guide. Using  
an entire NSView to act as a moveable graphic within a larger view is  
using a sledgehammer to crack a nut. It's very unscalable and will  
quickly suffer from performance issues.


It's much easier to create lightweight drawing objects that are drawn  
within one view. Apart from being much faster, you can overlay lines  
or other things on top as you wish - it gives you much more control.


--Graham


___

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


View with Subviews + Drawing on top of everything

2009-02-24 Thread rajesh

Hi All,

Sorry for the bad subject line,

Need help with drawing (I have done some basic drawings in Cocoa)

Problem:
 I have a View which in-turn has subviews(elements) e.g.,  
chocolates ,balloons,roses , etc.,

These elements have complex drawings and are subclasses of NSView.

I place these elements on to the view with some gaps/space in between  
(exposed part of main view), so far good , but I am really stuck at a  
point where I have to draw a line/lines which connect all the like  
elements or something like that.


When I attempt to draw a line joining the elements , line is drawn  
then subViews are placed over it , but I want the other way around.


There should be something fundamental flaw or I am missing the big  
picture.

I know that drawRect: is called first and the subViews are placed.

How should make my code to work as Intended

Any help is appreciated
and I did go through the basic drawing concepts and Googled for  
something of my requirement


Thanks
~Rajesh


Code goes something like this:

- (void)drawRect:(NSRect)rect {
//for now just draw a sample line diagonally.
[[NSColor blackColor] set];
NSBezierPath *sample = [NSBezierPath bezierPath];
[sample moveToPoint:NSMakePoint(0,0)];
[sample lineToPoint:NSMakePoint(500, 500)];
[sample stroke];
}
- (void)layout {
//NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
// NSLog(@"layout poloMainView");
	NSMutableArray *subviews = [NSMutableArray arrayWithArray:[self  
subviews]];

for( i = 0 ; i < (count - 1) ; i++)
{
Element *subview = [subviews objectAtIndex:i ];
// do the placing of the view accordingly
}

}

- (IBAction)addElement:(id)sender
{
		Element *box = [[[Element alloc] initWithFrame:NSMakeRect(0.0, 0.0,  
PAGEWIDTH, PAGEHEIGHT)] autorelease];


[self addSubview:box];


[self layout];

}
___

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: iTunes like transition?

2009-02-24 Thread Luca Pazzerello
Thanks!I solved with a simple subclass of NSTextField, in wich my beat (an
NSTimer) updates the drawing coordinates of the text.

Regards,
--Luca C.

2009/2/23 Kyle Sluder 

> On Mon, Feb 23, 2009 at 2:18 PM, Luca Pazzerello
>  wrote:
> > Maybe this screenshot clarifies about which transition i am talking
> about.
> > http://a1.s3.quickshareit.com/immagine28d926.png
>
> That's not really a transition, it's just drawing.  iTunes is a Carbon
> app, so it uses a different drawing model entirely.
>
> It looks like all you want is a custom NSTextFieldCell subclass whose
> objectValue can be set to an array of strings instead of just a single
> string, and then you want to do the drawing yourself.
>
> --Kyle Sluder
>
___

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

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

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

This email sent to arch...@mail-archive.com


Re: Disabled, auto-disappearing placeholder in search field like Safari, Console.app

2009-02-24 Thread Andrew Farmer

On 23 Feb 09, at 20:52, Jerry Krinock wrote:
When I bind to an NSSearchField with option key=value pair  
NSNullPlaceholderBindingOption="Search names", indeed "Search names"  
is displayed in the search field whenever the bound keyPath is nil.   
But it appears as normal black text which the user must overtype.


In contrast, the "Google" search field in Safari has disabled (gray)  
text that disappears when the field becomes the key view.  The  
search field in Console.app has similar behavior.


This is placeholder text. You can set it with the "placeholder" field  
on text input fields, or programatically using the  
setPlaceholderString on a NSTextFieldCell.

___

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: Adding text to NSImage using lockFocus/unlockFocus not working

2009-02-24 Thread Graham Cox


On 24/02/2009, at 9:50 PM, Ashish Tiwari wrote:

I am trying to get finder icon view like behavior in my  
application.  Using
IKImageBrowserView I am able to show icons for contents of a  
directory but I
also need file/directory name below those icons. For this I am  
trying to

insert NString into NSImage but text is now showing up in
IKImageBrowserView.



IKImageBrowserVIew has a much better way to handle this specific  
labelling requirement.


The objects it stores should implement the informal protocol for - 
imageTitle and -imageSubtitle, and the view will draw those strings  
below the icons for you.


Here are the methods I have in a simple custom object I use - I think  
I originally got this from one of Apple's samples though I'm afraid I  
forgot exactly which one. It simply provides the browser with the path  
to each image.


--Graham



//  
-

//  imageRepresentationType:
//
//  Set up the image browser to use a path representation.
//  
-

- (NSString*)   imageRepresentationType
{
return IKImageBrowserPathRepresentationType;
}

//  
-

//  imageRepresentation:
//
//  Give the path representation to the image browser.
//  
-

- (id)  imageRepresentation
{
return mPath;
}

//  
-

//  imageUID:
//
//  Use the absolute file path as the identifier.
//  
-

- (NSString*)   imageUID
{
return mPath;
}


- (NSString*)   imageTitle
{
return [[mPath lastPathComponent] stringByDeletingPathExtension];
}


- (NSString*)   imageSubtitle
{
NSDictionary* attribs = [self imageAttributes];

int w, h;

w = [[attribs objectForKey:@"PixelWidth"] intValue];
h = [[attribs objectForKey:@"PixelHeight"] intValue];

return [NSString stringWithFormat:@"%d x %d", w, h];
}

___

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


how to modify 'PictureSharing' example?

2009-02-24 Thread Carlo Gulliani
I made app like 'PictureSharing'.
In this example data changing just after i select my service in list (i should 
press on server line in Picture sharing browser to get new picture), how can i 
use NSNotificationCenter to catch event while my data is changed? In general i 
wanna change picture in Picture sharing and in picture sharing browser picture 
changed automatically w/o mouse event


  
___

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


Adding text to NSImage using lockFocus/unlockFocus not working

2009-02-24 Thread Ashish Tiwari
Hi All,

 

I am trying to get finder icon view like behavior in my application.  Using
IKImageBrowserView I am able to show icons for contents of a directory but I
also need file/directory name below those icons. For this I am trying to
insert NString into NSImage but text is now showing up in
IKImageBrowserView.

 

NSImage *img = [[NSWorkspace sharedWorkspace] iconForFile:[path
stringByAppendingPathComponent:file]];

//NSImage *img = [[NSImage
alloc]initWithContentsOfFile:@"/Users/ashisht/Desktop/downloads.png"];

NSString *imgID = [file lastPathComponent];

[img   setName:imgID];

 

 [img lockFocus]; 

NSFont *txtFont = [NSFont boldSystemFontOfSize:13];

NSDictionary *txtDict = [NSDictionary 

 
dictionaryWithObjectsAndKeys:txtFont,

NSFontAttributeName, nil];

NSString* myString = @"ABCDE"; 

 [myString drawAtPoint: NSMakePoint(0, 0) withAttributes: txtDict]; 



 [img unlockFocus];

 

Please tell me what I am doing wrong, is there any other way of attaching
text to NSImage (result should be NSImage)?

Note: IKImageBrowserView IB connections are proper also reloadData and other
delegates are working fine.

 

Thanks in advance.

 

Ashish Tiwari 

 

 

___

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