Re: Core Data bindings question

2011-02-07 Thread Jerry Krinock

On 2011 Feb 07, at 16:46, Darren Wheatley wrote:

> When I try to bind the  enabled property I get the following error:
> 
> "cannot create BOOL from object of class __NSArray0"
> 
> Does anyone have any idea how I can achieve the desired result?

Yes, most people get that the first time they try this.  It can be a little 
counterintuitive until you understand it.

The error is helpful, though.  As the error implies, you are probably binding a 
checkbox to an array (__NSArray0).  You need to bind the *table column* instead 
of the checkbox.  The typical binding for this case looks something like:

* Table Column Bindings
** Value, or Enabled
Bind to: FooArrayController
Controller Key:  arrangedObjects
Model Key Path:  active


___

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: Printing Appears Very Small in Lower-Left Corner of Page

2011-02-07 Thread Gerry Beggs
Thanks Raleigh.
I discovered a work-around. But there does appear to be a bug.

This was difficult for me to test because I wasn't able to reproduce it (from a 
new document) on my machine. But I received a document created by a user on 
their machine which I was able to use to reproduce the problem. This problem 
must depend on the printer driver being used.
The document file contains the PMPageFormat data saved as XML representation 
using PMPageFormatCreateDataRepresentation(...)


On my machine (and most users' machines) the print resolution saved in the XML 
is set to 72 dpi.
But in the sample document I received, the print resolution was set to 2400 dpi.

When drawing the page content, the CGContext transform was set correctly when 
rendering the print preview, but when rendering the actual printed page, the 
CGContext's transform scale was changed to 3% (= 72/2400) (If I tried to change 
the scaling back to 100%, the clipping rectangle still limited me to drawing in 
the small rectangle in the corner)


Long story short, I fixed the problem by calling the deprecated function 
PMSetResolution on the PMPageFormat to set it to 72 dpi before printing.
I use a preprocessor condition preventing this line from compiling as 64-bit. 


If there's a good explanation of why this happened, I'd like to know.
But the fact that the print preview didn't render the same as the actual 
printout tells me that it might be a bug.


On 2011-02-07, at 11:11 AM, Raleigh Ledet wrote:

> Gerry,
> 
> File a radar. Include the file or a sample project or whatever you can to 
> help us duplicate. If this is a Cocoa bug, then you should be able to 
> duplicate with a small sample app pretty quickly.
> 
> -raleigh
> 
> On Jan 18, 2011, at 5:42 PM, Gerry Beggs wrote:
> 
>> Just to follow-up (and clarify) my own problem:
>> 
>> I have implemented NSDocument's printOperationWithSettings: method to kick 
>> off the printing process when the user selects Print from the File menu.
>> 
>> I am using the same NSView drawRect: method to display on-screen as when 
>> printing.
>> The Print Preview in the Print Dialog always appears correct.
>> However, the final print output is appearing scaled down, either when 
>> printing to paper, or to PDF.
>> 
>> When the problem presents itself, the transformation of the CGContext is the 
>> same when drawing the print preview as when drawing the actual output. That 
>> is, it is scaled down, which explains why the output is small.
>> When the problem doesn't present itself, the transformation is the identity 
>> transformation when drawing the actual output.
>> 
>> 
>> I've discovered that if I run my application as a 64-bit executable, the 
>> problem goes away.
>> When running under 32-bit, the problem is consistent.
>> 
>> Thanks for any help.
>> 
>> On 2011-01-16, at 1:24 AM, Gerry Beggs wrote:
>> 
>>> I've been having a problem with my application sometimes (but not always) 
>>> printing the full page, but it appears VERY small in the lower-left corner 
>>> of the page.
>>> 
>>> I was having trouble reproducing it, but finally received a sample document 
>>> from one of my users that let me reproduce it.
>>> Still, sometimes it prints correctly filling the page, other times, it 
>>> prints scaled down in the lower-left corner of the page.
>>> 
>>> I am using NSPrintOperation from an NSDocument to handle the printing 
>>> operations.
>>> 
>>> When trying to debug this issue, I examined the transformation from my 
>>> view's drawRect method using CGContextGetCTM.
>>> I discovered something interesting:
>>> - When the printout appears scaled down, the transformation structure is 
>>> the same as it is when the print preview image is rendered.
>>> - When the printout appears full-sized, the transformation structure is the 
>>> identity matrix (ie. scale = 100%)
>>> 
>>> 
>>> Since the scale of the CGContext is the same when rendering the print 
>>> preview as it is when rendering the full-sized page, this explains why my 
>>> printouts are appearing very small in my output.
>>> 
>>> Values 'a' and 'd' in the CGAffineTransformation structure indicate the 
>>> scaling factor and for the print preview, it makes sense that it is scaled 
>>> down for the print preview. But somehow, the transformation is not being 
>>> set back to 100% scaling for the actual printing.
>>> 
>>> I've looked for unbalanced CGContextSaveGState/CGContextRestoreGState 
>>> calls, but they are all balanced.
>>> 
>>> I've spent too much time trying to debug this. If anyone can give any ideas 
>>> why my printouts are appearing scaled down, I would appreciate any help.
>>> Thanks.
>>> 
>>> -- 
>>> gbeg...@gmail.com   http://www.GerrysCuppaTea.org/
>>> 
>>> ___
>>> 
>>> 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/Unsubsc

Core Data bindings question

2011-02-07 Thread Darren Wheatley
Hi,

I have a Core Data app that displays data in a tableView with each column
bound to a field in a core data entity.

One field is called "active", and is of type BOOL

I box the BOOL for insertion into the Core Data store using [NSNumber
numberWithBool];

In the TableView I would like to bind the "enabled" property of each cell
to the "active" variable, so that if a record has "active" set to NO all
of the fields become read only.

When I try to bind the  enabled property I get the following error:

"cannot create BOOL from object of class __NSArray0"

Does anyone have any idea how I can achieve the desired result?

Regards

Darren.



___

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: NSDrawer dealloc causes kCGErrorIllegalArgument

2011-02-07 Thread Greg Parker
On Feb 7, 2011, at 12:10 PM, James Walker wrote:
> I have a dialog with a drawer, and when the dialog closes, my console log 
> contains these error messages:
> 
> : kCGErrorIllegalArgument: _CGSFindSharedWindow: WID 583
> : kCGErrorIllegalArgument: CGSGetWindowTags: Invalid window 0x247
> 
> I set a breakpoint at CGErrorBreakpoint, and when this breakpoint is hit, the 
> stack trace begins:
> 
> #0  0x90f9f32a in CGErrorBreakpoint ()
> #1  0x91034c24 in CGSGlobalErrorv ()
> #2  0x90e23b44 in _CGSFindSharedWindow ()
> #3  0x90e10ec7 in _CGSWindowByID ()
> #4  0x90e115c2 in CGSGetWindowTags ()
> #5  0x90083d67 in WindowData::OnActiveSpace ()
> #6  0x90083981 in WindowData::Destruct ()
> #7  0x9193b0cd in _CFRelease ()
> #8  0x93c07e87 in -[NSWindow dealloc] ()
> #9  0x93e0d951 in -[NSDrawer dealloc] ()
> #10 0x9193af38 in CFRelease ()
> #11 0x919655b2 in __CFArrayReleaseValues ()
> #12 0x9193b101 in _CFRelease ()
> #13 0x91967c6d in _CFAutoreleasePoolPop ()
> #14 0x91f1a0aa in NSPopAutoreleasePool ()
> #15 0x919b in CFRunLoopTimerInvalidate ()
> 
> So, I'm wondering if I'm doing something wrong (or failing to do something) 
> involving the memory management of the drawer.
> 
> The dialog is handled by an object derived from NSWindowController, and this 
> controller is the file's owner of the nib.  The NSDrawer is a top-level 
> object of the nib.  The docs say that when an NSWindowController is the owner 
> of a nib, it's responsible for cleaning up all the top-level objects, but I 
> wonder if that's really happening.

It could be a memory management error somewhere other than the drawer. Perhaps 
some other object is being used after deallocation, and the resulting memory 
smasher hits the CG WindowData object. In any case, you should start with 
NSZombies and see if it catches any problems before this call to -[NSDrawer 
dealloc].


-- 
Greg Parker gpar...@apple.com Runtime Wrangler


___

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: Escape in NSTableView cell

2011-02-07 Thread Kyle Sluder
On Mon, Feb 7, 2011 at 8:05 AM, Dave Reed  wrote:
> See this:
>
> http://www.cocoabuilder.com/archive/cocoa/176709-esc-to-cancel-editing-in-tableview.html
>
> Subclassing NSTableView and overriding cancelOperation appears to work. I 
> don't know if there's a better way though.

I'm not a fan of the "Escape-to-autocomplete" feature, but even aside
from that, dealing with it as a developer is frustrating. -[NSWindow
doCommandBySelector:] is the method responsible for converting
-cancelOperation: into -complete:. Since NSWindow is the only
implementor of -cancelOperation:, by default it's the one that gets
all the Escape key presses. This is why subclassing NSTableView to
implement -cancelOperation: works, but it's a pain in the neck to
implement on every single editable view in your app.

Instead, I've filed rdar://problem/8967168 asking for a new method on
NSResponder: -completeOrCancelOperation:. Rather than have -[NSWindow
doCommandBySelector:] perform trickery, NSTextView could implement
-completeOrCancelOperation: to do the appropriate thing. The
equivalent of the current behavior would have it call [self
doCommandBySelector:@selector(complete:)]. But an even better
implementation would call [self
doCommandBySelector:@selector(cancelOperation:)] if -isFieldEditor
returns YES. That way field editors get the expected behavior (Escape
cancels editing), multiline text views get the expected behavior
(Escape brings up the completion menu), and implementors have a nice
clean place to control the process (override -doCommandBySelector: or
-textView:doCommandBySelector: to handle -completeOrCancelOperation:).

I've duped this bug to http://www.openradar.me/radar?id=1073404 . If
any AppKit folks are reading this, please consider doing this. It
would make our lives as developers of apps with preferences related to
Escape-to-end-editing much easier.

--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: NSDocument Question

2011-02-07 Thread Quincey Morris
On Feb 7, 2011, at 11:54, Bruce Cresanta wrote:

> Ii have two subclasses of NSDocument.   One of the subclasses only ever needs 
> one instance window.   How do I query NSWindowController for the open window, 
> and if that fails, create it.   Sorry for the confusion.

Well, sorry but I'm still confused. You have two subclasses, but subclasses 
aren't objects. Are you saying you're creating one object of *each* NSDocument 
subclass when a *single* file is opened?

Or are you asking about the number of windows per NSDocument (in which case the 
existence of two subclasses seems irrelevant). The document controls how many 
windows get created (either via 'windowNibName' or 'makeWindowControllers' 
initially), so any given subclass can enforce its own single-window rule.

Or are you asking whether multiple document objects of one of the subclasses 
can share a single window? That seems like it would mess up the standard 
document semantics (and menu items).

If you need to know whether a file already has a document open, you can use 
'[[NSDocumentController sharedDocumentController] documentForURL:...]' to find 
it, and if you need to know what windows a document has, you can use [document 
windowControllers] to find their window controllers.

But I'm just throwing out random ideas at this point -- I still don't 
understand what you're trying to achieve.


___

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: NSDocument Question

2011-02-07 Thread Sherm Pendley
On Mon, Feb 7, 2011 at 2:54 PM, Bruce Cresanta  wrote:
> Ii have two subclasses of NSDocument.   One of the subclasses only ever needs 
> one instance window.   How do I query NSWindowController for the open window, 
> and if that fails, create it.   Sorry for the confusion.

Override -makeWindowControllers. The default calls -windowNibName, and
loads a new instance of the named Nib for every document, but you can
change that behavior to re-use a single window controller:

- (void)makeWindowControllers {
static NSWindowController *windowController;
if (!windowController) {
windowController = [[NSWindowController alloc]
initWithWindowNibName:@"MyDocumentNib" owner:self];
}
[self addWindowController:windowController];
}

sherm--

-- 
Cocoa programming in Perl:
http://camelbones.sourceforge.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


NSDrawer dealloc causes kCGErrorIllegalArgument

2011-02-07 Thread James Walker
I have a dialog with a drawer, and when the dialog closes, my console 
log contains these error messages:


: kCGErrorIllegalArgument: _CGSFindSharedWindow: WID 583
: kCGErrorIllegalArgument: CGSGetWindowTags: Invalid window 0x247

I set a breakpoint at CGErrorBreakpoint, and when this breakpoint is 
hit, the stack trace begins:


#0  0x90f9f32a in CGErrorBreakpoint ()
#1  0x91034c24 in CGSGlobalErrorv ()
#2  0x90e23b44 in _CGSFindSharedWindow ()
#3  0x90e10ec7 in _CGSWindowByID ()
#4  0x90e115c2 in CGSGetWindowTags ()
#5  0x90083d67 in WindowData::OnActiveSpace ()
#6  0x90083981 in WindowData::Destruct ()
#7  0x9193b0cd in _CFRelease ()
#8  0x93c07e87 in -[NSWindow dealloc] ()
#9  0x93e0d951 in -[NSDrawer dealloc] ()
#10 0x9193af38 in CFRelease ()
#11 0x919655b2 in __CFArrayReleaseValues ()
#12 0x9193b101 in _CFRelease ()
#13 0x91967c6d in _CFAutoreleasePoolPop ()
#14 0x91f1a0aa in NSPopAutoreleasePool ()
#15 0x919b in CFRunLoopTimerInvalidate ()

So, I'm wondering if I'm doing something wrong (or failing to do 
something) involving the memory management of the drawer.


The dialog is handled by an object derived from NSWindowController, and 
this controller is the file's owner of the nib.  The NSDrawer is a 
top-level object of the nib.  The docs say that when an 
NSWindowController is the owner of a nib, it's responsible for cleaning 
up all the top-level objects, but I wonder if that's really happening.

--
  James W. Walker, Innoventive Software LLC
  
___

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: NSDocument Question

2011-02-07 Thread Bruce Cresanta
Ii have two subclasses of NSDocument.   One of the subclasses only ever needs 
one instance window.   How do I query NSWindowController for the open window, 
and if that fails, create it.   Sorry for the confusion.

Bruce
On Feb 7, 2011, at 10:54 AM, Quincey Morris wrote:

> On Feb 7, 2011, at 07:37, Bruce Cresanta wrote:
> 
>>  I have two types of NSDocument.   One of them only ever needs to be 
>> active one at a time (No duplicates).   How do I check to see if the window 
>> is open first and make it key, and if it is not open already, open it once?
> 
> What do you mean by "two types of NSDocument"? Two subclasses? Two document 
> types? Two file types? NSDocument already has the behavior you describe, 
> based on the identity of the underlying file. If you don't see this behavior, 
> then you're likely subverting it somehow, or working with two different files.
> 
> 

___

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: Memory management about async object

2011-02-07 Thread ico
Hi All,

What if the handler retain itself, and then will perform some
NSURLConnection tasks, that will async download some data, and receive some
messages as a delegate by implementing
connection:didReceiveResponse
connection:didReceiveData
connection:didFailWithError
connection:didFinishLoading

when the application call the cancel method of NSURLConnection, no chance to
autorelease itself because those delegate methods will not have a chance to
be called as the official document stated:

Cancels an asynchronous load of a request.

- (void)cancel

*Discussion*

Once this method is called, the receiver’s delegate will no longer receive
any messages for this NSURLConnection.
Will this cause memory leak?


On Sun, Jan 2, 2011 at 12:50 AM, Steve Sisak  wrote:

> There's some good information on this in TechNote 2009
>
> 
>
> Also, here is some sample code you might find very helpful:
>
> 
>
> as it does almost what you're describing.
>
> HTH,
>
> -Steve
>
>
>
>
> At 5:28 PM +0800 12/28/10, ico wrote:
>
>> Hi Stephen,
>>
>> Thanks for your reply, so there is no any perfect solution for this kind
>> of
>> problem?
>> And can you give me a specific example to demonstrate why why it is not
>> safe
>> to
>> release these async objects inside a callback method and why not safe to
>> autorelease it?
>> Thanks.
>>
>


-- 
==
Life isn't about finding yourself.
Life is about creating yourself.
___

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: NSDocument Question

2011-02-07 Thread Quincey Morris
On Feb 7, 2011, at 07:37, Bruce Cresanta wrote:

>   I have two types of NSDocument.   One of them only ever needs to be 
> active one at a time (No duplicates).   How do I check to see if the window 
> is open first and make it key, and if it is not open already, open it once?

What do you mean by "two types of NSDocument"? Two subclasses? Two document 
types? Two file types? NSDocument already has the behavior you describe, based 
on the identity of the underlying file. If you don't see this behavior, then 
you're likely subverting it somehow, or working with two different files.


___

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: Composing an NSImage to print

2011-02-07 Thread Raleigh Ledet
Sorry to be so late to the party.

What Ken suggested will work. But generally, watermarks, header, and footers 
are drawn via your own -drawPageBorderWithSize: method.

http://developer.apple.com/library/mac/#documentation/cocoa/conceptual/Printing/Tasks/PaginatingViews.html%23//apple_ref/doc/uid/2912-BBCHHAHI

-raleigh

On Jan 15, 2011, at 1:18 PM, Ken Ferry wrote:

> Hi Olivier,
> 
> Unless I misread this, this section cannot be doing anything helpful:
> 
> NSImageView *tempIm = [[NSImageView alloc] initWithFrame:frontRect];
>> [tempIm setImage:[cusThumbFront image]];
>> 
>> NSData* theData = [tempIm dataWithPDFInsideRect:[tempIm bounds]];
>> NSPDFImageRep* pdfRep = [NSPDFImageRep imageRepWithData:theData];
>> 
>> // Create a new image to hold the PDF representation.
>> NSImage* pdfImage = [[NSImage alloc] initWithSize:IMG_SIZE];
>> [pdfImage addRepresentation:pdfRep];
> 
> 
> 
> Have you tried just using [cusThumbFront image] instead of going through
> this?  The system cannot create data where there isn't any, so the pdfImage
> cannot contain any data that wasn't already in the cusThumbFrontImage.
> 
> Okay, that aside, it happens I haven't implemented printing before, so
> forgive me if it turns out this is a non-standard way to do things.
> 
> It is the subview hierarchy that is printed.  If you want to put a watermark
> on top of an image, have a view that draws the base image and then draws the
> watermark image.  Or, make a subview of the view that draws the base that
> draws the watermark.
> 
> It is possible to produce an NSImage that has the watermark and still has
> all the quality available in the original, I just suspect it isn't the most
> straightforward way to do what you'd like to here.
> 
> The way you'd make such an image is to subclass NSImageRep.  Subclassing
> NSImageRep is pretty much the same as subclassing NSView.  Where in NSView
> you override drawRect:, in NSImageRep you override -draw.  The main
> difference between an image and a view is in the guarantees on how they
> scale.  If you stretch a button horizontally, the text doesn't stretch out,
> it stays centered.  An image scales… like an image (i.e. linearly).
> 
> So here's how you might make an NSImageRep that drew a base image and an
> overlay without rasterizing anything, even though I think this isn't the
> best way to solve your problem.
> 
> @interface CompositeImageRep : NSImageRep {
> 
>NSImage *_baseImage;
> 
>NSImage *_overlayImage;
> 
> 
> 
>NSRect _overlayFrame;
> 
> }
> 
> 
> - (id)initWithBaseImage:(NSImage *)baseImage
> overlayImage:(NSImage*)overlayImage overlayFrame:(
> NSRect)overlayFrame;
> 
> 
> @property (readonly) NSImage *baseImage;
> 
> @property (readonly) NSImage *overlayImage;
> 
> @property (readonly) NSRect overlayFrame;
> 
> 
> @end
> 
> @implementation CompositeImageRep
> 
> 
> - (id)initWithBaseImage:(NSImage *)baseImage
> overlayImage:(NSImage*)overlayImage overlayFrame:(
> NSRect)overlayFrame {
> 
>NSParameterAssert(baseImage != nil);
> 
> 
> 
>self = [super init];
> 
>if (self) {
> 
>{
> 
>_baseImage = [baseImage retain];
> 
>_overlayImage = [overlayImage retain];
> 
>_overlayFrame = overlayFrame;
> 
> 
>[self setSize:[baseImage size]];
> 
>}
> 
>}
> 
> 
> 
>return self;
> 
> }
> 
> 
> -(void)dealloc {
> 
>[_baseImage release];
> 
>[_overlayImage release];
> 
>[super dealloc];
> 
> }
> 
> 
> 
> - (BOOL)draw {
> 
>NSRect bounds = (NSRect){NSZeroPoint, [self size]};
> 
> 
> 
>[_baseImage drawInRect:bounds fromRect:NSZeroRect operation:
> NSCompositeSourceOver fraction:1.0];
> 
>[_overlayImage drawInRect:_overlayFrame fromRect:NSZeroRect operation:
> NSCompositeSourceOver fraction:1.0];
> 
>return YES;
> 
> }
> 
> 
> - (id)copyWithZone:(NSZone *)zone {
> 
>CompositeImageRep *rep = [super copyWithZone:zone];
> 
>// careful - superclass uses NSCopyObject. :-(
> 
>rep->_baseImage = [_baseImage retain];
> 
>rep->_overlayImage = [_baseImage retain];
> 
>rep->_overlayFrame = _overlayFrame;
> 
>return rep;
> 
> }
> 
> 
> @synthesize baseImage=_baseImage, overlayImage=_overlayImage,
> overlayFrame=_overlayFrame;
> 
> 
> @end
> 
> 
> 
> On Tue, Jan 11, 2011 at 7:57 AM, Olivier Palliere <
> oliv...@sunprotectingfactory.com> wrote:
> 
>> Hi Guys,
>> 
>> 
>> 
>> I'm working on an app for my personal use that needs to print images I drag
>> on an NSImageView to display a thumbnail.
>> 
>> 
>> 
>> Source images are about 500x500 at 300dpi for most.
>> 
>> 
>> 
>> When I want to print them, I use this snippet of code from Apple's
>> doc:
>> 
>> frontRect = NSMakeRect(0,0,500, 500);
>> 
>> 
>> 
>> NSImageView *tempIm = [[NSImageView alloc] initWithFrame:frontRect];
>> [tempIm setImage:[cusThumbFront image]];
>> 
>> NSData* theData = [tempIm dataWithPDFInsideRect:[tempIm bounds]];
>> NSPDFImageRep* pdfRep = [NSPDFImageRep imageRepWithData:theData];
>> 
>> /

Re: Printing Appears Very Small in Lower-Left Corner of Page

2011-02-07 Thread Raleigh Ledet
Gerry,

File a radar. Include the file or a sample project or whatever you can to help 
us duplicate. If this is a Cocoa bug, then you should be able to duplicate with 
a small sample app pretty quickly.

-raleigh

On Jan 18, 2011, at 5:42 PM, Gerry Beggs wrote:

> Just to follow-up (and clarify) my own problem:
> 
> I have implemented NSDocument's printOperationWithSettings: method to kick 
> off the printing process when the user selects Print from the File menu.
> 
> I am using the same NSView drawRect: method to display on-screen as when 
> printing.
> The Print Preview in the Print Dialog always appears correct.
> However, the final print output is appearing scaled down, either when 
> printing to paper, or to PDF.
> 
> When the problem presents itself, the transformation of the CGContext is the 
> same when drawing the print preview as when drawing the actual output. That 
> is, it is scaled down, which explains why the output is small.
> When the problem doesn't present itself, the transformation is the identity 
> transformation when drawing the actual output.
> 
> 
> I've discovered that if I run my application as a 64-bit executable, the 
> problem goes away.
> When running under 32-bit, the problem is consistent.
> 
> Thanks for any help.
> 
> On 2011-01-16, at 1:24 AM, Gerry Beggs wrote:
> 
>> I've been having a problem with my application sometimes (but not always) 
>> printing the full page, but it appears VERY small in the lower-left corner 
>> of the page.
>> 
>> I was having trouble reproducing it, but finally received a sample document 
>> from one of my users that let me reproduce it.
>> Still, sometimes it prints correctly filling the page, other times, it 
>> prints scaled down in the lower-left corner of the page.
>> 
>> I am using NSPrintOperation from an NSDocument to handle the printing 
>> operations.
>> 
>> When trying to debug this issue, I examined the transformation from my 
>> view's drawRect method using CGContextGetCTM.
>> I discovered something interesting:
>> - When the printout appears scaled down, the transformation structure is the 
>> same as it is when the print preview image is rendered.
>> - When the printout appears full-sized, the transformation structure is the 
>> identity matrix (ie. scale = 100%)
>> 
>> 
>> Since the scale of the CGContext is the same when rendering the print 
>> preview as it is when rendering the full-sized page, this explains why my 
>> printouts are appearing very small in my output.
>> 
>> Values 'a' and 'd' in the CGAffineTransformation structure indicate the 
>> scaling factor and for the print preview, it makes sense that it is scaled 
>> down for the print preview. But somehow, the transformation is not being set 
>> back to 100% scaling for the actual printing.
>> 
>> I've looked for unbalanced CGContextSaveGState/CGContextRestoreGState calls, 
>> but they are all balanced.
>> 
>> I've spent too much time trying to debug this. If anyone can give any ideas 
>> why my printouts are appearing scaled down, I would appreciate any help.
>> Thanks.
>> 
>> -- 
>> gbeg...@gmail.com   http://www.GerrysCuppaTea.org/
>> 
>> ___
>> 
>> 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/gbeggs1%40mts.net
>> 
>> This email sent to gbeg...@mts.net
>> 
> 
> -- 
> gbeg...@gmail.com   http://www.GerrysCuppaTea.org/
> 
> ___
> 
> 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/ledet%40apple.com
> 
> This email sent to le...@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: Debugging Allocations. Was:NSUndoManager

2011-02-07 Thread Charles Srstka
On Feb 6, 2011, at 9:18 PM, Jerry Krinock wrote:

> On 2011 Feb 06, at 07:44, Charles Srstka wrote:
> 
>> Object Allocations, with “Record Reference Counts” checked, will let you 
>> choose an object and show exactly where and when it was allocated, 
>> deallocated, retained, released, and even autoreleased. If you open the 
>> Extended Detail pane, you can get a full stack trace for each one of these 
>> occurrences, and you can double-click one of those frames to have it display 
>> the source file inline right in Instruments with the line at which the 
>> object was released, retained, etc. highlighted.
> 
> Thank you, Charles.  I've filed that advice away and hope that I never need 
> to use it.
> 
> I've had mostly negative experiences with Object Allocations – execution 
> slowing to a crawl, consuming memory until, it can't get any more, then 
> crashing.  Your description of all it does kind of explains why.  In 
> contrast, my brute force method only logs for one class.
> 
> But maybe since I have a big 64-bit Mac now with whoopee 4 GB of RAM, it will 
> work better.

It works pretty well on my MBP, and is incredibly handy when you’re trying to 
track down a leak or a memory-related crash. To get the logs for retain, 
release, etc., though, you have to make sure to get info on the ObjectAlloc 
instance and check the “Record Reference Counts” box. Otherwise, you just get 
allocations and deallocations.

Charles___

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: Escape in NSTableView cell

2011-02-07 Thread Dave Reed

On Feb 7, 2011, at 9:49 AM, Ivan C Myrvold wrote:

> I have developed an application with a table view and text edit cell. When I 
> press escape from a table view cell, I want the cell to lose focus and end 
> editing. Instead I get a list of words in the cell. See picture at 
> http://www.myrvold.org/cocoa/images/editcell_escape.png 
> 
> How can I avoid the list and get the functionality I want?

See this:

http://www.cocoabuilder.com/archive/cocoa/176709-esc-to-cancel-editing-in-tableview.html

Subclassing NSTableView and overriding cancelOperation appears to work. I don't 
know if there's a better way though.

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


NSDocument Question

2011-02-07 Thread Bruce Cresanta
Hello,

I have two types of NSDocument.   One of them only ever needs to be 
active one at a time (No duplicates).   How do I check to see if the window is 
open first and make it key, and if it is not open already, open it once?

Thanks,

Bruce
___

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: Need help sorting with NSSortDescriptor and/or/NSPredicate (Core Data)

2011-02-07 Thread Ken Thomases
On Feb 7, 2011, at 8:56 AM, Michael Crawford wrote:

> I'm trying to implement a feature where I sort a cross-section of music from 
> multiple genres with up to two different keys, where the items with a genre 
> matching the first key appear first in the collection and items with a genre 
> matching the second key appear after the first group in the collection.  All 
> songs with a genre not matching the first or second keys can be in any order 
> following the first two groups.
> 
> So I took a look at NSSortDescriptor but it is not apparent to me how I would 
> accomplish my goal with this class.  If I sort with it based on the genre 
> key, will basically sort them in alphabetical ascending or descending order, 
> not what I want.

Here are two possible approaches:

1) Implement a synthetic property which is more amenable to the sort ordering 
you want.  Something which returns 0 for the first genre, 1 for the second, and 
2 for all others, for example.

2) Implement a custom comparator method that compares the existing genre 
property in the manner you want: the first genre equal to itself but coming 
before all others; the second genre coming after the first, equal to itself, 
and coming before the remaining genres; all other genres coming after the first 
two but unordered with respect to each other.

Either or both of these methods could be implemented in a category if that 
makes things easier.

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


Need help sorting with NSSortDescriptor and/or/NSPredicate (Core Data)

2011-02-07 Thread Michael Crawford
I'm trying to implement a feature where I sort a cross-section of music from 
multiple genres with up to two different keys, where the items with a genre 
matching the first key appear first in the collection and items with a genre 
matching the second key appear after the first group in the collection.  All 
songs with a genre not matching the first or second keys can be in any order 
following the first two groups.
 
So I took a look at NSSortDescriptor but it is not apparent to me how I would 
accomplish my goal with this class.  If I sort with it based on the genre key, 
will basically sort them in alphabetical ascending or descending order, not 
what I want.
 
It seems what I really need to do is modify my predicate so that I issue a 
query for the first group.  And then issue another separate query for the 
second group, and finally a third query for the remaining items where the genre 
is not a match for the first or second group.
 
Three queries just to get this sorted collection.  I'm not experienced with 
NSSortDescriptor and I've only used very simple expressions with NSPredicate.  
Is there a way to get what I want with a single Core Data fetch-request?
 
-Michael
___

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


Escape in NSTableView cell

2011-02-07 Thread Ivan C Myrvold
I have developed an application with a table view and text edit cell. When I 
press escape from a table view cell, I want the cell to lose focus and end 
editing. Instead I get a list of words in the cell. See picture at 
http://www.myrvold.org/cocoa/images/editcell_escape.png 

How can I avoid the list and get the functionality I 
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